Ejemplo n.º 1
0
 public static DSS1_RetailerDriverStockOptimisation.BO.OrderForecast CopyOrderForecastToNew(this BO.OrderForecast @this)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("OrderForecast", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "CopyOrderForecastToNew")) {
         DSS1_RetailerDriverStockOptimisation.BO.OrderForecast orderF = @this?.Copy(false, null, true);
         orderF.CreatedBy = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentUserName(); orderF.CreatedOn = DateTime.UtcNow; orderF.Status = "New"; orderF.State = "Recalculated"; orderF.SalesForecast = @this?.SalesForecast; return(orderF);
     }
 }
 public static void CreateNotifications(DSS1_RetailerDriverStockOptimisation.BO.OrderForecast orderForecast)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Notification", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "CreateNotifications")) {
         zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Creating Alerts for Order Forecast: " + (orderForecast?.Id ?? 0));
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails> forecastOrderDetails = orderForecast?.OrderForecastDetails;
         foreach (var order in forecastOrderDetails ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>())
         {
             if ((order?.Notification != null))
             {
                 zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "---- Deleting " + (order?.Notification?.Id ?? 0) + "----");
                 new DSS1_RetailerDriverStockOptimisation.DAL.Repository().DeleteNotification(order?.Notification);
             }
             DSS1_RetailerDriverStockOptimisation.BO.Item currItem = order?.Item;
             var _var0 = currItem?.SKU; var _var1 = order?.RecommendedOrderDate?.Date; DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity supplierCapacity = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity>((a) => a.Item.SKU == _var0 && a.DateOfStockUpdate.GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value).Date == _var1)?.FirstOrDefault();
             if ((supplierCapacity == null || supplierCapacity?.Stock == 0))
             {
                 zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Don't have supplier capacity for item : " + (currItem?.SKU ?? ""));
                 continue;
             }
             int?totalStock    = (supplierCapacity?.Stock ?? 0);
             int?orderQuantity = (int)((order?.Quantity ?? 0));
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "Notification", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "totalStock " + (totalStock?.ToString() ?? "") + " : orderQuantity" + (orderQuantity?.ToString() ?? ""));
             if ((totalStock < orderQuantity))
             {
                 DSS1_RetailerDriverStockOptimisation.BO.Notification notification = new DSS1_RetailerDriverStockOptimisation.BO.Notification();
                 notification.Message = "Low Stock"; notification.Item = currItem; notification.Warehouse = order?.Warehouse; notification.TotalSupplierStock = totalStock; notification.SalesForecastDate = (order?.RecommendedOrderDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); notification.OrderForecastQuantity = orderQuantity; notification.Diff = orderQuantity.GetValueOrDefault(0) - totalStock.GetValueOrDefault(0); notification.OrderForecastDetails = order; notification.CreatedBy = "System"; new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Save <DSS1_RetailerDriverStockOptimisation.BO.Notification>(notification);
                 zAppDev.DotNet.Framework.Utilities.EMailMessage em = new zAppDev.DotNet.Framework.Utilities.EMailMessage();
                 em.To = new List <string> {
                     "*****@*****.**"
                 }.ToList(); em.Subject = "New Alert"; em.IsBodyHtml = true; em.Body = "A new alert is created due to low stock " + "for the Item: " + (notification?.Item?.SKU ?? ""); zAppDev.DotNet.Framework.Utilities.Email.SendMail(em, true);
             }
             string recommendationThresholdPercentString = zAppDev.DotNet.Framework.Identity.Model.ApplicationSetting.GetValue("RecommendationThresholdPercent");
             if (((recommendationThresholdPercentString == null || recommendationThresholdPercentString.Trim() == "")))
             {
                 continue;
             }
             int?recommendationThresholdPercent = int.Parse(recommendationThresholdPercentString);
             if ((100 * (totalStock.GetValueOrDefault(0) - orderQuantity.GetValueOrDefault(0)) / totalStock.GetValueOrDefault(0) >= recommendationThresholdPercent))
             {
                 DSS1_RetailerDriverStockOptimisation.BO.Notification notification = new DSS1_RetailerDriverStockOptimisation.BO.Notification();
                 notification.Message = "Excess of Stock"; notification.Item = currItem; notification.Warehouse = order?.Warehouse; notification.TotalSupplierStock = totalStock; notification.SalesForecastDate = (order?.RecommendedOrderDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); notification.OrderForecastQuantity = orderQuantity; notification.Diff = totalStock.GetValueOrDefault(0) - orderQuantity.GetValueOrDefault(0); notification.OrderForecastDetails = order; notification.CreatedBy = "System"; new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Save <DSS1_RetailerDriverStockOptimisation.BO.Notification>(notification);
             }
         }
     }
 }
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item> ItemsInSelectedForecast(DSS1_RetailerDriverStockOptimisation.BO.OrderForecast selectedOrderForecast)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Item", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "ItemsInSelectedForecast")) {
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item> items = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.Item>();
         if ((selectedOrderForecast == null))
         {
             return(items);
         }
         zAppDev.DotNet.Framework.Data.MiniSessionManager.Instance.Session.Refresh(selectedOrderForecast);
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.ItemParameter> itemParams = selectedOrderForecast?.ItemParameters;
         foreach (var i in itemParams ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.ItemParameter>())
         {
             items?.Add(i?.Item);
         }
         return(items);
     }
 }