namespace AsiaINFO.SMS.BusinessFactory { using AsiaINFO.SMS.DBFactory; using AsiaINFO.SMS.Entity; using Common; using System; using System.Collections.Generic; using System.Data; using System.Linq; public class MTBusiness { public static void AddReportWait(ReportInfo report, int ismg) { try { MTFactory.AddReportWait(report, ismg); } catch (Exception exception) { throw new Exception("[MTBusiness.AddReportWait] " + exception.Message); } } public static void DeleteMTWait(MTWaitInfo mtwait, int ismg) { try { switch (ismg) { case 1: MTFactory.Delete_MTWait_CM(mtwait.Guid); return; case 2: MTFactory.Delete_MTWait_CU(mtwait.Guid); return; case 3: MTFactory.Delete_MTWait_TEL(mtwait.Guid); return; } } catch (Exception exception) { throw new Exception("[MTBusiness.DeleteMTWait] " + exception.Message); } } public static List GetMTWaitList(int rows, int ismg, string out_gateway_id) { List list = null; DataTable table = null; try { SetSendToWait(); switch (ismg) { case 1: table = MTFactory.GetItemList_MTWait_CM(rows); goto Label_0050; case 2: table = MTFactory.GetItemList_MTWait_CU(rows); goto Label_0050; case 3: table = MTFactory.GetItemList_MTWait_TEL(rows); goto Label_0050; } } catch (Exception exception) { throw new Exception("[MTBusiness.GetMTWaitList_1] " + exception.Message); } Label_0050: list = (table == null) ? new List() : new List(table.Rows.Count); foreach (DataRow row in table.Rows) { try { string guid = row["GUID"].ToString().Trim(); string longSvrNo = row["LONG_SERV_NO"].ToString().Trim(); string svrCode = row["SERV_CODE"].ToString().Trim(); string mobileNo = row["MOBILE_NO"].ToString().Trim(); int num = Utils.StrToInt(row["MOBILE_NO_TYPE"].ToString().Trim(), 1); string str5 = row["FEE_TYPE"].ToString().Trim(); string fee = row["FEE"].ToString().Trim(); string str7 = row["SMS_CONTENT"].ToString(); string linkId = row["LINK_ID"].ToString().Trim(); string wapurl = row["WAPURL"].ToString().Trim(); uint msgSum = (uint)Utils.StrToInt(row["MSGSUM"].ToString().Trim(), 1); uint msgSub = (uint)Utils.StrToInt(row["MSGSUB"].ToString().Trim(), 1); MTWaitInfo item = new MTWaitInfo(guid, longSvrNo, svrCode, mobileNo, num, str5, fee, str7, linkId, wapurl, msgSum, msgSub); list.Add(item); continue; } catch (Exception exception2) { throw new Exception("[MTBusiness.GetMTWaitList_2] " + exception2.Message); } } try { switch (ismg) { case 1: foreach (MTWaitInfo info2 in list) { MTFactory.Update_MTWait_CM(info2.Guid, out_gateway_id); } return list; case 2: foreach (MTWaitInfo info3 in list) { MTFactory.Update_MTWait_CU(info3.Guid, out_gateway_id); } return list; case 3: break; default: return list; } foreach (MTWaitInfo info4 in list) { MTFactory.Update_MTWait_TEL(info4.Guid, out_gateway_id); } } catch (Exception exception3) { throw new Exception("[MTBusiness.GetMTWaitList_3] " + exception3.Message); } return list; } /// /// from SMS_Send to SMS_MT and SMS_MT to SMS_CM_WAIT /// public static void SetSendToWait() { try { DataTable sendMsgDt = MTFactory.GetSendMsg(); foreach (DataRow dr in sendMsgDt.Rows) { int batchid = Int32.Parse(dr["batchid"].ToString()); string smscontent = dr["smscontent"].ToString(); string sendtime = dr["sendtime"].ToString(); string subnumber = dr["subnumber"].ToString(); int priority = Int32.Parse(dr["Priority"].ToString()); //string svrCode = dr["SER_CODE"].ToString(); DataTable sendMsgNODt = MTFactory.GetSendMsgNo(batchid); List numberArr = new List(); foreach (DataRow numberDr in sendMsgNODt.Rows) { numberArr.Add(numberDr["mobileNo"].ToString()); } MTFactory.AddSMSInfo(smscontent, numberArr.ToArray(), subnumber, "",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),subnumber,sendtime,batchid,priority); MTFactory.UpdateSendMsg(batchid); } MTFactory.SendMTTOWait(); } catch(Exception ex) { log4netService.Error("send±í²åÈëmt±íÒì³£:"+ex.Message); throw new Exception("[MTBusiness.SetSendToWait] " + ex.Message); } } public static Dictionary SplitSmsIfOverLength(string smsContent) { Func func = null; Action action = null; Dictionary dict = new Dictionary(); if ((smsContent != null) && (smsContent.Length <= 70)) { dict.Add(1, smsContent); return dict; } int i = -1; int index = 0; if (smsContent != null) { if (func == null) { func = s => ++i / 70; } if (action == null) { action = delegate(string s) { dict.Add(++index, s); }; } (from g in Enumerable.GroupBy(smsContent, func) select new string(g.ToArray())).ToList().ForEach(action); } return dict; } public static bool UpdateMTInfo(ReportInfo report) { bool flag; try { if (MTFactory.UpdateMTInfo(report) > 0) { return true; } flag = false; } catch (Exception exception) { throw new Exception("[MTBusiness.UpdateMTInfo2] " + exception.Message+exception.StackTrace); } return flag; } public static void UpdateMTInfo(SubmitInfo submit) { try { MTFactory.UpdateMTInfo(submit); } catch (Exception exception) { throw new Exception("[MTBusiness.UpdateMTInfo1] " + exception.Message); } } public static void UpdateMTWait(string out_gateway_id, int ismg) { try { switch (ismg) { case 1: MTFactory.Update_MTWait_CM_REPLACE(out_gateway_id, ""); return; case 2: MTFactory.Update_MTWait_CU_REPLACE(out_gateway_id, ""); return; case 3: MTFactory.Update_MTWait_TEL_REPLACE(out_gateway_id, ""); return; } } catch (Exception exception) { throw new Exception("[MTBusiness.UpdateMTWait] " + exception.Message); } } //ÖØÐ·¢ËÍ public static void UpdateUnSendMsg() { MTFactory.UpdateUnSendMsg(); } } }