public async Task Login() { try { if (HasErrors) { ScrollToControlProperty(GetFirstInvalidPropertyName); } else { if (!string.IsNullOrEmpty(User_Id) && !string.IsNullOrEmpty(User_Password)) { if (Term_Condition_Checked == true) { _AppLoginClass.AppUser_Name = Base64Encode(User_Id); _AppLoginClass.AppUser_Password = Base64Encode(User_Password); var Wait = UserDialogs.Instance.Loading("Wait...", null, null, true, MaskType.Black); Wait.Show(); JObject result = await _IAllDataServices.CheckLoginAsync(_AppLoginClass); if (result != null) { string type = result["Type"].ToString(); if (type == "0") { AppLoginClass apc = new AppLoginClass(); apc.AppLogin_Id = (int)result["Result"]["AppLogin_Id"]; apc.AppUser_Name = (string)_AppLoginClass.AppUser_Name; apc.AppUser_Password = (string)_AppLoginClass.AppUser_Password; apc.AppUserType_Id = (int)result["Result"]["AppUserType_Id"]; apc.Other_Id = (int)result["Result"]["Other_Id"]; apc.User_Key = (string)result["Result"]["User_Key"]; _IAccountInformation.SaveCredentials(apc); var version = DependencyService.Get <IAppVersionProvider>(); var versionString = version.AppVersion; JObject output = await _IAllDataServices.GetProfile(versionString); if (output != null) { string Success = output["Type"].ToString(); if (Success == "1") { if (apc.AppUserType_Id == 1) { App.Code = (string)output["Result"]["Franchise_Code"]; App.ContectNo = (string)output["Result"]["Franchise_PrimaryMobileNo"]; App.Address = (string)output["Result"]["Franchise_PermanentAddress"] + ',' + (string)output["Result"]["City_Name"] + ',' + (string)output["Result"]["State_Name"]; App.MailId = (string)output["Result"]["Franchise_EmailId"]; App.Name = (string)output["Result"]["Franchise_OwnerName"]; App.Photo = "http://www.theshirtshop.in/TemplateContent/Admin/images/FranchiseImages/FranchisePhoto/" + (string)output["Result"]["Franchise_Photo"]; } else { App.Code = (string)output["Result"]["Emp_Code"]; App.ContectNo = (string)output["Result"]["Emp_PrimaryMobileNo"]; App.Address = (string)output["Result"]["Emp_PermanetAddress"] + ',' + (string)output["Result"]["City_Name"] + ',' + (string)output["Result"]["State_Name"]; App.MailId = (string)output["Result"]["Emp_EmailId"]; App.Name = (string)output["Result"]["Emp_FirstName"] + " " + (string)output["Result"]["Emp_LastName"]; App.Photo = "http://www.theshirtshop.in/TemplateContent/Admin/images/EmployeeImages/EmployeePhoto/" + (string)output["Result"]["Emp_Photo"]; } if (apc.AppUserType_Id == 1) { User_Id = ""; User_Password = ""; App.Current.MainPage = new FranchiseMaster(); } else if (apc.AppUserType_Id == 2) { User_Id = ""; User_Password = ""; App.Current.MainPage = new EmployeeFranchiseMaster(); } else if (apc.AppUserType_Id == 3) { User_Id = ""; User_Password = ""; App.Current.MainPage = new EmployeeRetailerMaster(); } else if (apc.AppUserType_Id == 4) { User_Id = ""; User_Password = ""; App.Current.MainPage = new EmployeeFranchiseWithRetailerMaster(); } else { await App.Current.MainPage.DisplayAlert("Error", (string)result["ResponseMessage"], "Ok"); // return Ok(new { StatusCode = HttpStatusCode.NotAcceptable, Type = "0", ResponseMessage = "You are not authorized person", Result = "" }); } } else if (Success == "101") { var outputs = await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig { Message = "Application new version available at play store you need to update new version of app.", OkText = "Yes", CancelText = "No", Title = "New Version" }); if (outputs) { Device.OpenUri(new Uri("https://play.google.com/store/apps/details?id=com.companyname.theshirtshopApp")); if (Application.Current.Properties.ContainsKey("Key")) { Application.Current.Properties["Key"] = null; Application.Current.Properties["UserName"] = null; Application.Current.Properties["Password"] = null; Application.Current.Properties["OtherId"] = null; Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); } App.Current.MainPage = new MainPage(); } else { if (Application.Current.Properties.ContainsKey("Key")) { Application.Current.Properties["Key"] = null; Application.Current.Properties["UserName"] = null; Application.Current.Properties["Password"] = null; Application.Current.Properties["OtherId"] = null; Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); } App.Current.MainPage = new MainPage(); } } else if (!string.IsNullOrEmpty(Success)) { if (Application.Current.Properties.ContainsKey("Key")) { Application.Current.Properties["Key"] = null; Application.Current.Properties["UserName"] = null; Application.Current.Properties["Password"] = null; Application.Current.Properties["OtherId"] = null; Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); } App.Current.MainPage = new MainPage(); } } } else if (Convert.ToInt32(type) > 0) { var con = await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig { Title = "Online Transaction", Message = (string)result["ResponseMessage"], OkText = "Yes", CancelText = "No", }); if (con) { await _navigation.PushModalAsync(new FranchiseAdminPaymentDeatailAfterLoginPage(Convert.ToInt32(type))); } } else { await App.Current.MainPage.DisplayAlert("Error", (string)result["ResponseMessage"], "Ok"); } } Wait.Dispose(); } else { await App.Current.MainPage.DisplayAlert("Opps!", "Please Checked Terms and Conditions then after login", "Ok"); } } else { User_Id = ""; User_Password = ""; } } } catch (Exception ee) { await App.Current.MainPage.DisplayAlert("Error", ee.Message, "Ok"); } }
public App() { try { var wait = UserDialogs.Instance.Loading(null, null, null, true, MaskType.Black); wait.Show(); exitcount = 0; Permissions ps = new Permissions(); ps.CheckGpsAsync(); IAllDataServices_data = new AllDataServices(); InitializeComponent(); if (Application.Current.Properties.ContainsKey("Key")) { Task ts = Task.Run(async() => { var version = DependencyService.Get <IAppVersionProvider>(); var versionString = version.AppVersion; JObject output = await IAllDataServices_data.GetProfile(versionString); if (output != null) { string Success = output["Type"].ToString(); if (Success == "1") { string[] key = Base64Decode(Application.Current.Properties["Key"].ToString()).Split('-'); if (key[1].ToString() == "1") { App.Code = (string)output["Result"]["Franchise_Code"]; App.ContectNo = (string)output["Result"]["Franchise_PrimaryMobileNo"]; App.Address = (string)output["Result"]["Franchise_PermanentAddress"] + ',' + (string)output["Result"]["City_Name"] + ',' + (string)output["Result"]["State_Name"]; App.MailId = (string)output["Result"]["Franchise_EmailId"]; App.Name = (string)output["Result"]["Franchise_OwnerName"]; App.Photo = "http://www.theshirtshop.in/TemplateContent/Admin/images/FranchiseImages/FranchisePhoto/" + (string)output["Result"]["Franchise_Photo"]; } else { App.Code = (string)output["Result"]["Emp_Code"]; App.ContectNo = (string)output["Result"]["Emp_PrimaryMobileNo"]; App.Address = (string)output["Result"]["Emp_PermanetAddress"] + ',' + (string)output["Result"]["City_Name"] + ',' + (string)output["Result"]["State_Name"]; App.MailId = (string)output["Result"]["Emp_EmailId"]; App.Name = (string)output["Result"]["Emp_FirstName"] + " " + (string)output["Result"]["Emp_LastName"]; App.Photo = "http://www.theshirtshop.in/TemplateContent/Admin/images/EmployeeImages/EmployeePhoto/" + (string)output["Result"]["Emp_Photo"]; } } else if (Success == "101") { var outputs = await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig { Message = "Application new version available at play store you need to update new version of app.", OkText = "Yes", CancelText = "No", Title = "New Version" }); if (outputs) { Device.OpenUri(new Uri("https://play.google.com/store/apps/details?id=com.companyname.theshirtshopApp")); if (Application.Current.Properties.ContainsKey("Key")) { Application.Current.Properties["Key"] = null; Application.Current.Properties["UserName"] = null; Application.Current.Properties["Password"] = null; Application.Current.Properties["OtherId"] = null; Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); } App.Current.MainPage = new MainPage(); } else { if (Application.Current.Properties.ContainsKey("Key")) { Application.Current.Properties["Key"] = null; Application.Current.Properties["UserName"] = null; Application.Current.Properties["Password"] = null; Application.Current.Properties["OtherId"] = null; Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); } App.Current.MainPage = new MainPage(); } } else if (!string.IsNullOrEmpty(Success)) { if (Application.Current.Properties.ContainsKey("Key")) { Application.Current.Properties["Key"] = null; Application.Current.Properties["UserName"] = null; Application.Current.Properties["Password"] = null; Application.Current.Properties["OtherId"] = null; Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); } App.Current.MainPage = new MainPage(); } } }); ts.Wait(); if (!string.IsNullOrEmpty(Application.Current.Properties["Key"].ToString())) { string[] TypeId = Base64Decode(Application.Current.Properties["Key"].ToString()).Split('-'); if (TypeId[1].ToString() == "1") { MainPage = new FranchiseMaster(); } else if (TypeId[1].ToString() == "2") { MainPage = new EmployeeFranchiseMaster(); } else if (TypeId[1].ToString() == "3") { MainPage = new EmployeeRetailerMaster(); } else if (TypeId[1].ToString() == "4") { //Both MainPage = new EmployeeFranchiseWithRetailerMaster(); } else { MainPage = new MainPage(); } } else { MainPage = new MainPage(); } } else { MainPage = new MainPage(); } wait.Hide(); } catch (Exception ee) { Application.Current.Properties.Remove("Key"); Application.Current.Properties.Remove("UserName"); Application.Current.Properties.Remove("Password"); Application.Current.Properties.Remove("OtherId"); MainPage = new MainPage(); } //MainPage = new MainPage(); }