Exemplo n.º 1
0
        public static string Titlebar()
        {
            string title = "";

            try
            {
                DateTime datetime = DateTime.Now;

                var hour = datetime.Hour;


                if (hour >= 18)
                {
                    title = "Good Night" + "," + SingletonSession.Instance().getUsername().ToUpper();
                }
                else if (hour >= 12)
                {
                    title = "Good Afternoon" + "," + SingletonSession.Instance().getUsername().ToUpper();
                }
                else
                {
                    title = "Good Morning" + "," + SingletonSession.Instance().getUsername().ToUpper();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(title);
        }
Exemplo n.º 2
0
 private void GoForLogin(string plantId)
 {
     if (!string.IsNullOrEmpty(plantId))
     {
         Intent i = new Intent(this, typeof(LoginActivity));
         StartActivity(i);
         //OverridePendingTransition(Resource.Animation.right_to_left, Resource.Animation.abc_fade_out);
         SingletonSession.Instance().setPlantID(plantId);
     }
     else
     {
         Helper.ShowToastMessage(this, Color.DarkRed, "Plant Is Empty..!!!", ToastLength.Short);
     }
 }
        public override void OnBackPressed()
        {
            try
            {
                var intent = new Intent(this, typeof(SitesActivity));
                intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);

                StartActivity(intent);
                SingletonSession.Instance().setPlantID("");
                Finish();
            }
            catch (System.Exception ex)
            {
                Helper.ShowToastMessage(this, Color.DarkRed, ex.Message, ToastLength.Short);
            }
        }
        private async void Btnsign_Click(object sender, EventArgs e)
        {
            Dialog dialog = null;

            try
            {
                if (txtusername.Text != "" && txtPassword.Text != "")
                {
                    if (CrossConnectivity.Current.IsConnected)
                    {
                        #region Loading Dialog
                        LayoutInflater      layoutInflater     = LayoutInflater.From(this);
                        View                progressDialogBox  = layoutInflater.Inflate(Resource.Layout.flashLayout, null);
                        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
                        alertDialogBuilder.SetView(progressDialogBox);
                        var progressBar1   = progressDialogBox.FindViewById <ProgressBar>(Resource.Id.ProgressBar01);
                        var txtviewmessage = progressDialogBox.FindViewById <TextView>(Resource.Id.txtmessage);
                        txtviewmessage.Text = "Please wait Loading...";
                        dialog = alertDialogBuilder.Create();
                        dialog.SetCanceledOnTouchOutside(false);
                        dialog.SetCancelable(false);
                        dialog.Show();
                        #endregion

                        var login = new Login(SingletonSession.Instance().getPlantID(), txtusername.Text, txtPassword.Text, 123);
                        HttpResponseMessage response = await login.LoggedIn();

                        if (response.ReasonPhrase == "OK")
                        {
                            var result = await response.Content.ReadAsStringAsync();

                            if (result.Contains("Success"))
                            {
                                SingletonSession.Instance().setUsername(txtusername.Text.ToString());
                                StartActivity(typeof(CategoryActivity));
                                //OverridePendingTransition(Resource.Animation.right_to_left,Resource.Animation.abc_fade_out);
                                dialog.Hide();
                                dialog.Dismiss();
                                Helper.ShowToastMessage(this, Color.DarkGreen, "Login Successful...", ToastLength.Short);
                            }
                            else
                            {
                                dialog.Hide();
                                dialog.Dismiss();
                                txtusername.Text = string.Empty;
                                txtPassword.Text = string.Empty;
                                SingletonSession.Instance().setUsername("");
                                throw new AndroidRuntimeException("User ID or Password Wrong...");
                            }
                        }
                        else
                        {
                            dialog.Hide();
                            dialog.Dismiss();
                            throw new AndroidRuntimeException("Internal server Error...");
                        }
                    }
                    else
                    {
                        throw new AndroidRuntimeException("Check your internet connection and try again..");
                    }
                }
                else
                {
                    throw new AndroidRuntimeException("Enter your User Id or Password .....");
                }
            }
            catch (AndroidRuntimeException ex)
            {
                Helper.ShowToastMessage(this, Color.DarkRed, ex.Message, ToastLength.Short);
            }
        }