//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); } }
private void InsertMsg(string CorpId, string Msg) { try { Msg = Msg.Replace("||", "|"); string[] temp = Msg.Split("|".ToCharArray()); for (int i = 0; i < temp.Length; i++) { if (temp[i].Trim() != "") { string[] temp1 = temp[i].Split("#".ToCharArray()); List<string> field = new List<string>(); List<string> value = new List<string>(); //temp0--手机号,temp1--回复内容,temp2--回复时间,temp3--回复号码 if (temp1.Length > 2) { field.Add("[Mobile]"); field.Add("[Content]"); field.Add("[GetDate]"); field.Add("[sendDate]"); field.Add("[CorpId]"); field.Add("[Flag]"); value.Add(temp1[0]); value.Add(temp1[1]); value.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); value.Add(temp1[2]); value.Add(CorpId); value.Add("0"); DBconnGet dbcg = new DBconnGet(); bool brst = dbcg.Insert("[dbo].[MobileGet]", field, value); }; }; }; } catch (Exception e) { log.Error(e); }; }
//Insert Success SendMsg private bool InsertBak(string ID, DataTable dtDetail, string RptNo,string now) { try { bool bRst = false; List<string> field = new List<string>(); List<string> value = new List<string>(); field.Add("ID"); field.Add("Flag"); field.Add("Com"); field.Add("Mobile"); field.Add("Content"); field.Add("CreateDate"); field.Add("DelaySendTime"); field.Add("RealSendTime"); field.Add("Status"); field.Add("SmsID"); for (int i = 0; i < dtDetail.Rows.Count; i++) { if (dtDetail.Rows[i]["ID"].ToString() == ID) { value.Add(ID); value.Add("1"); value.Add(dtDetail.Rows[i]["Com"].ToString()); value.Add(dtDetail.Rows[i]["Mobile"].ToString()); value.Add(dtDetail.Rows[i]["Content"].ToString()); value.Add(dtDetail.Rows[i]["CreateDate"].ToString()); value.Add(dtDetail.Rows[i]["DelaySendTime"].ToString()); value.Add(now); value.Add("1"); value.Add(RptNo); } }; DBconnGet dbcg = new DBconnGet(); bRst = dbcg.Insert("[dbo].[MobileSend_bak]", field, value); field = null; value = null; return bRst; } catch (Exception e) { log.Error(e); return false; }; }
//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); }; }