コード例 #1
0
 public async Task UpdataCampainTaskTypeAsync(CampainTaskType type)
 {
     if (campainFilter != type)
     {
         campainFilter = type;
         await campainTaskCollection.FilterAsync(FilterByCampainTaskType);
     }
 }
コード例 #2
0
        public async Task <List <ProductItem> > GetProductItemListAsync(CategoryType filter)
#endif
        {
            categoryFilter = filter;
#if !XF
#if WINDOWS_UWP
            productCollection.Filter = null;
#endif
            productCollection.Filter = new Predicate <object>(FilterByCategoryType);
#else
            await productCollection.FilterAsync(FilterByCategoryType);
#endif
            List <ProductItem> list = new List <ProductItem>();
            foreach (Product product in productCollection)
            {
                ProductItem item = new ProductItem(product);
                list.Add(item);
            }
            return(list);
        }
コード例 #3
0
        public async Task UpdataDataByDateRangeAsync()
#endif
        {
#if !XF
            saleCollection.Filter = new Predicate <object>(FilterByDateRange);
            saleCollection.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending));
            budgetCollection.Filter         = new Predicate <object>(FilterByDateRange);
            opportunityCollection.Filter    = new Predicate <object>(FilterByDateRange);
            regionWiseSaleCollection.Filter = new Predicate <object>(FilterByDateRange);
            regionSaleGoalCollection.Filter = new Predicate <object>(FilterByDateRange);
#else
            await saleCollection.FilterAsync(FilterByDateRange);

            await saleCollection.SortAsync("Date");

            await budgetCollection.FilterAsync(FilterByDateRange);

            await opportunityCollection.FilterAsync(FilterByDateRange);

            await regionWiseSaleCollection.FilterAsync(FilterByDateRange);

            await regionSaleGoalCollection.FilterAsync(FilterByDateRange);
#endif
            opportunityList = new List <Opportunity>();
            foreach (OpportunityLevel value in Enum.GetValues(typeof(OpportunityLevel)))
            {
                opportunityList.Add(new Opportunity {
                    Level = value, Sales = 0
                });
            }


            var campainTaskItems      = new List <CampainTaskItem>();
            var productSaleMap        = new Dictionary <int, SaleItem>();
            var customerSaleMap       = new Dictionary <int, SaleItem>();
            var productsWiseSaleItems = new List <ProductsWiseSaleItem>();

            foreach (Sale sale in saleCollection)
            {
                var profit = DataService.GetService().FindProfitFormCurrentSale(sale);
                if (sale.Campaign.Name != "None")
                {
                    campainTaskItems.Add(new CampainTaskItem(sale));
                }
                if (customerSaleMap.ContainsKey(sale.CustomerId))
                {
                    customerSaleMap[sale.CustomerId].Sales  += sale.Summ;
                    customerSaleMap[sale.CustomerId].Profit += profit;
                }
                else
                {
                    customerSaleMap.Add(sale.CustomerId, new SaleItem {
                        Id = sale.CustomerId, Sales = sale.Summ, Profit = profit, Name = sale.Customer.ToString(), Date = sale.Date
                    });
                }
                if (productSaleMap.ContainsKey(sale.ProductId))
                {
                    productSaleMap[sale.ProductId].Sales  += sale.Summ;
                    productSaleMap[sale.ProductId].Profit += profit;
                }
                else
                {
                    productSaleMap.Add(sale.ProductId, new SaleItem {
                        Id = sale.ProductId, Sales = sale.Summ, Profit = profit, Name = sale.Product.ToString(), Date = sale.Date
                    });
                }

                ProductsWiseSaleItem productsWiseSale = new ProductsWiseSaleItem();
                productsWiseSale.Date     = sale.Date;
                productsWiseSale.Quantity = sale.Quantity;
                productsWiseSale.Sale     = sale.Summ;
                productsWiseSale.ID       = sale.ProductId;
                productsWiseSale.Category = sale.Product.Category.ToString();
                productsWiseSale.Product  = sale.Product.Name;
                productsWiseSale.Region   = sale.Customer.Region.ToString();
                productsWiseSaleItems.Add(productsWiseSale);
            }

#if XF
            productWiseSaleCollection = new C1DataCollection <ProductsWiseSaleItem>(productsWiseSaleItems);
            var budgetSaleProfitMap = new Dictionary <int, CurrentPriorBudgetItem>();
#endif

            var regionSaleMap   = new Dictionary <int, SaleGoalItem>();
            var categorySaleMap = new Dictionary <int, SaleGoalItem>();

            foreach (BudgetItem budget in budgetCollection)
            {
                if (categorySaleMap.ContainsKey(budget.CategoryId))
                {
                    categorySaleMap[budget.CategoryId].Sales  += budget.Sales;
                    categorySaleMap[budget.CategoryId].Profit += budget.Profit;
                    categorySaleMap[budget.CategoryId].Goal   += budget.Goal;
                }
                else
                {
                    SaleGoalItem item = new SaleGoalItem();
                    item.Name   = budget.Category.ToString();
                    item.Goal   = budget.Goal;
                    item.Sales  = budget.Sales;
                    item.Profit = budget.Profit;
                    categorySaleMap.Add(budget.CategoryId, item);
                }

                if (budget.Expences > 0)
                {
                    int month = budget.Date.Month;
                    int year  = budget.Date.Year;
                    if (budgetSaleProfitMap.ContainsKey(month))
                    {
                        if (year == 2017)
                        {
                            budgetSaleProfitMap[month].Sales  += budget.Sales;
                            budgetSaleProfitMap[month].Profit += budget.Profit;
                        }
                        else
                        {
                            budgetSaleProfitMap[month].ProirSales  += budget.Sales;
                            budgetSaleProfitMap[month].ProirProfit += budget.Profit;
                        }
                    }
                    else
                    {
                        if (year == 2017)
                        {
                            budgetSaleProfitMap.Add(month, new CurrentPriorBudgetItem {
                                Date = budget.Date, Sales = budget.Sales, Profit = budget.Profit
                            });
                        }
                        else
                        {
                            budgetSaleProfitMap.Add(month, new CurrentPriorBudgetItem {
                                Date = budget.Date, ProirSales = budget.Sales, ProirProfit = budget.Profit
                            });
                        }
                    }
                }
            }

            budgetItemList = budgetSaleProfitMap.Values.ToList();

            foreach (RegionSalesGoal region in regionSaleGoalCollection)
            {
                if (regionSaleMap.ContainsKey(region.RegionId))
                {
                    regionSaleMap[region.RegionId].Sales  += region.Sales;
                    regionSaleMap[region.RegionId].Profit += region.Profit;
                    regionSaleMap[region.RegionId].Goal   += region.Goal;
                }
                else
                {
                    SaleGoalItem item = new SaleGoalItem();
                    item.Name   = region.Region.ToString();
                    item.Goal   = region.Goal;
                    item.Sales  = region.Sales;
                    item.Profit = region.Profit;
                    regionSaleMap.Add(region.RegionId, item);
                }
            }
#if !XF
            campainTaskCollection        = new ListCollectionView(campainTaskItems);
            campainTaskCollection.Filter = new Predicate <object>(FilterByCampainTaskType);
            productSaleCollection        = new ListCollectionView(productSaleMap.Values.ToList());
            productSaleCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending));
            customerSaleCollection = new ListCollectionView(customerSaleMap.Values.ToList());
            customerSaleCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending));
#else
            campainTaskCollection = new C1DataCollection <CampainTaskItem>(campainTaskItems);
            await campainTaskCollection.FilterAsync(FilterByCampainTaskType);

            productSaleCollection = new C1DataCollection <SaleItem>(productSaleMap.Values.ToList());
            await productSaleCollection.SortAsync("Sales", SortDirection.Descending);

            customerSaleCollection = new C1DataCollection <SaleItem>(customerSaleMap.Values.ToList());
            await customerSaleCollection.SortAsync("Sales", SortDirection.Descending);
#endif
            regionSalesVsGoal   = regionSaleMap.Values.ToList();
            categorySalesVsGoal = categorySaleMap.Values.ToList();

            foreach (OpportunityItem opportunity in opportunityCollection)
            {
                OpportunityItemList[opportunity.LevelId].Sales += opportunity.Sales;
            }
        }