//Get MsgReoprt protected void GetReoprt() { try { string strSQL = @"SELECT [AccountNo],[PassWord] FROM [dbo].[CFG_Account] WITH(NOLOCK) WHERE [AStatus] = 1 AND [SendStatus] = 1"; Dxt.LinkWS linkWs = new Dxt.LinkWS(); DBconnGet dbcg = new DBconnGet(); while (true) { lock (sync) { DataTable dtAccount = dbcg.getDataView(strSQL); if (dtAccount != null) { int iCount = dtAccount.Rows.Count; if (iCount > 0) { for (int i = 0; i < iCount; i++) { string CorpID = dtAccount.Rows[i]["AccountNo"].ToString(); string Pwd = dtAccount.Rows[i]["PassWord"].ToString(); //log.Info("GetReport_If is Begin"); string Report = linkWs.GetReportSMS(CorpID, Pwd); if (Report.Length > 0) { log.Info("GetReport_If is Back. Result is :" + Report); log.Info("------======------"); string[] cutReoprt = Report.Split("|||".ToCharArray()); if (cutReoprt.Length > 0) { int Count = cutReoprt.Length; for (int j = 0; j < Count; j++) { string rptDetail = cutReoprt[j]; if (rptDetail.Length > 0) { rptDetail = rptDetail.Replace("$$$$$", "|"); string[] temp = rptDetail.Split("|".ToCharArray()); if (temp.Length > 4) { List<string> field = new List<string>(); List<string> value = new List<string>(); field.Add("[CorpId]"); field.Add("[Smsid]"); field.Add("[Mobile]"); field.Add("[DelaySendTime]"); field.Add("[Result]"); field.Add("[Status]"); field.Add("[ReportDate]"); value.Add(CorpID); value.Add(temp[0]); value.Add(temp[1]); value.Add(temp[2]); value.Add(temp[3]); value.Add(temp[4]); value.Add(temp[5]); dbcg.Insert("[dbo].[MobileSend_Report]" , field, value); log.Info("Insert GetReport is OK."); log.Info("------======------"); field = null; value = null; }; } else { continue; }; }; }; }; }; } else { continue; }; }; }; //每次收取报告后休息。 System.Threading.Thread.Sleep(30000); }; } catch (Exception e) { log.Error(e); } }
//Get Message protected void GetMsg() { try { Dxt.LinkWS LinkWs = new Dxt.LinkWS(); string result; string strSQL = @"SELECT [AccountNo],[PassWord] FROM [dbo].[CFG_Account] WITH(NOLOCK) WHERE [AStatus] = 1 AND [SendStatus] = 1"; DBconnGet dbcg = new DBconnGet(); while (true) { lock (sync) { DataTable dt = dbcg.getDataView(strSQL); if (dt != null) { int iCount = dt.Rows.Count; if (iCount > 0) { for (int i = 0; i < iCount; i++) { string CorpID = dt.Rows[i]["AccountNo"].ToString(); string Pwd = dt.Rows[i]["PassWord"].ToString(); try { result = LinkWs.Get(CorpID.Trim(), Pwd.Trim()); if (result.Length != 0) { log.Info("GetMsg_If is Back. Result is :" + result); log.Info("------======------"); }; switch (result) { case "": break; case "-1": break; case "-2": break; case "-3": break; default: InsertMsg(CorpID, result); log.Info("Insert GetMsg is OK."); log.Info("------======------"); break; }; } catch (Exception ex) { log.Error(ex); }; }; } else { continue; }; }; }; //每次收取短信要间隔5分钟。 System.Threading.Thread.Sleep(300000); }; } catch (Exception e) { log.Error(e); }; }