public PartialViewResult Update(int webOrderRequestId, int webCooperatorId, string statusCode, string actionNote) { TempData["page_title"] = "Review"; ResultContainer resultContainer = null; WebOrderRequest webOrderRequest = new WebOrderRequest(); List <WebOrderRequest> webOrderRequests = null; GRINGlobalService service = new GRINGlobalService(this.AuthenticatedUserSession.Environment); webOrderRequest.ID = webOrderRequestId; webOrderRequest.WebCooperatorID = webCooperatorId; webOrderRequest.StatusCode = statusCode; webOrderRequest.Note = actionNote; resultContainer = service.UpdateWebOrderRequest(webOrderRequest); //webOrderRequests = service.GetWebOrderRequests("NRR_FLAGGED"); return(PartialView("~/Views/GRINGlobal/WebOrder/_List.cshtml", webOrderRequests)); }
public void PostSalesOrderToEDI(EDISalesOrder ediOrder) { if (!Connector.BSKIdentifier.HasValue) { Logger.WarnFormat("Connector doesn't have a BSK Identifier"); return; } WebOrderRequest request = new WebOrderRequest(); request.Version = "1.0"; request.WebOrderHeader = new WebOrderRequestHeader(); request.WebOrderHeader.ShipToCustomer = new Concentrator.Web.Objects.EDI.Customer(); //request.WebOrderHeader.ShipToCustomer.EanIdentifier = webOrderInfo.CustomerID; if (ediOrder.IsPickupOrder) { request.WebOrderHeader.ShipToCustomer.EanIdentifier = "F" + ediOrder.ShopID; } else { request.WebOrderHeader.ShipToCustomer.EanIdentifier = ediOrder.CustomerID; } request.WebOrderHeader.ShipToCustomer.Contact = new Contact(); request.WebOrderHeader.ShipToCustomer.Contact.Name = Configuration.AppSettings.Settings["ContactName"].Value.ToString(); request.WebOrderHeader.ShipToCustomer.Contact.Email = Configuration.AppSettings.Settings["ContactEmail"].Value.ToString(); request.WebOrderHeader.ShipToCustomer.Contact.PhoneNumber = Configuration.AppSettings.Settings["ContactPhoneNumber"].Value.ToString(); request.WebOrderHeader.ShipToShopID = ediOrder.CustomerShipping.StoreNumber; request.WebOrderHeader.ShipmentCosts = ediOrder.ShippingAmount; if (ediOrder.IsPickupOrder) { if (!string.IsNullOrEmpty(ediOrder.CustomerShipping.CustomerPO) && ediOrder.CustomerShipping.CustomerPO != null) { request.WebOrderHeader.CustomerOrderReference = "Winkel#:" + ediOrder.CustomerShipping.CustomerPO; } else { request.WebOrderHeader.CustomerOrderReference = "Winkel#:" + ediOrder.WebsiteOrderID + "/" + ediOrder.CustomerShipping.MailingName; } } else { if (!string.IsNullOrEmpty(ediOrder.CustomerBilling.CustomerPO) && ediOrder.CustomerBilling.CustomerPO != null) { request.WebOrderHeader.CustomerOrderReference = ediOrder.CustomerBilling.CustomerPO; } else { request.WebOrderHeader.CustomerOrderReference = Connector.Name + " - " + ediOrder.CustomerBilling.MailingName; } } request.WebOrderHeader.WebSiteOrderNumber = ediOrder.WebsiteOrderID.ToString(); request.WebOrderHeader.OrderLanguageCode = ediOrder.OrderLanguageCode; request.WebOrderHeader.RequestedDate = DateTime.Now.AddDays(1); request.WebOrderHeader.EdiVersion = "2.0"; if (ediOrder.IsPickupOrder) { request.WebOrderHeader.BSKIdentifier = Connector.ConnectorSettings.GetValueByKey("ShopOrderBSK", Connector.BSKIdentifier.Value); } else { request.WebOrderHeader.BSKIdentifier = Connector.BSKIdentifier.Value; } request.WebOrderHeader.RouteCode = "TRA"; if (!string.IsNullOrEmpty(ediOrder.CustomerShipping.ServicePointID)) { request.WebOrderHeader.RouteCode = "KIALA"; } if (ediOrder.IsPickupOrder) { request.WebOrderHeader.PaymentTermsCode = ediOrder.Payment; request.WebOrderHeader.PaymentInstrument = "T"; } else { #region Determine Payment Codes try { request.WebOrderHeader.PaymentInstrument = "T"; request.WebOrderHeader.PaymentTermsCode = ediOrder.Payment; } catch (Exception ex) { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("--p", "Fout tijdens het verwerken van de betaling"); } #endregion } request.WebOrderHeader.CustomerOverride = new CustomerOverride(); request.WebOrderHeader.CustomerOverride.CustomerContact = new Contact(); request.WebOrderHeader.CustomerOverride.Dropshipment = !ediOrder.IsPickupOrder; request.WebOrderHeader.CustomerOverride.CustomerContact.Email = ediOrder.CustomerShipping.EmailAddress; request.WebOrderHeader.CustomerOverride.CustomerContact.ServicePointCode = ediOrder.CustomerShipping.ServicePointCode; request.WebOrderHeader.CustomerOverride.CustomerContact.ServicePointID = ediOrder.CustomerShipping.ServicePointID; request.WebOrderHeader.CustomerOverride.CustomerContact.KialaCompanyName = ediOrder.CustomerShipping.KialaCompanyName; request.WebOrderHeader.CustomerOverride.OrderAddress = new Address(); request.WebOrderHeader.CustomerOverride.OrderAddress.AddressLine1 = ediOrder.CustomerShipping.Addressline1; request.WebOrderHeader.CustomerOverride.OrderAddress.AddressLine2 = !string.IsNullOrEmpty(ediOrder.CustomerShipping.Addressline2) ? ediOrder.CustomerShipping.Addressline2 : string.Empty; request.WebOrderHeader.CustomerOverride.OrderAddress.Name = ediOrder.CustomerShipping.MailingName; request.WebOrderHeader.CustomerOverride.OrderAddress.ZipCode = ediOrder.CustomerShipping.ZIPcode; request.WebOrderHeader.CustomerOverride.OrderAddress.City = ediOrder.CustomerShipping.City; request.WebOrderHeader.CustomerOverride.OrderAddress.Country = ediOrder.CustomerShipping.Country; request.WebOrderHeader.CustomerOverride.OrderAddress.HouseNumber = ediOrder.CustomerShipping.Number; request.WebOrderHeader.CustomerOverride.OrderAddress.HouseNumberExt = ediOrder.CustomerShipping.NumberExtension; request.WebOrderHeader.CustomerOverride.OrderAddress.Street = ediOrder.CustomerShipping.Street; request.WebOrderDetails = new WebOrderRequestDetail[ediOrder.OrderLines.Count]; request.WebCustomer = new CreateCustomer(); request.WebCustomer.CustomerContact = new WebContact(); request.WebCustomer.CustomerContact.Email = ediOrder.CustomerBilling.EmailAddress; request.WebCustomer.CustomerAddress = new WebAddress(); request.WebCustomer.CustomerAddress.AddressLine1 = ediOrder.CustomerBilling.Addressline1; request.WebCustomer.CustomerAddress.AddressLine2 = ediOrder.CustomerBilling.Addressline2; request.WebCustomer.CustomerAddress.Country = ediOrder.CustomerBilling.Country; request.WebCustomer.CustomerAddress.City = ediOrder.CustomerBilling.City; request.WebCustomer.CustomerAddress.Name = ediOrder.CustomerBilling.MailingName; request.WebCustomer.CustomerAddress.ZipCode = ediOrder.CustomerBilling.ZIPcode; request.WebCustomer.CustomerAddress.Number = ediOrder.CustomerBilling.Number; request.WebCustomer.CustomerAddress.NumberExtension = ediOrder.CustomerBilling.NumberExtension; request.WebCustomer.CustomerAddress.Street = ediOrder.CustomerBilling.Street; int rowcount = 0; Concentrator.Web.ServiceClient.AssortmentService.AssortmentServiceSoapClient soap = new Concentrator.Web.ServiceClient.AssortmentService.AssortmentServiceSoapClient(); foreach (var salesDetail in ediOrder.OrderLines) { var additionalProduct = AdditionalOrderProducts.FirstOrDefault(x => x.ConnectorProductID == salesDetail.ManufacturerID); string productID = string.Empty; if (additionalProduct != null) { Logger.DebugFormat("Found additional productID for {0}, connectorid {1}", salesDetail.ManufacturerID, Connector.ConnectorID); productID = additionalProduct.VendorProductID; } else { Logger.DebugFormat("Try get productID for {0}, manufactuerID {1}, brand {2} connectorid {3}", salesDetail.ConcentratorProductID, salesDetail.ManufacturerID, salesDetail.BrandName, Connector.ConnectorID); productID = salesDetail.ConcentratorProductID.ToString();//oap.GetVendorItemNumber(salesDetail.ConcentratorProductID, salesDetail.ManufacturerID, salesDetail.BrandName, Connector.ConnectorID); Logger.DebugFormat("Found product {0} for {1}, connector {2}", productID, salesDetail.ConcentratorProductID, Connector.ConnectorID); } if (string.IsNullOrEmpty(productID)) { productID = soap.GetVendorItemNumber(0, salesDetail.ManufacturerID, salesDetail.BrandName, Connector.ConnectorID); Logger.DebugFormat("Retry found product {0} for {1}, connector {2}", productID, salesDetail.ConcentratorProductID, Connector.ConnectorID); } request.WebOrderDetails[rowcount] = new WebOrderRequestDetail(); request.WebOrderDetails[rowcount].ProductIdentifier = new ProductIdentifier(); request.WebOrderDetails[rowcount].ProductIdentifier.ProductNumber = productID; request.WebOrderDetails[rowcount].ProductIdentifier.EANIdentifier = string.Empty; request.WebOrderDetails[rowcount].ProductIdentifier.ManufacturerItemID = salesDetail.ManufacturerID; request.WebOrderDetails[rowcount].Quantity = (int)salesDetail.Quantity; request.WebOrderDetails[rowcount].VendorItemNumber = string.Empty; request.WebOrderDetails[rowcount].WareHouseCode = string.Empty; request.WebOrderDetails[rowcount].CustomerReference = new CustomerReference(); request.WebOrderDetails[rowcount].CustomerReference.CustomerOrder = ediOrder.WebsiteOrderID.ToString(); request.WebOrderDetails[rowcount].UnitPrice = salesDetail.LinePrice.ToString(new CultureInfo("en-US")); request.WebOrderDetails[rowcount].LineDiscount = salesDetail.DiscountAmount.HasValue ? salesDetail.DiscountAmount.Value.ToString(new CultureInfo("en-US")) : null; request.WebOrderDetails[rowcount].BasePrice = salesDetail.BasePrice.ToString(new CultureInfo("en-US")); request.WebOrderDetails[rowcount].CustomerReference.CustomerOrderLine = salesDetail.LineNumber.ToString(); if (salesDetail.DiscountRules != null && salesDetail.DiscountRules.Count > 0) { request.WebOrderDetails[rowcount].LineDiscounts = new WebOrderRequestOrderLineDiscount[salesDetail.DiscountRules.Count]; for (int i = 0; i < salesDetail.DiscountRules.Count; i++) { request.WebOrderDetails[rowcount].LineDiscounts[i] = new WebOrderRequestOrderLineDiscount(); request.WebOrderDetails[rowcount].LineDiscounts[i].Code = salesDetail.DiscountRules[i].RuleCode; request.WebOrderDetails[rowcount].LineDiscounts[i].DiscountAmount = salesDetail.DiscountRules[i].DiscountAmount.ToString(new CultureInfo("en-US")); request.WebOrderDetails[rowcount].LineDiscounts[i].IsSet = salesDetail.DiscountRules[i].IsSetRule; request.WebOrderDetails[rowcount].LineDiscounts[i].Percentage = salesDetail.DiscountRules[i].Percentage; request.WebOrderDetails[rowcount].LineDiscounts[i].RuleID = salesDetail.DiscountRules[i].RuleID; } } rowcount++; } StringBuilder requestString = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; XmlWriter xw = XmlWriter.Create(requestString, settings); xw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\""); Logger.Info(request.WebOrderHeader.ShipmentCosts); Logger.Info(request.WebOrderHeader.ShipmentCosts.ToString(new CultureInfo("en-US"))); XmlSerializer rxs = new XmlSerializer(typeof(WebOrderRequest)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); rxs.Serialize(xw, request, ns); //rxs.Serialize(xw, request); XmlDocument requestXml = new XmlDocument(); requestXml.LoadXml(requestString.ToString()); bool usesShipmentsCosts = Connector.ConnectorSettings.GetValueByKey <bool>("UsesShipmentCosts", false); Concentrator.Web.ServiceClient.OrderInbound.OrderInboundSoapClient client = new Web.ServiceClient.OrderInbound.OrderInboundSoapClient(); var res = client.ImportOrderWithShipmentCosts(requestString.ToString(), Connector.ConnectorID, usesShipmentsCosts); Logger.AuditInfo(string.Format("For order : {0}, the status is: {1}, the message is :{2}", ediOrder.WebsiteOrderID, res.StatusCode, res.Message)); if (res.StatusCode == 200 || res.StatusCode == 400) { using (var helper = new OrderHelper(Connector.Connection)) { helper.UpdateOrderStatus( increment_id: ediOrder.WebsiteOrderID.ToString(), state: MagentoOrderState.Processing, status: MagentoOrderStatus.In_Transit ); } } }
private WebOrderRequestEditViewModel GetData(int id, bool reviewMode) { ResultContainer resultContainer = null; WebOrderRequest webOrderRequest = null; GRINGlobalService grinGlobalService = new GRINGlobalService(this.AuthenticatedUserSession.Environment); WebOrderRequestEditViewModel viewModel = new WebOrderRequestEditViewModel(); try { if (reviewMode) { resultContainer = grinGlobalService.SetReviewStatus(id, AuthenticatedUser.Cooperator.WebCooperator.ID, true); resultContainer = grinGlobalService.AddWebOrderRequestAction(new WebOrderRequestAction { WebOrderRequestID = id, ActionCode = "NRR_REVIEW", CreatedByCooperatorID = AuthenticatedUser.WebUserID }); } webOrderRequest = grinGlobalService.GetWebOrderRequest(id); if (webOrderRequest == null) { throw new NullReferenceException(String.Format("Null web order request returned for ID {0}", id)); } viewModel.AuthenticatedUser = AuthenticatedUser; viewModel.WebCooperatorID = AuthenticatedUser.Cooperator.WebCooperator.ID; viewModel.StatusCode = webOrderRequest.StatusCode; viewModel.OrderDate = webOrderRequest.OrderDate; viewModel.WebCooperator = webOrderRequest.Cooperators.First(); viewModel.IsReviewMode = reviewMode; viewModel.IsLocked = webOrderRequest.IsLocked; viewModel.ID = webOrderRequest.ID; viewModel.OrderDate = webOrderRequest.OrderDate; viewModel.IntendedUseCode = webOrderRequest.IntendedUseCode; viewModel.IntendedUseNote = webOrderRequest.IntendedUseNote; viewModel.Note = webOrderRequest.Note; viewModel.SpecialInstruction = webOrderRequest.SpecialInstruction; viewModel.OwnedDate = webOrderRequest.OwnedDate; viewModel.OwnedByCooperatorID = webOrderRequest.OwnedByCooperatorID; viewModel.OwnedByCooperatorName = webOrderRequest.OwnedByCooperatorName; viewModel.WebOrderRequestItems = webOrderRequest.WebOrderRequestItems; viewModel.WebOrderRequestAddresses = webOrderRequest.Addresses; viewModel.EmailAddressList = webOrderRequest.EmailAddressList; viewModel.EmailTemplates = grinGlobalService.GetEmailTemplates(); var queryWebOrderRequestDates = from action in webOrderRequest.WebOrderRequestActions group action by action.ActionDate into webOrderRequestActionGroup orderby webOrderRequestActionGroup.Key descending select webOrderRequestActionGroup; foreach (var group in queryWebOrderRequestDates) { WebOrderRequestActionGroupViewModel webOrderRequestActionGroupViewModel = new WebOrderRequestActionGroupViewModel(); webOrderRequestActionGroupViewModel.ActionDate = DateTime.Parse(group.Key.ToString()); foreach (var subGroup in group) { WebOrderRequestAction webOrderRequestAction = new WebOrderRequestAction(); webOrderRequestAction.ID = subGroup.ID; webOrderRequestAction.ActionCode = subGroup.ActionCode; webOrderRequestAction.Title = subGroup.Title; webOrderRequestAction.Description = subGroup.Description; webOrderRequestAction.Note = subGroup.Note; webOrderRequestAction.ActionDate = subGroup.ActionDateTime; webOrderRequestAction.CreatedByCooperatorName = subGroup.CreatedByCooperatorName; webOrderRequestActionGroupViewModel.WebOrderRequestActions.Add(webOrderRequestAction); } viewModel.WebOrderRequestActionGroupViewModels.Add(webOrderRequestActionGroupViewModel); } } catch (Exception ex) { Log.Error(ex, ex.Message); } return(viewModel); }
public ActionResult Edit(WebOrderRequestEditViewModel viewModel) { string emailRecipientList = String.Empty; ResultContainer resultContainer = null; GRINGlobalService grinGlobalService = new GRINGlobalService(this.AuthenticatedUserSession.Environment); SmtpService smtpService = new SmtpService(); try { WebOrderRequest webOrderRequest = new WebOrderRequest(); webOrderRequest.ID = viewModel.ID; webOrderRequest.StatusCode = viewModel.Action; if (viewModel.Action == OrderRequestAction.NRRReviewEnd) { grinGlobalService.SetReviewStatus(viewModel.ID, AuthenticatedUser.Cooperator.WebCooperator.ID, false); } else { if ((viewModel.Action != "NRR_NOTE") && (viewModel.Action != "NRR_INFO")) { resultContainer = grinGlobalService.UpdateWebOrderRequest(webOrderRequest); } resultContainer = grinGlobalService.AddWebOrderRequestAction(new WebOrderRequestAction { WebOrderRequestID = viewModel.ID, ActionCode = viewModel.Action, Note = viewModel.ActionNote, CreatedByCooperatorID = AuthenticatedUser.WebUserID }); if (viewModel.Action == "NRR_APPROVE") { emailRecipientList = grinGlobalService.GetEmailNotificationList(viewModel.ID); grinGlobalService.SendEmail(viewModel.ID, "CAP", emailRecipientList); resultContainer = grinGlobalService.AddWebOrderRequestAction(new WebOrderRequestAction { WebOrderRequestID = viewModel.ID, ActionCode = viewModel.Action, Note = viewModel.ActionNote, CreatedByCooperatorID = AuthenticatedUser.WebUserID }); } else if (viewModel.Action == "NRR_REJECT") { emailRecipientList = grinGlobalService.GetEmailNotificationList(viewModel.ID); grinGlobalService.SendEmail(viewModel.ID, "CCL", emailRecipientList); grinGlobalService.SendEmail(viewModel.ID, "RRJ", viewModel.WebCooperator.EmailAddress); resultContainer = grinGlobalService.AddWebOrderRequestAction(new WebOrderRequestAction { WebOrderRequestID = viewModel.ID, ActionCode = viewModel.Action, Note = viewModel.ActionNote, CreatedByCooperatorID = AuthenticatedUser.WebUserID }); } else if (viewModel.Action == "NRR_INFO") { grinGlobalService.SendEmail(viewModel.ID, "RQI", viewModel.WebCooperator.EmailAddress); } if (resultContainer.ResultCode == ResultContainer.ResultCodeValue.Error.ToString()) { throw new Exception("Error sending mail: " + resultContainer.ResultMessage + resultContainer.ResultDescription); } } if ((viewModel.Action != "NRR_NOTE") && (viewModel.Action != "NRR_INFO")) { return(RedirectToAction("Index", "WebOrder")); } else { return(RedirectToAction("Edit", "WebOrder", new { id = viewModel.ID })); } } catch (Exception ex) { Log.Error(ex, ex.Message); return(RedirectToAction("InternalServerError", "Error")); } }
public ActionResult Edit(WebOrderRequestEditViewModel viewModel) { ResultContainer resultContainer = null; GRINGlobalService grinGlobalService = new GRINGlobalService(this.AuthenticatedUserSession.Environment); SmtpService smtpService = new SmtpService(); try { WebOrderRequest webOrderRequest = new WebOrderRequest(); webOrderRequest.ID = viewModel.ID; webOrderRequest.StatusCode = viewModel.Action; if (viewModel.Action == OrderRequestAction.NRRReviewEnd) { grinGlobalService.SetReviewStatus(viewModel.ID, AuthenticatedUser.WebCooperatorID, false); } else { if (viewModel.Action != "NRR_NOTE") { resultContainer = grinGlobalService.UpdateWebOrderRequest(webOrderRequest); } resultContainer = grinGlobalService.AddWebOrderRequestAction(new WebOrderRequestAction { WebOrderRequestID = viewModel.ID, ActionCode = viewModel.Action, Note = viewModel.ActionNote, CreatedByCooperatorID = AuthenticatedUser.WebCooperatorID }); EmailMessage emailMessage = new EmailMessage(); emailMessage.SenderAddress = "*****@*****.**"; emailMessage.IsHtmlFormat = true; if (viewModel.Action == "NRR_APPROVE") { emailMessage.RecipientAddress = "*****@*****.**"; emailMessage.Subject = "NRR Review Update: Order #" + webOrderRequest.ID + " Approved"; emailMessage.Body = "Order # " + webOrderRequest.ID + " has been approved. You may now process it normally via the Order Wizard."; smtpService.SendMessage(emailMessage); } else if (viewModel.Action == "NRR_REJECT") { // EMAIL TO REQUESTOR //emailMessage.RecipientAddress = viewModel.WebCooperator.EmailAddress; emailMessage.RecipientAddress = "*****@*****.**"; emailMessage.Subject = "Your Germplasm Request (Order #" + webOrderRequest.ID + ")"; System.Text.StringBuilder sbEmailBody = new System.Text.StringBuilder(); sbEmailBody.Append("Dear Germplasm Requestor,<p>Thank you for your interest in our germplasm collection.The mission of the National Plant Germplasm System(NPGS)"); sbEmailBody.Append("is to provide materials in small quantities to research and education entities when genetic diversity or genetic standards are a"); sbEmailBody.Append("requirement.The accessions maintained by NPGS are not intended for home or personal use that can"); sbEmailBody.Append("be better served by commercially - available varieties."); sbEmailBody.Append("*** PLACEHOLDER FOR TEMPLATE TEXT ***"); emailMessage.Body = sbEmailBody.ToString(); smtpService.SendMessage(emailMessage); // EMAIL TO CURATORS emailMessage.RecipientAddress = "*****@*****.**"; emailMessage.Subject = "NRR Review Update: Order " + webOrderRequest.ID + " Canceled"; emailMessage.Body = "Order # " + webOrderRequest.ID + " has been determined to be a Non-Research Request (NRR), and has been cancelled. You may reference this order within the Order Wizard."; smtpService.SendMessage(emailMessage); } } if (viewModel.Action != "NRR_NOTE") { return(RedirectToAction("Index", "WebOrder")); } else { return(RedirectToAction("Edit", "WebOrder", new { id = viewModel.ID })); } } catch (Exception ex) { log.Error(ex.Message, ex); //TO DO: CHANGE return(View("~/Views/GRINGlobal/WebOrder/Index.cshtml")); } }
public ResultContainer UpdateWebOrderRequest(WebOrderRequest webOrderRequest) { return(_webOrderRequestDAO.Update(webOrderRequest)); }