public MainService() { InitializeComponent(); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); ConnectionString = ini.Read("Options", "ConnectionString"); }
public void WriteIni(string Section, string Message) { if (String.IsNullOrEmpty(FileName)) { return; } Shove._IO.IniFile ini = new Shove._IO.IniFile(FileName); ini.Write(Section, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + System.DateTime.Now.Millisecond.ToString(), Message); }
public MainService() { InitializeComponent(); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); try { ConnectionString = ini.Read("Config", "ConnectionString").Replace("\"", ""); ConnectionStringInformation = ini.Read("Config", "ConnectionStringInformation").Replace("\"", ""); MatchSpaceTime = Shove._Convert.StrToInt(ini.Read("Config", "MatchSpaceTime"), 1); RateSpaceTime = Shove._Convert.StrToInt(ini.Read("Config", "RateSpaceTime"), 1); //抓取赔率间隔时间 Source = ini.Read("Config", "Source"); PathName = ini.Read("Config", "PathName"); } catch (Exception e) { new Log("Sporttery").Write("配置文件错误:" + e.Message); return; } }
public MainService() { InitializeComponent(); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); try { ConnectionString = ini.Read("Config", "ConnectionString").Replace("\"",""); ConnectionStringInformation = ini.Read("Config", "ConnectionStringInformation").Replace("\"", ""); MatchSpaceTime = Shove._Convert.StrToInt(ini.Read("Config", "MatchSpaceTime"), 1); RateSpaceTime = Shove._Convert.StrToInt(ini.Read("Config", "RateSpaceTime"), 1); //抓取赔率间隔时间 Source = ini.Read("Config", "Source"); PathName = ini.Read("Config", "PathName"); } catch(Exception e) { new Log("Sporttery").Write("配置文件错误:" + e.Message); return; } }
public void Do() { while (true) { if (State == 2) { msg.Send("SendSMSTask Stop."); log.Write("SendSMSTask Stop."); State = 0; Stop(); return; } System.Threading.Thread.Sleep(1000); // 1秒为单位 gCount1++; #region 5 秒, 遍历待发短信表,发送短信 if (gCount1 >= 5) { gCount1 = 0; int SendCount = 0; try { SendCount = Send(); msg.Send("Send (" + SendCount.ToString() + ")...... OK."); } catch (Exception e) { msg.Send("Send is Fail: " + e.Message); log.Write("Send is Fail: " + e.Message); } } #endregion gCount2++; #region 1 分钟, 检索是否有紧急票 if (gCount2 >= 60 * 1) { gCount2 = 0; try { Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); bool IsSendSMSForSchemeCheck = Shove._Convert.StrToBool(ini.Read("Options", "IsSendSMSForSchemeCheck"), false); if (IsSendSMSForSchemeCheck) { SchemeCheck(); msg.Send("SchemeCheck ...... OK."); } } catch (Exception e) { msg.Send("SchemeCheck is Fail: " + e.Message); log.Write("SchemeCheck is Fail: " + e.Message); } } #endregion } }
public void WriteSPToJsFile(string FileName, string Message) { string AppDir = System.AppDomain.CurrentDomain.BaseDirectory; if (!AppDir.EndsWith("\\")) { AppDir += "\\"; } Shove._IO.IniFile ini = new Shove._IO.IniFile(AppDir + "Config.ini"); string PathName = ini.Read("Config", "PathName"); if (PathName == "") { return; } if (!Directory.Exists(PathName)) { try { Directory.CreateDirectory(PathName); } catch { throw; } } FileName = PathName + @"\" + FileName; using (FileStream fs = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write)) { StreamWriter writer = new StreamWriter(fs, System.Text.Encoding.GetEncoding("utf-8")); try { writer.WriteLine(Message); } catch { } writer.Close(); } }
public void WriteToFile() { string AppDir = System.AppDomain.CurrentDomain.BaseDirectory; if (!AppDir.EndsWith("\\")) { AppDir += "\\"; } Shove._IO.IniFile ini = new Shove._IO.IniFile(AppDir + "Config.ini"); //第一步:读取最近一期的SP值 DataTable dt = Shove.Database.MSSQL.Select(ConnectionString, "select * from T_CompensationRate where [Day] >= YEAR(GETDATE()) * 10000 + MONTH(GETDATE()) * 100 + Day(GETDATE())", null); StringBuilder sb_Average99 = new StringBuilder(); StringBuilder sb_Willhill = new StringBuilder(); StringBuilder sb_Lad = new StringBuilder(); StringBuilder sb_Bet365 = new StringBuilder(); StringBuilder sb_Macau = new StringBuilder(); //第二步:将结果写入文件中 if (dt != null && dt.Rows.Count > 0) { sb_Average99.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?> "); sb_Average99.Append("<xml>"); sb_Willhill.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?> "); sb_Willhill.Append("<xml>"); sb_Lad.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?> "); sb_Lad.Append("<xml>"); sb_Bet365.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?> "); sb_Bet365.Append("<xml>"); sb_Macau.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?> "); sb_Macau.Append("<xml>"); foreach (DataRow rw in dt.Rows) { foreach (DataColumn col in dt.Columns) { switch (col.ColumnName) { #region 让球胜平负的sp值 case "Average99_S": sb_Average99.Append("<m id=\"" + rw["MatchID"] + "\" win=\"" + rw["Average99_S"].ToString() + "\" "); break; case "Average99_P": sb_Average99.Append("draw=\"" + rw["Average99_P"].ToString() + "\" "); break; case "Average99_F": sb_Average99.Append("lost=\"" + rw["Average99_F"].ToString() + "\" />"); break; #endregion #region 总进球数的sp值 case "Willhill_S": sb_Willhill.Append("<m id=\"" + rw["MatchID"] + "\" win=\"" + rw["Willhill_S"].ToString() + "\" "); break; case "Willhill_P": sb_Willhill.Append("draw=\"" + rw["Willhill_P"].ToString() + "\" "); break; case "Willhill_F": sb_Willhill.Append("lost=\"" + rw["Willhill_F"].ToString() + "\" />"); break; #endregion #region 比分的sp值 case "Lad_S": sb_Lad.Append("<m id=\"" + rw["MatchID"] + "\" win=\"" + rw["Lad_S"].ToString() + "\" "); break; case "Lad_P": sb_Lad.Append("draw=\"" + rw["Lad_P"].ToString() + "\" "); break; case "Lad_F": sb_Lad.Append("lost=\"" + rw["Lad_F"].ToString() + "\" />"); break; #endregion #region 半全场胜平负的sp值 case "Bet365_S": sb_Bet365.Append("<m id=\"" + rw["MatchID"] + "\" win=\"" + rw["Bet365_S"].ToString() + "\" "); break; case "Bet365_P": sb_Bet365.Append("draw=\"" + rw["Bet365_P"].ToString() + "\" "); break; case "Bet365_F": sb_Bet365.Append("lost=\"" + rw["Bet365_F"].ToString() + "\" />"); break; #endregion #region 半全场胜平负的sp值 case "Macau_S": sb_Macau.Append("<m id=\"" + rw["MatchID"] + "\" win=\"" + rw["Macau_S"].ToString() + "\" "); break; case "Macau_P": sb_Macau.Append("draw=\"" + rw["Macau_P"].ToString() + "\" "); break; case "Macau_F": sb_Macau.Append("lost=\"" + rw["Macau_F"].ToString() + "\" />"); break; #endregion } } } sb_Average99.Append("</xml>"); sb_Willhill.Append("</xml>"); sb_Lad.Append("</xml>"); sb_Bet365.Append("</xml>"); sb_Macau.Append("</xml>"); WriteSPToJsFile("Average99.xml", sb_Average99.ToString()); WriteSPToJsFile("Willhill.xml", sb_Willhill.ToString()); WriteSPToJsFile("Lad.xml", sb_Lad.ToString()); WriteSPToJsFile("Bet365.xml", sb_Bet365.ToString()); WriteSPToJsFile("Macau.xml", sb_Macau.ToString()); } }
protected override void OnStart(string[] args) { try { System.Data.SqlClient.SqlConnection conn = Shove.Database.MSSQL.CreateDataConnection<System.Data.SqlClient.SqlConnection>(ConnectionString); while (conn.State != ConnectionState.Open) { conn.Open(); new Log("System").Write("数据库连接失败"); System.Threading.Thread.Sleep(1000); } conn.Close(); } catch (Exception e) { new Log("System").Write(e.Message); } SystemOptions so = new SystemOptions(ConnectionString); // 恒朋上海电子票自动任务 try { if (so["ElectronTicket_HPSH_Status_ON"].ToBoolean(false) && (new DAL.Tables.T_Lotteries().GetCount(ConnectionString, "PrintOutType = 102") > 0)) { ElectronTicket_HPSH_Task = new ElectronTicket_HPSH(ConnectionString); ElectronTicket_HPSH_Task.ElectronTicket_HPSH_Getway = so["ElectronTicket_HPSH_Getway"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserName = so["ElectronTicket_HPSH_UserName"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserPassword = so["ElectronTicket_HPSH_UserPassword"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_AlipayName = so["ElectronTicket_PrintOut_AlipayName"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_IDCardNumber = so["ElectronTicket_PrintOut_IDCardNumber"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_Mobile = so["ElectronTicket_PrintOut_Mobile"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_RealityName = so["ElectronTicket_PrintOut_RealityName"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_Email = so["ElectronTicket_PrintOut_Email"].ToString(""); ElectronTicket_HPSH_GP_Task = new ElectronTicket_HPSH_GP(ConnectionString); ElectronTicket_HPSH_GP_Task.ElectronTicket_HPSH_Getway = so["ElectronTicket_HPSH_Getway"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_HPSH_UserName = so["ElectronTicket_HPSH_UserName"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_HPSH_UserPassword = so["ElectronTicket_HPSH_UserPassword"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_AlipayName = so["ElectronTicket_PrintOut_AlipayName"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_IDCardNumber = so["ElectronTicket_PrintOut_IDCardNumber"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_Mobile = so["ElectronTicket_PrintOut_Mobile"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_RealityName = so["ElectronTicket_PrintOut_RealityName"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_Email = so["ElectronTicket_PrintOut_Email"].ToString(""); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); ElectronTicket_HPSH_GP_Task.t_Datetime = ini.Read("Options", "DateTime"); if ((ElectronTicket_HPSH_Task.ElectronTicket_HPSH_Getway != "") && (ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserName != "") && (ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserPassword != "")) { ElectronTicket_HPSH_Task.Run(); ElectronTicket_HPSH_GP_Task.Run(); } } } catch (Exception e) { new Log("System").Write("ElectronTicket_HPSH 启动失败:" + e.Message); } }
protected override void OnStart(string[] args) { try { System.Data.SqlClient.SqlConnection conn = Shove.Database.MSSQL.CreateDataConnection <System.Data.SqlClient.SqlConnection>(ConnectionString); while (conn.State != ConnectionState.Open) { conn.Open(); new Log("System").Write("数据库连接失败"); System.Threading.Thread.Sleep(1000); } conn.Close(); } catch (Exception e) { new Log("System").Write(e.Message); } SystemOptions so = new SystemOptions(ConnectionString); // 恒朋上海电子票自动任务 try { if (so["ElectronTicket_HPSH_Status_ON"].ToBoolean(false) && (new DAL.Tables.T_Lotteries().GetCount(ConnectionString, "PrintOutType = 102") > 0)) { ElectronTicket_HPSH_Task = new ElectronTicket_HPSH(ConnectionString); ElectronTicket_HPSH_Task.ElectronTicket_HPSH_Getway = so["ElectronTicket_HPSH_Getway"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserName = so["ElectronTicket_HPSH_UserName"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserPassword = so["ElectronTicket_HPSH_UserPassword"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_AlipayName = so["ElectronTicket_PrintOut_AlipayName"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_IDCardNumber = so["ElectronTicket_PrintOut_IDCardNumber"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_Mobile = so["ElectronTicket_PrintOut_Mobile"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_RealityName = so["ElectronTicket_PrintOut_RealityName"].ToString(""); ElectronTicket_HPSH_Task.ElectronTicket_PrintOut_Email = so["ElectronTicket_PrintOut_Email"].ToString(""); ElectronTicket_HPSH_GP_Task = new ElectronTicket_HPSH_GP(ConnectionString); ElectronTicket_HPSH_GP_Task.ElectronTicket_HPSH_Getway = so["ElectronTicket_HPSH_Getway"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_HPSH_UserName = so["ElectronTicket_HPSH_UserName"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_HPSH_UserPassword = so["ElectronTicket_HPSH_UserPassword"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_AlipayName = so["ElectronTicket_PrintOut_AlipayName"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_IDCardNumber = so["ElectronTicket_PrintOut_IDCardNumber"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_Mobile = so["ElectronTicket_PrintOut_Mobile"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_RealityName = so["ElectronTicket_PrintOut_RealityName"].ToString(""); ElectronTicket_HPSH_GP_Task.ElectronTicket_PrintOut_Email = so["ElectronTicket_PrintOut_Email"].ToString(""); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); ElectronTicket_HPSH_GP_Task.t_Datetime = ini.Read("Options", "DateTime"); if ((ElectronTicket_HPSH_Task.ElectronTicket_HPSH_Getway != "") && (ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserName != "") && (ElectronTicket_HPSH_Task.ElectronTicket_HPSH_UserPassword != "")) { ElectronTicket_HPSH_Task.Run(); ElectronTicket_HPSH_GP_Task.Run(); } } } catch (Exception e) { new Log("System").Write("ElectronTicket_HPSH 启动失败:" + e.Message); } }
protected override void OnStart(string[] args) { try { System.Data.SqlClient.SqlConnection conn = Shove.Database.MSSQL.CreateDataConnection <System.Data.SqlClient.SqlConnection>(ConnectionString); while (conn.State != ConnectionState.Open) { conn.Open(); new Log("System").Write("数据库连接失败"); System.Threading.Thread.Sleep(1000); } conn.Close(); } catch (Exception e) { new Log("System").Write(e.Message); } SystemOptions so = new SystemOptions(ConnectionString); // 上海大赢家电子票自动任务 try { if ((new DAL.Tables.T_Lotteries().GetCount(ConnectionString, "PrintOutType = 101") > 0)) { ElectronTicket_Task = new ElectronTicket(ConnectionString); ElectronTicket_Task.ElectronTicket_Getway = so["ElectronTicket_Getway"].ToString(""); ElectronTicket_Task.ElectronTicket_Agent_UserNumber = so["ElectronTicket_Agent_UserNumber"].ToString(""); ElectronTicket_Task.ElectronTicket_Agent_Key = so["ElectronTicket_Agent_Key"].ToString(""); ElectronTicket_Task.ElectronTicket_Agent_UserName = so["ElectronTicket_Agent_UserName"].ToString(""); ElectronTicket_Task.ElectronTicket_Agent_UserPassword = so["ElectronTicket_Agent_UserPassword"].ToString(""); ElectronTicket_Task.ElectronTicket_Agent_PostPassword = so["ElectronTicket_Agent_PostPassword"].ToString(""); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if ((ElectronTicket_Task.ElectronTicket_Getway != "") && (ElectronTicket_Task.ElectronTicket_Agent_UserNumber != "") && (ElectronTicket_Task.ElectronTicket_Agent_Key != "") && (ElectronTicket_Task.ElectronTicket_Agent_UserName != "") && (ElectronTicket_Task.ElectronTicket_Agent_UserPassword != "") && (ElectronTicket_Task.ElectronTicket_Agent_PostPassword != "")) { ElectronTicket_Task.Run(); } } } catch (Exception e) { new Log("System").Write("ElectronTicket 启动失败:" + e.Message); } // 上海大赢家自动录入开奖号任务 try { WinNumber_Task = new WinNumber(ConnectionString); WinNumber_Task.ElectronTicket_Getway = so["ElectronTicket_Getway"].ToString(""); WinNumber_Task.ElectronTicket_Agent_UserNumber = so["ElectronTicket_Agent_UserNumber"].ToString(""); WinNumber_Task.ElectronTicket_Agent_Key = so["ElectronTicket_Agent_Key"].ToString(""); WinNumber_Task.ElectronTicket_Agent_UserName = so["ElectronTicket_Agent_UserName"].ToString(""); WinNumber_Task.ElectronTicket_Agent_UserPassword = so["ElectronTicket_Agent_UserPassword"].ToString(""); WinNumber_Task.ElectronTicket_Agent_PostPassword = so["ElectronTicket_Agent_PostPassword"].ToString(""); Shove._IO.IniFile ini = new Shove._IO.IniFile(System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if ((WinNumber_Task.ElectronTicket_Getway != "") && (WinNumber_Task.ElectronTicket_Agent_UserNumber != "") && (WinNumber_Task.ElectronTicket_Agent_Key != "") && (WinNumber_Task.ElectronTicket_Agent_UserName != "") && (WinNumber_Task.ElectronTicket_Agent_UserPassword != "") && (WinNumber_Task.ElectronTicket_Agent_PostPassword != "")) { WinNumber_Task.Run(); } } catch (Exception e) { new Log("System").Write("WinNumber 启动失败:" + e.Message); } }