Ejemplo n.º 1
0
 private void SetInfo(Foresight.DataAccess.ThirdCustomer data)
 {
     this.tdProjectName.Value  = data.ProjectName;
     this.tdRoomName.Value     = data.RoomName;
     this.tdCustomerName.Value = data.CustomerName;
     this.tdPhoneNumber.Value  = data.PhoneNumber;
     this.tdSignDate.Value     = WebUtil.GetStrDate(data.SignDate);
 }
Ejemplo n.º 2
0
        public static Ui.DataGrid GetThirdCustomerListByKeywords(string Keywords, DateTime StartTime, DateTime EndTime, int SendStatus, string ProjectName, string orderBy, long startRowIndex, int pageSize, bool canexport = false)
        {
            long totalRows = 0;
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("1=1");
            #region 关键字查询
            if (!string.IsNullOrEmpty(Keywords))
            {
                conditions.Add("(CustomerName like @Keywords or PhoneNumber like @Keywords or RoomName like @Keywords)");
                parameters.Add(new SqlParameter("@Keywords", "%" + Keywords + "%"));
            }
            #endregion
            if (StartTime > DateTime.MinValue)
            {
                conditions.Add("SignDate>=@StartTime");
                parameters.Add(new SqlParameter("@StartTime", StartTime));
            }
            if (EndTime > DateTime.MinValue)
            {
                conditions.Add("SignDate<=@EndTime");
                parameters.Add(new SqlParameter("@EndTime", EndTime.AddDays(1)));
            }
            if (SendStatus == 1)//未发送
            {
                conditions.Add("LastSendTime is null");
            }
            else if (SendStatus == 2)//已发送
            {
                conditions.Add("LastSendTime is not null");
            }
            if (!string.IsNullOrEmpty(ProjectName))
            {
                conditions.Add("[ProjectName]=@ProjectName");
                parameters.Add(new SqlParameter("@ProjectName", ProjectName));
            }
            string          fieldList = "[ThirdCustomer].*";
            string          Statement = " from [ThirdCustomer] where  " + string.Join(" and ", conditions.ToArray());
            ThirdCustomer[] list      = new ThirdCustomer[] { };
            if (canexport)
            {
                list      = GetList <ThirdCustomer>("select " + fieldList + Statement + " " + orderBy, parameters).ToArray();
                totalRows = list.Length;
            }
            else
            {
                list = GetList <ThirdCustomer>(fieldList, Statement, parameters, orderBy, startRowIndex, pageSize, out totalRows).ToArray();
            }
            DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
            dg.rows  = list;
            dg.total = totalRows;
            dg.page  = pageSize;
            return(dg);
        }
Ejemplo n.º 3
0
        public static bool Send_SmsTemplteMsg(List <int> IDList, DateTime StartTime, DateTime EndTime, int SmsTemplateID, int MyUserID, string Keywords, string ProjectName, int SendStatus, bool IsSelectAll, ref string error, int RestCount)
        {
            var dataList = ThirdCustomer.GetThirdCustomerListByIDList(Keywords, StartTime, EndTime, SendStatus, ProjectName, IDList, IsSelectAll);

            if (dataList.Length == 0)
            {
                error = "客户数据为空";
                return(false);
            }
            var templateList = Sms_Tencent_Template.GetSms_Tencent_Templates().ToArray();

            if (SmsTemplateID > 0)
            {
                templateList = templateList.Where(p => p.ID == SmsTemplateID).ToArray();
            }
            if (templateList.Length == 0)
            {
                error = "选中的短信模板不存在";
                return(false);
            }
            var templateParamList = Sms_Tencent_Param.GetSms_Tencent_Params().Where(p => (templateList.Select(q => q.ID).Contains(p.SmsTemplateID))).ToArray();

            bool sendStatus    = false;
            var  sendParamList = new List <Dictionary <string, object> >();
            int  needSendCount = 0;

            foreach (var dataItem in dataList)
            {
                foreach (var item in templateList)
                {
                    var sendParamItem = new Dictionary <string, object>();
                    var myParamList   = templateParamList.Where(p => p.SmsTemplateID == item.ID).Take(item.ParamCount).ToArray();
                    var paramList     = new List <string>();
                    foreach (var myParamItem in myParamList)
                    {
                        if (myParamItem.ParamType == 203)//业主姓名
                        {
                            paramList.Add(dataItem.CustomerName);
                            continue;
                        }
                        if (myParamItem.ParamType == 204)//业主电话
                        {
                            paramList.Add(dataItem.PhoneNumber);
                            continue;
                        }
                        if (myParamItem.ParamType == 201)//项目名称
                        {
                            paramList.Add(dataItem.ProjectName);
                            continue;
                        }
                        if (myParamItem.ParamType == 202)//资源编号
                        {
                            paramList.Add(dataItem.RoomName);
                            continue;
                        }
                        if (myParamItem.ParamType == 101)//验证码
                        {
                            paramList.Add(Utility.Tools.GetVerifyCode());
                            continue;
                        }
                        if (myParamItem.ParamType == 102)//有效分钟
                        {
                            paramList.Add(myParamItem.ParamValue);
                            continue;
                        }
                    }
                    string sendResult = string.Empty;
                    sendParamItem["RelatePhoneNumber"] = dataItem.PhoneNumber;
                    sendParamItem["TemplateID"]        = item.TemplateID;
                    sendParamItem["paramList"]         = paramList;
                    sendParamItem["TemplateSign"]      = item.TemplateSign;
                    sendParamItem["dataItem"]          = dataItem;
                    sendParamList.Add(sendParamItem);
                    needSendCount += GetRealSmsCountByContent(item.TemplateContent, paramList);
                }
            }
            if (RestCount < needSendCount)
            {
                error = "短信余额不足,请先充值";
                return(false);
            }
            var sendResultList = new List <Sms_SendResult>();
            var customerList   = new List <ThirdCustomer>();

            foreach (var sendParamItem in sendParamList)
            {
                var    dataItem          = sendParamItem["dataItem"] as ThirdCustomer;
                string RelatePhoneNumber = sendParamItem["RelatePhoneNumber"].ToString();
                string TemplateID        = sendParamItem["TemplateID"].ToString();
                var    paramList         = sendParamItem["paramList"] as List <string>;
                string TemplateSign      = sendParamItem["TemplateSign"].ToString();
                string sendResult        = string.Empty;
                bool   status            = Utility.TencentSmsNew.doPostSmsMethod(new string[] { RelatePhoneNumber }, paramList, TemplateID, ref sendResult, sign: TemplateSign);
                if (status)
                {
                    sendStatus            = true;
                    dataItem.LastSendTime = DateTime.Now;
                    customerList.Add(dataItem);
                }
                var sendResultItem = new Sms_SendResult();
                sendResultItem.TemplateID = !string.IsNullOrEmpty(TemplateID) ? TemplateID : "无";
                sendResultItem.SendTime   = DateTime.Now;
                sendResultItem.SendStatus = status ? 1 : 2;
                sendResultItem.SendResult = sendResult;
                sendResultItem.CustomerID = dataItem.ID;
                sendResultList.Add(sendResultItem);
            }
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    foreach (var item in sendResultList)
                    {
                        item.Save(helper);
                    }
                    foreach (var item in customerList)
                    {
                        item.Save(helper);
                    }
                    helper.Commit();
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    Utility.LogHelper.WriteError("Sms_SendResult", "Save", ex);
                }
            }
            return(sendStatus);
        }