Exemple #1
0
        private Task <bool> CheckGuestureLockAsync()
        {
            var tcs = new TaskCompletionSource <bool>();

            Task.Factory.StartNew(() =>
            {
                if (string.IsNullOrEmpty(GuestureLockService.GuestureLock))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        MainPage = new MyNavigationPage(new GuestureLockPage(() =>
                        {
                            tcs.SetResult(true);
                        }));
                    });
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        MainPage = new MyNavigationPage(new GuestureVerifyPage(() =>
                        {
                            tcs.SetResult(true);
                        }));
                    });
                }
            });
            return(tcs.Task);
        }
Exemple #2
0
        //private static LocalDatabaseHelper database;   //Comment
        //public static LocalDatabaseHelper Database
        //{
        //    get
        //    {
        //        if (database == null)
        //        {
        //            database = new LocalDatabaseHelper(Path.Combine(FileSystem.CacheDirectory, "XMartSQLite.db3"));
        //        }
        //        return database;
        //    }
        //}

        public App()
        {
            InitializeComponent();

            MainPage         mainPage       = new MainPage();
            MyNavigationPage navigationPage = new MyNavigationPage(mainPage)
            {
                BarBackgroundColor = Color.FromHex("fafafa"),
                BarTextColor       = Color.Black
            };

            MainPage = navigationPage;
        }
Exemple #3
0
        private async Task <bool> CheckSecureKeyAsync()
        {
            var tcs = new TaskCompletionSource <bool>();
            await Task.Factory.StartNew(async() =>
            {
                await SecureKeyService.LoadSecureKeyAsync();
                if (string.IsNullOrEmpty(SecureKeyService.SecureKey))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        MainPage = new MyNavigationPage(new SecureKeyPage(() => {
                            tcs.SetResult(true);
                        }));
                    });
                }
                else
                {
                    tcs.SetResult(true);
                }
            });

            return(await tcs.Task);
        }
Exemple #4
0
 public App()
 {
     DetailPage = new MasterDetailPage1();
     Detail     = new MyNavigationPage(new MainPageLinearList(AppType))
     {
         BarBackgroundColor = Color.FromHex("#104e8b"), BarTextColor = Color.White
     };
     DetailPage.Detail = Detail;
     MainPage          = DetailPage;
     InitializeComponent();
     // Добавление данных по умолчанию, если их нет
     if (!Current.Properties.TryGetValue("address", out object _))
     {
         Current.Properties.Add("address", "mobile.aisisso.ru");
     }
     if (!Current.Properties.TryGetValue("port", out object _))
     {
         Current.Properties.Add("port", 8790);
     }
     if (!Current.Properties.TryGetValue("support_port", out var _))
     {
         Current.Properties.Add("support_port", 80);
     }
 }
Exemple #5
0
        /// <summary>
        /// 响应登录事件
        /// </summary>
        private async void Login()
        {
            try
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Short);
                    IsLoading = false;
                    return;
                }

                if (string.IsNullOrWhiteSpace(TelOrEmpNo))
                {
                    CrossToastPopUp.Current.ShowToastError("手机号或员工号不能为空", ToastLength.Short);
                    IsLoading = false;
                    return;
                }

                if (string.IsNullOrWhiteSpace(Password))
                {
                    CrossToastPopUp.Current.ShowToastError("密码不能为空", ToastLength.Short);
                    IsLoading = false;
                    return;
                }

                string result = await RestSharpService.Login(TelOrEmpNo, Password);

                if (string.IsNullOrWhiteSpace(result))
                {
                    CrossToastPopUp.Current.ShowToastError("服务器返回值为空", ToastLength.Short);
                    IsLoading = false;
                    return;
                }
                else
                {
                    BaseResponse baseResponse = JsonConvert.DeserializeObject <BaseResponse>(result);

                    if (baseResponse.Flag == "success")
                    {
                        //GlobalVariables.LoggedUser = JsonConvert.DeserializeObject<UserInfo>(result);
                        //CrossToastPopUp.Current.ShowToastSuccess(baseResponse.Msg, ToastLength.Short);

                        LoginRD loginRD = JsonConvert.DeserializeObject <LoginRD>(baseResponse.Result.ToString());
                        loginRD.DBName = loginRD.DBName.TrimStart('[');

                        GlobalVariables.LoggedUser       = loginRD;
                        GlobalVariables.IsLogged         = true;
                        GlobalVariables.LoggedUser.EmpNo = TelOrEmpNo;
                        //提供自动登录的信息  除非用户手动退出登录 LoginState变为False
                        string dateNow = DateTime.Now.ToString();
                        string text    = "";
                        if (IsRememberPwd)
                        {
                            text = "State:Checked\n" + "Account:" + TelOrEmpNo + "\n" + "Password:"******"\n" + "LoginDate:" + dateNow;
                            File.WriteAllText(autoLoginFileName, text);
                        }

                        //MainPage mainPage = new MainPage();
                        //await Application.Current.MainPage.Navigation.PushAsync(mainPage);
                        MyNavigationPage myNavigationPage = new MyNavigationPage(new MainPage());
                        Application.Current.MainPage = myNavigationPage;
                    }
                    else
                    {
                        CrossToastPopUp.Current.ShowToastError(baseResponse.Msg, ToastLength.Short);
                        IsLoading = false;
                        return;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #6
0
        /// <summary>
        /// 注册
        /// </summary>
        private async void Register()
        {
            try
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Short);
                    return;
                }

                //string content1 = await RestSharpService.CheckIfRegister(TelOrEmpNo);
                //if (string.IsNullOrWhiteSpace(content1))
                //{
                //    CrossToastPopUp.Current.ShowToastError("服务器错误", ToastLength.Short);
                //    return;
                //}
                //BaseResponse baseResponse1 = JsonConvert.DeserializeObject<BaseResponse>(content1);
                //if (baseResponse1.Flag == "success")
                //{
                //    if (baseResponse1.Result.ToString() == "TelExist")
                //    {
                //        CrossToastPopUp.Current.ShowToastError("电话号码已注册", ToastLength.Short);
                //        return;
                //    }
                //}

                string content = await RestSharpService.Register(DBName.dbName, TelOrEmpNo, Password, RealName, "");

                if (string.IsNullOrWhiteSpace(content))
                {
                    CrossToastPopUp.Current.ShowToastError("注册失败", ToastLength.Short);
                    return;
                }

                BaseResponse baseResponse = JsonConvert.DeserializeObject <BaseResponse>(content);
                if (baseResponse.Flag == "success")
                {
                    CrossToastPopUp.Current.ShowToastSuccess("注册成功", ToastLength.Long);
                    // 注册成功后 ,自动保存全局的登录信息,并跳转界面 ,content中有除 PhotoUrl的其他变量

                    GlobalVariables.LoggedUser = JsonConvert.DeserializeObject <LoginRD>(baseResponse.Result.ToString());
                    //Console.Write(GlobalVariables.LoggedUser.ToString());
                    GlobalVariables.LoggedUser.PhotoUrl = null;  //注册成功后的headPic为空
                    GlobalVariables.IsLogged            = true;
                    GlobalVariables.LoggedUser.EmpNo    = TelOrEmpNo;
                    GlobalVariables.LoggedUser.DBName   = DBName.dbName;

                    //MainPage mainPage = new MainPage();
                    //await Application.Current.MainPage.Navigation.PushAsync(mainPage);
                    MyNavigationPage myNavigationPage = new MyNavigationPage(new MainPage());
                    Application.Current.MainPage = myNavigationPage;
                }
                else
                {
                    CrossToastPopUp.Current.ShowToastError(baseResponse.Msg, ToastLength.Short);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public App()
        {
            InitializeComponent();

            MainPage = new MyNavigationPage(new MainPage());
        }
Exemple #8
0
 public App()
 {
     MainPage = new MyNavigationPage(new Views.MainPage());
 }