/// <summary> /// Retrieve an IAddressInfo from the address controller using the address id. /// </summary> /// <param name="addressId">Address ID to be loaded.</param> /// <returns> /// A populated IAddressInfo if the address was found; /// otherwise the user's registration address. /// </returns> private IAddressInfo LoadAddress(int addressId) { if (addressId > 0) { return(_controller.GetAddress(addressId)); } return(_controller.GetRegistrationAddress(PortalId, UserId, _addressDefaultDescription)); }
protected void Page_Load(object sender, EventArgs e) { try { // Get localized default address description _addressDefaultDescription = Localization.GetString("AddressDefaultDescription", LocalResourceFile); // Get the navigation settings and AddressID _addressNav = new AddressNavigation(Request.QueryString); _addressID = _addressNav.AddressID; if (!IsPostBack) { // Get an Address controler AddressController controller = new AddressController(); // Define default address settings AddressSettings addressSettings = controller.GetAddressSettings(PortalId); addressEdit.Settings = addressSettings; // Edit Address if (_addressID > 0) { plhGrid.Visible = false; plhEditAddress.Visible = true; AddressInfo address = (AddressInfo)controller.GetAddress(_addressID); bool authorizedUser = (address.UserID == UserId); if (authorizedUser) { if (string.IsNullOrEmpty(address.Email)) { address.Email = UserInfo.Email; } addressEdit.Address = address; addressEdit.ShowUserSaved = false; addressEdit.ShowDescription = true; // Set delete confirmation cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); cmdDelete.Visible = true; } else { ErrorMessage = Localization.GetString("ErrorLoading", LocalResourceFile); // Someone is trying to steal an address! // A log entry will be added in the parent control InvokeSecurityProviderError(); } } // Add Address else if (_addressID == 0) { plhGrid.Visible = false; plhEditAddress.Visible = true; addressEdit.Address = new AddressInfo { UserSaved = true }; addressEdit.ShowUserSaved = false; addressEdit.ShowDescription = true; } // Display user's addresses else { List <AddressInfo> addresses = controller.GetAddresses <AddressInfo>(PortalId, UserId, _addressDefaultDescription); if (addresses.Count > 0) { grdAddresses.DataSource = addresses; grdAddresses.DataBind(); } plhGrid.Visible = true; plhEditAddress.Visible = false; } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// Calculate the final order and place it into a "waiting for payment" state. /// </summary> /// <returns>OrderInfo with the final cart, tax, and shipping totals.</returns> public OrderInfo GetFinalizedOrderInfo() { // Save the address information, so that it can be associated with the order. // // NOTE: This may just update the address with duplicate information, but it is easier than // trying to determine if a change was made the existing address. In the future the // AddressProvider may be able to supply a "Modified" property. AddressController controller = new AddressController(); int m_BillingAddressID = 0; int m_ShippingAddressID = 0; if (Null.IsNull(BillingAddress.AddressID) || BillingAddress.AddressID == -1) { BillingAddress.PortalID = this.PortalId; BillingAddress.UserID = this.UserId; m_BillingAddressID = controller.AddAddress(BillingAddress); } else { controller.UpdateAddress(BillingAddress); } if (Null.IsNull(ShippingAddress.AddressID) || ShippingAddress.AddressID == -1) { ShippingAddress.PortalID = this.PortalId; ShippingAddress.UserID = this.UserId; if (ShippingAddress.Address1.Length == 0) { m_ShippingAddressID = controller.AddAddress(BillingAddress); } else { m_ShippingAddressID = controller.AddAddress(ShippingAddress); } } else { controller.UpdateAddress(ShippingAddress); } //Now that the addresses are saved update the tax and shipping. //CalculateTaxandShipping(_orderInfo); //Save order details OrderController orderController = new OrderController(); orderController.UpdateOrder(_orderInfo.OrderID, System.DateTime.Now, "", m_ShippingAddressID, m_BillingAddressID, _orderInfo.Tax, _orderInfo.ShippingCost, true, 1, UserId); BillingAddress = controller.GetAddress(m_BillingAddressID); ShippingAddress = controller.GetAddress(m_ShippingAddressID); //throw new NotImplementedException("gfhgfH"); return _orderInfo; }
/// <summary> /// Retrieve an IAddressInfo from the address controller using /// the address id. /// </summary> /// <param name="addressId">Address ID to be loaded.</param> /// <returns>A populated IAddressID if found the address is was found; otherwise null</returns> private IAddressInfo loadAddress(int addressId) { AddressController controller = new AddressController(); if (addressId > 0) { return controller.GetAddress(addressId); } else { return controller.GetAddress(PortalId, UserId); } }
protected virtual void generateOrderConfirmation() { Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - Start generateOrderConfirmation", " ", "", "", "", "", "", ""); StringBuilder emailText = new StringBuilder(); string textLine = ""; string storeEmail = ""; string customerEmail = ""; StoreInfo storeInfo = CheckoutControl.StoreData; IAddressInfo billingAddress = CheckoutControl.BillingAddress; IAddressInfo shippingAddress = CheckoutControl.ShippingAddress; //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 1", " ", "", "", "", "", "", ""); OrderInfo orderInfo = CheckoutControl.OrderInfo; if (DotNetNuke.Common.Utilities.Null.IsNull(shippingAddress.Address1) || shippingAddress.Address1.Length == 0) { // canandean changed: load the address from the order if the address controls are empty if (DotNetNuke.Common.Utilities.Null.IsNull(billingAddress.Address1) || billingAddress.Address1.Length == 0) { AddressController controller = new AddressController(); billingAddress = controller.GetAddress(orderInfo.BillingAddressID); shippingAddress = controller.GetAddress(orderInfo.ShippingAddressID); } shippingAddress = billingAddress; } //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 2", " ", "", "", "", "", "", ""); if (storeInfo == null) { StoreController storeController = new StoreController(); storeInfo = storeController.GetStoreInfo(PortalId); } //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 3", " ", "", "", "", "", "", ""); NumberFormatInfo LocalFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); if (storeInfo.CurrencySymbol != string.Empty) { LocalFormat.CurrencySymbol = storeInfo.CurrencySymbol; } //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 4", " ", "", "", "", "", "", ""); UserController userController = new UserController(); UserInfo userInfo = userController.GetUser(PortalId, orderInfo.CustomerID); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 5", " ", "", "", "", "", "", ""); if (storeInfo != null && orderInfo != null && userInfo != null) { //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 6", " ", "", "", "", "", "", ""); storeEmail = storeInfo.DefaultEmailAddress; customerEmail = userInfo.Membership.Email; OrderController orderController = new OrderController(); ArrayList orderDetails = orderController.GetOrderDetails(orderInfo.OrderID); TabController tabControler = new TabController(); TabInfo tabInfo = tabControler.GetTab(storeInfo.ShoppingCartPageID, storeInfo.PortalID, true); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7", " ", "", "", "", "", "", ""); //Order email header String _Message = Services.Localization.Localization.GetString("OrderEmailHeader", this.LocalResourceFile); textLine = String.Format(_Message, PortalSettings.PortalName, tabInfo.TabName, storeEmail); emailText.Append(textLine + "\r\n\r\n"); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.1", " ", "", "", "", "", "", ""); //Order number and date _Message = Services.Localization.Localization.GetString("OrderNumber", this.LocalResourceFile); emailText.Append(_Message + " " + orderInfo.OrderID.ToString()); emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderDate", this.LocalResourceFile); String _DateFormat = Services.Localization.Localization.GetString("OrderDateFormat", this.LocalResourceFile); emailText.Append(_Message + " " + orderInfo.OrderDate.ToString(_DateFormat)); emailText.Append("\r\n"); emailText.Append("\r\n"); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.2", " ", "", "", "", "", "", ""); //Order Contents _Message = Services.Localization.Localization.GetString("OrderContents", this.LocalResourceFile); emailText.Append(_Message); emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderItems", this.LocalResourceFile); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.2.1", " ", "", "", "", "", "", ""); foreach (OrderDetailsInfo item in orderDetails) { //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.2.2 " + item.ModelName, " ", "", "", "", "", "", ""); //textLine = String.Format(_Message, item.Quantity, item.ModelName, item.UnitCost.ToString("C", LocalFormat)); textLine = String.Format(_Message, item.Quantity, item.ModelName, item.ProdCost.ToString("C", LocalFormat)); emailText.Append(textLine + "\r\n"); } emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderSubTotal", this.LocalResourceFile); emailText.Append(String.Format(_Message, orderInfo.OrderTotal.ToString("C", LocalFormat))); emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderShipping", this.LocalResourceFile); emailText.Append(String.Format(_Message, orderInfo.ShippingCost.ToString("C", LocalFormat))); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.2.3", " ", "", "", "", "", "", ""); if (orderInfo.Tax > 0) { emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderTax", this.LocalResourceFile); emailText.Append(String.Format(_Message, orderInfo.Tax.ToString("C", LocalFormat))); } emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderTotal", this.LocalResourceFile); emailText.Append(String.Format(_Message, orderInfo.GrandTotal.ToString("C", LocalFormat))); emailText.Append("\r\n"); emailText.Append("\r\n"); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.3", " ", "", "", "", "", "", ""); // canadean changed: add information about company and VAT emailText.Append("Company: " + userInfo.Profile.ProfileProperties["Company"].PropertyValue); emailText.Append("\r\n"); emailText.Append("VAT N.: " + userInfo.Profile.ProfileProperties["VATNo"].PropertyValue); emailText.Append("\r\n"); emailText.Append("\r\n"); //Billing Address _Message = Services.Localization.Localization.GetString("OrderBillingAddress", this.LocalResourceFile); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.3.1", " ", "", "", "", "", "", ""); emailText.Append(_Message); emailText.Append("\r\n"); emailText.Append(billingAddress.Name); emailText.Append("\r\n"); emailText.Append(billingAddress.Address1); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.3.2", " ", "", "", "", "", "", ""); if (billingAddress.Address2.Length > 0) { emailText.Append("\r\n"); emailText.Append(billingAddress.Address2); } //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.4", " ", "", "", "", "", "", ""); emailText.Append("\r\n"); emailText.Append(billingAddress.City); emailText.Append("\r\n"); emailText.Append(billingAddress.RegionCode); emailText.Append("\r\n"); emailText.Append(billingAddress.PostalCode); emailText.Append("\r\n"); emailText.Append(billingAddress.CountryCode); emailText.Append("\r\n"); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.5", " ", "", "", "", "", "", ""); //Shipping Address emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderShippingAddress", this.LocalResourceFile); emailText.Append(_Message); emailText.Append("\r\n"); emailText.Append(shippingAddress.Name); emailText.Append("\r\n"); emailText.Append(shippingAddress.Address1); emailText.Append("\r\n"); if (shippingAddress.Address2.Length > 0) { emailText.Append(shippingAddress.Address2); emailText.Append("\r\n"); } emailText.Append(shippingAddress.City); emailText.Append("\r\n"); emailText.Append(shippingAddress.RegionCode); emailText.Append("\r\n"); emailText.Append(shippingAddress.PostalCode); emailText.Append("\r\n"); emailText.Append(shippingAddress.CountryCode); emailText.Append("\r\n"); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.6", " ", "", "", "", "", "", ""); //Email body footer emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderTermsOfUse", this.LocalResourceFile); emailText.Append(_Message); emailText.Append("\r\n"); emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderCannotBeProcessed", this.LocalResourceFile); emailText.Append(_Message); emailText.Append("\r\n"); emailText.Append("\r\n"); _Message = Services.Localization.Localization.GetString("OrderThanks", this.LocalResourceFile); emailText.Append(_Message); emailText.Append("\r\n"); emailText.Append("\r\n"); emailText.Append("http://" + PortalSettings.PortalAlias.HTTPAlias); emailText.Append("\r\n"); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.7", " ", "", "", "", "", "", ""); // send email SmtpClient smtpClient = new SmtpClient((string)DotNetNuke.Common.Globals.HostSettings["SMTPServer"]); DotNetNuke.Services.Mail.Mail mail = new DotNetNuke.Services.Mail.Mail(); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.8", " ", "", "", "", "", "", ""); System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential((string)DotNetNuke.Common.Globals.HostSettings["SMTPUsername"], (string)DotNetNuke.Common.Globals.HostSettings["SMTPPassword"]); smtpClient.UseDefaultCredentials = false; smtpClient.Port = 25; smtpClient.EnableSsl = false; smtpClient.Credentials = networkCredential; //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 7.9", " ", "", "", "", "", "", ""); MailMessage message = new MailMessage(); try { //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 8", " ", "", "", "", "", "", ""); MailAddress fromAddress = new MailAddress(storeEmail); //From address will be given as a MailAddress Object message.From = fromAddress; // To address collection of MailAddress message.To.Add(customerEmail); _Message = Services.Localization.Localization.GetString("OrderSubject", this.LocalResourceFile); message.Subject = String.Format(_Message, storeInfo.Name); //Body can be Html or text format //Specify true if it is html message message.IsBodyHtml = false; message.BodyEncoding = Encoding.UTF8; // Message body content message.Body = emailText.ToString(); // Send SMTP mail smtpClient.Send(message); _Message = Services.Localization.Localization.GetString("OrderSubjectToAdmin", this.LocalResourceFile); message.Subject = String.Format(_Message, orderInfo.OrderID); message.To.Clear(); message.To.Add(storeEmail); message.Priority = System.Net.Mail.MailPriority.High; smtpClient.Send(message); //Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 9", " ", "", "", "", "", "", ""); } catch (Exception ex) { Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation exception" + ex.Message + " " + ex.StackTrace, " ", "", "", "", "", "", ""); } Mail.SendMail("*****@*****.**", "*****@*****.**", "", "Canadean Payment Processing - generateOrderConfirmation 10 " + orderInfo.OrderID , " ", "", "", "", "", "", ""); } }
protected void Page_Load(object sender, System.EventArgs e) { try { // Get the navigation settings addressNav = new AddressNavigation(Request.QueryString); if (addressNav.AddressID.Length > 0) { addressId = int.Parse(addressNav.AddressID); } else { addressId = -1; } if (!Page.IsPostBack) { AddressController controller = new AddressController(); ArrayList addresses = controller.GetAddresses(this.PortalId, this.UserId); if (addresses.Count > 0) { grdAddresses.DataSource = addresses; grdAddresses.DataBind(); } // Set delete confirmation cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); // Edit Address if (addressId > 0) { plhGrid.Visible = false; plhEditAddress.Visible = true; lblEditTitle.Text = Localization.GetString("EditAddress", this.LocalResourceFile); AddressInfo address = (AddressInfo)controller.GetAddress(addressId); if (address != null) { //BUG: This does not work because the page_load event is called prior to the controls load event. this.addressEdit.AddressInfo = address; cmdDelete.Visible = true; chkPrimary.Checked = address.PrimaryAddress; } } // Add Address else if (addressId == 0) { plhGrid.Visible = false; plhEditAddress.Visible = true; lblEditTitle.Text = Localization.GetString("AddAddress", this.LocalResourceFile); } // No Action else { plhGrid.Visible = true; plhEditAddress.Visible = false; lblEditTitle.Text = Localization.GetString("Addresses", this.LocalResourceFile); } } } catch(Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }