/// <summary> /// 获取固定节假日发送的客户关怀计划 /// </summary> /// <param name="FixType">节假日类型</param> /// <returns></returns> public IList <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo> GetFixTypeSend(params EyouSoft.Model.EnumType.CompanyStructure.CustomerCareForSendSpecialTime[] FixType) { if (FixType == null || FixType.Length <= 0) { return(null); } string strFixTypes = string.Empty; foreach (EyouSoft.Model.EnumType.CompanyStructure.CustomerCareForSendSpecialTime t in FixType) { strFixTypes += ((int)t).ToString() + ","; } strFixTypes = strFixTypes.Trim(','); DbCommand dc = _db.GetStoredProcCommand("proc_CustomerCarefor_GetWillSendList"); _db.AddInParameter(dc, "IsTime", DbType.Int32, 2); _db.AddInParameter(dc, "CurrTime", DbType.DateTime, DBNull.Value); _db.AddInParameter(dc, "FixTypes", DbType.String, strFixTypes); IList <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo> list = new List <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo>(); using (IDataReader dr = DbHelper.RunReaderProcedure(dc, _db)) { EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo tModel = null; while (dr.Read()) { tModel = new EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo(); if (!dr.IsDBNull(dr.GetOrdinal("Id"))) { tModel.CustomerCareforId = int.Parse(dr["Id"].ToString()); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyId"))) { tModel.CompanyId = int.Parse(dr["CompanyId"].ToString()); } tModel.MobileCode = dr["MobileCode"].ToString(); tModel.Content = dr["Content"].ToString(); if (!dr.IsDBNull(dr.GetOrdinal("ChannelId"))) { tModel.ChannelId = int.Parse(dr["ChannelId"].ToString()); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorId"))) { tModel.OperatorId = int.Parse(dr["OperatorId"].ToString()); } IList <EyouSoft.Model.CompanyStructure.NameAndMobile> listName = new List <EyouSoft.Model.CompanyStructure.NameAndMobile>(); if (!dr.IsDBNull(dr.GetOrdinal("CustomerInfo")) && !string.IsNullOrEmpty(dr["CustomerInfo"].ToString())) { listName = listName.Union(this.GetNameAndMobileByXML(dr["CustomerInfo"].ToString(), "tbl_CustomerContactInfo", "Name", "Mobile")).ToList(); } if (!dr.IsDBNull(dr.GetOrdinal("SupplierInfo")) && !string.IsNullOrEmpty(dr["SupplierInfo"].ToString())) { listName = listName.Union(this.GetNameAndMobileByXML(dr["SupplierInfo"].ToString(), "tbl_SupplierContact", "ContactName", "ContactMobile")).ToList(); } if (!dr.IsDBNull(dr.GetOrdinal("DepartmentInfo")) && !string.IsNullOrEmpty(dr["DepartmentInfo"].ToString())) { listName = listName.Union(this.GetNameAndMobileByXML(dr["DepartmentInfo"].ToString(), "tbl_CompanyUser", "ContactName", "ContactMobile")).ToList(); } tModel.NameAndMobile = listName; if (!(string.IsNullOrEmpty(tModel.MobileCode) && tModel.NameAndMobile.Count <= 0)) { list.Add(tModel); } } } //更新是否发送状态 if (list != null && list.Count > 0) { foreach (var item in list) { UpdateIsSeded(item.CustomerCareforId, true); } } return(list); }
/// <summary> /// 获取固定时间发送的客户关怀计划 /// </summary> /// <param name="Time">固定发送时间</param> /// <returns></returns> public IList <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo> GetTimeSend(DateTime Time) { DbCommand dc = _db.GetStoredProcCommand("proc_CustomerCarefor_GetWillSendList"); _db.AddInParameter(dc, "IsTime", DbType.Int32, 1); _db.AddInParameter(dc, "CurrTime", DbType.DateTime, Time); _db.AddInParameter(dc, "FixTypes", DbType.String, DBNull.Value); IList <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo> list = new List <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo>(); using (IDataReader dr = DbHelper.RunReaderProcedure(dc, _db)) { EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo tModel = null; while (dr.Read()) { tModel = new EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo(); if (!dr.IsDBNull(dr.GetOrdinal("Id"))) { tModel.CustomerCareforId = int.Parse(dr["Id"].ToString()); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyId"))) { tModel.CompanyId = int.Parse(dr["CompanyId"].ToString()); } tModel.MobileCode = dr["MobileCode"].ToString(); tModel.Content = dr["Content"].ToString(); if (!dr.IsDBNull(dr.GetOrdinal("ChannelId"))) { tModel.ChannelId = int.Parse(dr["ChannelId"].ToString()); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorId"))) { tModel.OperatorId = int.Parse(dr["OperatorId"].ToString()); } IList <EyouSoft.Model.CompanyStructure.NameAndMobile> listName = new List <EyouSoft.Model.CompanyStructure.NameAndMobile>(); if (!dr.IsDBNull(dr.GetOrdinal("CustomerInfo")) && !string.IsNullOrEmpty(dr["CustomerInfo"].ToString())) { listName = listName.Union(this.GetNameAndMobileByXML(dr["CustomerInfo"].ToString(), "tcci", "Name", "Mobile")).ToList(); } if (!dr.IsDBNull(dr.GetOrdinal("SupplierInfo")) && !string.IsNullOrEmpty(dr["SupplierInfo"].ToString())) { listName = listName.Union(this.GetNameAndMobileByXML(dr["SupplierInfo"].ToString(), "tsc", "ContactName", "ContactMobile")).ToList(); } if (!dr.IsDBNull(dr.GetOrdinal("DepartmentInfo")) && !string.IsNullOrEmpty(dr["DepartmentInfo"].ToString())) { listName = listName.Union(this.GetNameAndMobileByXML(dr["DepartmentInfo"].ToString(), "tbl_CompanyUser", "ContactName", "ContactMobile")).ToList(); } tModel.NameAndMobile = listName; list.Add(tModel); } } //更新是否发送状态 if (list != null && list.Count > 0) { foreach (var item in list) { UpdateIsSeded(item.CustomerCareforId, true); } } return(list); }
/// <summary> /// 发送短信 /// </summary> /// <param name="info"></param> private void SendMessage(EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo info) { if (info == null) { return; } if (string.IsNullOrEmpty(info.MobileCode) && (info.NameAndMobile == null || info.NameAndMobile.Count < 1)) { return; } EyouSoft.BackgroundServices.SMSSOAP.SMSChannel channel = SmsUtils.GetSmsSendChannel(info.ChannelId); #region 输入号码 if (!string.IsNullOrEmpty(info.MobileCode))//输入号码 { EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo messageInfo = new EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo(); string[] mobileArr = info.MobileCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[] mobiles = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[mobileArr.Length]; for (int i = 0; i < mobileArr.Length; i++) { mobiles[i] = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo(); mobiles[i].Mobile = mobileArr[i]; mobiles[i].IsEncrypt = false; } SmsUtils.WLog(string.Format("客户关怀后台服务发送固定时间(指定的时间值)将要发送短信条数:{0}", mobiles.Length), "Config/BackgroundServicesLog.txt"); messageInfo.Mobiles = mobiles; messageInfo.CompanyId = info.CompanyId; messageInfo.CompanyName = ""; messageInfo.SendChannel = channel; messageInfo.SendTime = DateTime.Now; messageInfo.SendType = EyouSoft.BackgroundServices.SMSSOAP.SendType.直接发送; messageInfo.SMSContent = info.Content; messageInfo.SMSType = 0; messageInfo.UserFullName = ""; messageInfo.UserId = info.OperatorId; EyouSoft.BackgroundServices.SMSSOAP.SMSAPI api = EyouSoft.Services.BackgroundServices.SmsUtils.GetSmsApi(); EyouSoft.BackgroundServices.SMSSOAP.SendResultInfo result = api.Send(messageInfo); } #endregion #region 匹配号码 if (info.NameAndMobile != null && info.NameAndMobile.Count > 0)//匹配号码 { SmsUtils.WLog(string.Format("客户关怀后台服务发送节假日及生日短信将要发送短信条数:{0}", info.NameAndMobile.Count), "Config/BackgroundServicesLog.txt"); foreach (var nameAndMobile in info.NameAndMobile) { if (string.IsNullOrEmpty(nameAndMobile.ContactMobile)) { continue; } EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo messageInfo = new EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo(); EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[] mobiles = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[1]; mobiles[0] = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo(); mobiles[0].Mobile = nameAndMobile.ContactMobile; mobiles[0].IsEncrypt = false; messageInfo.Mobiles = mobiles; messageInfo.CompanyId = info.CompanyId; messageInfo.CompanyName = ""; messageInfo.SendChannel = channel; messageInfo.SendTime = DateTime.Now; messageInfo.SendType = EyouSoft.BackgroundServices.SMSSOAP.SendType.直接发送; messageInfo.SMSContent = info.Content.Replace("[姓名]", nameAndMobile.ContactName); messageInfo.SMSType = 0; messageInfo.UserFullName = ""; messageInfo.UserId = info.OperatorId; EyouSoft.BackgroundServices.SMSSOAP.SMSAPI api = EyouSoft.Services.BackgroundServices.SmsUtils.GetSmsApi(); EyouSoft.BackgroundServices.SMSSOAP.SendResultInfo result = api.Send(messageInfo); } } #endregion }