Пример #1
0
    /// <summary>
    /// Assigns the AFF Id and notifies the customer, if their preferences are set
    /// to notify on file confirmations
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        Affinity.WsResponse wsr = this.order.Confirm(txtInternalId.Text, this.GetSystemSettings());

        // we have to re-direct so the requests will be updated
        this.Redirect("AdminOrder.aspx?id=" + this.order.Id + "&feedback=" + Server.UrlEncode("The order was confirmed." + wsr.NotificationMessage));
    }
Пример #2
0
    public Affinity.WsResponse SyncRequest(Affinity.WsToken token, System.Xml.XmlDocument doc)
    {
        Affinity.WsResponse resp = new Affinity.WsResponse();

        Phreezer phreezer = new Phreezer(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);

        try
        {
            Hashtable   ht     = new Hashtable();
            XmlNodeList fields = doc.GetElementsByTagName("field");

            // enumerate all the fields and convert to a hashtable
            foreach (XmlNode field in fields)
            {
                ht.Add(XmlForm.GetAttribute(field, "sp_id"), field.InnerText);
            }

            if (ht.ContainsKey("WEB_ID") == false || ht["WEB_ID"].Equals(""))
            {
                throw new Exception("WEB_ID is required");
            }

            if (ht.ContainsKey("AFF_ID") == false || ht["AFF_ID"].Equals(""))
            {
                throw new Exception("AFF_ID is required");
            }

            Affinity.Order order = new Affinity.Order(phreezer);
            order.Load(ht["WEB_ID"]);

            if (order.InternalId.Equals(""))
            {
                // the order doesn't have an AFF ID so this is a confirmation

                // we have to get the system settings to pass them in to the order confirm method
                Hashtable settings = (Hashtable)Application[Affinity.SystemSetting.DefaultCode];

                resp = order.Confirm(ht["AFF_ID"].ToString(), settings);
            }
            else
            {
                resp.IsSuccess      = true;
                resp.ActionWasTaken = false;
                resp.Message        = "No action was taken";
            }
        }
        catch (Exception ex)
        {
            resp.Message = ex.Message;
        }
        finally
        {
            phreezer.Close();
        }

        return(resp);
    }
Пример #3
0
        /// <summary>
        /// Confirms the order, which means that it is assigned an Affinity Id and all requests are
        /// marked as "In Progress".  If the customer preference is set, a notification email will
        /// be sent out as well
        /// </summary>
        /// <param name="internalId">Affinity ID to assign to this order</param>
        /// <returns>Affinity.WsResponse</returns>
        public Affinity.WsResponse Confirm(string internalId, Hashtable systemSettings)
        {
            Affinity.WsResponse wsr = new WsResponse();

            this.InternalId = internalId;

            Affinity.Requests rs = this.GetCurrentRequests();

            foreach (Affinity.Request r in rs)
            {
                r.StatusCode = Affinity.RequestStatus.InProgressCode;
                r.Update();
            }

            this.SyncStatus();             // this will also update the order

            wsr.IsSuccess      = true;
            wsr.ActionWasTaken = true;
            wsr.Message        = "Order was confirmed";

            wsr.NotificationMessage = " The customer was *NOT* notified based on their user preference.";

            // send the notification email if the originator wants it
            if (this.Account.GetPreference("EmailOnConfirmation").Equals("Yes"))
            {
                string to = this.Account.GetPreference("EmailOnConfirmationAddress", this.Account.Email);

                if (!to.Equals(""))
                {
                    string url     = systemSettings["RootUrl"].ToString() + "MyOrder.aspx?id=" + this.Id.ToString();
                    string subject = "Affinity Order '" + this.ClientName.Replace("\r", "").Replace("\n", "") + "' #" + this.WorkingId + " Confirmed";

                    // send the email
                    Com.VerySimple.Email.Mailer mailer = new Com.VerySimple.Email.Mailer(systemSettings["SmtpHost"].ToString());

                    string msg = "Dear " + this.Account.FirstName + ",\r\n\r\n"
                                 + "Your Affinity order for '" + this.ClientName + "' has been confirmed and assigned the AFF ID "
                                 + this.InternalId + ".  You may use this ID when corresponding with us regarding this order.\r\n\r\n"
                                 + "Friendly: " + this.ClientName + "\r\n"
                                 + "Tracking Code: " + this.CustomerId + "\r\n\r\n"
                                 + "You may view the full details of your order anytime online at " + url + ".  "
                                 + "If you would prefer to not receive this notification, you may also login "
                                 + "to your Affinity account and customize your email notification preferences.\r\n\r\n"
                                 + systemSettings["EmailFooter"].ToString();

                    wsr.NotificationSent = mailer.Send(
                        systemSettings["SendFromEmail"].ToString()
                        , to.Replace(";", ",")
                        , subject
                        , msg);

                    if (wsr.NotificationSent)
                    {
                        wsr.NotificationMessage = " A notification email was sent to " + to + ".";
                    }
                    else
                    {
                        wsr.NotificationMessage = " Unable to deliver notification email to " + to + ".  Please check the server debug logs for more information.";
                    }
                }
            }

            return(wsr);
        }