private async Task InitializeStore() { var Current = ""; if (ChangeStore) { ResetValues(); UserSettings.Remove("current_url"); UserSettings.Add("current_url", StoreUrl); UserSettings.Remove("current_user"); UserSettings.Add("current_user", UserName); } UserSettings.TryGetValue("current_user", out Current); SideMenu.Header = await api.GetStoreName(); SideMenu.Header = SideMenu.Header.ToString().ToLower(); AdminName.Text = await api.GetFullName(Current); if (!ChangeStore) { foreach (KeyValuePair <string, object> url in UserSettings) { if (url.Key.StartsWith("store_url_")) { var Name = url.Key.Substring(10); UrlsMap.Add(new KeyValuePair <String, String>(Name, (string)url.Value)); urls.Add(Name); } } MyStoresList.ItemsSource = urls; } var Currency = await api.GetCurrency(); var SaleValuesIn = settings.GetValueOrDefault <int>(SaleValuesDash, 0); var PendingV = await api.GetStats(3); var CompleteV = await api.GetStats(2); var CancelledV = await api.GetStats(1); if (SaleValuesIn == 0) { PendingSales.Text = PendingV + " " + Currency;; CompleteSales.Text = CompleteV + " " + Currency;; CancelledSales.Text = CancelledV + " " + Currency;; } else { PendingSales.Text = PendingV.ToString("0.0#") + " " + Currency;; CompleteSales.Text = CompleteV.ToString("0.0#") + " " + Currency;; CancelledSales.Text = CancelledV.ToString("0.0#") + " " + Currency;; } var PendingOrdersCount = await api.GetPendingOrdersCount(); var CartsCount = await api.GetCartsCount(); var WishlistCount = await api.GetWishlistCount(); PendingOrders.Text = PendingOrdersCount.ToString(); Carts.Text = CartsCount.ToString(); Wishlists.Text = WishlistCount.ToString(); var VisitorsCount = await api.GetOnlineCount(); var RegisteredCount = await api.GetRegisteredCustomersCount(); var VendorsCount = await api.GetVendorsCount(); Visitors.Text = VisitorsCount.ToString(); Registered.Text = RegisteredCount.ToString(); Vendors.Text = VendorsCount.ToString(); var NPopWords = settings.GetValueOrDefault <int>(KeywordsInDash, 3); var PopularWords = await api.GetPopularKeywords(NPopWords); WordsHolder.Children.Clear(); foreach (KeywordDTO word in PopularWords) { var Sp = new StackPanel(); var WordBlock = new TextBlock(); WordBlock.Text = word.Keyword; WordBlock.FontSize = 20; Sp.Background = new SolidColorBrush(Colors.Gray); WordBlock.Margin = new System.Windows.Thickness { Left = 5, Right = 5 }; Sp.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; Sp.VerticalAlignment = System.Windows.VerticalAlignment.Center; Sp.Margin = new System.Windows.Thickness { Left = 5 }; Sp.Children.Add(WordBlock); WordsHolder.Children.Add(Sp); } var BestAmount = await api.GetBestsellerByAmount(); BestsellerAmount.Text = BestAmount.First().Product.Name; var BestQuantity = await api.GetBestsellerByQuantity(); BestsellerQuantity.Text = BestQuantity.First().Product.Name; var WeekCustomers = await api.GetCustomerCountByTime(7); var TwoWeeksCustomers = await api.GetCustomerCountByTime(14); var MonthCustomers = await api.GetCustomerCountByTime(30); var YearCustomers = await api.GetCustomerCountByTime(365); var registered = new int[4] { WeekCustomers, TwoWeeksCustomers, MonthCustomers, YearCustomers }; RegisteredUsersGraph Graph = new RegisteredUsersGraph(registered, true); RegisteredPlot.Model = Graph.MyModel; ChangeStore = false; }
private async Task UpdateValues(NopCore api) { ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); var PendingV = FindViewById <TextView>(Resource.Id.pending); var CompleteV = FindViewById <TextView>(Resource.Id.complete); var CancelledV = FindViewById <TextView>(Resource.Id.cancelled); var PendingCountV = FindViewById <TextView>(Resource.Id.pendingorders); var CartsCountV = FindViewById <TextView>(Resource.Id.carts); var WishlistCountV = FindViewById <TextView>(Resource.Id.wishlists); var RegisteredV = FindViewById <TextView>(Resource.Id.registered); var OnlineV = FindViewById <TextView>(Resource.Id.online); var VendorsV = FindViewById <TextView>(Resource.Id.vendors); var BestsellerQV = FindViewById <TextView>(Resource.Id.bestsellersquantity); var BestsellerAV = FindViewById <TextView>(Resource.Id.bestsellersamount); var KeywordsLoadingV = FindViewById <TextView>(Resource.Id.keywords); var KeywordsLayoutHolder = FindViewById <LinearLayout>(Resource.Id.wordlayout); var Complete = await api.GetStats(2); var Pending = await api.GetStats(3); var Cancelled = await api.GetStats(1); var Currency = await api.GetCurrency(); if (prefs.GetString("sales_format", "Integer").Equals("Integer")) { PendingV.Text = Pending.ToString("0") + " " + Currency; CompleteV.Text = Complete.ToString("0") + " " + Currency; CancelledV.Text = Cancelled.ToString("0") + " " + Currency; } else { PendingV.Text = Pending.ToString("0.0#") + " " + Currency; CompleteV.Text = Complete.ToString("0.0#") + " " + Currency; CancelledV.Text = Cancelled.ToString("0.0#") + " " + Currency; } var PendingCount = await api.GetPendingOrdersCount(); var CartsCount = await api.GetCartsCount(); var WishlistCount = await api.GetWishlistCount(); PendingCountV.Text = PendingCount.ToString(); CartsCountV.Text = CartsCount.ToString(); WishlistCountV.Text = WishlistCount.ToString(); var Registered = await api.GetRegisteredCustomersCount(); var Online = await api.GetOnlineCount(); var Vendors = await api.GetVendorsCount(); RegisteredV.Text = Registered.ToString(); OnlineV.Text = Online.ToString(); VendorsV.Text = Vendors.ToString(); var Keywords = await api.GetPopularKeywords(3); var BestsellerQ = await api.GetBestsellerByQuantity(); var BestsellerA = await api.GetBestsellerByAmount(); int wordSpace = DensityPixel(2); KeywordsLayoutHolder.RemoveAllViews(); for (int i = 0; i < prefs.GetInt("keywords_dashboard", 3); i++) { LinearLayout WordHolder = new LinearLayout(this); LinearLayout.LayoutParams WordLayout = (LinearLayout.LayoutParams)KeywordsLayoutHolder.LayoutParameters; WordHolder.Orientation = Orientation.Horizontal; var WHParams = WordLayout; WHParams.SetMargins(0, 0, wordSpace, 0); WordHolder.LayoutParameters = WHParams; TextView word = new TextView(this); word.Text = Keywords[i].Keyword; word.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.keyword_holder_bg)); word.SetTextColor(Resources.GetColor(Resource.Color.white)); word.SetPadding(wordSpace, wordSpace, wordSpace, wordSpace); word.SetSingleLine(); WordHolder.AddView(word); KeywordsLayoutHolder.AddView(WordHolder); } BestsellerAV.Text = BestsellerA[0].Product.Name; BestsellerQV.Text = BestsellerQ[0].Product.Name; var WeekCustomers = await api.GetCustomerCountByTime(7); var TwoWeeksCustomers = await api.GetCustomerCountByTime(14); var MonthCustomers = await api.GetCustomerCountByTime(30); var YearCustomers = await api.GetCustomerCountByTime(365); var registered = new int [4] { WeekCustomers, TwoWeeksCustomers, MonthCustomers, YearCustomers }; RegisteredUsersGraph Graph = new RegisteredUsersGraph(registered, false); var plotView = FindViewById <PlotView>(Resource.Id.plotView_Temp); plotView.Model = Graph.MyModel; dialog.Dismiss(); }