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_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 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);
        }
Esempio n. 4
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);
        }