private List<EntityMessage> SaveLicenceNumberSMS(List<string> VehicleCode, EntityMessage entityMsg) { List<EntityMessage> list= new List<EntityMessage>(); for (int i = 1; i < VehicleCode.Count;i++ ) { EntityMessage entity = new EntityMessage(); ESmsHistory historyentity = new ESmsHistory(); entity.SearchLocation = historyentity; entity.SearchLocation.smshistory_id = IdentityNoService.GetESMShistoryID(); entity.SearchLocation.LicenceNumber = VehicleCode[i]; entity.SearchLocation.IsProfessional = entityMsg.SearchLocation.IsProfessional; entity.SearchLocation.DownSMSContent = entityMsg.SearchLocation.DownSMSContent; entity.SearchLocation.ReceiveUserName = entityMsg.SearchLocation.ReceiveUserName; entity.SearchLocation.SMSType = entityMsg.SearchLocation.SMSType; entity.SearchLocation.telephone_number = entityMsg.SearchLocation.telephone_number; entity.SearchLocation.TenantCode = entityMsg.SearchLocation.TenantCode; entity.SearchLocation.UpSMSContent = entityMsg.SearchLocation.UpSMSContent; list.Add(entity); } return list; }
public bool SearchVehicle(string MNumber, string upMsg) { string tententcode = string.Empty; string IsProfessional = GetBindVehicle(MNumber,out tententcode); if (string.IsNullOrEmpty(IsProfessional)) { return true; } PlatformType type = IsProfessional == "1" ? PlatformType.GPS : PlatformType.MOVO; ICWZ iservice = GetInstance(type); if (upMsg.Trim().Equals("CWZ", StringComparison.OrdinalIgnoreCase)) { try { iservice.SearchVehicleInfo(null, MNumber, 0); } catch (Exception ex) { Logger.Error(ex); } } else { DataTable dt = QueryVehicleSetting(MNumber); if (upMsg.ToUpper().IndexOf("CWZ") >= 0) { //上行短信中不允许有空格 if (upMsg.IndexOf(" ") > 0) { string msg = "您好,短信查车请输入:CWZ#车牌号,最多可同时查询5辆车,车牌号之间以#分开!"; List<EntityMessage> entitymsg = new List<EntityMessage>(); EntityMessage e = new EntityMessage(); e.isHistory = true; e.SearchLocation = new PES.GPS.Entity.Report.ESmsHistory() { telephone_number = MNumber, DownSMSContent = msg, TenantCode = tententcode, UpSMSContent = upMsg, SendTime = System.DateTime.Now, IsProfessional = int.Parse(IsProfessional), SMSType = 0, smshistory_id = IdentityNoService.GetESMShistoryID() }; e.SearchLocation.ReceiveUserName = dt.Rows[0]["customername"].ToString(); entitymsg.Add(e); sms.SendMessage(entitymsg); return true; } string[] strVehicle = upMsg.Split('#'); if (strVehicle == null || strVehicle.Length < 2) { string msg = "您好,短信查车请输入:CWZ#车牌号,最多可同时查询5辆车,车牌号之间以#分开!"; List<EntityMessage> entitymsg = new List<EntityMessage>(); EntityMessage e = new EntityMessage(); e.isHistory = true; e.SearchLocation = new PES.GPS.Entity.Report.ESmsHistory() { telephone_number = MNumber, DownSMSContent = msg, TenantCode = tententcode, UpSMSContent = upMsg, SendTime = System.DateTime.Now, IsProfessional = int.Parse(IsProfessional), SMSType = 0, smshistory_id = IdentityNoService.GetESMShistoryID() }; e.SearchLocation.ReceiveUserName = dt.Rows[0]["customername"].ToString(); entitymsg.Add(e); sms.SendMessage(entitymsg); } else if (strVehicle != null && strVehicle.Length == 2) { string[] arrVehicle = iservice.GetVehicleNumber(MNumber, strVehicle[1]); if (arrVehicle == null || arrVehicle.Length == 0) return true; if (arrVehicle != null && arrVehicle.Length >= 1 && arrVehicle.Length <= 5) { handleSMS(iservice, arrVehicle, MNumber); } if (arrVehicle != null && arrVehicle.Length >5) { string msg = "您好,查车短信请输入:CWZ#车牌号#车牌号。最多可同时查询5辆车,车牌号之间以#分开!"; List<EntityMessage> entitymsg = new List<EntityMessage>(); EntityMessage e = new EntityMessage(); e.isHistory = true; e.SearchLocation = new PES.GPS.Entity.Report.ESmsHistory() { telephone_number = MNumber, DownSMSContent = msg, TenantCode = tententcode, UpSMSContent = upMsg, SendTime = System.DateTime.Now, IsProfessional = int.Parse(IsProfessional), SMSType = 0, smshistory_id = IdentityNoService.GetESMShistoryID() }; e.SearchLocation.ReceiveUserName = dt.Rows[0]["customername"].ToString(); entitymsg.Add(e); sms.SendMessage(entitymsg); } } else if (strVehicle != null && strVehicle.Length >= 3 && strVehicle.Length <= 6) { try { IList<string> vehiclelist = new List<string>(); for (int i = 1; i < strVehicle.Length; i++) { if (!vehiclelist.Contains(strVehicle[i])) { vehiclelist.Add(strVehicle[i]); } } iservice.SearchVehicleInfo(vehiclelist, MNumber, 0); } catch (Exception ex) { Logger.Error(ex); } } else { string msg = "您好,查车短信请输入:CWZ#车牌号#车牌号。最多可同时查询5辆车,车牌号之间以#分开!"; List<EntityMessage> entitymsg = new List<EntityMessage>(); EntityMessage e = new EntityMessage(); e.isHistory = true; e.SearchLocation = new PES.GPS.Entity.Report.ESmsHistory() { telephone_number = MNumber, DownSMSContent = msg, TenantCode = tententcode, UpSMSContent = upMsg, SendTime = System.DateTime.Now, IsProfessional = int.Parse(IsProfessional), SMSType = 0, smshistory_id = IdentityNoService.GetESMShistoryID() }; e.SearchLocation.ReceiveUserName = dt.Rows[0]["customername"].ToString(); entitymsg.Add(e); sms.SendMessage(entitymsg); } } else { string msg = "您好,短信查车请输入:CWZ#车牌号,最多可同时查询5辆车,车牌号之间以#分开!"; List<EntityMessage> entitymsg = new List<EntityMessage>(); EntityMessage e = new EntityMessage(); e.isHistory = true; e.SearchLocation = new PES.GPS.Entity.Report.ESmsHistory() { telephone_number = MNumber, DownSMSContent = msg, TenantCode = tententcode, UpSMSContent = upMsg, SendTime = System.DateTime.Now, IsProfessional = int.Parse(IsProfessional), SMSType = 0, smshistory_id = IdentityNoService.GetESMShistoryID() }; e.SearchLocation.ReceiveUserName = dt.Rows[0]["customername"].ToString(); entitymsg.Add(e); sms.SendMessage(entitymsg); } } return true; }
/// <summary> /// 创建发送短信信息实体 /// </summary> /// <param name="mobile"></param> /// <returns></returns> protected virtual EntityMessage CreateEntityMessage(string mobile) { EntityMessage entityMsg = new EntityMessage(); ESmsHistory info = new ESmsHistory(); DataTable dt = QueryVehicleSetting(mobile); if (dt != null && dt.Rows.Count > 0) { info.smshistory_id = IdentityNoService.GetESMShistoryID(); //544545454; info.SMSType = 0; info.IsProfessional = int.Parse(dt.Rows[0]["IsProfessional"].ToString()); info.telephone_number = mobile; info.UpSMSContent = "CWZ"; info.ReceiveUserName = dt.Rows[0]["customername"].ToString(); info.TenantCode = dt.Rows[0]["tenantcode"].ToString(); } entityMsg.SearchLocation = info; entityMsg.isHistory = true; return entityMsg; }