Пример #1
0
        public string SendMessageOnOrderPay(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = EmailCore.GetMessageContentConfig();
            string         str        = messageContentConfig.OrderPay.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);
            decimal        totalMoney = info.TotalMoney;
            string         str1       = str.Replace("#Total#", totalMoney.ToString("F2"));

            SendMessage(destination, string.Concat(info.SiteName, "订单支付成功"), str1, false);
            return(str1);
        }
Пример #2
0
        public string SendMessageOnOrderRefund(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = EmailCore.GetMessageContentConfig();
            string         str         = messageContentConfig.OrderRefund.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);
            decimal        refundMoney = info.RefundMoney;
            string         str1        = str.Replace("#RefundMoney#", refundMoney.ToString("F2"));

            SendMessage(destination, string.Concat(info.SiteName, "订单(", info.OrderId, ")退款已处理"), str1, false);
            return(str1);
        }
Пример #3
0
        public void SetFormValues(IEnumerable <KeyValuePair <string, string> > values)
        {
            KeyValuePair <string, string> keyValuePair = values.FirstOrDefault((KeyValuePair <string, string> item) => item.Key == "SmtpServer");

            if (string.IsNullOrWhiteSpace(keyValuePair.Value))
            {
                throw new PluginConfigException("SMTP服务器不能为空");
            }
            KeyValuePair <string, string> keyValuePair1 = values.FirstOrDefault((KeyValuePair <string, string> item) => item.Key == "SmtpPort");

            if (!ValidateHelper.IsNumeric(keyValuePair1.Value))
            {
                throw new PluginConfigException("SMTP端口错误");
            }
            KeyValuePair <string, string> keyValuePair2 = values.FirstOrDefault((KeyValuePair <string, string> item) => item.Key == "EmailName");

            if (string.IsNullOrWhiteSpace(keyValuePair2.Value))
            {
                throw new PluginConfigException("SMTP用户名不能为空");
            }
            KeyValuePair <string, string> keyValuePair3 = values.FirstOrDefault((KeyValuePair <string, string> item) => item.Key == "Password");

            if (string.IsNullOrWhiteSpace(keyValuePair3.Value))
            {
                throw new PluginConfigException("SMTP密码不能为空");
            }
            KeyValuePair <string, string> keyValuePair4 = values.FirstOrDefault((KeyValuePair <string, string> item) => item.Key == "SendAddress");

            if (string.IsNullOrWhiteSpace(keyValuePair4.Value))
            {
                throw new PluginConfigException("SMTP邮箱不能为空");
            }
            if (!ValidateHelper.IsEmail(keyValuePair4.Value))
            {
                throw new PluginConfigException("SMTP邮箱错误");
            }
            KeyValuePair <string, string> keyValuePair5 = values.FirstOrDefault((KeyValuePair <string, string> item) => item.Key == "DisplayName");

            if (string.IsNullOrWhiteSpace(keyValuePair5.Value))
            {
                throw new PluginConfigException("SMTP显示名称不能为空");
            }
            MessageEmailConfig config = EmailCore.GetConfig();

            config.SmtpPort    = keyValuePair1.Value;
            config.SmtpServer  = keyValuePair.Value;
            config.EmailName   = keyValuePair2.Value;
            config.Password    = keyValuePair3.Value;
            config.SendAddress = keyValuePair4.Value;
            config.DisplayName = keyValuePair5.Value;
            EmailCore.SaveConfig(config);
        }
Пример #4
0
        public FormData GetFormData()
        {
            MessageEmailConfig config    = EmailCore.GetConfig();
            FormData           formDatum = new FormData();

            FormData.FormItem[] formItemArray = new FormData.FormItem[6];
            FormData.FormItem   formItem      = new FormData.FormItem();
            formItem.DisplayName = "SMTP服务器";
            formItem.Name        = "SmtpServer";
            formItem.IsRequired  = true;
            formItem.Type        = FormData.FormItemType.text;
            formItem.Value       = config.SmtpServer;
            formItemArray[0]     = formItem;
            FormData.FormItem formItem1 = new FormData.FormItem();
            formItem1.DisplayName = "SMTP服务器端口";
            formItem1.Name        = "SmtpPort";
            formItem1.IsRequired  = true;
            formItem1.Type        = FormData.FormItemType.text;
            formItem1.Value       = config.SmtpPort;
            formItemArray[1]      = formItem1;
            FormData.FormItem formItem2 = new FormData.FormItem();
            formItem2.DisplayName = "SMTP用户名";
            formItem2.Name        = "EmailName";
            formItem2.IsRequired  = true;
            formItem2.Type        = FormData.FormItemType.text;
            formItem2.Value       = config.EmailName;
            formItemArray[2]      = formItem2;
            FormData.FormItem formItem3 = new FormData.FormItem();
            formItem3.DisplayName = "SMTP用户密码";
            formItem3.Name        = "Password";
            formItem3.IsRequired  = true;
            formItem3.Type        = FormData.FormItemType.password;
            formItem3.Value       = config.Password;
            formItemArray[3]      = formItem3;
            FormData.FormItem formItem4 = new FormData.FormItem();
            formItem4.DisplayName = "SMTP邮箱";
            formItem4.Name        = "SendAddress";
            formItem4.IsRequired  = true;
            formItem4.Type        = FormData.FormItemType.text;
            formItem4.Value       = config.SendAddress;
            formItemArray[4]      = formItem4;
            FormData.FormItem formItem5 = new FormData.FormItem();
            formItem5.DisplayName = "显示名称";
            formItem5.Name        = "DisplayName";
            formItem5.IsRequired  = true;
            formItem5.Type        = FormData.FormItemType.text;
            formItem5.Value       = config.DisplayName;
            formItemArray[5]      = formItem5;
            formDatum.Items       = formItemArray;
            return(formDatum);
        }