コード例 #1
0
        private void BuildContractChangeNotifications(List <ContractChange> changes)
        {
            try
            {
                Customer customer = _customerRepo.GetCustomerByCustomerNumber(changes[0].CustomerNumber,
                                                                              changes[0].BranchId);

                if (customer != null)
                {
                    var notifcation = BuildContractChangeNotification(changes, customer);
                    _queueRepo.PublishToDirectedExchange(notifcation.ToJson(),
                                                         BEKConfiguration.Get("RabbitMQNotificationServer"),
                                                         BEKConfiguration.Get("RabbitMQNotificationPublisherUserName"),
                                                         BEKConfiguration.Get("RabbitMQNotificationPublisherUserPassword"),
                                                         BEKConfiguration.Get("RabbitMQNotificationVHost"),
                                                         BEKConfiguration.Get("RabbitMQNotificationExchangeV2"),
                                                         Constants.RABBITMQ_NOTIFICATION_HASNEWS_ROUTEKEY);
                    _log.WriteInformationLog(string.Format("Published to notification exchange, {0}",
                                                           notifcation.ToJson()));
                }
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("Error creating contract change notification", ex);
            }

            if (changes != null &&
                changes.Count > 0)
            {
                _contractChangesRepo.Update(changes.First().ParentList_Id, true);
            }
        }
コード例 #2
0
        public bool ProcessIncomingConfirmation(ConfirmationFile confirmation)
        {
            if (String.IsNullOrEmpty(confirmation.Header.ConfirmationNumber))
            {
                throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Confirmation Number is Required", new Exception());
            }
            ;
            if (String.IsNullOrEmpty(confirmation.Header.InvoiceNumber))
            {
                throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Invoice Number is Required", new Exception());
            }
            ;
            if (confirmation.Header.ConfirmationStatus == null)
            {
                throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Confirmation Status is Required", new Exception());
            }
            ;

            var           poNum = confirmation.Header.ConfirmationNumber;
            PurchaseOrder po    = GetCsPurchaseOrderByNumber(poNum);

            NewRelic.Api.Agent.NewRelic.AddCustomParameter("ConfirmationNumber", confirmation.Header.ConfirmationNumber);
            NewRelic.Api.Agent.NewRelic.AddCustomParameter("CustomerNumber", confirmation.Header.CustomerNumber);
            NewRelic.Api.Agent.NewRelic.AddCustomParameter("Branch", confirmation.Header.Branch);
            NewRelic.Api.Agent.NewRelic.AddCustomParameter("ItemCount", confirmation.Detail.Count());

            if (po == null)
            {
                _log.WriteWarningLog("Could not find PO for confirmation number: {ConfirmationNumber}, Line: 399, Method: ProcessIncomingConfirmation".InjectSingleValue("ConfirmationNumber", poNum));
            }
            else
            {
                // make sure that there are items to process
                if (po.LineItemCount == 0 || po.OrderForms[0].LineItems.Count == 0)
                {
                    throw new QueueDataError <ConfirmationFile>(confirmation, "ProcessIncomingConfirmation", "Process incoming confirmations", "Purchase order has no line items", new Exception());
                }

                // need to save away pre and post status info, then if different, add something to the messaging
                LineItem[] currLineItems = new LineItem[po.LineItemCount];
                LineItem[] origLineItems = new LineItem[po.LineItemCount];
                po.OrderForms[0].LineItems.CopyTo(currLineItems, 0);
                po.OrderForms[0].LineItems.CopyTo(origLineItems, 0);
                string originalStatus = po.Status;

                if (confirmation.Header.ConfirmationStatus.Equals(Constants.CONFIRMATION_HEADER_REJECTED_CODE, StringComparison.InvariantCultureIgnoreCase))
                {
                    // Update line item status' to rejected
                    foreach (var item in currLineItems)
                    {
                        item["MainFrameStatus"] = "Rejected";
                    }
                }
                else
                {
                    SetCsLineInfo(currLineItems, confirmation);
                }

                SetCsHeaderInfo(confirmation, po, currLineItems);

                string logMessage = string.Format("Updating purchase order status to '{0}' for tracking number {1}, confirmation number {2}, and invoice number {3}.", po.Status, po.TrackingNumber, confirmation.Header.ConfirmationNumber, confirmation.Header.InvoiceNumber);
                _log.WriteInformationLog(logMessage);

                po.Save();

                // use internal messaging logic to put order up message on the queue
                OrderChange orderChange = BuildOrderChanges(po, currLineItems, origLineItems, originalStatus, confirmation.Header.SpecialInstructions, confirmation.Header.ShipDate);
                if (orderChange.OriginalStatus != orderChange.CurrentStatus || orderChange.ItemChanges.Count > 0)
                {
                    OrderConfirmationNotification orderConfNotification = new OrderConfirmationNotification();
                    orderConfNotification.OrderChange    = orderChange;
                    orderConfNotification.OrderNumber    = (string)po["OrderNumber"];
                    orderConfNotification.CustomerNumber = (string)po["CustomerId"];
                    orderConfNotification.BranchId       = (string)po["BranchId"];
                    orderConfNotification.InvoiceNumber  = confirmation.Header.InvoiceNumber;

                    genericeQueueRepository.PublishToDirectedExchange(orderConfNotification.ToJson(), Configuration.RabbitMQNotificationServer,
                                                                      Configuration.RabbitMQNotificationUserNamePublisher, Configuration.RabbitMQNotificationUserPasswordPublisher,
                                                                      Configuration.RabbitMQVHostNotification, Configuration.RabbitMQExchangeNotificationV2,
                                                                      Constants.RABBITMQ_NOTIFICATION_ORDERCONFIRMATION_ROUTEKEY);
                }
            }

            return(true);
        }