Example #1
0
 public OrderForecasts_OrderForecastDTO(DSS1_RetailerDriverStockOptimisation.BO.OrderForecast original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.Id == 0) ? original._GetUniqueIdentifier() as object : original.Id as object;
     _runtimeType = original?.GetType().FullName;
     Id           = original.Id;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
     CreatedOn = original.CreatedOn;
     CreatedBy = original.CreatedBy;
 }
 public ApplicationPermissionDTO(zAppDev.DotNet.Framework.Identity.Model.ApplicationPermission original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.Id == 0) ? original._GetUniqueIdentifier() as object : original.Id as object;
     _runtimeType = original?.GetType().FullName;
     Id           = original.Id;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
     Name        = original.Name;
     Description = original.Description;
 }
        /*<ControllerActionImplementation:NewRole:1/>*/
        public ActionResult ExecuteNewRole()
        {
            if (_parentController == null)
            {
                _parentController = new MasterPageForSlide.MasterPageForSlideController(new  DSS3_LogisticsPoolingForUrbanDistribution.UI.ViewModels.MasterPageForSlide.MasterPageForSlideViewModel());
            }
            ((MasterPageForSlide.MasterPageForSlideController)_parentController).ExecuteRender();
            ActionResult _result = null;

            zAppDev.DotNet.Framework.Identity.Model.ApplicationRole role = new zAppDev.DotNet.Framework.Identity.Model.ApplicationRole();
            role.IsCustom          = true;
            @model.ApplicationRole = role;
            @model.Title           = BaseViewPage <string> .GetResourceValue("ManageRole", "RES_PAGETITLE_NewRole").ToString();

            return(_result);
        }
Example #4
0
        /*<ControllerActionImplementation:Save:1/>*/
        public ActionResult ExecuteSave()
        {
            ActionResult _result = null;

            zAppDev.DotNet.Framework.Identity.Model.ApplicationRole role = new DSS2_SynchromodalityCapacityOptimisation.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((r) => r.Name == "Administrator")?.FirstOrDefault();
            if (role == null)
            {
                throw new Exception((BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_CUSTOM_NoAdminRoleFound").ToString()));
            }
            if ((@model.ApplicationUser?.IsInRole("Administrator") ?? false))
            {
                throw new Exception((BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_CUSTOM_AlreadyAdmin").ToString()));
            }
            @model.ApplicationUser?.AddRoles(role);
            new DSS2_SynchromodalityCapacityOptimisation.DAL.Repository().Save <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(@model.ApplicationUser);
            _result = GetRedirectInfo("HomePage", "Render", new  RouteValueDictionary(new {  }));
            return(_result);
        }
Example #5
0
 public SupplierDataSet_SupplierDTO(DSS5_SupplyChainFinancialsOptimisation.BO.Supplier original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.UserName == "") ? original._GetUniqueIdentifier() as object : original.UserName as object;
     _runtimeType = original?.GetType().FullName;
     UserName     = original.UserName;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
     Company        = original.Company;
     Email          = original.Email;
     Business       = original.Business;
     SupplierStatus = original.SupplierStatus;
 }
Example #6
0
 public ItemDataSet_ItemDTO(DSS1_RetailerDriverStockOptimisation.BO.Item original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.SKU == "") ? original._GetUniqueIdentifier() as object : original.SKU as object;
     _runtimeType = original?.GetType().FullName;
     if (original.VersionTimestamp != null && original.VersionTimestamp.Length > 0)
     {
         _versionTimestamp = BitConverter.ToInt64(original.VersionTimestamp, 0).ToString();
     }
     SKU = original.SKU;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
 }
Example #7
0
 public DeliveryNoteDataSet_TransactionDTO(DSS5_SupplyChainFinancialsOptimisation.BO.Transaction original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.Id == 0) ? original._GetUniqueIdentifier() as object : original.Id as object;
     _runtimeType = original?.GetType().FullName;
     if (original.VersionTimestamp != null && original.VersionTimestamp.Length > 0)
     {
         _versionTimestamp = BitConverter.ToInt64(original.VersionTimestamp, 0).ToString();
     }
     Id = original.Id;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
 }
 public CalendarSet_ApplicationUserDTO(zAppDev.DotNet.Framework.Identity.Model.ApplicationUser original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.UserName == "") ? original._GetUniqueIdentifier() as object : original.UserName as object;
     _runtimeType = original?.GetType().FullName;
     if (original.VersionTimestamp != null && original.VersionTimestamp.Length > 0)
     {
         _versionTimestamp = BitConverter.ToInt64(original.VersionTimestamp, 0).ToString();
     }
     UserName = original.UserName;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
 }
        /*<ControllerActionImplementation:Render:1/>*/
        public ActionResult ExecuteRender()
        {
            if (_parentController == null)
            {
                _parentController = new MasterPage.MasterPageController(new  DSS5_SupplyChainFinancialsOptimisation.UI.ViewModels.MasterPage.MasterPageViewModel());
            }
            ((MasterPage.MasterPageController)_parentController).ExecuteRender();
            ActionResult _result = null;

            if ((zAppDev.DotNet.Framework.Utilities.Common.GetConfigurationKey("FirstAdminSetup") != "true"))
            {
                throw new Exception((BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_CUSTOM_NoAccess").ToString()));
            }
            @model.ApplicationUser = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser();
            @model.Title           = BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_PAGETITLE_Render").ToString();

            return(_result);
        }
        /*<ControllerActionImplementation:ChangePassword:1/>*/
        public ActionResult ExecuteChangePassword()
        {
            ActionResult _result = null;

            if (@model.txtNewRepeat != @model.txtNew)
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ChangePassword", "RES_CUSTOM_PassError").ToString(), MessageType.Error);
                return(null);
            }
            string result = zAppDev.DotNet.Framework.Identity.IdentityHelper.ChangePassword(zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser(), @model.txtCurrent, @model.txtNew);

            if (((((result) == null || (result) == "")) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, result, MessageType.Error);
                return(null);
            }
            _result = CloseForm();
            return(_result);
        }
Example #11
0
        /*<ControllerActionImplementation:SetPassword:1/>*/
        public ActionResult ExecuteSetPassword()
        {
            ActionResult _result = null;

            if (((zAppDev.DotNet.Framework.Identity.IdentityHelper.PasswordIsValid(@model.NewPassword).Result) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ManageUser", "RES_CUSTOM_NotValidPassword").ToString() + " " + @model.NewPassword);
                return(null);
            }
            string error = zAppDev.DotNet.Framework.Identity.IdentityHelper.ResetPasswordByAdmin(@model.ApplicationUser, @model.NewPassword);

            if (((error == null || error.Trim() == "")))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, "OK", MessageType.Success);
            }
            else
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, error, MessageType.Error);
            }
            return(_result);
        }
Example #12
0
 public List1DataSet_ApplicationOperationDTO(zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.Id == 0) ? original._GetUniqueIdentifier() as object : original.Id as object;
     _runtimeType = original?.GetType().FullName;
     if (original.VersionTimestamp != null && original.VersionTimestamp.Length > 0)
     {
         _versionTimestamp = BitConverter.ToInt64(original.VersionTimestamp, 0).ToString();
     }
     Id = original.Id;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
     ParentControllerName = original.ParentControllerName;
     Name = original.Name;
     IsAvailableToAnonymous          = original.IsAvailableToAnonymous;
     IsAvailableToAllAuthorizedUsers = original.IsAvailableToAllAuthorizedUsers;
 }
 public AgreementDataSet_AgreementDTO(DSS1_RetailerDriverStockOptimisation.BO.Agreement original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.Id == 0) ? original._GetUniqueIdentifier() as object : original.Id as object;
     _runtimeType = original?.GetType().FullName;
     if (original.VersionTimestamp != null && original.VersionTimestamp.Length > 0)
     {
         _versionTimestamp = BitConverter.ToInt64(original.VersionTimestamp, 0).ToString();
     }
     Id = original.Id;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
     Supplier = original.Supplier == null
                ? null
                : DTOHelper.GetDTOFromModel <AgreementDataSet_SupplierDTO>(original.Supplier as DSS1_RetailerDriverStockOptimisation.BO.Supplier);
     DateCreated = original.DateCreated;
 }
Example #14
0
        /*<ControllerActionImplementation:Render:1/>*/
        public ActionResult ExecuteRender()
        {
            if (_parentController == null)
            {
                _parentController = new MasterPage.MasterPageController(new  DSS2_SynchromodalityCapacityOptimisation.UI.ViewModels.MasterPage.MasterPageViewModel());
            }
            ((MasterPage.MasterPageController)_parentController).ExecuteRender();
            ActionResult _result = null;

            if ((new DSS2_SynchromodalityCapacityOptimisation.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>()?.Any((x) => x.Roles.Any((r) => r.Name == "Administrator")) ?? false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_CUSTOM_NoAccess").ToString(), MessageType.Error, (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                                                                                                                                                                             System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                              "/HomePage/Render");
                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "FirstAdminSetup", DSS2_SynchromodalityCapacityOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Admin user already exists");
                return(null);
            }
            @model.ApplicationUser = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser();
            @model.Title           = BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_PAGETITLE_Render").ToString();

            return(_result);
        }
Example #15
0
        /*<ControllerActionImplementation:SignIn:1/>*/
        public ActionResult ExecuteSignIn()
        {
            ActionResult _result = null;
            bool         success = zAppDev.DotNet.Framework.Identity.IdentityHelper.SignIn(@model.UserNameTextBox, @model.PasswordTextBox, @model.RememberMeCB);

            if (((success) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("SignInPage", "SignInFailed").ToString(), MessageType.Error);
                return(null);
            }
            string returnUrl = zAppDev.DotNet.Framework.Utilities.Web.GetFormArgument("returnUrl");

            if (((((returnUrl == null || returnUrl.Trim() == "")) == false)))
            {
                ClientCommand(ClientCommands.REDIRECT, (!string.IsNullOrEmpty(ConfigurationHandler.GetAppSetting("ServerExternalPath")) ? ConfigurationHandler.GetAppSetting("ServerExternalPath"): zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) + returnUrl);
            }
            else
            {
                _result = GetRedirectInfo("HomePage", "Render", new  RouteValueDictionary(new {  }));
            }
            return(_result);
        }
        /*<ControllerActionImplementation:SignIn:1/>*/
        public ActionResult ExecuteSignIn()
        {
            ActionResult _result = null;
            bool         success = zAppDev.DotNet.Framework.Identity.IdentityHelper.SignIn(@model.UserNameTextBox, @model.PasswordTextBox, @model.RememberMeCB);

            if (((success) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("SignInPage", "SignInFailed").ToString(), MessageType.Error);
                return(null);
            }
            string returnUrl = zAppDev.DotNet.Framework.Utilities.Web.GetFormArgument("returnUrl");

            zAppDev.DotNet.Framework.Identity.Model.ApplicationUser user = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>((a) => a.UserName == @model.UserNameTextBox)?.FirstOrDefault();
            if (((((returnUrl == null || returnUrl.Trim() == "")) == false)))
            {
                ClientCommand(ClientCommands.REDIRECT, (!string.IsNullOrEmpty(ConfigurationHandler.GetAppSetting("ServerExternalPath")) ? ConfigurationHandler.GetAppSetting("ServerExternalPath"): zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) + returnUrl);
            }
            else
            {
                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "SignInPage", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, user == null);
                if (((user?.HasPermission("IsStockManager") ?? false)))
                {
                    zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "SignInPage", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "IsStockManager");
                    _result = GetRedirectInfo("StockManagerView", "Render", new  RouteValueDictionary(new {  }));
                }
                else if ((user?.IsInRole("Supplier") ?? false))
                {
                    zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "SignInPage", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Supplier");
                    _result = GetRedirectInfo("SupplierView", "Render", new  RouteValueDictionary(new {  }));
                }
                else
                {
                    zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "SignInPage", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Normal");
                    _result = GetRedirectInfo("StockManagerView", "Render", new  RouteValueDictionary(new {  }));
                }
            }
            return(_result);
        }
Example #17
0
        /*<ControllerActionImplementation:ResetPasswordRequest:1/>*/
        public ActionResult ExecuteResetPasswordRequest()
        {
            ActionResult _result = null;

            zAppDev.DotNet.Framework.Identity.Model.ApplicationUser user = new DSS3_LogisticsPoolingForUrbanDistribution.DAL.Repository().GetById <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(@model.txtUsername);
            if (user == null)
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_NotFound").ToString(), MessageType.Error);
                return(null);
            }
            if (((user?.Email ?? "") == null || (user?.Email ?? "").Trim() == "") || ((((user?.Email ?? "") == null ? false : CSharpVerbalExpressions.VerbalExpressions.DefaultExpression.Add(CSharpVerbalExpressions.CommonRegex.Email).Test((user?.Email ?? "")))) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_NoMail").ToString(), MessageType.Error);
                return(null);
            }
            string key      = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetUserManager().GeneratePasswordResetTokenAsync(user.UserName).Result;
            string resetUrl = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                               System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                              "/ForgotPassword/ResetPassword" + "?username="******"")) + "&key=" + System.Web.HttpUtility.UrlEncode(System.Web.HttpUtility.UrlEncode(key));

            zAppDev.DotNet.Framework.Utilities.EMailMessage mail       = new zAppDev.DotNet.Framework.Utilities.EMailMessage();
            System.Collections.Generic.List <string>        recipients = new System.Collections.Generic.List <string>();
            recipients.Add((user?.Email ?? ""));
            mail.To         = recipients.ToList();
            mail.IsBodyHtml = true;
            mail.Subject    = BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_ResetPasswordLink").ToString() + " " + "DSS3_LogisticsPoolingForUrbanDistribution";

            mail.Body = "<h3>" + BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_ClickToReset").ToString() + "</h3>" + "<a href='" + resetUrl + "'>" + BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_ResetPassword").ToString() + "</a>" + "<h3>" + BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_CopyPaste").ToString() + "</h3><p>" + resetUrl + "</p>";

            zAppDev.DotNet.Framework.Utilities.Email.SendMail(mail);
            string signInUrl = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                                System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                               "/SignInPage/Load";

            ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_MailSoon").ToString(), MessageType.Success, signInUrl);
            return(_result);
        }
 public SupplierTurnoverDataSet_SupplierStatisticDTO(DSS5_SupplyChainFinancialsOptimisation.BO.SupplierStatistic original)
 {
     if (original == null)
     {
         throw new ApplicationException(BaseViewPage <object> .GetResourceValue("GlobalResources", "RES_DATASOURCE_Null_Value_In_Resultset", null, "The resultset of your DataSource contains null values."));
     }
     _key         = (original.Id == 0) ? original._GetUniqueIdentifier() as object : original.Id as object;
     _runtimeType = original?.GetType().FullName;
     if (original.VersionTimestamp != null && original.VersionTimestamp.Length > 0)
     {
         _versionTimestamp = BitConverter.ToInt64(original.VersionTimestamp, 0).ToString();
     }
     Id = original.Id;
     if (!DTOHelper.SeenDTOInstances.ContainsKey(original))
     {
         DTOHelper.SeenDTOInstances.Add(original, this);
     }
     Supplier = original.Supplier == null
                ? null
                : DTOHelper.GetDTOFromModel <SupplierTurnoverDataSet_SupplierDTO>(original.Supplier as DSS5_SupplyChainFinancialsOptimisation.BO.Supplier);
     CurrentTurnover  = original.CurrentTurnover;
     NextTurnover     = original.NextTurnover;
     PreviousTurnover = original.PreviousTurnover;
 }
Example #19
0
        /*<ControllerActionImplementation:ResetPassword:1/>*/
        public ActionResult ExecuteResetPassword(string username, string key)
        {
            if (_parentController == null)
            {
                _parentController = new MasterPage.MasterPageController(new  DSS3_LogisticsPoolingForUrbanDistribution.UI.ViewModels.MasterPage.MasterPageViewModel());
            }
            ((MasterPage.MasterPageController)_parentController).ExecuteRender();
            ActionResult _result = null;

            @model.Title = null;
            if (((username == null || username.Trim() == "")))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_InvalidLink").ToString(), MessageType.Error);
                return(null);
            }
            zAppDev.DotNet.Framework.Identity.Model.ApplicationUser user = new DSS3_LogisticsPoolingForUrbanDistribution.DAL.Repository().GetById <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(username);
            if (user == null)
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_NotFound").ToString(), MessageType.Error);
                return(null);
            }
            string newPassword = "******" + Guid.NewGuid().ToString().ToLower().Replace("-", "").Substring(0, 10);
            bool   success     = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetUserManager().ResetPasswordAsync(user.UserName, key, newPassword).Result.Succeeded;

            if (((success) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_InvalidLink").ToString(), MessageType.Error);
                return(null);
            }
            string signInUrl = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                                System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                               "/SignInPage/Load";

            ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_YourNewPass").ToString() + " " + newPassword, MessageType.Success, signInUrl);
            return(_result);
        }
Example #20
0
        public string OrderProposalList_ExportImplementation(DatasourceRequest datasourceRequest, ExportHelper.ExportOptions exportOptions, List <AggregatorInfo <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails> > aggregatorsInfo)
        {
            if (exportOptions.Range == ExportHelper.Range.TOP100)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
            }
            else if (exportOptions.Range == ExportHelper.Range.ALL)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
            }
            if (string.IsNullOrWhiteSpace(exportOptions.Filename))
            {
                exportOptions.Filename = "OrderProposalList";
            }
            if (exportOptions.ColumnOptions == null)
            {
                exportOptions.ColumnOptions = new List <ExportHelper.ColumnOptions>
                {
                    new ExportHelper.ColumnOptions {
                        Column = "Item.SKU", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Item.Description", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Warehouse.Description", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Quantity", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "RecommendedOrderDate", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "SalesForecastDate", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "SupplierCanDeliver", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "SupplierMaxQuantity", IsVisible = true
                    },
                };
            }
            var queryable   = Get_OrderProposalList_DatasourceQueryable(datasourceRequest);
            var totalRows   = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count();
            var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
            var dto         = items.Select(i => new OrderProposalDataSet_OrderForecastDetailsDTO(i));
            var formattings = new Dictionary <string, string>();

            formattings.Add("RecommendedOrderDate", "dd/MM/yyyy");
            formattings.Add("SalesForecastDate", "dd/MM/yyyy");
            var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);

            foreach (var a in aggregators)
            {
                var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                a.Calculate(queryable, formatting);
            }
            var exportDataDTO = new List <ExportHelper.ExportRecordDTO>();

            foreach (var record in dto)
            {
                var recordDTO = new ExportHelper.ExportRecordDTO();
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = "Item.SKU",
                    Value          = record?.Item?.SKU,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Item.SKU")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = "Item.Description",
                    Value          = record?.Item?.Description,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Item.Description")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = "Warehouse.Description",
                    Value          = record?.Warehouse?.Description,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Warehouse.Description")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.Quantity),
                    Value          = record?.Quantity,
                    ColumnDataType = "decimal",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Quantity")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.RecommendedOrderDate),
                    Value          = record?.RecommendedOrderDate,
                    ColumnDataType = "DateTime",
                    Format         = "dd/MM/yyyy",
                    ExcelFormat    = @"dd/MM/yyyy",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_RecommendedOrderDate")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.SalesForecastDate),
                    Value          = record?.SalesForecastDate,
                    ColumnDataType = "DateTime",
                    Format         = "dd/MM/yyyy",
                    ExcelFormat    = @"dd/MM/yyyy",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_SalesForecastDate")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.SupplierCanDeliver),
                    Value          = record?.SupplierCanDeliver,
                    ColumnDataType = "bool",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_SupplierCanDeliver")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.SupplierMaxQuantity),
                    Value          = record?.SupplierMaxQuantity,
                    ColumnDataType = "decimal",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_SupplierMaxQuantity")
                });
                exportDataDTO.Add(recordDTO);
            }
            if (aggregators.Count > 0)
            {
                foreach (AggregatorType aggregatorType in Enum.GetValues(typeof(AggregatorType)))
                {
                    var emptyAggregatorRow = true;
                    var recordDTO          = new ExportHelper.ExportRecordDTO();
                    foreach (var columnOption in exportOptions.ColumnOptions)
                    {
                        var aggregatorValue = "";
                        switch (aggregatorType)
                        {
                        case AggregatorType.COUNT:
                            if (columnOption.CountIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.COUNT);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandCount")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.SUM:
                            if (columnOption.SumIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.SUM);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandTotal")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.AVERAGE:
                            if (columnOption.AverageIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.AVERAGE);
                                aggregatorValue   += $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandAverage")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;
                        }
                        recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                        {
                            ColumnName     = columnOption.Column,
                            Value          = aggregatorValue,
                            ColumnDataType = "string",
                            Format         = ""
                        });
                    }
                    if (!emptyAggregatorRow)
                    {
                        exportDataDTO.Add(recordDTO);
                    }
                }
            }
            var path     = ExportHelper.ExportList(exportDataDTO, exportOptions, totalRows);
            var content  = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName = Path.GetFileName(path);

            return(FileHelper.PendingDownloadInstance.Add("SupplierOrderForecast", content, fileName));
        }
        public string DeliveryNoteListNoDT_ExportV2Implementation(DatasourceRequest datasourceRequest, ExportOptionsV2 exportOptions, List <AggregatorInfo <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote> > aggregatorsInfo)
        {
            var  watch = System.Diagnostics.Stopwatch.StartNew();
            long elapsedMilliseconds = 0;

            switch (exportOptions.Range)
            {
            case ExportHelper.Range.ALL:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
                break;

            case ExportHelper.Range.TOP100:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
                break;
            }
            var queryable    = Get_DeliveryNoteListNoDT_DatasourceQueryable(datasourceRequest);
            var formattings  = new Dictionary <string, string>();
            var path         = "";
            var exportHelper = new ExportHelperV2 <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote>(exportOptions, new Dictionary <string, Func <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote, object> >
            {
                { "Transaction.Id", item => item?.Transaction?.Id }, { "DeliveryNoteNumber", item => item?.DeliveryNoteNumber }, { "Description", item => item?.Description }, { "DateIssued", item => item?.DateIssued }, { "Amount", item => item?.Amount }, { "Transaction.Supplier.Company", item => item?.Transaction?.Supplier?.Company },
            });

            if (exportHelper.Options.ColumnInfo == null)
            {
                exportHelper.Options.ColumnInfo = new List <ColumnOptionsV2>
                {
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Transaction.Id"), Formatting = "", Name = "Transaction.Id", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_DeliveryNoteNumber"), Formatting = "", Name = "DeliveryNoteNumber", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Description"), Formatting = "", Name = "Description", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_DateIssued"), Formatting = "dd/MM/yyyy", Name = "DateIssued", ExcelFormat = @"dd/MM/yyyy"
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Amount"), Formatting = "#,0.00;'-'#,0.00;'0'", Name = "Amount", ExcelFormat = @"#,##0.00;-#,##0.00;#,##0.00"
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Transaction.Supplier.Company"), Formatting = "", Name = "Transaction.Supplier.Company", ExcelFormat = @""
                    },
                };
            }
            if (string.IsNullOrWhiteSpace(exportHelper.Options.Filename))
            {
                exportHelper.Options.Filename = "DeliveryNoteListNoDT";
            }
            if (datasourceRequest.GroupBy.Any())
            {
                var groups      = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, aggregatorsInfo);
                var aggregators = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, aggregatorsInfo, true);
                GroupsHelper.FormatGroupedAggregators(aggregators, formattings);
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: DeliveryNoteListNoDT export query with grouping and range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(groups, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: DeliveryNoteListNoDT export to excel with grouping and range {exportOptions.Range} took {watch.ElapsedMilliseconds}ms");
            }
            else
            {
                var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                var loadedItems = items.ToList();
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: DeliveryNoteListNoDT export query with range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(loadedItems, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: DeliveryNoteListNoDT export to excel with range {exportOptions.Range} took {elapsedMilliseconds}ms");
            }
            var content     = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName    = Path.GetFileName(path);
            var downloadKey = FileHelper.PendingDownloadInstance.Add("AdminDeliveryNoteList", content, fileName);

            _logger.Info($"ExportV2 Performance: Total export time for DeliveryNoteListNoDT: {elapsedMilliseconds}ms");
            return(downloadKey);
        }
        public string DeliveryNoteListNoDT_ExportImplementation(DatasourceRequest datasourceRequest, ExportHelper.ExportOptions exportOptions, List <AggregatorInfo <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote> > aggregatorsInfo)
        {
            if (exportOptions.Range == ExportHelper.Range.TOP100)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
            }
            else if (exportOptions.Range == ExportHelper.Range.ALL)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
            }
            if (string.IsNullOrWhiteSpace(exportOptions.Filename))
            {
                exportOptions.Filename = "DeliveryNoteListNoDT";
            }
            if (exportOptions.ColumnOptions == null)
            {
                exportOptions.ColumnOptions = new List <ExportHelper.ColumnOptions>
                {
                    new ExportHelper.ColumnOptions {
                        Column = "Transaction.Id", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "DeliveryNoteNumber", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Description", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "DateIssued", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Amount", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Transaction.Supplier.Company", IsVisible = true
                    },
                };
            }
            var queryable   = Get_DeliveryNoteListNoDT_DatasourceQueryable(datasourceRequest);
            var totalRows   = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count();
            var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
            var dto         = items.Select(i => new DeliveryNoteDataSet_DeliveryNoteDTO(i));
            var formattings = new Dictionary <string, string>();

            formattings.Add("DateIssued", "dd/MM/yyyy");
            formattings.Add("Amount", "#,0.00;'-'#,0.00;'0'");
            var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);

            foreach (var a in aggregators)
            {
                var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                a.Calculate(queryable, formatting);
            }
            var exportDataDTO = new List <ExportHelper.ExportRecordDTO>();

            foreach (var record in dto)
            {
                var recordDTO = new ExportHelper.ExportRecordDTO();
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = "Transaction.Id",
                    Value          = record?.Transaction?.Id,
                    ColumnDataType = "int",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Transaction.Id")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.DeliveryNoteNumber),
                    Value          = record?.DeliveryNoteNumber,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_DeliveryNoteNumber")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.Description),
                    Value          = record?.Description,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Description")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.DateIssued),
                    Value          = record?.DateIssued,
                    ColumnDataType = "DateTime",
                    Format         = "dd/MM/yyyy",
                    ExcelFormat    = @"dd/MM/yyyy",
                    Caption        = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_DateIssued")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.Amount),
                    Value          = record?.Amount,
                    ColumnDataType = "decimal",
                    Format         = "#,0.00;'-'#,0.00;'0'",
                    ExcelFormat    = @"#,##0.00;-#,##0.00;#,##0.00",
                    Caption        = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Amount")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = "Transaction.Supplier.Company",
                    Value          = record?.Transaction?.Supplier?.Company,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("AdminDeliveryNoteList", "RES_LIST_DeliveryNoteListNoDT_COLUMN_Transaction.Supplier.Company")
                });
                exportDataDTO.Add(recordDTO);
            }
            if (aggregators.Count > 0)
            {
                foreach (AggregatorType aggregatorType in Enum.GetValues(typeof(AggregatorType)))
                {
                    var emptyAggregatorRow = true;
                    var recordDTO          = new ExportHelper.ExportRecordDTO();
                    foreach (var columnOption in exportOptions.ColumnOptions)
                    {
                        var aggregatorValue = "";
                        switch (aggregatorType)
                        {
                        case AggregatorType.COUNT:
                            if (columnOption.CountIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.COUNT);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandCount")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.SUM:
                            if (columnOption.SumIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.SUM);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandTotal")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.AVERAGE:
                            if (columnOption.AverageIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.AVERAGE);
                                aggregatorValue   += $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandAverage")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;
                        }
                        recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                        {
                            ColumnName     = columnOption.Column,
                            Value          = aggregatorValue,
                            ColumnDataType = "string",
                            Format         = ""
                        });
                    }
                    if (!emptyAggregatorRow)
                    {
                        exportDataDTO.Add(recordDTO);
                    }
                }
            }
            var path     = ExportHelper.ExportList(exportDataDTO, exportOptions, totalRows);
            var content  = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName = Path.GetFileName(path);

            return(FileHelper.PendingDownloadInstance.Add("AdminDeliveryNoteList", content, fileName));
        }
Example #23
0
        public string OrderProposalList_ExportV2Implementation(DatasourceRequest datasourceRequest, ExportOptionsV2 exportOptions, List <AggregatorInfo <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails> > aggregatorsInfo)
        {
            var  watch = System.Diagnostics.Stopwatch.StartNew();
            long elapsedMilliseconds = 0;

            switch (exportOptions.Range)
            {
            case ExportHelper.Range.ALL:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
                break;

            case ExportHelper.Range.TOP100:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
                break;
            }
            var queryable    = Get_OrderProposalList_DatasourceQueryable(datasourceRequest);
            var formattings  = new Dictionary <string, string>();
            var path         = "";
            var exportHelper = new ExportHelperV2 <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>(exportOptions, new Dictionary <string, Func <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails, object> >
            {
                { "Item.SKU", item => item?.Item?.SKU }, { "Item.Description", item => item?.Item?.Description }, { "Warehouse.Description", item => item?.Warehouse?.Description }, { "Quantity", item => item?.Quantity }, { "RecommendedOrderDate", item => item?.RecommendedOrderDate }, { "SalesForecastDate", item => item?.SalesForecastDate }, { "SupplierCanDeliver", item => item?.SupplierCanDeliver }, { "SupplierMaxQuantity", item => item?.SupplierMaxQuantity },
            });

            if (exportHelper.Options.ColumnInfo == null)
            {
                exportHelper.Options.ColumnInfo = new List <ColumnOptionsV2>
                {
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Item.SKU"), Formatting = "", Name = "Item.SKU", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Item.Description"), Formatting = "", Name = "Item.Description", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Warehouse.Description"), Formatting = "", Name = "Warehouse.Description", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_Quantity"), Formatting = "", Name = "Quantity", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_RecommendedOrderDate"), Formatting = "dd/MM/yyyy", Name = "RecommendedOrderDate", ExcelFormat = @"dd/MM/yyyy"
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_SalesForecastDate"), Formatting = "dd/MM/yyyy", Name = "SalesForecastDate", ExcelFormat = @"dd/MM/yyyy"
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_SupplierCanDeliver"), Formatting = "", Name = "SupplierCanDeliver", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("SupplierOrderForecast", "RES_LIST_OrderProposalList_COLUMN_SupplierMaxQuantity"), Formatting = "", Name = "SupplierMaxQuantity", ExcelFormat = @""
                    },
                };
            }
            if (string.IsNullOrWhiteSpace(exportHelper.Options.Filename))
            {
                exportHelper.Options.Filename = "OrderProposalList";
            }
            if (datasourceRequest.GroupBy.Any())
            {
                var groups      = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, aggregatorsInfo);
                var aggregators = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, aggregatorsInfo, true);
                GroupsHelper.FormatGroupedAggregators(aggregators, formattings);
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: OrderProposalList export query with grouping and range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(groups, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: OrderProposalList export to excel with grouping and range {exportOptions.Range} took {watch.ElapsedMilliseconds}ms");
            }
            else
            {
                var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                var loadedItems = items.ToList();
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: OrderProposalList export query with range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(loadedItems, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: OrderProposalList export to excel with range {exportOptions.Range} took {elapsedMilliseconds}ms");
            }
            var content     = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName    = Path.GetFileName(path);
            var downloadKey = FileHelper.PendingDownloadInstance.Add("SupplierOrderForecast", content, fileName);

            _logger.Info($"ExportV2 Performance: Total export time for OrderProposalList: {elapsedMilliseconds}ms");
            return(downloadKey);
        }
        public string SupplierListNoDT_ExportV2Implementation(DatasourceRequest datasourceRequest, ExportOptionsV2 exportOptions, List <AggregatorInfo <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier> > aggregatorsInfo)
        {
            var  watch = System.Diagnostics.Stopwatch.StartNew();
            long elapsedMilliseconds = 0;

            switch (exportOptions.Range)
            {
            case ExportHelper.Range.ALL:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
                break;

            case ExportHelper.Range.TOP100:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
                break;
            }
            var queryable    = Get_SupplierListNoDT_DatasourceQueryable(datasourceRequest);
            var formattings  = new Dictionary <string, string>();
            var path         = "";
            var exportHelper = new ExportHelperV2 <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>(exportOptions, new Dictionary <string, Func <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier, object> >
            {
                { "UserName", item => item?.UserName }, { "Company", item => item?.Company }, { "Business", item => item?.Business }, { "PercentageOfCreditNotes", item => item?.PercentageOfCreditNotes }, { "AcceptedPolicyTerms", item => item?.AcceptedPolicyTerms }, { "SupplierStatus", item => item?.SupplierStatus },
            });

            if (exportHelper.Options.ColumnInfo == null)
            {
                exportHelper.Options.ColumnInfo = new List <ColumnOptionsV2>
                {
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_UserName"), Formatting = "", Name = "UserName", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_Company"), Formatting = "", Name = "Company", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_Business"), Formatting = "", Name = "Business", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_PercentageOfCreditNotes"), Formatting = "", Name = "PercentageOfCreditNotes", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_AcceptedPolicyTerms"), Formatting = "", Name = "AcceptedPolicyTerms", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_SupplierStatus"), Formatting = "", Name = "SupplierStatus", ExcelFormat = @""
                    },
                };
            }
            if (string.IsNullOrWhiteSpace(exportHelper.Options.Filename))
            {
                exportHelper.Options.Filename = "SupplierListNoDT";
            }
            if (datasourceRequest.GroupBy.Any())
            {
                var groups      = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.UserName, aggregatorsInfo);
                var aggregators = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.UserName, aggregatorsInfo, true);
                GroupsHelper.FormatGroupedAggregators(aggregators, formattings);
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: SupplierListNoDT export query with grouping and range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(groups, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: SupplierListNoDT export to excel with grouping and range {exportOptions.Range} took {watch.ElapsedMilliseconds}ms");
            }
            else
            {
                var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                var loadedItems = items.ToList();
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: SupplierListNoDT export query with range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(loadedItems, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: SupplierListNoDT export to excel with range {exportOptions.Range} took {elapsedMilliseconds}ms");
            }
            var content     = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName    = Path.GetFileName(path);
            var downloadKey = FileHelper.PendingDownloadInstance.Add("PendingRegisteredSuppliersList", content, fileName);

            _logger.Info($"ExportV2 Performance: Total export time for SupplierListNoDT: {elapsedMilliseconds}ms");
            return(downloadKey);
        }
        public string List_ExportImplementation(DatasourceRequest datasourceRequest, ExportHelper.ExportOptions exportOptions, List <AggregatorInfo <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation> > aggregatorsInfo)
        {
            if (exportOptions.Range == ExportHelper.Range.TOP100)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
            }
            else if (exportOptions.Range == ExportHelper.Range.ALL)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
            }
            if (string.IsNullOrWhiteSpace(exportOptions.Filename))
            {
                exportOptions.Filename = "List";
            }
            if (exportOptions.ColumnOptions == null)
            {
                exportOptions.ColumnOptions = new List <ExportHelper.ColumnOptions>
                {
                    new ExportHelper.ColumnOptions {
                        Column = "ParentControllerName", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Name", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "IsAvailableToAllAuthorizedUsers", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "IsAvailableToAnonymous", IsVisible = true
                    },
                };
            }
            var queryable   = Get_List_DatasourceQueryable(datasourceRequest);
            var totalRows   = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count();
            var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
            var dto         = items.Select(i => new List1DataSet_ApplicationOperationDTO(i));
            var formattings = new Dictionary <string, string>();
            var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);

            foreach (var a in aggregators)
            {
                var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                a.Calculate(queryable, formatting);
            }
            var exportDataDTO = new List <ExportHelper.ExportRecordDTO>();

            foreach (var record in dto)
            {
                var recordDTO = new ExportHelper.ExportRecordDTO();
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.ParentControllerName),
                    Value          = record?.ParentControllerName,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_ParentControllerName")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.Name),
                    Value          = record?.Name,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_Name")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.IsAvailableToAllAuthorizedUsers),
                    Value          = record?.IsAvailableToAllAuthorizedUsers,
                    ColumnDataType = "bool",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_IsAvailableToAllAuthorizedUsers")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.IsAvailableToAnonymous),
                    Value          = record?.IsAvailableToAnonymous,
                    ColumnDataType = "bool",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_IsAvailableToAnonymous")
                });
                exportDataDTO.Add(recordDTO);
            }
            if (aggregators.Count > 0)
            {
                foreach (AggregatorType aggregatorType in Enum.GetValues(typeof(AggregatorType)))
                {
                    var emptyAggregatorRow = true;
                    var recordDTO          = new ExportHelper.ExportRecordDTO();
                    foreach (var columnOption in exportOptions.ColumnOptions)
                    {
                        var aggregatorValue = "";
                        switch (aggregatorType)
                        {
                        case AggregatorType.COUNT:
                            if (columnOption.CountIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.COUNT);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandCount")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.SUM:
                            if (columnOption.SumIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.SUM);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandTotal")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.AVERAGE:
                            if (columnOption.AverageIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.AVERAGE);
                                aggregatorValue   += $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandAverage")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;
                        }
                        recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                        {
                            ColumnName     = columnOption.Column,
                            Value          = aggregatorValue,
                            ColumnDataType = "string",
                            Format         = ""
                        });
                    }
                    if (!emptyAggregatorRow)
                    {
                        exportDataDTO.Add(recordDTO);
                    }
                }
            }
            var path     = ExportHelper.ExportList(exportDataDTO, exportOptions, totalRows);
            var content  = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName = Path.GetFileName(path);

            return(FileHelper.PendingDownloadInstance.Add("OperationsList", content, fileName));
        }
        public string List_ExportV2Implementation(DatasourceRequest datasourceRequest, ExportOptionsV2 exportOptions, List <AggregatorInfo <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation> > aggregatorsInfo)
        {
            var  watch = System.Diagnostics.Stopwatch.StartNew();
            long elapsedMilliseconds = 0;

            switch (exportOptions.Range)
            {
            case ExportHelper.Range.ALL:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
                break;

            case ExportHelper.Range.TOP100:
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
                break;
            }
            var queryable    = Get_List_DatasourceQueryable(datasourceRequest);
            var formattings  = new Dictionary <string, string>();
            var path         = "";
            var exportHelper = new ExportHelperV2 <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation>(exportOptions, new Dictionary <string, Func <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation, object> >
            {
                { "ParentControllerName", item => item?.ParentControllerName }, { "Name", item => item?.Name }, { "IsAvailableToAllAuthorizedUsers", item => item?.IsAvailableToAllAuthorizedUsers }, { "IsAvailableToAnonymous", item => item?.IsAvailableToAnonymous },
            });

            if (exportHelper.Options.ColumnInfo == null)
            {
                exportHelper.Options.ColumnInfo = new List <ColumnOptionsV2>
                {
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_ParentControllerName"), Formatting = "", Name = "ParentControllerName", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_Name"), Formatting = "", Name = "Name", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_IsAvailableToAllAuthorizedUsers"), Formatting = "", Name = "IsAvailableToAllAuthorizedUsers", ExcelFormat = @""
                    },
                    new ColumnOptionsV2 {
                        Caption = BaseViewPage <object> .GetResourceValue("OperationsList", "RES_LIST_List_COLUMN_IsAvailableToAnonymous"), Formatting = "", Name = "IsAvailableToAnonymous", ExcelFormat = @""
                    },
                };
            }
            if (string.IsNullOrWhiteSpace(exportHelper.Options.Filename))
            {
                exportHelper.Options.Filename = "List";
            }
            if (datasourceRequest.GroupBy.Any())
            {
                var groups      = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, aggregatorsInfo);
                var aggregators = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, aggregatorsInfo, true);
                GroupsHelper.FormatGroupedAggregators(aggregators, formattings);
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: List export query with grouping and range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(groups, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: List export to excel with grouping and range {exportOptions.Range} took {watch.ElapsedMilliseconds}ms");
            }
            else
            {
                var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                var loadedItems = items.ToList();
                watch.Stop();
                elapsedMilliseconds = watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: List export query with range {exportOptions.Range} took {elapsedMilliseconds}ms");
                watch.Restart();
                path = exportHelper.Export(loadedItems, aggregators);
                watch.Stop();
                elapsedMilliseconds += watch.ElapsedMilliseconds;
                _logger.Info($"ExportV2 Performance: List export to excel with range {exportOptions.Range} took {elapsedMilliseconds}ms");
            }
            var content     = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName    = Path.GetFileName(path);
            var downloadKey = FileHelper.PendingDownloadInstance.Add("OperationsList", content, fileName);

            _logger.Info($"ExportV2 Performance: Total export time for List: {elapsedMilliseconds}ms");
            return(downloadKey);
        }
        public string SupplierListNoDT_ExportImplementation(DatasourceRequest datasourceRequest, ExportHelper.ExportOptions exportOptions, List <AggregatorInfo <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier> > aggregatorsInfo)
        {
            if (exportOptions.Range == ExportHelper.Range.TOP100)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = 100;
            }
            else if (exportOptions.Range == ExportHelper.Range.ALL)
            {
                datasourceRequest.StartRow = 0;
                datasourceRequest.PageSize = int.MaxValue;
            }
            if (string.IsNullOrWhiteSpace(exportOptions.Filename))
            {
                exportOptions.Filename = "SupplierListNoDT";
            }
            if (exportOptions.ColumnOptions == null)
            {
                exportOptions.ColumnOptions = new List <ExportHelper.ColumnOptions>
                {
                    new ExportHelper.ColumnOptions {
                        Column = "UserName", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Company", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "Business", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "PercentageOfCreditNotes", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "AcceptedPolicyTerms", IsVisible = true
                    },
                    new ExportHelper.ColumnOptions {
                        Column = "SupplierStatus", IsVisible = true
                    },
                };
            }
            var queryable   = Get_SupplierListNoDT_DatasourceQueryable(datasourceRequest);
            var totalRows   = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count();
            var items       = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
            var dto         = items.Select(i => new SupplierDataSet_SupplierDTO(i));
            var formattings = new Dictionary <string, string>();
            var aggregators = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);

            foreach (var a in aggregators)
            {
                var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                a.Calculate(queryable, formatting);
            }
            var exportDataDTO = new List <ExportHelper.ExportRecordDTO>();

            foreach (var record in dto)
            {
                var recordDTO = new ExportHelper.ExportRecordDTO();
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.UserName),
                    Value          = record?.UserName,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_UserName")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.Company),
                    Value          = record?.Company,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_Company")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.Business),
                    Value          = record?.Business,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_Business")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.PercentageOfCreditNotes),
                    Value          = record?.PercentageOfCreditNotes,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_PercentageOfCreditNotes")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.AcceptedPolicyTerms),
                    Value          = record?.AcceptedPolicyTerms,
                    ColumnDataType = "bool",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_AcceptedPolicyTerms")
                });
                recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                {
                    ColumnName     = nameof(record.SupplierStatus),
                    Value          = record?.SupplierStatus,
                    ColumnDataType = "string",
                    Format         = "",
                    ExcelFormat    = @"",
                    Caption        = BaseViewPage <object> .GetResourceValue("PendingRegisteredSuppliersList", "RES_LIST_SupplierListNoDT_COLUMN_SupplierStatus")
                });
                exportDataDTO.Add(recordDTO);
            }
            if (aggregators.Count > 0)
            {
                foreach (AggregatorType aggregatorType in Enum.GetValues(typeof(AggregatorType)))
                {
                    var emptyAggregatorRow = true;
                    var recordDTO          = new ExportHelper.ExportRecordDTO();
                    foreach (var columnOption in exportOptions.ColumnOptions)
                    {
                        var aggregatorValue = "";
                        switch (aggregatorType)
                        {
                        case AggregatorType.COUNT:
                            if (columnOption.CountIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.COUNT);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandCount")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.SUM:
                            if (columnOption.SumIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.SUM);
                                aggregatorValue    = $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandTotal")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;

                        case AggregatorType.AVERAGE:
                            if (columnOption.AverageIsVisible)
                            {
                                var averageAggregator = aggregators.SingleOrDefault(agg => agg.Column == columnOption.Column && agg.Type == AggregatorType.AVERAGE);
                                aggregatorValue   += $"{BaseViewPage<object>.GetResourceValue("GlobalResources", "RES_DATALIST_AGGREGATORS_GrandAverage")} {averageAggregator?.ValueFormatted}";
                                emptyAggregatorRow = false;
                            }
                            break;
                        }
                        recordDTO.Columns.Add(new ExportHelper.ExportColumnDTO
                        {
                            ColumnName     = columnOption.Column,
                            Value          = aggregatorValue,
                            ColumnDataType = "string",
                            Format         = ""
                        });
                    }
                    if (!emptyAggregatorRow)
                    {
                        exportDataDTO.Add(recordDTO);
                    }
                }
            }
            var path     = ExportHelper.ExportList(exportDataDTO, exportOptions, totalRows);
            var content  = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), path));
            var fileName = Path.GetFileName(path);

            return(FileHelper.PendingDownloadInstance.Add("PendingRegisteredSuppliersList", content, fileName));
        }