欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → [原创]4种预警方法

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有12510人关注过本帖树形打印复制链接

主题:[原创]4种预警方法

帅哥哟,离线,有人找我吗?
deni977
  11楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:581 积分:171 威望:0 精华:0 注册:2013/4/2 6:58:20
  发帖心情 Post By:2014/12/12 9:13:26 [只看该作者]

请教,有没有“微信”预警?不需要和QQ关联微信那种。

 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  12楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
AutoIt版  发帖心情 Post By:2015/5/16 21:24:33 [只看该作者]

AutoIt版
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20150516212242.png
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  13楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2015/5/16 21:25:50 [只看该作者]

以下内容为程序代码:

1 #include <SmtpMailer_UDF.au3>
2
3 Global $c
4
5 ;邮件预警
6 Func mail_alarm()
7 Local $smtpServer = "smtp.139.com"
8 Local $fromName = "Dennis"
9 Local $fromAddress = "888888@139.com"
10 Local $toAddress = "888888@139.com"
11 Local $subject = "预警"
12 Local $body = $content
13 Local $attachFiles = ""
14 Local $ccAddress = ""
15 Local $bccAddress = ""
16 Local $importance = "Normal"
17 Local $username = "888888"
18 Local $password = "888888"
19 Local $port = 25
20 Local $ssl = False
21 Local $isHtmlBody = False
22 _INetSmtpMailCom($smtpSErver, $fromName, $fromAddress, $toAddress, $subject, $body, $attachFiles, $ccAddress, $bccAddress, $importance, $username, $password, $port, $ssl, $isHtmlBody, 0)
23 EndFunc
24
25 ;语音预警
26 Func voice_alarm()
27 $speech = ObjCreate("SAPI.SpVoice")
28 $speech.Speak($content)
29 $speech = ""
30 EndFunc
31
32 ;短信预警
33 Func sms_alarm()
34 Local $smtpServer = "smtp.139.com"
35 Local $fromName = "Dennis"
36 Local $fromAddress = "888888@139.com"
37 Local $toAddress = "888888@139.com"
38 Local $subject = "预警"
39 Local $body = $content
40 Local $attachFiles = ""
41 Local $ccAddress = ""
42 Local $bccAddress = ""
43 Local $importance = "Normal"
44 Local $username = "888888"
45 Local $password = "888888"
46 Local $port = 25
47 Local $ssl = False
48 Local $isHtmlBody = False
49 _INetSmtpMailCom($smtpSErver, $fromName, $fromAddress, $toAddress, $subject, $body, $attachFiles, $ccAddress, $bccAddress, $importance, $username, $password, $port, $ssl, $isHtmlBody, 0)
50 EndFunc
51
52 mail_alarm()
53 voice_alarm()
54 sms_alarm()
55

[此贴子已经被作者于2015/5/16 21:26:34编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  14楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2016/1/5 9:20:41 [只看该作者]

Poco版:

#include <Poco/Net/SMTPClientSession.h>
#include <Poco/Net/MailMessage.h>
#include <Poco/Net/NetException.h>

using namespace std;
using namespace Poco::Net;
using namespace Poco;

string c;

//邮件预警
void mailAlarm(){
    string host = "smtp.139.com";
    int port = 25;
    string user = "888888";
    string password = "888888";
    string to = "888888@139.com";
    string from = "888888@139.com";
    string subject = "预警";

    MailMessage message;
    message.setSender(from);
    message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, to));
    message.setSubject(subject);
    message.setContent(content);

    try{
        SMTPClientSession session(host, port);
        session.open();
        try{
            session.login(SMTPClientSession::AUTH_LOGIN, user, password);
            session.sendMessage(message);
            session.close();
        }catch(SMTPException &e){
            cerr << e.displayText() << endl;
            session.close();
            return;
        }
    }catch(NetException &e){
        cerr << e.displayText() << endl;
        return;
    }
}

//短信预警
void smsAlarm(){
    string host = "smtp.139.com";
    int port = 25;
    string user = "888888";
    string password = "888888";
    string to = "888888@139.com";
    string from = "888888@139.com";
    string subject = "预警";

    MailMessage message;
    message.setSender(from);
    message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, to));
    message.setSubject(subject);
    message.setContent(content);

    try{
        SMTPClientSession session(host, port);
        session.open();
        try{
            session.login(SMTPClientSession::AUTH_LOGIN, user, password);
            session.sendMessage(message);
            session.close();
        }catch(SMTPException &e){
            cerr << e.displayText() << endl;
            session.close();
            return;
        }
    }catch(NetException &e){
        cerr << e.displayText() << endl;
        return;
    }
}

int main(){
    mailAlarm();
    smsAlarm();
}


			

 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  15楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2016/1/5 22:27:35 [只看该作者]

#include <Poco/Logger.h>
#include <Poco/SplitterChannel.h>
#include <Poco/ConsoleChannel.h>
#include <Poco/FileChannel.h>
#include <Poco/FormattingChannel.h>
#include <Poco/PatternFormatter.h>
#include <Poco/AutoPtr.h>
#include <Poco/Util/PropertyFileConfiguration.h>
#include <Poco/Util/LoggingConfigurator.h>
#include <thread>

using namespace std;

using namespace Poco;
using namespace Poco::Util;

void config_logger(){
    AutoPtr<ConsoleChannel> console_channel(new ConsoleChannel);
    AutoPtr<FileChannel> file_channel(new FileChannel);
    file_channel->setProperty("path", "bingo.log");
    file_channel->setProperty("rotation", "daily");
    file_channel->setProperty("archive", "number");
    file_channel->setProperty("times", "local");
    file_channel->setProperty("purgeCount", "5");
    AutoPtr<SplitterChannel> splitter_channel(new SplitterChannel);

    splitter_channel->addChannel(console_channel);
    splitter_channel->addChannel(file_channel);

    AutoPtr<PatternFormatter> pattern_formatter(new PatternFormatter);
    pattern_formatter->setProperty("pattern", "[%Y-%m-%d %H:%M:%S][%s][%t]");
    pattern_formatter->setProperty("times", "local");


    AutoPtr<FormattingChannel> formatting_channel(new FormattingChannel);
    formatting_channel->setFormatter(pattern_formatter);
    formatting_channel->setChannel(splitter_channel);

    Logger::root().setChannel(formatting_channel);
}

void print1(){
    Logger &trade_log = Logger::get("Trade");

    for(int i = 0; i < 99; ++i){
        trade_log.information("000");
    }
}

void print2(){
    Logger &quote_log = Logger::get("Quote");

    for(int i = 0; i < 99; ++i){
        quote_log.information("111");
    }
}


int main(){
    config_logger();

    thread t1(print1);
    thread t2(print2);

    t1.join();
    t2.join();
}
		


 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  16楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2016/1/6 11:48:39 [只看该作者]

#include <Poco/Base64Decoder.h>
#include <Poco/Base64Encoder.h>
#include <string>
#include <iostream>
#include <sstream>

using namespace std;
using namespace Poco;

string encode(const string &password){
    ostringstream oss;
    Base64Encoder encoder(oss);
    encoder << password;
    return oss.str();
}

string decode(const string &password){
    string temp;
    istringstream iss(password);
    Base64Decoder decoder(iss);
    decoder >> temp;
    return temp;
}

int main(){
    string encode_password = encode("123456");

    cout << "encode_password = " << encode_password << endl;

    string decode_password = decode(encode_password);

    cout << "decode_password = " << decode_password << endl;
}


 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  17楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2016/1/6 14:44:12 [只看该作者]

#include <iostream>
#include <Poco/Crypto/Cipher.h>
#include <Poco/Crypto/CipherFactory.h>
#include <Poco/Crypto/RSAKey.h>

using namespace std;
using namespace Poco::Crypto;

int main(){
    Cipher::Ptr chiper = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
    string val = "EasyQuant";
    string enc = chiper->encryptString(val);
    string dec = chiper->decryptString(enc);

    cout << "加密后 : " << enc << endl;
    cout << "加密前 : " << dec << endl;

    getchar();
}


 回到顶部
帅哥哟,离线,有人找我吗?
z7c9
  18楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2016/1/6 21:50:06 [只看该作者]

#include <iostream>
#include <SFML/Audio.hpp>

using namespace std;
using namespace sf;

int main()
{
    SoundBuffer buffer;

    if(!buffer.loadFromFile("canary.wav")){
        return 1;
    }

    Sound sound(buffer);
    sound.play();

    while(sound.getStatus() == Sound::Playing){
        sleep(milliseconds(100));
    }

    return 0;
}


 回到顶部
总数 18 上一页 1 2