// load songs into the grid async void BindITunesGrid() { // load songs _songs = await MediaLibraryStorage.Load(); // build view var view = new C1.Xaml.C1CollectionView(_songs); view.GroupDescriptions.Add(new C1.Xaml.PropertyGroupDescription("Artist")); view.GroupDescriptions.Add(new C1.Xaml.PropertyGroupDescription("Album")); // configure grid var fg = _flexMedia; fg.CellFactory = new MusicCellFactory(); fg.MergeManager = null; // << review this, should not merge cells with content fg.Columns["Duration"].ValueConverter = new SongDurationConverter(); fg.Columns["Size"].ValueConverter = new SongSizeConverter(); fg.ItemsSource = view; // configure search box _srchMedia.View = view; foreach (string name in "Artist|Album|Name".Split('|')) { _srchMedia.FilterProperties.Add(typeof(Song).GetRuntimeProperty(name)); } // show media library summary UpdateSongStatus(); view.VectorChanged += (s, e) => { UpdateSongStatus(); }; // done loading songs, hide progress indicator _progressBar.Visibility = Visibility.Collapsed; }
private void OnLoaded(object sender, RoutedEventArgs e) { vectorLayer = new C1VectorLayer(); Map.Source = new VirtualEarthRoadSource(); Map.Layers.Add(vectorLayer); if (!MainPage.IsWindowsPhoneDevice()) { scaleLayer = new C1VectorLayer(); ScaleMap.Source = new VirtualEarthRoadSource(); ScaleMap.Layers.Add(scaleLayer); } collectionView = DataService.GetService().ProductWiseSaleCollection; ProductList.ItemsSource = DataService.GetService().ProductList; RegionList.ItemsSource = DataService.GetService().RegionList; ProductList.SelectAll(); RegionList.SelectAll(); }
public static void UpdataMapMark(C1VectorLayer vectorLayer, C1VectorLayer scaleLayer, bool isPhone) #endif { vectorLayer.Children.Clear(); #if WINDOWS_UWP if (!isPhone) { scaleLayer.Children.Clear(); } #endif var regionSalesCollection = new ListCollectionView(DataService.GetService().GetRegionWiseSales()); regionSalesCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending)); #if WPF double maxValue = (regionSalesCollection.GetItemAt(0) as RegionSaleItem).Sales; #elif WINDOWS_UWP double maxValue = (regionSalesCollection.ElementAt(0) as RegionSaleItem).Sales; #endif foreach (RegionSaleItem sales in regionSalesCollection) { C1VectorPlacemark mark = new C1VectorPlacemark(); mark.Label = string.Format("{0:C}", sales.Sales); mark.LabelPosition = LabelPosition.Center; mark.Geometry = CreateMarkBySale(sales.Sales, maxValue); mark.Fill = sales.Profit > 0 ? new SolidColorBrush(Colors.Orange) : new SolidColorBrush(Colors.RoyalBlue); mark.GeoPoint = sales.Locat; vectorLayer.Children.Add(mark); #if WINDOWS_UWP if (!isPhone) { C1VectorPlacemark clone = new C1VectorPlacemark(); clone.Label = mark.Label; clone.LabelPosition = mark.LabelPosition; clone.Geometry = mark.Geometry; clone.Fill = mark.Fill; clone.GeoPoint = sales.Locat; scaleLayer.Children.Add(clone); } #endif } }
public async void InitializeDataServiceAsync() #endif { #if WPF || WinForms || ASP || WINDOWS_UWP VerifyDatabase(); if (Error != null) { return; } dashboardContext.Budget.Load(); dashboardContext.Sales.Load(); dashboardContext.Products.Load(); dashboardContext.Regions.Load(); dashboardContext.RegionWiseSales.Load(); dashboardContext.Opportunities.Load(); dashboardContext.RegionSales.Load(); #if NETCORE var budgetList = dashboardContext.Budget.ToList(); var productList = dashboardContext.Products.ToList(); var saleList = dashboardContext.Sales .Include(s => s.Product).ThenInclude(p => p.Category) .Include(s => s.Customer).ThenInclude(c => c.Region) .Include(s => s.Campaign).ToList(); var opportunityList = dashboardContext.Opportunities.ToList(); var regionWiseSales = dashboardContext.RegionWiseSales.ToList(); var regionSales = dashboardContext.RegionSales.ToList(); #else var budgetList = dashboardContext.Budget.ToList(); var productList = dashboardContext.Products.ToList(); var saleList = dashboardContext.Sales.ToList(); var opportunityList = dashboardContext.Opportunities.ToList(); var regionWiseSales = dashboardContext.RegionWiseSales.ToList(); var regionSales = dashboardContext.RegionSales.ToList(); #endif budgetCollection = new ListCollectionView(budgetList); productCollection = new ListCollectionView(productList); saleCollection = new ListCollectionView(saleList); opportunityCollection = new ListCollectionView(opportunityList); regionWiseSaleCollection = new ListCollectionView(regionWiseSales); regionSaleGoalCollection = new ListCollectionView(regionSales); regionWiseSaleCollection.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending)); saleCollection.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending)); #elif XF Assembly assembly = Assembly.Load(new AssemblyName("DashboardXamarin")); var stream = assembly.GetManifestResourceStream("DashboardXamarin.InitialData.xml"); model = Model.GetPopulated(stream); budgetCollection = new C1CollectionView <BudgetItem>(model.Budget.ToList()); productCollection = new C1CollectionView <Product>(model.Products.ToList()); saleCollection = new C1CollectionView <Sale>(model.Sales.ToList()); opportunityCollection = new C1CollectionView <OpportunityItem>(model.Opportunities.ToList()); regionWiseSaleCollection = new C1CollectionView <RegionWiseSale>(model.RegionWiseSales.ToList()); regionSaleGoalCollection = new C1CollectionView <RegionSalesGoal>(model.RegionSales.ToList()); await regionWiseSaleCollection.SortAsync("Date"); await saleCollection.SortAsync("Date"); #endif var dateSaleMap = new Dictionary <DateTime, SaleItem>(); var productsWiseSaleItems = new List <ProductsWiseSaleItem>(); int i = 0; foreach (Sale sale in saleCollection) { ProductsWiseSaleItem productsWiseSale = new ProductsWiseSaleItem(); productsWiseSale.Date = sale.Date; productsWiseSale.Quantity = sale.Quantity; productsWiseSale.Sales = 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 (dateSaleMap.ContainsKey(sale.Date)) { dateSaleMap[sale.Date].Sales += sale.Summ; } else { dateSaleMap.Add(sale.Date, new SaleItem { Sales = sale.Summ, Date = sale.Date, Id = i++ }); } } dateSaleList = dateSaleMap.Values.ToList(); #if !XF productWiseSaleCollection = new ListCollectionView(productsWiseSaleItems); #else productWiseSaleCollection = new C1CollectionView <ProductsWiseSaleItem>(productsWiseSaleItems); #endif var budgetSaleProfitMap = new Dictionary <int, CurrentPriorBudgetItem>(); foreach (BudgetItem budget in budgetCollection) { 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(); #if XF await UpdataDataByDateRangeAsync(); #endif }
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>(); 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 }); } } 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); } } 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 C1CollectionView <CampainTaskItem>(campainTaskItems); await campainTaskCollection.FilterAsync(FilterByCampainTaskType); productSaleCollection = new C1CollectionView <SaleItem>(productSaleMap.Values.ToList()); await productSaleCollection.SortAsync("Sales", SortDirection.Descending); customerSaleCollection = new C1CollectionView <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; } }