/// <summary> /// 短信查车修改 /// </summary> /// <param name="smsID"></param> /// <param name="tenantCode"></param> /// <param name="customerName"></param> /// <param name="telphone"></param> /// <param name="vehicleCodes"></param> /// <param name="LicenceNumbers"></param> /// <param name="msg"></param> /// <returns></returns> public bool SaveSMSQuery(ulong smsID, string tenantCode,string selectTenantCode,string customerName, string telphone, string vehicleCodes, string LicenceNumbers, out string msg) { try { if (string.IsNullOrEmpty(customerName)) { msg = "请输入姓名!"; return false; } if (string.IsNullOrEmpty(telphone)) { msg = "请输入手机号码!"; return false; } List<Guid> codes = new List<Guid>(); if (!string.IsNullOrEmpty(vehicleCodes)) { string[] codeArray = vehicleCodes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int length = codeArray.Count(); for (int i = 0; i < length; i++) { codes.Add(new Guid(codeArray[i])); } } if (codes.Count <= 0) { msg = "请选择查询车辆!"; return false; } List<string> licenceList = new List<string>(); if (!string.IsNullOrEmpty(LicenceNumbers)) { string[] licenceArray = LicenceNumbers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int length = licenceArray.Count(); for (int i = 0; i < length; i++) { licenceList.Add(licenceArray[i]); } } if (licenceList.Count <= 0) { msg = "请选择查询车辆!"; return false; } List<string> msgList = new List<string>(); for (int i = 0; i < codes.Count; i++) { List<ulong> smsIDList = DACFacade.Gps.GpsSmsVehicleDAC.SelectIDByCode(selectTenantCode, codes[i].ToString()); if (smsIDList.Count > 5 || smsIDList.Count == 5 && !smsIDList.Contains(smsID)) { msgList.Add(licenceList[i]); } } if (msgList.Count > 0) { msg = string.Format("操作失败,以下车辆已被关注5次\r\n{0}\r\n请重新选择车辆", string.Join(",", msgList.ToArray())); return false; } //修改 ESmsQueryVehicleSetting entity = DACFacade.Gps.SmsQueryVehicleSettinDAC.Select(smsID); entity.TenantCode = tenantCode; entity.CustomerName = customerName; entity.CustomerTelephone = telphone; entity.IsProfessional = false; entity.SMSVehicle.Clear(); if (codes != null && codes.Count > 0) { for (int i = 0; i < codes.Count; i++) { ESmsVehicle vehicle = new ESmsVehicle() { smsvehicle_id = DACFacade.Movo.IdentityNoDAC.GetSMSVehicleID(), VehicleCode = codes[i].ToString(), TenantCode = tenantCode, LicenseNumber = licenceList[i] }; entity.SMSVehicle.Add(vehicle); } } bool exist = DACFacade.Gps.SmsQueryVehicleSettinDAC.IsExistTelephone(entity.Sms_vehicle_set_id.ToString(),telphone); if (exist) { msg = "手机号码己存在,请输入其它号码。"; return false; } else { DACFacade.Gps.SmsQueryVehicleSettinDAC.UpdateSmsVehicle(entity); } msg = "修改成功"; return true; } catch (Exception ex) { msg = "修改失败" + ex.Message; return false; } }
/// <summary> /// 新增 /// </summary> /// <returns></returns> public bool CreateSMSQuery(string customerName, string telphone, string vehicleCodes, string LicenceNumbers, string tenanetCode, string selectTenantCode, out string msg) { try { if (string.IsNullOrEmpty(customerName)) { msg = "请输入姓名!"; return false; } if (string.IsNullOrEmpty(telphone)) { msg = "请输入手机号码!"; return false; } List<Guid> codes = new List<Guid>(); if (!string.IsNullOrEmpty(vehicleCodes)) { string[] codeArray = vehicleCodes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int length = codeArray.Count(); for (int i = 0; i < length; i++) { codes.Add(new Guid(codeArray[i])); } } if (codes.Count <= 0) { msg = "请选择查询车辆!"; return false; } List<string> licenceList = new List<string>(); if (!string.IsNullOrEmpty(LicenceNumbers)) { string[] licenceArray = LicenceNumbers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int length = licenceArray.Count(); for (int i = 0; i < length; i++) { licenceList.Add(licenceArray[i]); } } if (licenceList.Count <= 0) { msg = "请选择查询车辆!"; return false; } List<ESmsVehicle> list = DACFacade.Gps.GpsSmsVehicleDAC.Select(selectTenantCode); if (list != null && list.Count > 0) { List<string> msgList = new List<string>(); for (int i = 0; i < list.Count; i++) { for (int j = 0; j < codes.Count; j++) { if (list[i].VehicleCode.ToString() == codes[j].ToString()) { if (licenceList.Count > j) { msgList.Add(licenceList[j]); break; } } } } if (msgList.Count > 0) { msg = string.Format("操作失败,以下车辆已被关注5次\r\n{0}\r\n请重新选择车辆", string.Join(",", msgList.ToArray())); return false; } } //新增操作 ESmsQueryVehicleSetting entity = new ESmsQueryVehicleSetting(); entity.Sms_vehicle_set_id = DACFacade.Movo.IdentityNoDAC.GetSMSQueryVehicleSettingID(); entity.CreateDate = DateTime.Now; entity.TenantCode = tenanetCode; entity.CustomerName = customerName; entity.CustomerTelephone = telphone; entity.IsProfessional = false; if (codes.Count > 0) { entity.SMSVehicle = new List<ESmsVehicle>(); for (int i = 0; i < codes.Count; i++) { ESmsVehicle vehicle = new ESmsVehicle() { smsvehicle_id = DACFacade.Movo.IdentityNoDAC.GetSMSVehicleID(), VehicleCode = codes[i].ToString(), TenantCode = tenanetCode, LicenseNumber = licenceList[i] }; entity.SMSVehicle.Add(vehicle); } } bool exist = DACFacade.Gps.SmsQueryVehicleSettinDAC.IsExistTelephone(null,telphone); if (exist) { msg = "手机号码己存在,请输入其它号码。"; return false; } else { DACFacade.Gps.SmsQueryVehicleSettinDAC.AddSmsVehicle(entity); } msg = "新增成功!"; return true; } catch (Exception ex) { msg = "新增失败!" + ex.Message; return false; } }