/// <summary> /// submits the order /// </summary> protected void SubmitOrder() { this.header.InnerText = "Your order has been submitted"; this.Master.SetLayout(this.header.InnerText, MasterPage.LayoutStyle.ContentOnly); // parse the controls on the page and generate an xml doc XmlDocument doc = this.xmlForm.GetResponse(pnlForm); XmlNode TractSearchNode = doc.SelectSingleNode("//field[@name = 'TractSearch']"); XmlNode BuyerNameNode = doc.SelectSingleNode("//field[@name = 'Buyer']"); if (TractSearchNode != null && TractSearchNode.InnerText.Equals("Yes") && BuyerNameNode != null && BuyerNameNode.InnerText.Equals("")) { BuyerNameNode.InnerText = "."; } Affinity.Request req = new Affinity.Request(this.phreezer); req.OrderId = order.Id; req.OriginatorId = this.GetAccount().Id; req.RequestTypeCode = this.rtype.Code; req.StatusCode = (this.isChange || this.rtype.Code == Affinity.RequestType.DefaultChangeCode) ? Affinity.RequestStatus.ChangedCode : Affinity.RequestStatus.DefaultCode; req.Xml = XmlForm.XmlToString(doc).Replace("’", "'"); req.Insert(); string surveyServices = req.GetDataValue("SurveyServices"); // if this is a change, we have to update any previous requests of the // same type so they are no longer recognized as the most current and we // know that they have been replaced by a newer request if (this.isChange) { Affinity.Request cr = new Affinity.Request(this.phreezer); cr.Load(this.changeId); // just a safety check to block any querystring monkeybusiness if (cr.OrderId == order.Id) { cr.IsCurrent = false; cr.Update(); } if (surveyServices != cr.GetDataValue("SurveyServices")) { // the survey services has been changed. it's either new or cancelled SendSurveyNotification(req, (surveyServices != "REQUIRED"), (surveyServices == "REQUIRED")); } } else if (surveyServices == "REQUIRED") { // send a notification that a new survey service has been requested SendSurveyNotification(req, false, true); } // if this was a property change, we need to update the master order record // as well so the data on the datagrids shows correctly if (this.rtype.Code == Affinity.RequestType.DefaultChangeCode) { order.ClientName = FindOrderField(pnlForm, "ClientName", order.ClientName); order.Pin = FindOrderField(pnlForm, "PIN", order.Pin); // case is different order.AdditionalPins = FindOrderField(pnlForm, "AdditionalPins", order.AdditionalPins); order.PropertyAddress = FindOrderField(pnlForm, "PropertyAddress", order.PropertyAddress2); order.PropertyAddress2 = FindOrderField(pnlForm, "PropertyAddress2", order.PropertyAddress); order.PropertyCity = FindOrderField(pnlForm, "PropertyCity", order.PropertyCity); order.PropertyState = FindOrderField(pnlForm, "PropertyState", order.PropertyState); order.PropertyZip = FindOrderField(pnlForm, "PropertyZip", order.PropertyZip); order.CustomerId = FindOrderField(pnlForm, "CustomerId", order.CustomerId); order.PropertyCounty = FindOrderField(pnlForm, "PropertyCounty", order.PropertyCounty); string closingDate = FindOrderField(pnlForm, "ClosingDate", order.ClosingDate.ToShortDateString()); try { order.ClosingDate = DateTime.Parse(closingDate); } catch (FormatException ex) { // TODO: check this at an earlier stage so we can roll back the transaction this.Master.ShowFeedback("Your order was updated however the new closing date was ignored because it was not a valid date in the format 'mm/dd/yyyy'", MasterPage.FeedbackType.Error); } } // we have to sync the status of the order because any new requests may change it // this will also call Update on the order if we've made any changes order.SyncStatus(); // notify affinity if specified in system settings SendNotification(req); //TODO: redirect to a thank-you page instead of just showing the message ShowConfirmation(); }
/// <summary> /// The form controls are created at this point. if we create them at page load /// then their viewstate will not be persisted. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> override protected void PageBase_Init(object sender, System.EventArgs e) { bool isRefinance = (Request["Refinance"] != null && Request["Refinance"].Equals("True")); // we have to call the base first so phreezer is instantiated base.PageBase_Init(sender, e); int orderId = NoNull.GetInt(Request["id"], 0); string requestCode = NoNull.GetString(Request["code"], Affinity.RequestType.DefaultCode); this.order = new Affinity.Order(this.phreezer); order.Load(orderId); // make sure this user has permission to make updates to this order if (!order.CanUpdate(this.GetAccount())) { this.Crash(300, "Permission denied."); } this.rtype = new Affinity.RequestType(this.phreezer); rtype.Load(requestCode); this.xmlForm = new XmlForm(this.order.Account); this.changeId = NoNull.GetInt(Request["change"], 0); this.isChange = (!changeId.Equals(0)); if (this.rtype.Code.Equals("ClerkingRequest")) { ContentFooterSpan.InnerHtml = "© Copyright <%=DateTime.Now.Year.ToString() %>, Advocate Title Services, LLC"; } string busindxml = "<field name=\"BusinessLicenseID\">" + this.GetAccount().BusinessLicenseID + "</field>" + "<field name=\"IndividualLicenseID\">" + this.GetAccount().IndividualLicenseID + "</field>"; if (this.isChange) { // create a form for a change request Affinity.Request req = new Affinity.Request(this.phreezer); req.Load(changeId); pnlForm.Controls.Add(this.xmlForm.GetFormFieldControl(rtype.Definition, req.Xml.Replace("</response>", "") + busindxml + "</response>")); this.btnCancelChange.Visible = true; this.btnChange.Visible = true; this.btnCancelSubmit.Visible = false; this.btnSubmit.Visible = false; } else if (rtype.Code == Affinity.RequestType.DefaultChangeCode) { // this is a change to the main order, we store this as a request as well // but we treat it a little bit differently string resXml = XmlForm.XmlToString(order.GetResponse()); pnlForm.Controls.Add(this.xmlForm.GetFormFieldControl(rtype.Definition, resXml.Replace("</response>", "") + busindxml + "</response>")); this.btnCancelChange.Visible = true; this.btnChange.Visible = true; this.btnCancelSubmit.Visible = false; this.btnSubmit.Visible = false; } else { // create a form for a new request //string reqXml = XmlForm.XmlToString(order.GetResponse()); string reqXml = this.GetAccount().PreferencesXml; if (this.rtype.Code.Equals("ClerkingRequest")) { Affinity.RequestCriteria rc = new Affinity.RequestCriteria(); rc.RequestTypeCode = "Order"; Affinity.Requests reqs = order.GetOrderRequests(rc); if (reqs.Count > 0) { Affinity.Request r = (Affinity.Request)reqs[reqs.Count - 1]; //log.Debug(r.Xml); reqXml = reqXml.Replace("</response>", "") + busindxml + XmlForm.XmlToString(order.GetResponse()).Replace("<response>", "").Replace("</response>", "") + r.Xml.Replace("<response>", ""); pnlForm.Controls.Add(this.xmlForm.GetFormFieldControl(rtype.Definition, reqXml)); } else { reqXml = reqXml.Replace("</response>", "") + busindxml + XmlForm.XmlToString(order.GetResponse()).Replace("<response>", "").Replace("</response>", ""); pnlForm.Controls.Add(this.xmlForm.GetFormFieldControl(rtype.Definition, XmlForm.XmlToString(order.GetResponse()))); } } else { pnlForm.Controls.Add(this.xmlForm.GetFormFieldControl(rtype.Definition, reqXml)); } } }
protected void Page_Load(object sender, EventArgs e) { this.RequirePermission(Affinity.RolePermission.SubmitOrders); string id = NoNull.GetString(Request["id"]); string keyAttribute = NoNull.GetString(Request["key"], "sp_id"); string format = NoNull.GetString(Request["format"], "hash"); string exportformat = "PFT"; if (!format.Equals("entire")) { Affinity.Request r = new Affinity.Request(this.phreezer); r.Load(id); // make sure this user has permission to make updates to this order if (!r.Order.CanRead(this.GetAccount())) { this.Crash(300, "Permission denied."); } IBaseRenderer renderer = null; // depending on the format requested, get the correct renderer object switch (format) { case "entire": break; case "xml": exportformat = "Generic XML"; renderer = new XmlRenderer(r, this.GetSystemSettings()); break; case "rei": exportformat = "REI XML"; renderer = new XmlREIRenderer(r, this.GetSystemSettings()); break; case "change": exportformat = "PFT (Changes Only)"; renderer = new PFTChangeRenderer(r, this.GetSystemSettings()); break; case "TPS": exportformat = "TPS"; renderer = new TPSServicePFTRenderer(r, this.GetSystemSettings()); break; //case "special": // renderer = new XmlSpecialRenderer(r, this.GetSystemSettings()); // break; default: renderer = new PFTRenderer(r, this.GetSystemSettings()); break; } Affinity.ExportLog exportlog = new Affinity.ExportLog(this.phreezer); Affinity.Account account = this.GetAccount(); exportlog.AccountID = account.Id; exportlog.OrderID = r.OrderId; exportlog.RequestID = r.Id; exportlog.ExportFormat = exportformat; exportlog.Insert(); // output the results of the renderer OutputRenderer(renderer, keyAttribute); } else { Affinity.RequestTypes rts = new Affinity.RequestTypes(this.phreezer); Affinity.RequestTypeCriteria rtc = new Affinity.RequestTypeCriteria(); rtc.IsActive = 1; rts.Query(rtc); Object [] renderers = new Object[rts.Count]; IEnumerator i = rts.GetEnumerator(); int j = 0; bool isClerkingServices = false; Affinity.Account account = this.GetAccount(); exportformat = "Entire Order"; while (i.MoveNext()) { Affinity.RequestType rt = (Affinity.RequestType)i.Current; Affinity.Order order = new Affinity.Order(this.phreezer); order.Load(id); Affinity.RequestCriteria rc = new Affinity.RequestCriteria(); rc.RequestTypeCode = rt.Code; order.GetOrderRequests(rc); Affinity.Requests reqs = order.GetOrderRequests(rc); Affinity.Request r = null; if (reqs.Count > 0) { r = (Affinity.Request)reqs[0]; if (rt.Code.Equals("ClerkingRequest")) { isClerkingServices = true; } IBaseRenderer renderer = new PFTRenderer(r, this.GetSystemSettings()); renderers[j] = renderer; j++; } if (r != null) { Affinity.ExportLog exportlog = new Affinity.ExportLog(this.phreezer); exportlog.AccountID = account.Id; exportlog.OrderID = r.OrderId; exportlog.RequestID = r.Id; exportlog.ExportFormat = exportformat; exportlog.Insert(); } } OutputMultiRenderer(renderers, keyAttribute, isClerkingServices); } }