Example #1
0
 internal static void EnqueuEmail(MailMessage email, SiteSettings settings)
 {
     if (((email != null) && (email.To != null)) && (email.To.Count > 0))
     {
         new EmailQueueDao().QueueEmail(email);
     }
 }
Example #2
0
 public static void SendQueuedEmails(int failureInterval, int maxNumberOfTries, SiteSettings settings)
 {
     if (settings != null)
     {
         HiConfiguration config = HiConfiguration.GetConfig();
         Dictionary<Guid, MailMessage> dictionary = new EmailQueueDao().DequeueEmail();
         IList<Guid> list = new List<Guid>();
         EmailSender sender = Messenger.CreateEmailSender(settings);
         if (sender != null)
         {
             int num = 0;
             short smtpServerConnectionLimit = config.SmtpServerConnectionLimit;
             foreach (Guid guid in dictionary.Keys)
             {
                 if (Messenger.SendMail(dictionary[guid], sender))
                 {
                     new EmailQueueDao().DeleteQueuedEmail(guid);
                     if ((smtpServerConnectionLimit != -1) && (++num >= smtpServerConnectionLimit))
                     {
                         Thread.Sleep(new TimeSpan(0, 0, 0, 15, 0));
                         num = 0;
                     }
                 }
                 else
                 {
                     list.Add(guid);
                 }
             }
             if (list.Count > 0)
             {
                 new EmailQueueDao().QueueSendingFailure(list, failureInterval, maxNumberOfTries);
             }
         }
     }
 }
Example #3
0
 public override bool AddSiteSettings(SiteSettings settings, int requestId, DbTransaction dbtran)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO distro_Settings(UserId,SiteUrl,SiteUrl2,Disabled, RequestDate,CreateDate,RecordCode,RecordCode2,LogoUrl,SiteDescription,SiteName,Theme,Footer,SearchMetaKeywords,SearchMetaDescription,DecimalLength,YourPriceName,DefaultProductImage,PointsRate,OrderShowDays,HtmlOnlineServiceCode) VALUES(@UserId,@SiteUrl,@SiteUrl2,@Disabled,@RequestDate,@CreateDate,@RecordCode,@RecordCode2,@LogoUrl,@SiteDescription,@SiteName,@Theme,@Footer,@SearchMetaKeywords,@SearchMetaDescription,@DecimalLength,@YourPriceName,@DefaultProductImage,@PointsRate,@OrderShowDays,@HtmlOnlineServiceCode)");
     database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, settings.UserId);
     database.AddInParameter(sqlStringCommand, "SiteUrl", DbType.String, settings.SiteUrl);
     database.AddInParameter(sqlStringCommand, "RecordCode", DbType.String, settings.RecordCode);
     database.AddInParameter(sqlStringCommand, "LogoUrl", DbType.String, settings.LogoUrl);
     database.AddInParameter(sqlStringCommand, "SiteDescription", DbType.String, settings.SiteDescription);
     database.AddInParameter(sqlStringCommand, "SiteName", DbType.String, settings.SiteName);
     database.AddInParameter(sqlStringCommand, "Theme", DbType.String, settings.Theme);
     database.AddInParameter(sqlStringCommand, "Footer", DbType.String, settings.Footer);
     database.AddInParameter(sqlStringCommand, "SearchMetaKeywords", DbType.String, settings.SearchMetaKeywords);
     database.AddInParameter(sqlStringCommand, "SearchMetaDescription", DbType.String, settings.SearchMetaDescription);
     database.AddInParameter(sqlStringCommand, "DecimalLength", DbType.Int32, settings.DecimalLength);
     database.AddInParameter(sqlStringCommand, "YourPriceName", DbType.String, settings.YourPriceName);
     database.AddInParameter(sqlStringCommand, "Disabled", DbType.Boolean, settings.Disabled);
     database.AddInParameter(sqlStringCommand, "DefaultProductImage", DbType.String, settings.DefaultProductImage);
     database.AddInParameter(sqlStringCommand, "PointsRate", DbType.Decimal, settings.PointsRate);
     database.AddInParameter(sqlStringCommand, "OrderShowDays", DbType.Int32, settings.OrderShowDays);
     database.AddInParameter(sqlStringCommand, "HtmlOnlineServiceCode", DbType.String, settings.HtmlOnlineServiceCode);
     database.AddInParameter(sqlStringCommand, "SiteUrl2", DbType.String, settings.SiteUrl2);
     database.AddInParameter(sqlStringCommand, "RequestDate", DbType.DateTime, settings.RequestDate);
     database.AddInParameter(sqlStringCommand, "CreateDate", DbType.DateTime, settings.CreateDate);
     database.AddInParameter(sqlStringCommand, "RecordCode2", DbType.String, settings.RecordCode2);
     if (dbtran != null)
     {
         return (database.ExecuteNonQuery(sqlStringCommand, dbtran) >= 1);
     }
     return (database.ExecuteNonQuery(sqlStringCommand) >= 1);
 }
Example #4
0
 private void BindData(SiteSettings siteSettings)
 {
     IList<ManageThemeInfo> list = this.LoadThemes(siteSettings.VTheme);
     this.dtManageThemes.DataSource = list;
     this.dtManageThemes.DataBind();
     this.lblThemeCount.Text = list.Count.ToString();
 }
Example #5
0
 private static void SaveMasterSettings(SiteSettings settings)
 {
     string masterSettingsFilename = GetMasterSettingsFilename();
     XmlDocument doc = new XmlDocument();
     if (File.Exists(masterSettingsFilename))
     {
         doc.Load(masterSettingsFilename);
     }
     settings.WriteToXml(doc);
     doc.Save(masterSettingsFilename);
 }
Example #6
0
 public static bool AddSiteSettings(SiteSettings siteSettings, int requestId, int siteQty)
 {
     bool flag;
     using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
     {
         connection.Open();
         DbTransaction dbTran = connection.BeginTransaction();
         try
         {
             DistributorProvider provider = DistributorProvider.Instance();
             if (!provider.AcceptSiteRequest(siteQty, requestId, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             if (!provider.AddSiteSettings(siteSettings, requestId, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             if (!DistributorProvider.Instance().AddInitData(siteSettings.UserId.Value, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             dbTran.Commit();
             flag = true;
         }
         catch
         {
             dbTran.Rollback();
             flag = false;
         }
         finally
         {
             connection.Close();
         }
     }
     return flag;
 }
Example #7
0
 protected int GetAmount(SiteSettings settings)
 {
     int num = 0;
     if (!string.IsNullOrEmpty(settings.SMSSettings))
     {
         int num2;
         string xml = HiCryptographer.Decrypt(settings.SMSSettings);
         XmlDocument document = new XmlDocument();
         document.LoadXml(xml);
         string innerText = document.SelectSingleNode("xml/Appkey").InnerText;
         string postData = "method=getAmount&Appkey=" + innerText;
         string s = this.PostData("http://sms.kuaidiantong.cn/getAmount.aspx", postData);
         if (int.TryParse(s, out num2))
         {
             num = Convert.ToInt32(s);
         }
     }
     return num;
 }
Example #8
0
 private static void GenericUserMessages(SiteSettings settings, string UserName, string userEmail, string password, string dealPassword, MessageTemplate template, out MailMessage email, out string smsMessage, out string innerSubject, out string innerMessage)
 {
     email = null;
     smsMessage = null;
     innerSubject = (string) (innerMessage = null);
     if ((template != null) && (settings != null))
     {
         if (template.SendEmail && settings.EmailEnabled)
         {
             email = GenericUserEmail(template, settings, UserName, userEmail, password, dealPassword);
         }
         if (template.SendSMS && settings.SMSEnabled)
         {
             smsMessage = GenericUserMessageFormatter(settings, template.SMSBody, UserName, userEmail, password, dealPassword);
         }
         if (template.SendInnerMessage)
         {
             innerSubject = GenericUserMessageFormatter(settings, template.InnerMessageSubject, UserName, userEmail, password, dealPassword);
             innerMessage = GenericUserMessageFormatter(settings, template.InnerMessageBody, UserName, userEmail, password, dealPassword);
         }
     }
 }
Example #9
0
 private static MailMessage GenericUserEmail(MessageTemplate template, SiteSettings settings, string UserName, string userEmail, string password, string dealPassword)
 {
     MailMessage emailTemplate = MessageTemplateHelper.GetEmailTemplate(template, userEmail);
     if (emailTemplate == null)
     {
         return null;
     }
     emailTemplate.Subject = GenericUserMessageFormatter(settings, emailTemplate.Subject, UserName, userEmail, password, dealPassword);
     emailTemplate.Body = GenericUserMessageFormatter(settings, emailTemplate.Body, UserName, userEmail, password, dealPassword);
     return emailTemplate;
 }
Example #10
0
 private static string GenericOrderMessageFormatter(SiteSettings settings, string UserName, string stringToFormat, string orderId, decimal total, string memo, string shippingType, string shippingName, string shippingAddress, string shippingZip, string shippingPhone, string shippingCell, string shippingEmail, string shippingBillno, decimal refundMoney, string closeReason)
 {
     stringToFormat = stringToFormat.Replace("$SiteName$", settings.SiteName.Trim());
     stringToFormat = stringToFormat.Replace("$UserName$", UserName);
     stringToFormat = stringToFormat.Replace("$OrderId$", orderId);
     stringToFormat = stringToFormat.Replace("$Total$", total.ToString("F"));
     stringToFormat = stringToFormat.Replace("$Memo$", memo);
     stringToFormat = stringToFormat.Replace("$Shipping_Type$", shippingType);
     stringToFormat = stringToFormat.Replace("$Shipping_Name$", shippingName);
     stringToFormat = stringToFormat.Replace("$Shipping_Addr$", shippingAddress);
     stringToFormat = stringToFormat.Replace("$Shipping_Zip$", shippingZip);
     stringToFormat = stringToFormat.Replace("$Shipping_Phone$", shippingPhone);
     stringToFormat = stringToFormat.Replace("$Shipping_Cell$", shippingCell);
     stringToFormat = stringToFormat.Replace("$Shipping_Email$", shippingEmail);
     stringToFormat = stringToFormat.Replace("$Shipping_Billno$", shippingBillno);
     stringToFormat = stringToFormat.Replace("$RefundMoney$", refundMoney.ToString("F"));
     stringToFormat = stringToFormat.Replace("$CloseReason$", closeReason);
     return stringToFormat;
 }
Example #11
0
 private static TemplateMessage GenerateWeixinMessageWhenPasswordChange(string templateId, SiteSettings settings, MemberInfo user, string passowordType)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "productName",
         Value = passowordType + "密码"
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "time",
         Value = DateTime.Now.ToString("M月d日 HH:mm")
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Example #12
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderRefund(string templateId, SiteSettings settings, MemberInfo user, string orderId, decimal amount)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单号为" + orderId + "的订单已经退款"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "reason",
         Value = "-"
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "refund",
         Color = "#ff3300",
         Value = "¥" + amount.ToString("F2")
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Example #13
0
 private bool SaveSiteSettings(out string errorMsg)
 {
     errorMsg = null;
     try
     {
         string filename = base.Request.MapPath(Globals.ApplicationPath + "/config/SiteSettings.config");
         XmlDocument doc = new XmlDocument();
         SiteSettings settings = new SiteSettings(base.Request.Url.Host);
         doc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Settings></Settings>");
         settings.CheckCode = CreateKey(20);
         settings.ApplicationDescription = "<img src=\"/Storage/master/gallery/201501/20150114091939_5651.jpg\" title=\"20150114091939_5651\" alt=\"20150114091939_5651\" border=\"0\" />";
         settings.SaleService = settings.SaleService + "<div class=\"sale-service clearfix\">";
         settings.SaleService = settings.SaleService + "<a href=\"http://wpa.b.qq.com/cgi/wpa.php?ln=2&amp;uin=123456789\" class=\"col-sm-4\" target=\"_blank\">";
         settings.SaleService = settings.SaleService + "  <img src=\"/Storage/master/gallery/201501/20150112160440_7779.png\" title=\"QQ_service\" alt=\"QQ_service\" border=\"0\" /></a>   ";
         settings.SaleService = settings.SaleService + "<a href=\"http://wpa.b.qq.com/cgi/wpa.php?ln=2&amp;uin=450235251\" target=\"_blank\" class=\"col-sm-4\"><img src=\"/Storage/master/gallery/201501/20150112160517_9570.png\" title=\"QQ_service\" alt=\"QQ_service\" border=\"0\" /></a>   ";
         settings.SaleService = settings.SaleService + " <a href=\"\" http:=\"\" wpa.qq.com=\"\" msgrd?v=\"3&amp;uin=&amp;site=qq&amp;menu=yes\" \"=\"\" class=\"col-sm-4\"><img src=\"/Storage/master/gallery/201501/20150112160440_7779.png\" /></a> </div> ";
         settings.SaleService = settings.SaleService + "<a type=\"button\" class=\"btn btn-danger btn-block\" href=\"tel:18211111111\">服务电话:18211111111</a>";
         settings.DistributorBackgroundPic = "/Storage/data/DistributorBackgroundPic/default.jpg|";
         settings.MentionNowMoney = "1";
         settings.DistributorDescription = settings.DistributorDescription + "<p>微信分销的功课:</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>1.研究兴趣取向:通过观察和研究他们发布的朋友圈,了解他们可能会被我们产品的那一方面打动,整合我们产品的特点,激发他们的兴趣。&nbsp;</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>2.推送信息:根据他们的兴趣特点来发布信息;字数不宜超过20字;要留悬念,让他们主动发问;图文并茂;</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>3.每天不要超过三条,更不要同时发送,选择的热度时间不同微信不一样,方法是观察朋友圈在哪段时间大家发微信比较勤奋,比他们的时间早5分钟左右发布。</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p><span style=\"line-height:1.5;\">4.因为一般人的习惯是先看后发。最初,要学会烘托气氛,当我们开始做朋友圈营销的时候,一定不能做的像一个新手一样,发图片,然后写一些介绍。</span></p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>微信分销的五要点&nbsp;</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>第一建立一个信任度;</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>第二呢第一时间让对方感兴趣;</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>第三点呢就是顾客的二次营销;&nbsp;</p>";
         settings.DistributorDescription = settings.DistributorDescription + "<p>第四点呢互动;";
         settings.DistributorDescription = settings.DistributorDescription + "第五个呢老顾客的忠诚和信息的推广;</p>";
         settings.OpenManyService = false;
         settings.WriteToXml(doc);
         doc.Save(filename);
         return true;
     }
     catch (Exception exception)
     {
         errorMsg = exception.Message;
         return false;
     }
 }
Example #14
0
 public abstract bool AddSiteSettings(SiteSettings siteSettings, int requestId, DbTransaction dbtran);
Example #15
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SiteRequestInfo siteRequestInfo = DistributorHelper.GetSiteRequestInfo(int.Parse(hidRequestId.Value));

            if (siteRequestInfo == null)
            {
                base.GotoResourceNotFound();
            }
            else
            {

                int siteQty = 0;

                bool isValid = false, expired = false;

                SiteSettings siteSettings = new SiteSettings(siteRequestInfo.FirstSiteUrl, new int?(siteRequestInfo.UserId));

                siteSettings.RecordCode = siteRequestInfo.FirstRecordCode;

                siteSettings.SiteUrl2 = siteRequestInfo.SecondSiteUrl;

                siteSettings.RecordCode2 = siteRequestInfo.SecondRecordCode;

                siteSettings.Disabled = false;

                siteSettings.CreateDate = new DateTime?(DateTime.Now);

                siteSettings.RequestDate = new DateTime?(siteRequestInfo.RequestTime);

                siteSettings.LogoUrl = "/utility/pics/agentlogo.jpg";

                siteSettings.IsShowOnlineGift = false;

                LicenseChecker.Check(out isValid, out expired, out siteQty);

                if (!DistributorHelper.AddSiteSettings(siteSettings, siteRequestInfo.RequestId, siteQty))
                {
                    ShowMsg("开通分销商站点失败,可能是您能够开启的数量已经达到了授权的上限或是授权已过有效期!", false);
                }
                else
                {
                    IList<ManageThemeInfo> list = LoadThemes();

                    string path = Page.Request.MapPath(Globals.ApplicationPath + "/Storage/sites/") + siteSettings.UserId.ToString();

                    string str2 = Page.Request.MapPath(Globals.ApplicationPath + "/Templates/sites/") + siteSettings.UserId.ToString() + @"\" + list[0].ThemeName;

                    string srcPath = Page.Request.MapPath(Globals.ApplicationPath + "/Templates/library/") + list[0].ThemeName;

                    if (!Directory.Exists(path))
                    {

                        try
                        {

                            Directory.CreateDirectory(path);
                            Directory.CreateDirectory(path + "/article");
                            Directory.CreateDirectory(path + "/brand");
                            Directory.CreateDirectory(path + "/fckfiles");
                            Directory.CreateDirectory(path + "/help");
                            Directory.CreateDirectory(path + "/link");

                        }
                        catch
                        {

                            ShowMsg("开通分销商站点失败", false);
                            return;

                        }

                    }
                    if (!Directory.Exists(str2))
                    {
                        try
                        {

                            CopyDir(srcPath, str2);

                            siteSettings.Theme = list[0].ThemeName;

                            SettingsManager.Save(siteSettings);

                        }
                        catch
                        {

                            ShowMsg("开通分销商站点失败", false);

                            return;

                        }

                    }

                    BindRequests();

                    ShowMsg("成功开通了分销商的站点", true);

                }

            }
        }
Example #16
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderCreate(string templateId, SiteSettings settings, OrderInfo order, MemberInfo user)
 {
     TemplateMessage message = null;
     if (!string.IsNullOrWhiteSpace(user.OpenId))
     {
         string weixinToken = settings.WeixinToken;
         TemplateMessage message2 = new TemplateMessage {
             Url = "",
             TemplateId = templateId,
             Touser = user.OpenId
         };
         TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[3];
         TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
             Name = "first",
             Value = "您的订单已提交成功!"
         };
         partArray[0] = part;
         TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
             Name = "orderID",
             Value = order.OrderId
         };
         partArray[1] = part2;
         TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
             Name = "orderMoneySum",
             Color = "#ff3300",
             Value = "¥" + order.GetTotal().ToString("F2")
         };
         partArray[2] = part3;
         message2.Data = partArray;
         message = message2;
     }
     return message;
 }
Example #17
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderPay(string templateId, SiteSettings settings, MemberInfo user, string orderId, decimal fee)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单" + orderId + "支付成功"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "orderMoneySum",
         Color = "#ff3300",
         Value = "¥" + fee.ToString("F2")
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "orderProductName",
         Value = ""
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Example #18
0
 public static SendStatus SendMail(string subject, string body, string emailTo, SiteSettings settings, out string msg)
 {
     msg = "";
     if ((((string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(body)) || (string.IsNullOrEmpty(emailTo) || (subject.Trim().Length == 0))) || (body.Trim().Length == 0)) || (emailTo.Trim().Length == 0))
     {
         return SendStatus.RequireMsg;
     }
     if (!((settings != null) && settings.EmailEnabled))
     {
         return SendStatus.NoProvider;
     }
     EmailSender sender = CreateEmailSender(settings, out msg);
     if (sender == null)
     {
         return SendStatus.ConfigError;
     }
     MailMessage email = new MailMessage {
         IsBodyHtml = true,
         Priority = MailPriority.High,
         Body = body.Trim(),
         Subject = subject.Trim()
     };
     email.To.Add(emailTo);
     return (SendMail(email, sender, out msg) ? SendStatus.Success : SendStatus.Fail);
 }
Example #19
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderSend(string templateId, SiteSettings settings, MemberInfo user, OrderInfo order)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[5];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单号已经发货"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "keyword1",
         Value = order.OrderId
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "keyword2",
         Value = order.ExpressCompanyName
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "keyword3",
         Value = order.ShipOrderNumber
     };
     partArray[3] = part4;
     TemplateMessage.MessagePart part5 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[4] = part5;
     message2.Data = partArray;
     return message2;
 }
Example #20
0
 public static SendStatus SendMail(string subject, string body, string[] cc, string[] bcc, SiteSettings settings, out string msg)
 {
     msg = "";
     if (((string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(body)) || ((subject.Trim().Length == 0) || (body.Trim().Length == 0))) || (((cc == null) || (cc.Length == 0)) && ((bcc == null) || (bcc.Length == 0))))
     {
         return SendStatus.RequireMsg;
     }
     if (!((settings != null) && settings.EmailEnabled))
     {
         return SendStatus.NoProvider;
     }
     EmailSender sender = CreateEmailSender(settings, out msg);
     if (sender == null)
     {
         return SendStatus.ConfigError;
     }
     MailMessage email = new MailMessage {
         IsBodyHtml = true,
         Priority = MailPriority.High,
         Body = body.Trim(),
         Subject = subject.Trim()
     };
     if ((cc != null) && (cc.Length > 0))
     {
         foreach (string str in cc)
         {
             email.CC.Add(str);
         }
     }
     if ((bcc != null) && (bcc.Length > 0))
     {
         foreach (string str in bcc)
         {
             email.Bcc.Add(str);
         }
     }
     return (SendMail(email, sender, out msg) ? SendStatus.Success : SendStatus.Fail);
 }
Example #21
0
 private static MailMessage GenericOrderEmail(MessageTemplate template, SiteSettings settings, string UserName, string userEmail, string orderId, decimal total, string memo, string shippingType, string shippingName, string shippingAddress, string shippingZip, string shippingPhone, string shippingCell, string shippingEmail, string shippingBillno, decimal refundMoney, string closeReason)
 {
     MailMessage emailTemplate = MessageTemplateHelper.GetEmailTemplate(template, userEmail);
     if (emailTemplate == null)
     {
         return null;
     }
     emailTemplate.Subject = GenericOrderMessageFormatter(settings, UserName, emailTemplate.Subject, orderId, total, memo, shippingType, shippingName, shippingAddress, shippingZip, shippingPhone, shippingCell, shippingEmail, shippingBillno, refundMoney, closeReason);
     emailTemplate.Body = GenericOrderMessageFormatter(settings, UserName, emailTemplate.Body, orderId, total, memo, shippingType, shippingName, shippingAddress, shippingZip, shippingPhone, shippingCell, shippingEmail, shippingBillno, refundMoney, closeReason);
     return emailTemplate;
 }
Example #22
0
 public static SendStatus SendSMS(string[] phoneNumbers, string message, SiteSettings settings, out string msg)
 {
     msg = "";
     if ((((phoneNumbers == null) || string.IsNullOrEmpty(message)) || (phoneNumbers.Length == 0)) || (message.Trim().Length == 0))
     {
         return SendStatus.RequireMsg;
     }
     if (!((settings != null) && settings.SMSEnabled))
     {
         return SendStatus.NoProvider;
     }
     SMSSender sender = CreateSMSSender(settings, out msg);
     if (sender == null)
     {
         return SendStatus.ConfigError;
     }
     return (sender.Send(phoneNumbers, message, out msg) ? SendStatus.Success : SendStatus.Fail);
 }
Example #23
0
 private static void GenericOrderMessages(SiteSettings settings, string UserName, string userEmail, string orderId, decimal total, string memo, string shippingType, string shippingName, string shippingAddress, string shippingZip, string shippingPhone, string shippingCell, string shippingEmail, string shippingBillno, decimal refundMoney, string closeReason, MessageTemplate template, out MailMessage email, out string smsMessage, out string innerSubject, out string innerMessage)
 {
     email = null;
     smsMessage = null;
     innerSubject = (string) (innerMessage = null);
     if ((template != null) && (settings != null))
     {
         if (template.SendEmail && settings.EmailEnabled)
         {
             email = GenericOrderEmail(template, settings, UserName, userEmail, orderId, total, memo, shippingType, shippingName, shippingAddress, shippingZip, shippingPhone, shippingCell, shippingEmail, shippingBillno, refundMoney, closeReason);
         }
         if (template.SendSMS && settings.SMSEnabled)
         {
             smsMessage = GenericOrderMessageFormatter(settings, UserName, template.SMSBody, orderId, total, memo, shippingType, shippingName, shippingAddress, shippingZip, shippingPhone, shippingCell, shippingEmail, shippingBillno, refundMoney, closeReason);
         }
         if (template.SendInnerMessage)
         {
             innerSubject = GenericOrderMessageFormatter(settings, UserName, template.InnerMessageSubject, orderId, total, memo, shippingType, shippingName, shippingAddress, shippingZip, shippingPhone, shippingCell, shippingEmail, shippingBillno, refundMoney, closeReason);
             innerMessage = GenericOrderMessageFormatter(settings, UserName, template.InnerMessageBody, orderId, total, memo, shippingType, shippingName, shippingAddress, shippingZip, shippingPhone, shippingCell, shippingEmail, shippingBillno, refundMoney, closeReason);
         }
     }
 }
Example #24
0
 internal static SMSSender CreateSMSSender(SiteSettings settings)
 {
     string str;
     return CreateSMSSender(settings, out str);
 }
Example #25
0
 private static string GenericUserMessageFormatter(SiteSettings settings, string stringToFormat, string UserName, string userEmail, string password, string dealPassword)
 {
     stringToFormat = stringToFormat.Replace("$SiteName$", settings.SiteName.Trim());
     stringToFormat = stringToFormat.Replace("$UserName$", UserName.Trim());
     stringToFormat = stringToFormat.Replace("$Email$", userEmail.Trim());
     stringToFormat = stringToFormat.Replace("$Password$", password);
     stringToFormat = stringToFormat.Replace("$DealPassword$", dealPassword);
     return stringToFormat;
 }
Example #26
0
 internal static SMSSender CreateSMSSender(SiteSettings settings, out string msg)
 {
     try
     {
         msg = "";
         if (!settings.SMSEnabled)
         {
             return null;
         }
         return SMSSender.CreateInstance(settings.SMSSender, HiCryptographer.Decrypt(settings.SMSSettings));
     }
     catch (Exception exception)
     {
         msg = exception.Message;
         return null;
     }
 }
Example #27
0
 private static void Send(MessageTemplate template, SiteSettings settings, MemberInfo user, bool sendFirst, MailMessage email, string innerSubject, string innerMessage, string smsMessage, TemplateMessage templateMessage)
 {
     if (template.SendEmail && (email != null))
     {
         if (sendFirst)
         {
             EmailSender sender = CreateEmailSender(settings);
             if (!((sender != null) && SendMail(email, sender)))
             {
                 Emails.EnqueuEmail(email, settings);
             }
         }
         else
         {
             Emails.EnqueuEmail(email, settings);
         }
     }
     if (template.SendSMS)
     {
     }
     if (template.SendInnerMessage)
     {
     }
     if ((template.SendWeixin && !string.IsNullOrWhiteSpace(template.WeixinTemplateId)) && (templateMessage != null))
     {
         TemplateApi.SendMessage(TokenApi.GetToken_Message(settings.WeixinAppId, settings.WeixinAppSecret), templateMessage);
     }
 }
Example #28
0
 private static TemplateMessage GenerateWeixinMessageWhenFindPassword(string templateId, SiteSettings settings, MemberInfo user, string password)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的账号信息如下"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "keyword1",
         Value = user.UserName
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "keyword2",
         Value = password
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = "请妥善保管。"
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Example #29
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderClose(string templateId, SiteSettings settings, MemberInfo user, OrderInfo order, string reason)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[5];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单已关闭,请核对"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "transid",
         Value = order.OrderId
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "fee",
         Color = "#ff3300",
         Value = "¥" + order.GetTotal().ToString("F2")
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "pay_time",
         Value = (order.PayDate.ToString() != "") ? DateTime.Parse(order.PayDate.ToString()).ToString("M月d日 HH:mm:ss") : DateTime.Parse(order.OrderDate.ToString()).ToString("M月d日 HH:mm:ss")
     };
     partArray[3] = part4;
     TemplateMessage.MessagePart part5 = new TemplateMessage.MessagePart {
         Name = "remark",
         Color = "#000000",
         Value = "关闭原因:" + reason
     };
     partArray[4] = part5;
     message2.Data = partArray;
     return message2;
 }
Example #30
0
 public static void Save(SiteSettings settings)
 {
     SaveMasterSettings(settings);
     HiCache.Remove("FileCache-MasterSettings");
 }