Example #1
0
        public async void Preinfo(string CardNumber)
        {
            AndHUD.Shared.Show(this, "Please Wait", Convert.ToInt32(MaskType.Clear));
            try
            {
                BtnLogin.Visibility  = ViewStates.Invisible;
                BtnResend.Visibility = ViewStates.Invisible;
                AuthServ             = await svc.AuthencateUser("test", CardNumber, CurrentUser.GetDeviceID());

                LoggingClass.LogInfo("User Tried to login with " + CardNumber, screenid);
                if (CardNumber != null)
                {
                    CurrentUser.SaveCardNumber(CardNumber);
                }
                if (AuthServ != null)
                {
                    if (AuthServ.customer.Email != "" && AuthServ.customer.Email != null)
                    {
                        TxtScanresult.Text = AuthServ.ErrorDescription;//" Hi " + authen.customer.FirstName + authen.customer.LastName + ",\n We have sent an email at  " + authen.customer.Email + ".\n Please verify email to continue login. \n If you have not received email Click Resend Email.\n To get Email Id changed, contact store.";
                        TxtScanresult.SetTextColor(Android.Graphics.Color.Black);
                        BtnContinue.Visibility    = ViewStates.Visible;
                        BtnUpdateEmail.Visibility = ViewStates.Visible;
                        BtnContinue.Click        += async delegate
                        {
                            AndHUD.Shared.Show(this, " Please Wait", Convert.ToInt32(MaskType.Clear));
                            AuthServ = await svc.ContinueService(AuthServ);

                            ShowInfo(AuthServ);
                            AndHUD.Shared.Dismiss();
                        };
                        BtnUpdateEmail.Click += delegate
                        {
                            BtnUpdateEmail_Click("please enter your new e-mail id");
                        };
                    }
                }
                else
                {
                    TxtScanresult.Text   = "Sorry. Your Card number is not matching our records.\n Please re-scan Or Try app as Guest Log In.";
                    BtnResend.Visibility = ViewStates.Invisible;
                    BtnLogin.Visibility  = ViewStates.Invisible;
                    TxtScanresult.SetTextColor(Android.Graphics.Color.Red);
                    AndHUD.Shared.Dismiss();
                }
                AndHUD.Shared.Dismiss();
            }
            catch (Exception exe)
            {
            }
        }
        public async void Preinfo(string CardNumber)
        {
            AndHUD.Shared.Show(this, "Please Wait...", Convert.ToInt32(MaskType.Clear));
            try
            {
                BtnLogin.Visibility  = ViewStates.Gone;
                BtnResend.Visibility = ViewStates.Gone;
                try
                {
                    //CurrentUser.
                    EmailVerification(false);
                }
                catch (Exception ex)
                {
                    LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
                }
                AuthServ = await svc.AuthencateUser("test", CardNumber, CurrentUser.GetDeviceID());

                CurrentUser.SaveInternalCustometID(AuthServ.customer.CustomerID.ToString());
                LoggingClass.LogInfo("User Tried to login with " + CardNumber, screenid);
                if (CardNumber != null)
                {
                    CurrentUser.SaveCardNumber(CardNumber);
                }
                if (AuthServ != null)
                {
                    CurrentUser.SaveUserName(AuthServ.customer.FirstName + AuthServ.customer.LastName, AuthServ.customer.CustomerID.ToString());
                    CurrentUser.SavePrefered(AuthServ.customer.PreferredStore);
                    if (AuthServ.customer.Email != "" && AuthServ.customer.Email != null)
                    {
                        SendRegistrationToAppServer(CurrentUser.getDeviceToken());
                        if (AuthServ.ErrorDescription != null || AuthServ.ErrorDescription == "")
                        {
                            TxtScanresult.Text = AuthServ.ErrorDescription;
                        }
                        else
                        {
                            TxtScanresult.Text = " Hi " + AuthServ.customer.FirstName + AuthServ.customer.LastName + ",\nWe are sending a verification email to " + AuthServ.customer.Email + "..To proceed press continue. To change your emailAddress click on Update.";
                        }
                        TxtScanresult.SetTextColor(Android.Graphics.Color.Black);
                        BtnContinue.Visibility    = ViewStates.Visible;
                        BtnUpdateEmail.Visibility = ViewStates.Invisible;
                        update.Visibility         = ViewStates.Visible;
                        BtnContinue.Click        += async delegate
                        {
                            {
                                AndHUD.Shared.Show(this, " Please Wait...", Convert.ToInt32(MaskType.Clear));
                                AuthServ = await svc.ContinueService(AuthServ);

                                ShowInfo(AuthServ);
                                AndHUD.Shared.Dismiss();
                            }
                        };
                        update.Click += delegate
                        {
                            TxtScanresult.Text        = "";
                            BtnContinue.Visibility    = ViewStates.Gone;
                            update.Visibility         = ViewStates.Gone;
                            txtmail.Visibility        = ViewStates.Visible;
                            Txtem.Visibility          = ViewStates.Visible;
                            BtnUpdateEmail.Visibility = ViewStates.Visible;
                        };
                        BtnUpdateEmail.Click += delegate
                        {
                            {
                                BtnUpdateEmail_Click("please enter your new e-mail id.");
                            }
                        };
                    }
                    else
                    {
                        if (AuthServ.ErrorDescription != null || AuthServ.ErrorDescription == "")
                        {
                            TxtScanresult.Text = AuthServ.ErrorDescription;
                        }
                        else
                        {
                            TxtScanresult.Text = "Hi " + AuthServ.customer.FirstName + AuthServ.customer.LastName + ", \nIt seems we do not have your email address! Please update it so we can send you a verification link that will activate your account.";
                        }
                        TxtScanresult.SetTextColor(Android.Graphics.Color.Red);
                        BtnContinue.Visibility    = ViewStates.Gone;
                        BtnUpdateEmail.Visibility = ViewStates.Visible;
                        txtmail.Visibility        = ViewStates.Visible;
                        Txtem.Visibility          = ViewStates.Visible;
                        BtnUpdateEmail.Click     += delegate
                        {
                            BtnUpdateEmail_Click("please enter your new e-mail id.");
                        };
                    }
                }
                else
                {
                    TxtScanresult.Text   = "Sorry. Your Card number is not matching our records.\n Please re-scan Or Try app as Guest Log In.";
                    BtnResend.Visibility = ViewStates.Invisible;
                    BtnLogin.Visibility  = ViewStates.Invisible;
                    TxtScanresult.SetTextColor(Android.Graphics.Color.Red);
                    AndHUD.Shared.Dismiss();
                }
                AndHUD.Shared.Dismiss();
            }
            catch (Exception exe)
            {
            }
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.OtpReceiverLayout);
            string   Sentotp         = Intent.GetStringExtra("otp");
            string   username        = Intent.GetStringExtra("username");
            EditText receivedOtp     = FindViewById <EditText>(Resource.Id.txtOtp);
            Button   btnVerification = FindViewById <Button>(Resource.Id.btnVerify);

            btnVerification.Click += delegate
            {
                if (Sentotp == receivedOtp.Text)
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Successfully your logged in");
                    alert.SetMessage("Thank You");
                    alert.SetNegativeButton("Ok", delegate { });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                    CustomerResponse authen = new CustomerResponse();
                    ServiceWrapper   svc    = new ServiceWrapper();
                    try
                    {
                        authen = svc.AuthencateUser(username).Result;
                        if (authen.customer != null && authen.customer.CustomerID != 0)
                        {
                            CurrentUser.SaveUserName(username, authen.customer.CustomerID.ToString());
                            Intent intent = new Intent(this, typeof(TabActivity));
                            StartActivity(intent);
                        }
                        else
                        {
                            AlertDialog.Builder aler = new AlertDialog.Builder(this);
                            aler.SetTitle("Sorry");
                            aler.SetMessage("You entered wrong ");
                            aler.SetNegativeButton("Ok", delegate { });
                            Dialog dialog1 = aler.Create();
                            dialog1.Show();
                        };
                    }
                    catch (Exception exception)
                    {
                        if (exception.Message.ToString() == "One or more errors occurred.")
                        {
                            AlertDialog.Builder aler = new AlertDialog.Builder(this);
                            aler.SetTitle("Sorry");
                            aler.SetMessage("Please check your internet connection");
                            aler.SetNegativeButton("Ok", delegate { });
                            Dialog dialog2 = aler.Create();
                            dialog2.Show();
                        }
                        else
                        {
                            AlertDialog.Builder aler = new AlertDialog.Builder(this);
                            aler.SetTitle("Sorry");
                            aler.SetMessage("We're under maintanence");
                            aler.SetNegativeButton("Ok", delegate { });
                            Dialog dialog3 = aler.Create();
                            dialog3.Show();
                        }
                    }
                }
                else
                {
                    AlertDialog.Builder aler = new AlertDialog.Builder(this);
                    aler.SetTitle("Incorrect Otp");
                    aler.SetMessage("Please Check Again");
                    aler.SetNegativeButton("Ok", delegate { });
                    Dialog dialog = aler.Create();
                    dialog.Show();
                }
            };
        }
Example #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.login);
            MobileCenter.Start("{Analytics,Crashes,Distribute}", typeof(Analytics), typeof(Crashes), typeof(Distribute));

            Button login = FindViewById <Button>(Resource.Id.btnLoginLL);

            EditText username      = FindViewById <EditText>(Resource.Id.txtUsername);
            EditText txtUserNumber = FindViewById <EditText>(Resource.Id.MobileNumber);

            ServiceWrapper svc = new ServiceWrapper();
            //new Thread(new ThreadStart(delegate
            //{
            //    RunOnUiThread(() => bvb.DownloadImages(Convert.ToInt32(CurrentUser.getUserId())));
            //})).Start();

            //bvb.DownloadImages(Convert.ToInt32(CurrentUser.getUserId()));
            var TaskA = new Task(() => {
                BlobWrapper.DownloadImages(Convert.ToInt32(CurrentUser.getUserId()));
            });

            TaskA.Start();


            if (CurrentUser.getUserName() == null ||
                CurrentUser.getUserName() == "")
            {
                // Do nothing
            }
            else
            {
                Intent intent = new Intent(this, typeof(TabActivity));
                StartActivity(intent);
            }



            login.Click += delegate
            {
                //1. Call Auth service and check for this user, it returns one.
                //2. If it returns 1 save Username and go to Tab Activity.
                //3. Else Show message, incorrect username.
                //
                if (username.Text == "") //|| txtUserNumber.Text == "")
                {
                    AlertDialog.Builder aler = new AlertDialog.Builder(this);
                    aler.SetTitle("Sorry");
                    aler.SetMessage("Enter proper details");
                    aler.SetNegativeButton("Ok", delegate { });
                    Dialog dialog = aler.Create();
                    dialog.Show();
                    return;
                }
                else
                {
                    CustomerResponse authen = new CustomerResponse();
                    try
                    {
                        authen = svc.AuthencateUser(username.Text).Result;
                        if (authen.customer != null && authen.customer.CustomerID != 0)
                        {
                            CurrentUser.SaveUserName(username.Text, authen.customer.CustomerID.ToString());
                            Intent intent = new Intent(this, typeof(TabActivity));
                            StartActivity(intent);
                        }
                        else
                        {
                            AlertDialog.Builder aler = new AlertDialog.Builder(this);
                            aler.SetTitle("Sorry");
                            aler.SetMessage("You entered wrong ");
                            aler.SetNegativeButton("Ok", delegate { });
                            Dialog dialog1 = aler.Create();
                            dialog1.Show();
                        };
                    }
                    catch (Exception exception)
                    {
                        if (exception.Message.ToString() == "One or more errors occurred.")
                        {
                            AlertDialog.Builder aler = new AlertDialog.Builder(this);
                            aler.SetTitle("Sorry");
                            aler.SetMessage("Please check your internet connection");
                            aler.SetNegativeButton("Ok", delegate { });
                            Dialog dialog2 = aler.Create();
                            dialog2.Show();
                        }
                        else
                        {
                            AlertDialog.Builder aler = new AlertDialog.Builder(this);
                            aler.SetTitle("Sorry");
                            aler.SetMessage("We're under maintanence");
                            aler.SetNegativeButton("Ok", delegate { });
                            Dialog dialog3 = aler.Create();
                            dialog3.Show();
                        }
                    }
                    MobileCenter.Start("4403e7d2-95d8-414e-9390-6c1dbd241c21",
                                       typeof(Analytics), typeof(Crashes));

                    //SendSmsgs(txtUserNumber.Text);
                    //var intent = new Intent(this, typeof(VerificationActivity));
                    ////var intent = new Intent(this, typeof(TabActivity));
                    //intent.PutExtra("otp", otp);
                    //intent.PutExtra("username", username.Text);
                    //StartActivity(intent);
                }
                //CustomerResponse authen = new CustomerResponse();
                //try
                //{
                //    authen = svc.AuthencateUser(username.Text).Result;
                //    if (authen.customer != null && authen.customer.CustomerID != 0)
                //    {
                //        CurrentUser.SaveUserName(username.Text, authen.customer.CustomerID.ToString());
                //        Intent intent = new Intent(this, typeof(TabActivity));
                //        StartActivity(intent);

                //    }
                //    else
                //    {
                //        AlertDialog.Builder aler = new AlertDialog.Builder(this);
                //        aler.SetTitle("Sorry");
                //        aler.SetMessage("Incorrect Details");
                //        aler.SetNegativeButton("Ok", delegate { });
                //        Dialog dialog = aler.Create();
                //        dialog.Show();
                //    };
                //}
                //catch(Exception exception)
                //{
                //    if (exception.Message.ToString() == "One or more errors occurred.")
                //    {
                //        AlertDialog.Builder aler = new AlertDialog.Builder(this);
                //        aler.SetTitle("Sorry");
                //        aler.SetMessage("Please check your internet connection");
                //        aler.SetNegativeButton("Ok", delegate { });
                //        Dialog dialog = aler.Create();
                //        dialog.Show();
                //    }
                //    else {
                //        AlertDialog.Builder aler = new AlertDialog.Builder(this);
                //        aler.SetTitle("Sorry");
                //        aler.SetMessage("We're under maintanence");
                //        aler.SetNegativeButton("Ok", delegate { });
                //        Dialog dialog = aler.Create();
                //        dialog.Show();

                //    }

                //}
            };
        }