示例#1
0
 public static void SendEmailOrderToClient(String templateName, int orderId, String emailsubjectresxkey = "", String fromEmail = "", String emailmsg = "")
 {
     var ordData = new OrderData(orderId);
     var lang = ordData.Lang;
     if (ordData.GetInfo().UserId > 0)
     {
         // this order is linked to a DNN user, so get the order email from the DNN profile (so if it's updated since the order, we pickup the new one)
         var objUser = UserController.GetUserById(ordData.PortalId, ordData.GetInfo().UserId);
         if (objUser != null)
         {
             if (ordData.EmailAddress != objUser.Email)
             {
                 ordData.EmailAddress = objUser.Email;
                 ordData.SavePurchaseData();
             }
             if (objUser.Profile.PreferredLocale != "") lang = objUser.Profile.PreferredLocale;
         }
     }
     if (lang == "") lang = Utils.GetCurrentCulture();
     // we're going to send email to all email addreses linked to the order.
     var emailList = ordData.EmailAddress;
     if (!emailList.Contains(ordData.EmailShippingAddress) && Utils.IsEmail(ordData.EmailShippingAddress)) emailList += "," + ordData.EmailShippingAddress;
     if (!emailList.Contains(ordData.EmailBillingAddress) && Utils.IsEmail(ordData.EmailBillingAddress)) emailList += "," + ordData.EmailBillingAddress;
     ordData.PurchaseInfo.SetXmlProperty("genxml/emailmsg", emailmsg);
     SendEmail(emailList, templateName, ordData.GetInfo(), emailsubjectresxkey, fromEmail, lang);
 }
示例#2
0
        public static void SendOrderEmail(string emailtype, int orderId, string emailsubjectresxkey, string fromEmail, string emailmsg, bool onlyUserManagerOnly)
        {
            var ordData = new OrderData(orderId);
            var lang = ordData.ClientLang;
            if (ordData.GetInfo().UserId > 0)
            {
                // this order is linked to a DNN user, so get the order email from the DNN profile (so if it's updated since the order, we pickup the new one)
                var objUser = UserController.GetUserById(ordData.PortalId, ordData.GetInfo().UserId);
                if (objUser != null)
                {
                    if (ordData.EmailAddress != objUser.Email)
                    {
                        ordData.EmailAddress = objUser.Email;
                        ordData.SavePurchaseData();
                    }
                    lang = ordData.ClientLang; // pickup is the client prefered local has changed.
                }
            }
            if (lang == "") lang = Utils.GetCurrentCulture();
            // we're going to send email to all email addreses linked to the order.
            var emailList = ordData.EmailAddress;
            if (!emailList.Contains(ordData.EmailShippingAddress) && Utils.IsEmail(ordData.EmailShippingAddress)) emailList += "," + ordData.EmailShippingAddress;
            if (!emailList.Contains(ordData.EmailBillingAddress) && Utils.IsEmail(ordData.EmailBillingAddress)) emailList += "," + ordData.EmailBillingAddress;

            // also send to manager is created.
            if (emailtype == "OrderCreatedClient")
            {
                emailList += "," + StoreSettings.Current.ManagerEmail;
            }

            if (!onlyUserManagerOnly || UserController.Instance.GetCurrentUserInfo().UserID > 0)
            {

                var passSettings = new Dictionary<string, string>();
                passSettings.Add("printtype", emailtype);
                passSettings.Add("emailmessage", emailmsg);
                foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                {
                    if (passSettings.ContainsKey(s.Key))
                        passSettings[s.Key] = s.Value;
                    else
                        passSettings.Add(s.Key, s.Value);
                }

                // check for user or manager.
                var sendEmailFlag = true;
                if (onlyUserManagerOnly && UserController.Instance.GetCurrentUserInfo().UserID != ordData.UserId)
                {
                    if (!NBrightBuyUtils.CheckRights())
                    {
                        sendEmailFlag = false;
                    }
                }

                if (sendEmailFlag)
                {
                    var emailBody = "";
                    emailBody = NBrightBuyUtils.RazorTemplRender("OrderHtmlOutput.cshtml", 0, "", ordData, "/DesktopModules/NBright/NBrightBuy", StoreSettings.Current.Get("themefolder"), lang, passSettings);
                    if (StoreSettings.Current.DebugModeFileOut) Utils.SaveFile(PortalSettings.Current.HomeDirectoryMapPath + "\\testemail.html", emailBody);
                    SendEmail(emailBody, emailList, emailtype, ordData.GetInfo(), emailsubjectresxkey, fromEmail, lang);
                    ordData.AddAuditMessage(emailmsg, "email", UserController.Instance.GetCurrentUserInfo().Username, "False", NBrightBuyUtils.ResourceKey("Notification." + emailsubjectresxkey, StoreSettings.Current.EditLanguage));
                    ordData.SavePurchaseData();
                }
            }
        }
示例#3
0
        private void DisplayDataEntryRepeater(String entryId)
        {
            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var orderData = new OrderData(PortalId, Convert.ToInt32(entryId));

                //render the detail page
                base.DoDetail(rpData, orderData.GetInfo());

                base.DoDetail(rpItemH, orderData.GetInfo());
                rpItem.DataSource = orderData.GetCartItemList(StoreSettings.Current.Get("chkgroupresults") == "True");
                rpItem.DataBind();
                base.DoDetail(rpItemF, orderData.GetInfo());

                // display header (Do header so we pickup the special invoice document field in the header)
                base.DoDetail(rpDataH, orderData.GetInfo());

                // display footer (Do here so we pickup the itemid of the order for the action buttons.)
                base.DoDetail(rpDataF, orderData.GetInfo());

            }
        }
示例#4
0
        private void DisplayDataEntryRepeater(String entryId)
        {
            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var orderData = new OrderData(PortalId, Convert.ToInt32(entryId));

                if (orderData.UserId == UserId)
                {
                    // if debug , output the xml used.
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(orderData.GetInfo().XMLData);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_order.xml");
                    }

                    //render the detail page
                    base.DoDetail(rpData, orderData.GetInfo());

                    base.DoDetail(rpItemH, orderData.GetInfo());
                    rpItem.DataSource = orderData.GetCartItemList(StoreSettings.Current.Get("chkgroupresults") == "True");
                    rpItem.DataBind();
                    base.DoDetail(rpItemF, orderData.GetInfo());

                    // display header (Do header after the data return so the productcount works)
                    base.DoDetail(rpDataH, orderData.GetInfo());
                }

            }
        }