示例#1
0
        public void SetAllStatus(Dictionary <MessageTypeEnum, StatusEnum> dic)
        {
            foreach (var d in dic)
            {
                SetMessageStatus(d.Key, d.Value);
            }

            EmailCore.SaveMessageStatus(messageStatus);
        }
示例#2
0
        public void SetFormValues(IEnumerable <KeyValuePair <string, string> > values)
        {
            var SmtpServerItem = values.FirstOrDefault(item => item.Key == "SmtpServer");

            if (string.IsNullOrWhiteSpace(SmtpServerItem.Value))
            {
                throw new Himall.Core.PluginConfigException("SMTP服务器不能为空");
            }

            var SmtpPortItem = values.FirstOrDefault(item => item.Key == "SmtpPort");

            if (!Core.Helper.ValidateHelper.IsNumeric(SmtpPortItem.Value))
            {
                throw new Himall.Core.PluginConfigException("SMTP端口错误");
            }

            var EmailNameItem = values.FirstOrDefault(item => item.Key == "EmailName");

            if (string.IsNullOrWhiteSpace(EmailNameItem.Value))
            {
                throw new Himall.Core.PluginConfigException("SMTP用户名不能为空");
            }

            var PasswordItem = values.FirstOrDefault(item => item.Key == "Password");

            if (string.IsNullOrWhiteSpace(PasswordItem.Value))
            {
                throw new Himall.Core.PluginConfigException("SMTP密码不能为空");
            }

            var SendAddressItem = values.FirstOrDefault(item => item.Key == "SendAddress");

            if (string.IsNullOrWhiteSpace(SendAddressItem.Value))
            {
                throw new Himall.Core.PluginConfigException("SMTP邮箱不能为空");
            }

            if (!Core.Helper.ValidateHelper.IsEmail(SendAddressItem.Value))
            {
                throw new Himall.Core.PluginConfigException("SMTP邮箱错误");
            }
            var DisplayNameItem = values.FirstOrDefault(item => item.Key == "DisplayName");

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

            oldConfig.SmtpPort    = SmtpPortItem.Value;
            oldConfig.SmtpServer  = SmtpServerItem.Value;
            oldConfig.EmailName   = EmailNameItem.Value;
            oldConfig.Password    = PasswordItem.Value;
            oldConfig.SendAddress = SendAddressItem.Value;
            oldConfig.DisplayName = DisplayNameItem.Value;
            EmailCore.SaveConfig(oldConfig);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
0
        public void Enable(MessageTypeEnum e)
        {
            CheckCanEnable();
            if (dic.Where(a => a.Key == e).FirstOrDefault().Value == Himall.Core.Plugins.Message.StatusEnum.Disable)
            {
                throw new Himall.Core.HimallException("该功能已被禁止,不能进行设置");
            }
            SetMessageStatus(e, StatusEnum.Open);
            //using (FileStream fs = new FileStream(EmailCore.WorkDirectory + "/Data/config.xml", FileMode.Create))
            //{
            //    XmlSerializer xs = new XmlSerializer(typeof(MessageStatus));
            //    xs.Serialize(fs, messageStatus);
            //}

            EmailCore.SaveMessageStatus(messageStatus);
        }
示例#8
0
        void InitMessageStatus()
        {
            #region 原读取本地方法
            //DirectoryInfo dir = new DirectoryInfo(EmailCore.WorkDirectory);
            ////查找该目录下的
            //var configFile = dir.GetFiles("Data/config.xml").FirstOrDefault();
            //if (configFile != null)
            //{
            //    using (FileStream fs = new FileStream(configFile.FullName, FileMode.Open))
            //    {
            //        XmlSerializer xs = new XmlSerializer(typeof(MessageStatus));
            //        messageStatus = (MessageStatus)xs.Deserialize(fs);
            //        dic.Clear();
            //        dic.Add(MessageTypeEnum.FindPassWord, (StatusEnum)messageStatus.FindPassWord);
            //        dic.Add(MessageTypeEnum.OrderCreated, (StatusEnum)messageStatus.OrderCreated);
            //        dic.Add(MessageTypeEnum.OrderPay, (StatusEnum)messageStatus.OrderPay);
            //        dic.Add(MessageTypeEnum.OrderRefund, (StatusEnum)messageStatus.OrderRefund);
            //        dic.Add(MessageTypeEnum.OrderShipping, (StatusEnum)messageStatus.OrderShipping);
            //        dic.Add(MessageTypeEnum.ShopAudited, (StatusEnum)messageStatus.ShopAudited);
            //        //2.4删除
            //        // dic.Add(MessageTypeEnum.ShopSuccess, (StatusEnum)messageStatus.ShopSuccess);去掉
            //        dic.Add(MessageTypeEnum.ShopHaveNewOrder, (StatusEnum)messageStatus.ShopHaveNewOrder);
            //        dic.Add(MessageTypeEnum.ReceiveBonus, (StatusEnum)messageStatus.ReceiveBonus);
            //        dic.Add(MessageTypeEnum.LimitTimeBuy, (StatusEnum)messageStatus.LimitTimeBuy);
            //        dic.Add(MessageTypeEnum.SubscribeLimitTimeBuy, (StatusEnum)messageStatus.SubscribeLimitTimeBuy);
            //        dic.Add(MessageTypeEnum.RefundDeliver, (StatusEnum)messageStatus.RefundDeliver);

            //        #region 拼团
            //        dic.Add(MessageTypeEnum.FightGroupOpenSuccess, (StatusEnum)messageStatus.FightGroupOpenSuccess);
            //        dic.Add(MessageTypeEnum.FightGroupJoinSuccess, (StatusEnum)messageStatus.FightGroupJoinSuccess);
            //        dic.Add(MessageTypeEnum.FightGroupNewJoin, (StatusEnum)messageStatus.FightGroupNewJoin);
            //        dic.Add(MessageTypeEnum.FightGroupFailed, (StatusEnum)messageStatus.FightGroupFailed);
            //        dic.Add(MessageTypeEnum.FightGroupSuccess, (StatusEnum)messageStatus.FightGroupSuccess);
            //        #endregion

            //        //发送优惠券
            //        dic.Add(MessageTypeEnum.SendCouponSuccess, (StatusEnum)messageStatus.SendCouponSuccess);
            //    }
            //}
            #endregion

            messageStatus = EmailCore.GetMessageStatus();
            if (messageStatus != null)
            {
                dic.Clear();
                dic.Add(MessageTypeEnum.FindPassWord, (StatusEnum)messageStatus.FindPassWord);
                dic.Add(MessageTypeEnum.OrderCreated, (StatusEnum)messageStatus.OrderCreated);
                dic.Add(MessageTypeEnum.OrderPay, (StatusEnum)messageStatus.OrderPay);
                dic.Add(MessageTypeEnum.OrderRefund, (StatusEnum)messageStatus.OrderRefund);
                dic.Add(MessageTypeEnum.OrderShipping, (StatusEnum)messageStatus.OrderShipping);
                dic.Add(MessageTypeEnum.ShopAudited, (StatusEnum)messageStatus.ShopAudited);
                //2.4删除
                // dic.Add(MessageTypeEnum.ShopSuccess, (StatusEnum)messageStatus.ShopSuccess);去掉
                dic.Add(MessageTypeEnum.ShopHaveNewOrder, (StatusEnum)messageStatus.ShopHaveNewOrder);
                dic.Add(MessageTypeEnum.ReceiveBonus, (StatusEnum)messageStatus.ReceiveBonus);
                dic.Add(MessageTypeEnum.LimitTimeBuy, (StatusEnum)messageStatus.LimitTimeBuy);
                dic.Add(MessageTypeEnum.SubscribeLimitTimeBuy, (StatusEnum)messageStatus.SubscribeLimitTimeBuy);
                dic.Add(MessageTypeEnum.RefundDeliver, (StatusEnum)messageStatus.RefundDeliver);

                #region 拼团
                dic.Add(MessageTypeEnum.FightGroupOpenSuccess, (StatusEnum)messageStatus.FightGroupOpenSuccess);
                dic.Add(MessageTypeEnum.FightGroupJoinSuccess, (StatusEnum)messageStatus.FightGroupJoinSuccess);
                dic.Add(MessageTypeEnum.FightGroupNewJoin, (StatusEnum)messageStatus.FightGroupNewJoin);
                dic.Add(MessageTypeEnum.FightGroupFailed, (StatusEnum)messageStatus.FightGroupFailed);
                dic.Add(MessageTypeEnum.FightGroupSuccess, (StatusEnum)messageStatus.FightGroupSuccess);
                #endregion

                //发送优惠券
                dic.Add(MessageTypeEnum.SendCouponSuccess, (StatusEnum)messageStatus.SendCouponSuccess);
            }
        }
示例#9
0
        public Core.Plugins.FormData GetFormData()
        {
            var config = EmailCore.GetConfig();

            var formData = new Core.Plugins.FormData()
            {
                Items = new Core.Plugins.FormData.FormItem[] {
                    //SmtpServer
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "SMTP服务器",
                        Name        = "SmtpServer",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.SmtpServer
                    },
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "SMTP服务器端口",
                        Name        = "SmtpPort",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.SmtpPort
                    },
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "SMTP用户名",
                        Name        = "EmailName",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.EmailName
                    },
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "SMTP用户密码",
                        Name        = "Password",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.password,
                        Value       = config.Password
                    },
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "SMTP邮箱",
                        Name        = "SendAddress",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.SendAddress
                    },
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "显示名称",
                        Name        = "DisplayName",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.DisplayName
                    }
                }
            };

            return(formData);
        }