Пример #1
0
        /// <summary>
        /// If this is a change request, returns the previous request of the same type.  This
        /// is useful for comparing the difference when a change is submitted.  If no previous
        /// request exists, then null is returned
        /// </summary>
        /// <returns>Affinity.Request || null</returns>
        public Affinity.Request GetPreviousRequest()
        {
            RequestCriteria rc = new RequestCriteria();

            rc.RequestTypeCode = this.RequestTypeCode;
            rc.IdLessThan      = this.Id;

            rc.AppendToOrderBy("Id", true);

            Affinity.Requests rs   = this.Order.GetOrderRequests(rc);
            Affinity.Request  prev = null;

            if (rs.Count > 0)
            {
                prev = (Affinity.Request)rs[0];
            }

            return(prev);
        }
Пример #2
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);
        }