public ActionResult RunIndexingTool()
        {
            SannsynAdminViewModel viewModel = new SannsynAdminViewModel();

            List <PurchaseOrder> allOrders = _sannsynOrderIndexerService.GetOrders(string.Empty, string.Empty, int.MaxValue);

            foreach (var order in allOrders)
            {
                _sannsynOrderIndexerService.AddLineItemsToSannsyn(order);
            }
            viewModel.StatusMessage = string.Format("Sent {0} orders to sannsyn", allOrders.Count);
            return(View(string.Format("{0}{1}/Views/SannsynAdmin/Index.cshtml", Paths.ProtectedRootPath, "Sannsyn"), viewModel));
        }
コード例 #2
0
        /// <summary>
        /// Adding lineitem entries to Sannsyn. Since OrderGroupUpdated is called often, we add last
        /// order indexed in DDS, so we don't index duplicate orders. All code is in a try, then the order
        /// will still be completed if error occures when calling sannsyn or DDS
        /// </summary>
        /// <param name="order"></param>
        /// <param name="e"></param>
        private void GenerateSannsynData(OrderGroup order, OrderGroupEventArgs e)
        {
            if (order.Status.Equals("InProgress"))
            {
                try
                {
                    SannsynDdsModel lastOrderIndexed = SannsynDdsModel.GetLastOrderIndexed();
                    if (lastOrderIndexed.LastIndexedOrderId < order.OrderGroupId)
                    {
                        ISannsynOrderIndexerService sannsynOrderIndexerService = ServiceLocator.Current.GetInstance <ISannsynOrderIndexerService>();
                        sannsynOrderIndexerService.AddLineItemsToSannsyn(order);

                        lastOrderIndexed.LastIndexedOrderId = order.OrderGroupId;
                        lastOrderIndexed.Save();
                    }
                }
                catch (Exception ex)
                {
                    _log.Error("Could not add order items to Sannsyn", ex);
                }
            }
        }