Exemple #1
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();

                //    }

                //}
            };
        }
        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();
            }
        }
Exemple #3
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);
        }