예제 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.AddNote);

            NopCore api = new NopCore();

            Button   apply     = FindViewById <Button>(Resource.Id.applyButton);
            EditText noteField = FindViewById <EditText>(Resource.Id.note);

            string user     = Intent.GetStringExtra("user") ?? "Data not available";
            string password = Intent.GetStringExtra("pass") ?? "Data not available";
            int    orderID  = Intent.GetIntExtra("orderid", -1);

            apply.Click += delegate
            {
                string note = noteField.Text.ToString();

                api.NewOrderNote(orderID, note, "*****@*****.**", "adminadmin");
                Toast.MakeText(this, "Note Added!", ToastLength.Long).Show();
                hideSoftKeyboard(this, apply);
                this.Finish();
            };
        }
예제 #2
0
 private void RefreshClick(NopCore api)
 {
     dialog = ProgressDialog.Show(this, "", "Loading. Please wait... ", true);
     var ValuesTask = UpdateValues(api);
 }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(this);
            ISharedPreferencesEditor editor = prefs.Edit();
            NopCore api = new NopCore();

            if (prefs.GetBoolean("login_state", false) && !prefs.GetString("current_url", "").Equals("") &&
                prefs.GetBoolean("stay_connected", false) && !Intent.GetBooleanExtra("associate", false))
            {
                api.SetStoreUrl(prefs.GetString("current_url", ""));
                Intent intent = new Intent(this, typeof(Dashboard));
                intent.SetFlags(ActivityFlags.ReorderToFront);
                StartActivity(intent);
                Finish();
            }

            SetContentView(Resource.Layout.login);

            if (!Intent.GetBooleanExtra("associate", false))
            {
                SupportActionBar.Hide();
            }
            else
            {
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetDisplayShowHomeEnabled(false);
                SupportActionBar.Title = "Associate New Store";
            }

            EditText email         = FindViewById <EditText>(Resource.Id.email);
            Spinner  StoreDrop     = FindViewById <Spinner>(Resource.Id.storedrop);
            EditText passwordField = FindViewById <EditText>(Resource.Id.password);
            TextView ErrorMessage  = FindViewById <TextView>(Resource.Id.errorMessage);
            TextView Http          = FindViewById <TextView>(Resource.Id.http);
            EditText SiteUrl       = FindViewById <EditText>(Resource.Id.siteurl);
            Button   loginB        = FindViewById <Button>(Resource.Id.login);
            Button   NewStoreB     = FindViewById <Button>(Resource.Id.loginwithnew);
            CheckBox SaveUrl       = FindViewById <CheckBox>(Resource.Id.saveUrl);
            CheckBox StayConnected = FindViewById <CheckBox>(Resource.Id.stayConnected);

            bool newStore = true;

            var keys = prefs.All;
            var urls = new List <string>();

            foreach (KeyValuePair <string, object> url in keys)
            {
                if (url.Key.StartsWith("store_url_"))
                {
                    urls.Add((string)url.Value);
                }
            }

            if (urls.Count > 0)
            {
                newStore           = false;
                StoreDrop.Adapter  = new ArrayAdapter <string>(this, Android.Resource.Layout.login_url_dropdown_item, urls);
                SiteUrl.Visibility = ViewStates.Gone;
                Http.Visibility    = ViewStates.Gone;
                SaveUrl.Visibility = ViewStates.Gone;
            }
            else
            {
                newStore             = true;
                NewStoreB.Visibility = ViewStates.Gone;
                StoreDrop.Visibility = ViewStates.Gone;
                SaveUrl.Visibility   = ViewStates.Visible;
            }

            if (Intent.GetBooleanExtra("associate", false))
            {
                StoreDrop.Visibility     = ViewStates.Gone;
                Http.Visibility          = ViewStates.Visible;
                SiteUrl.Visibility       = ViewStates.Visible;
                SaveUrl.Visibility       = ViewStates.Gone;
                NewStoreB.Visibility     = ViewStates.Gone;
                StayConnected.Visibility = ViewStates.Gone;
                newStore = true;
            }

            NewStoreB.Click += delegate
            {
                if (!newStore)
                {
                    StoreDrop.Visibility = ViewStates.Gone;
                    Http.Visibility      = ViewStates.Visible;
                    SiteUrl.Visibility   = ViewStates.Visible;
                    SaveUrl.Visibility   = ViewStates.Visible;
                    NewStoreB.Text       = "Login with existing store";
                    newStore             = true;
                }
                else
                {
                    StoreDrop.Visibility = ViewStates.Visible;
                    Http.Visibility      = ViewStates.Gone;
                    SiteUrl.Visibility   = ViewStates.Gone;
                    SaveUrl.Visibility   = ViewStates.Gone;
                    NewStoreB.Text       = "Login with new store";
                    newStore             = false;
                }
            };

            loginB.Click += delegate
            {
                if (!Processing)
                {
                    Processing = true;
                    var Task = ProcessLogin(SiteUrl, email, passwordField, loginB, api, SaveUrl, prefs, editor, StayConnected,
                                            ErrorMessage, newStore, StoreDrop);
                }
            };
        }
예제 #4
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();
        }
예제 #5
0
        private async Task ProcessLogin(EditText SiteUrl, EditText email, EditText passwordField, Button loginB, NopCore api,
                                        CheckBox SaveUrl, ISharedPreferences prefs, ISharedPreferencesEditor editor, CheckBox StayConnected, TextView ErrorMessage,
                                        Boolean newStore, Spinner Urls)
        {
            string url = "";

            if (newStore)
            {
                url = SiteUrl.Text.ToString();
            }
            else
            {
                url = Urls.SelectedItem.ToString();
            }

            string user     = email.Text.ToString();
            string password = passwordField.Text.ToString();

            try
            {
                hideSoftKeyboard(this, loginB);
                dialog = ProgressDialog.Show(this, "", "Connecting. Please wait... ", true);

                api.SetStoreUrl(url);
                var LoginSuccess = false;
                LoginSuccess = await api.CheckLogin(user, password);

                if (LoginSuccess)
                {
                    Intent intent = new Intent(this, typeof(Dashboard));

                    editor.PutString("current_user", user);
                    var Associate = Intent.GetBooleanExtra("associate", false);
                    if ((SaveUrl.Checked || Associate) && !prefs.GetString("store_url_" + api.GetStoreName(), "").Equals(url) && newStore)
                    {
                        editor.PutString("store_url_" + api.GetStoreName(), url);
                        editor.PutString("current_url", url);
                    }

                    if (StayConnected.Checked)
                    {
                        editor.PutBoolean("stay_connected", true);
                    }

                    editor.PutBoolean("login_state", true);
                    editor.Apply();
                    dialog.Dismiss();
                    Processing = false;
                    if (Associate)
                    {
                        Dashboard.DashboardA.Finish();
                    }

                    StartActivity(intent);
                    Finish();
                }
                else
                {
                    throw new LoginException("The credentials seem to be incorrect");
                }
            }

            catch (LoginException ex)
            {
                Console.WriteLine(ex.Message);
                loginB.Text = "Login";
                api         = new NopCore();
                dialog.Dismiss();
                Processing        = false;
                ErrorMessage.Text = ex.Message;
            }
            catch (WrongUrlException wue)
            {
                Console.WriteLine(wue.Message);
                loginB.Text = "Login";
                api         = new NopCore();
                dialog.Dismiss();
                Processing        = false;
                ErrorMessage.Text = wue.Message;
            }
        }