예제 #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)
            {
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EmailVerificationLayout);
            EmailVerification();
            //string Sentotp = Intent.GetStringExtra("otp");//receiving otp from previous activity
            //string username = Intent.GetStringExtra("username");//receiving username from previous activity
            //EditText txtreceivedOtp = FindViewById<EditText>(Resource.Id.txtOtp);
            Button   btnVerification = FindViewById <Button>(Resource.Id.btnVerify);
            Button   btnResendMail   = FindViewById <Button>(Resource.Id.btnResendMail);
            EditText editEmail       = FindViewById <EditText>(Resource.Id.txtEmail);

            editEmail.Text = CurrentUser.GetCardNumber();//GetMailId();

            btnResendMail.Click += async delegate
            {
                CurrentUser.SaveCardNumber(editEmail.Text);
                await sc.AuthencateUser1(CurrentUser.GetCardNumber());
            };
            btnVerification.Click += delegate
            {
                EmailVerification();
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            CheckInternetConnection();
            Stopwatch st = new Stopwatch();

            st.Start();
            //for direct login
            //CurrentUser.SaveUserName("Sumanth","3");
            //Preinfo("8902519310330");
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LoginView);
            var TaskA = new System.Threading.Tasks.Task(() =>
            {
                BlobWrapper.DownloadImages(Convert.ToInt32(CurrentUser.getUserId()));
            });

            TaskA.Start();
            //checking user id's exist or not.
            if ((CurrentUser.getUserId() != null || CurrentUser.getUserId() != "0") && (CurrentUser.getUserId() != null))
            {
                IntoApp();
            }
            else if (CurrentUser.GetGuestId() != null || CurrentUser.getUserId() == "0")
            {
                IntoApp();
            }
            else
            {
                //if (CurrentUser.GetCardNumber() != null)
                //{
                //    Preinfo(CurrentUser.GetCardNumber());
                //}
                ImageButton BtnScanner    = FindViewById <ImageButton>(Resource.Id.btnScanner);
                Button      BtnGuestLogin = FindViewById <Button>(Resource.Id.btnGuestLogin);
                LoggingClass.LogInfo("Opened the app", screenid);
                BtnScanner.Click += async delegate
                {
                    try
                    {
                        MobileBarcodeScanner.Initialize(Application);
                        var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                        scanner.UseCustomOverlay = false;
                        var result = await scanner.Scan();// "8902519310330";// "900497354894";//await scanner.Scan();

                        if (result != null)
                        {
                            LoggingClass.LogInfo("User Tried to login with " + result, screenid);
                            Preinfo(result.Text);
                            CurrentUser.SaveCardNumber(result.Text);
                            txtmail.Visibility = ViewStates.Gone;
                            Txtem.Visibility   = ViewStates.Gone;
                        }
                    }
                    catch (Exception exe)
                    {
                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                    }
                };

                BtnGuestLogin.Click += async delegate
                {
                    Intent intent = new Intent(this, typeof(Login));
                    ProgressIndicator.Show(this);
                    LoggingClass.LogInfo("User Tried to login with Guest Login ", screenid);
                    StartActivity(intent);
                    CustomerResponse csr = new CustomerResponse();
                    csr = await svc.InsertUpdateGuest("Didn't get the token");

                    CurrentUser.SaveGuestId(csr.customer.CustomerID.ToString());
                };
                TxtScanresult             = FindViewById <TextView>(Resource.Id.txtScanresult);
                Txtem                     = FindViewById <TextView>(Resource.Id.textV);
                BtnLogin                  = FindViewById <Button>(Resource.Id.btnLogin);
                txtmail                   = FindViewById <EditText>(Resource.Id.txtmail);
                BtnResend                 = FindViewById <Button>(Resource.Id.btnResend);
                update                    = FindViewById <Button>(Resource.Id.btnUpdateEmailclick);
                BtnContinue               = FindViewById <Button>(Resource.Id.btnContinue);
                BtnUpdateEmail            = FindViewById <Button>(Resource.Id.btnUpdateEmail);
                BtnResend.Visibility      = ViewStates.Gone;
                update.Visibility         = ViewStates.Gone;
                BtnLogin.Visibility       = ViewStates.Gone;
                BtnContinue.Visibility    = ViewStates.Gone;
                BtnUpdateEmail.Visibility = ViewStates.Gone;
                txtmail.Visibility        = ViewStates.Gone;
                Txtem.Visibility          = ViewStates.Gone;
                if (IsPlayServicesAvailable())
                {
                    var TaskB = new System.Threading.Tasks.Task(() =>
                    {
                        var intent = new Intent(this, typeof(RegistrationIntentService));
                        StartService(intent);
                    });
                    TaskB.Start();
                }
                var telephonyDeviceID             = string.Empty;
                var telephonySIMSerialNumber      = string.Empty;
                TelephonyManager telephonyManager = (TelephonyManager)this.ApplicationContext.GetSystemService(Context.TelephonyService);
                if (telephonyManager != null)
                {
                    if (!string.IsNullOrEmpty(telephonyManager.DeviceId))
                    {
                        telephonyDeviceID = telephonyManager.DeviceId;
                    }
                    if (!string.IsNullOrEmpty(telephonyManager.SimSerialNumber))
                    {
                        telephonySIMSerialNumber = telephonyManager.SimSerialNumber;
                    }
                }
                var androidID  = Android.Provider.Settings.Secure.GetString(this.ApplicationContext.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                var deviceUuid = new UUID(androidID.GetHashCode(), ((long)telephonyDeviceID.GetHashCode() << 32) | telephonySIMSerialNumber.GetHashCode());
                var DeviceID   = deviceUuid.ToString();
                CurrentUser.SaveDeviceID(DeviceID);
                BtnScanner.Dispose();
            }
        }
        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)
            {
            }
        }
예제 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            CheckInternetConnection();
            Stopwatch st = new Stopwatch();

            st.Start();
            //for direct login
            //CurrentUser.SaveUserName("Mohana Android","48732");
            //Preinfo("8902519310330");
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.login);
            var TaskA = new System.Threading.Tasks.Task(() =>
            {
                BlobWrapper.DownloadImages(Convert.ToInt32(CurrentUser.getUserId()));
            });

            TaskA.Start();
            ImageButton BtnScanner    = FindViewById <ImageButton>(Resource.Id.btnScanner);
            Button      BtnGuestLogin = FindViewById <Button>(Resource.Id.btnGuestLogin);

            LoggingClass.LogInfo("Opened the app", screenid);

            BtnScanner.Click += async delegate
            {
                try
                {
                    MobileBarcodeScanner.Initialize(Application);
                    var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                    scanner.UseCustomOverlay = false;
                    var result = await scanner.Scan();//"8902519310330";//await scanner.Scan();

                    if (result.Text != null)
                    {
                        LoggingClass.LogInfo("User Tried to login with " + result, screenid);
                        Preinfo(result.Text);
                        CurrentUser.SaveCardNumber(result.Text);
                    }
                }
                catch (Exception exe)
                {
                    LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                }
                BtnScanner.Click -= null;
            };

            BtnGuestLogin.Click += async delegate
            {
                //await svc.InsertUpdateGuest(CurrentUser.getAuthToken());
                CurrentUser.SaveUserName("Guest", "0");


                Intent intent = new Intent(this, typeof(TabActivity));
                ProgressIndicator.Show(this);
                LoggingClass.LogInfo("User Tried to login with Guest Login ", screenid);
                StartActivity(intent);
                await svc.InsertUpdateGuest("Didn't get the token");
            };
            TxtScanresult             = FindViewById <TextView>(Resource.Id.txtScanresult);
            BtnLogin                  = FindViewById <Button>(Resource.Id.btnLogin);
            BtnResend                 = FindViewById <Button>(Resource.Id.btnResend);
            BtnContinue               = FindViewById <Button>(Resource.Id.btnContinue);
            BtnUpdateEmail            = FindViewById <Button>(Resource.Id.btnUpdateEmail);
            BtnResend.Visibility      = ViewStates.Invisible;
            BtnLogin.Visibility       = ViewStates.Invisible;
            BtnContinue.Visibility    = ViewStates.Invisible;
            BtnUpdateEmail.Visibility = ViewStates.Invisible;
            if (IsPlayServicesAvailable())
            {
                var TaskB = new System.Threading.Tasks.Task(() =>
                {
                    var intent = new Intent(this, typeof(RegistrationIntentService));
                    StartService(intent);
                });
                TaskB.Start();
            }
            if (CurrentUser.getUserName() == null ||
                CurrentUser.getUserName() == "")
            {
                SendRegistrationToAppServer(CurrentUser.getDeviceToken());
                if (CurrentUser.GetCardNumber() != null)
                {
                    Preinfo(CurrentUser.GetCardNumber());
                }
            }
            else if (CurrentUser.GetGuestId() != null || CurrentUser.getUserId() == "0")
            {
                Intent intent = new Intent(this, typeof(TabActivity));
                ProgressIndicator.Show(this);
                LoggingClass.LogInfo("User Tried to login with Guest Login ", screenid);
                StartActivity(intent);
            }
            else
            {
                int storename = Convert.ToInt32(CurrentUser.GetPrefered());
                if (storename == 1)
                {
                    Intent intent = new Intent(this, typeof(GridViewActivity));
                    intent.PutExtra("MyData", "Wall Store");
                    ProgressIndicator.Show(this);
                    StartActivity(intent);
                }
                else if (storename == 2)
                {
                    Intent intent = new Intent(this, typeof(GridViewActivity));
                    intent.PutExtra("MyData", "Point Pleasant Store");
                    ProgressIndicator.Show(this);
                    StartActivity(intent);
                }
                else
                {
                    Intent intent = new Intent(this, typeof(TabActivity));
                    ProgressIndicator.Show(this);
                    StartActivity(intent);
                }
            }
            var telephonyDeviceID             = string.Empty;
            var telephonySIMSerialNumber      = string.Empty;
            TelephonyManager telephonyManager = (TelephonyManager)this.ApplicationContext.GetSystemService(Context.TelephonyService);

            if (telephonyManager != null)
            {
                if (!string.IsNullOrEmpty(telephonyManager.DeviceId))
                {
                    telephonyDeviceID = telephonyManager.DeviceId;
                }
                if (!string.IsNullOrEmpty(telephonyManager.SimSerialNumber))
                {
                    telephonySIMSerialNumber = telephonyManager.SimSerialNumber;
                }
            }
            var androidID  = Android.Provider.Settings.Secure.GetString(this.ApplicationContext.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
            var deviceUuid = new UUID(androidID.GetHashCode(), ((long)telephonyDeviceID.GetHashCode() << 32) | telephonySIMSerialNumber.GetHashCode());
            var DeviceID   = deviceUuid.ToString();

            CurrentUser.SaveDeviceID(DeviceID);
        }