Exemplo n.º 1
0
        private async Task UpdateValues()
        {
            mAdapter = new SeparatedListAdapter(this);
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);

            mAdapter.AddSectionHeaderItem("Popular Keywords");
            var Keywords = await api.GetPopularKeywords(prefs.GetInt("keywords_stats", 5));

            for (int i = 0; i < prefs.GetInt("keywords_stats", 5); i++)
            {
                mAdapter.AddItem(Keywords[i].Keyword);
            }

            mAdapter.AddSectionHeaderItem("Registered Users");

            var WeekCustomers = await api.GetCustomerCountByTime(7);

            var TwoWeeksCustomers = await api.GetCustomerCountByTime(14);

            var MonthCustomers = await api.GetCustomerCountByTime(30);

            var YearCustomers = await api.GetCustomerCountByTime(365);

            mAdapter.AddItem("Last 7 Days: " + WeekCustomers);
            mAdapter.AddItem("Last 14 Days: " + TwoWeeksCustomers);
            mAdapter.AddItem("Last Month: " + MonthCustomers);
            mAdapter.AddItem("Last Year: " + YearCustomers);

            mAdapter.AddSectionHeaderItem("Total Sales");
            var WeekSales = await api.GetTotalSalesByTime(7);

            var TwoWeeksSales = await api.GetTotalSalesByTime(14);

            var MonthSales = await api.GetTotalSalesByTime(30);

            var YearSales = await api.GetTotalSalesByTime(365);

            var Currency = await api.GetCurrency();

            mAdapter.AddItem("Last 7 Days: " + WeekSales.ToString("0.0#") + " " + Currency);
            mAdapter.AddItem("Last 14 Days: " + TwoWeeksSales.ToString("0.0#") + " " + Currency);
            mAdapter.AddItem("Last Month: " + MonthSales.ToString("0.0#") + " " + Currency);
            mAdapter.AddItem("Last Year: " + YearSales.ToString("0.0#") + " " + Currency);

            StatsList.Adapter = mAdapter;
            dialog.Dismiss();
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        private async Task InitializeStats()
        {
            var PopularKeywords = await api.GetPopularKeywords(20);

            var PopularByCount = new List <KeywordDTO>();

            PopularByCount.AddRange(PopularKeywords);
            var PopularByAlphabet = new List <KeywordDTO>();

            PopularByAlphabet.AddRange(PopularKeywords);
            PopularByAlphabet.Sort(delegate(KeywordDTO x, KeywordDTO y) { return(x.Keyword.CompareTo(y.Keyword)); });

            var MaxCount = PopularByCount.First().Count;
            var MinCount = PopularByCount.Last().Count;

            var Counter   = 0;
            var NPopWords = settings.GetValueOrDefault <int>(KeywordsInStats, 10);

            foreach (KeywordDTO K in PopularByAlphabet)
            {
                if (Counter == NPopWords)
                {
                    break;
                }
                var Word  = new TextBlock();
                var Delta = 1 + ((double)(MaxCount - MinCount) / 6);
                if (K.Count <= Delta)
                {
                    Word.Foreground = new SolidColorBrush(Color.FromArgb(255, 176, 229, 124));
                    Word.FontSize   = SIZE1;
                }
                else if (K.Count > Delta && K.Count < Delta * 2)
                {
                    Word.Foreground = new SolidColorBrush(Color.FromArgb(255, 180, 216, 231));
                    Word.FontSize   = SIZE2;
                }
                else if (K.Count > Delta * 2 && K.Count < Delta * 3)
                {
                    Word.Foreground = new SolidColorBrush(Color.FromArgb(255, 86, 186, 236));
                    Word.FontSize   = SIZE3;
                }
                else if (K.Count > Delta * 3 && K.Count < Delta * 4)
                {
                    Word.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 240, 170));
                    Word.FontSize   = SIZE4;
                }
                else if (K.Count > Delta * 4 && K.Count < Delta * 5)
                {
                    Word.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 174, 174));
                    Word.FontSize   = SIZE5;
                }
                else
                {
                    Word.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 236, 148));
                    Word.FontSize   = SIZE6;
                }

                Word.Text = K.Keyword;
                Word.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                Word.Margin            = new Thickness(0, 0, 5, 0);

                KeywordsHolder.Children.Add(Word);
            }

            var WeekCustomers = await api.GetCustomerCountByTime(7);

            var TwoWeeksCustomers = await api.GetCustomerCountByTime(14);

            var MonthCustomers = await api.GetCustomerCountByTime(30);

            var YearCustomers = await api.GetCustomerCountByTime(365);

            UsersSeven.Text = WeekCustomers.ToString();
            UsersFour.Text  = TwoWeeksCustomers.ToString();
            UsersMonth.Text = MonthCustomers.ToString();
            UsersYear.Text  = YearCustomers.ToString();

            var WeekSales = await api.GetTotalSalesByTime(7);

            var TwoWeeksSales = await api.GetTotalSalesByTime(14);

            var MonthSales = await api.GetTotalSalesByTime(30);

            var YearSales = await api.GetTotalSalesByTime(365);

            var Currency = await api.GetCurrency();

            TotalSeven.Text = WeekSales.ToString("0.0#") + " " + Currency;
            TotalFour.Text  = TwoWeeksSales.ToString("0.0#") + " " + Currency;
            TotalMonth.Text = MonthSales.ToString("0.0#") + " " + Currency;
            TotalYear.Text  = YearSales.ToString("0.0#") + " " + Currency;
        }