public JsonResult UserPreferences_LanguageBoxDataSet_Datasource()
        {
            var postedData        = _LoadViewModel();
            var datasourceRequest = DeserializeDatasourceRequest(postedData["datasourceRequest"].ToString());
            var queryable         = Get_UserPreferences_LanguageBoxDataSet_DatasourceQueryable(datasourceRequest);
            var response          = new ListResponse
            {
                TotalRows = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count(),
            };

            //Total items count
            if (CLMS.AppDev.Cache.CacheManager.Current.HasKey($"{Request.RequestContext.HttpContext.Session.SessionID}_UserPreferences_LanguageBoxDataSet_TotalItems"))
            {
                CLMS.AppDev.Cache.CacheManager.Current.Set($"{Request.RequestContext.HttpContext.Session.SessionID}_UserPreferences_LanguageBoxDataSet_TotalItems", response.TotalRows);
            }
            else
            {
                CLMS.AppDev.Cache.CacheManager.Current.Add($"{Request.RequestContext.HttpContext.Session.SessionID}_UserPreferences_LanguageBoxDataSet_TotalItems", response.TotalRows);
            }
            if (response.TotalRows < datasourceRequest.StartRow + 1)
            {
                datasourceRequest.StartRow = 0;
            }
            var _dto = DynamicDtoInfo.CreateFromPropsArray(datasourceRequest.DtoProperties);
            var _convertionMethod = _dto.GetConvertionFunc <zAppDev.DotNet.Framework.Identity.Model.ApplicationLanguage>();

            if (datasourceRequest.GroupBy.Any())
            {
                var groups = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, postedData);
                var items  = groups.GetAllItems();
                response.Data   = items.ToList().Select(i => _convertionMethod(i)).ToList();
                response.Groups = groups;
//Fix for total items in GetGroupsClosed
                if (datasourceRequest.GroupBy.FirstOrDefault().GetGroupsClosed)
                {
                    response.TotalRows = DatasourceRetriever.GetTotalGroups(groups);
                }
            }
            else
            {
                var items = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                response.Data = items.ToList().Select(i => _convertionMethod(i)).ToList();
            }
            var __result = Json(new
            {
                Type = "DatasourceData", Data = Serialize(response)
            }, JsonRequestBehavior.AllowGet);

            __result.MaxJsonLength = int.MaxValue;
            return(__result);
        }
Ejemplo n.º 2
0
        public JsonResult AdminInvoiceListNoDT_Datasource()
        {
            var postedData        = _LoadViewModel();
            var datasourceRequest = DeserializeDatasourceRequest(postedData["datasourceRequest"].ToString());
            var queryable         = Get_AdminInvoiceListNoDT_DatasourceQueryable(datasourceRequest);
            var response          = new ListResponse
            {
                TotalRows = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count(),
            };

            //Total items count
            if (CLMS.AppDev.Cache.CacheManager.Current.HasKey($"{Request.RequestContext.HttpContext.Session.SessionID}_AdminInvoiceListNoDT_TotalItems"))
            {
                CLMS.AppDev.Cache.CacheManager.Current.Set($"{Request.RequestContext.HttpContext.Session.SessionID}_AdminInvoiceListNoDT_TotalItems", response.TotalRows);
            }
            else
            {
                CLMS.AppDev.Cache.CacheManager.Current.Add($"{Request.RequestContext.HttpContext.Session.SessionID}_AdminInvoiceListNoDT_TotalItems", response.TotalRows);
            }
            if (response.TotalRows < datasourceRequest.StartRow + 1)
            {
                datasourceRequest.StartRow = 0;
            }
            if (datasourceRequest.GroupBy.Any())
            {
                var groups = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, postedData);
                var items  = groups.GetAllItems();
                response.Data   = items.Select(i => new InvoiceDataSet_InvoiceDTO(i, true)).ToList();
                response.Groups = groups;
                Evaluate_AdminInvoiceListNoDT_ConditionalFormattings(items.ToList(), response);
//Fix for total items in GetGroupsClosed
                if (datasourceRequest.GroupBy.FirstOrDefault().GetGroupsClosed)
                {
                    response.TotalRows = DatasourceRetriever.GetTotalGroups(groups);
                }
            }
            else
            {
                var items = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                response.Data = items.Select(i => new InvoiceDataSet_InvoiceDTO(i, true)).ToList();
                Evaluate_AdminInvoiceListNoDT_ConditionalFormattings(items.ToList(), response);
            }
            var __result = Json(new
            {
                Type = "DatasourceData", Data = Serialize(response)
            }, JsonRequestBehavior.AllowGet);

            __result.MaxJsonLength = int.MaxValue;
            return(__result);
        }
        public JsonResult TransactionListNoDT_DatasourceAggregators()
        {
            object aggregatorsResponse = null;
            var    postedData          = _LoadViewModel();
            var    datasourceRequest   = DeserializeDatasourceRequest(postedData["datasourceRequest"].ToString());
            var    queryable           = Get_TransactionListNoDT_DatasourceQueryable(datasourceRequest);

            queryable = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable);
            var formattings = new Dictionary <string, string>();

            formattings.Add("TransactionDateOccured", "dd/MM/yyyy");
            formattings.Add("TransactionValue", "#,0.00;'-'#,0.00;'0'");
            formattings.Add("FundedAmount", "#,0.00;'-'#,0.00;'0'");
            formattings.Add("ToBePaidAmount", "#,0.00;'-'#,0.00;'0'");
            formattings.Add("PaymentDate", "dd/MM/yyyy");
            formattings.Add("RestPaymentAmount", "#,0.00;'-'#,0.00;'0'");
            if (datasourceRequest.GroupBy.Any() /* && datasourceRequest.GroupBy.First().GetGroupsClosed*/)
            {
                var groups = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, postedData, true);
                GroupsHelper.FormatGroupedAggregators(groups, formattings);
                aggregatorsResponse = new ListResponse()
                {
                    Groups = groups
                };
            }
            else
            {
                var aggregatorsInfo = DeserializeAggregatorsRequest <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>(postedData["aggregatorsRequest"].ToString());
                var aggregators     = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                aggregatorsResponse = aggregators;
            }
            var __result = Json(new
            {
                Type = "DatasourceData", Data = Serialize(aggregatorsResponse)
            }, JsonRequestBehavior.AllowGet);

            __result.MaxJsonLength = int.MaxValue;
            return(__result);
        }
Ejemplo n.º 4
0
        public JsonResult List_DatasourceAggregators()
        {
            object aggregatorsResponse = null;
            var    postedData          = _LoadViewModel();
            var    datasourceRequest   = DeserializeDatasourceRequest(postedData["datasourceRequest"].ToString());
            var    queryable           = Get_List_DatasourceQueryable(datasourceRequest);

            queryable = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable);
            var formattings = new Dictionary <string, string>();

            formattings.Add("OrderForecast_CreatedOn", "dd/MM/yyyy");
            formattings.Add("OrderForecast_StartDate", "dd/MM/yyyy");
            formattings.Add("OrderForecast_EndDate", "dd/MM/yyyy");
            formattings.Add("RecommendedOrderDate", "dd/MM/yyyy");
            formattings.Add("SalesForecastDate", "dd/MM/yyyy");
            if (datasourceRequest.GroupBy.Any() /* && datasourceRequest.GroupBy.First().GetGroupsClosed*/)
            {
                var groups = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, postedData, true);
                GroupsHelper.FormatGroupedAggregators(groups, formattings);
                aggregatorsResponse = new ListResponse()
                {
                    Groups = groups
                };
            }
            else
            {
                var aggregatorsInfo = DeserializeAggregatorsRequest <DSS1_RetailerDriverStockOptimisation.BO.OrderForecastDetails>(postedData["aggregatorsRequest"].ToString());
                var aggregators     = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                aggregatorsResponse = aggregators;
            }
            var __result = Json(new
            {
                Type = "DatasourceData", Data = Serialize(aggregatorsResponse)
            }, JsonRequestBehavior.AllowGet);

            __result.MaxJsonLength = int.MaxValue;
            return(__result);
        }
Ejemplo n.º 5
0
        public JsonResult List_DatasourceAggregators()
        {
            object aggregatorsResponse = null;
            var    postedData          = _LoadViewModel();
            var    datasourceRequest   = DeserializeDatasourceRequest(postedData["datasourceRequest"].ToString());
            var    queryable           = Get_List_DatasourceQueryable(datasourceRequest);

            queryable = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable);
            var formattings = new Dictionary <string, string>();

            if (datasourceRequest.GroupBy.Any() /* && datasourceRequest.GroupBy.First().GetGroupsClosed*/)
            {
                var groups = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, postedData, true);
                GroupsHelper.FormatGroupedAggregators(groups, formattings);
                aggregatorsResponse = new ListResponse()
                {
                    Groups = groups
                };
            }
            else
            {
                var aggregatorsInfo = DeserializeAggregatorsRequest <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation>(postedData["aggregatorsRequest"].ToString());
                var aggregators     = RuntimePredicateBuilder.BuildAggregatorPredicates(aggregatorsInfo);
                foreach (var a in aggregators)
                {
                    var formatting = formattings.ContainsKey(a.Column) ? formattings[a.Column] : null;
                    a.Calculate(queryable, formatting);
                }
                aggregatorsResponse = aggregators;
            }
            var __result = Json(new
            {
                Type = "DatasourceData", Data = Serialize(aggregatorsResponse)
            }, JsonRequestBehavior.AllowGet);

            __result.MaxJsonLength = int.MaxValue;
            return(__result);
        }
Ejemplo n.º 6
0
        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 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 JsonResult Chart11_Datasource()
        {
            var postedData        = _LoadViewModel();
            var datasourceRequest = DeserializeDatasourceRequest(postedData["datasourceRequest"].ToString());
            var queryable         = Get_Chart11_DatasourceQueryable(datasourceRequest);
            var response          = new ListResponse
            {
                TotalRows = DatasourceRetriever.ApplyDynamicFilterToQueryable(datasourceRequest, queryable).Count(),
            };

            //Total items count
            if (CLMS.AppDev.Cache.CacheManager.Current.HasKey($"{Request.RequestContext.HttpContext.Session.SessionID}_Chart11_TotalItems"))
            {
                CLMS.AppDev.Cache.CacheManager.Current.Set($"{Request.RequestContext.HttpContext.Session.SessionID}_Chart11_TotalItems", response.TotalRows);
            }
            else
            {
                CLMS.AppDev.Cache.CacheManager.Current.Add($"{Request.RequestContext.HttpContext.Session.SessionID}_Chart11_TotalItems", response.TotalRows);
            }
            if (response.TotalRows < datasourceRequest.StartRow + 1)
            {
                datasourceRequest.StartRow = 0;
            }
            if (datasourceRequest.GroupBy.Any())
            {
                var groups = DatasourceRetriever.RetrieveGrouped(datasourceRequest, queryable, q => q.Id, postedData);
                IDictionary <string, string> groupLabels = new Dictionary <string, string>()
                {
                    { "isavailabletoallauthorizedusers", "Actions" }, { "id", "Actions" }
                };
                var data = new List <ChartHelper.ChartResult>();
                foreach (var group in groups.SubGroups)
                {
                    var result = new ChartHelper.ChartResult();
                    result.Label = group.KeyFormatted;
                    foreach (var aggr in group.Aggregates)
                    {
                        if (aggr.Column == "__Count")
                        {
                            continue;
                        }
                        result.Values.Add(aggr.Value);
                        if (groupLabels.ContainsKey(aggr.Column.ToLower()))
                        {
                            result.ValueLabels.Add(groupLabels[aggr.Column.ToLower()]);
                        }
                        else
                        {
                            result.ValueLabels.Add(aggr.Column);
                        }
                    }
                    data.Add(result);
                }
                response.Data = data;
//Fix for total items in GetGroupsClosed
                if (datasourceRequest.GroupBy.FirstOrDefault().GetGroupsClosed)
                {
                    response.TotalRows = DatasourceRetriever.GetTotalGroups(groups);
                }
            }
            else
            {
                var items     = DatasourceRetriever.Retrieve(datasourceRequest, queryable);;
                var _dtos     = items.Select(i => new ApplicationOperationDataSet_ApplicationOperationDTO(i, true)).ToList();
                var chartData = new List <ChartHelper.ChartResult>();
                foreach (var _dto in _dtos)
                {
                    chartData.Add(new ChartHelper.ChartResult(_dto, _dto?.IsAvailableToAllAuthorizedUsers, new List <object> {
                        _dto?.Id
                    }, new List <object> {
                        "Actions"
                    }, new List <object> {
                    }));
                }
                response.Data = chartData;
            }
            var __result = Json(new
            {
                Type = "DatasourceData", Data = Serialize(response)
            }, JsonRequestBehavior.AllowGet);

            __result.MaxJsonLength = int.MaxValue;
            return(__result);
        }
        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);
        }
Ejemplo n.º 10
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);
        }