/// <summary> /// 获取配置信息 /// </summary> /// <returns></returns> public T_Config GetConfig() { try { T_Config config = new T_Config(); //string id = Db.Context_SqlServer.FromSql("select logname from T_Agent where logname='888999'").ToScalar<string>(); config = Db.Context_Sqlite.From <T_Config>().Where(d => d.id == 999).ToFirst(); if (config == null) { config.id = 999; config.Ip = "127.0.0.1"; config.Port = 27000; config.IsAutoCut = 1; config.AutoCutTime = 30; config.LockPass = CommonHelper.MD5("123"); Db.Context_Sqlite.Insert <T_Config>(); } return(config); } catch (Exception ex) { LogHelper.WriteLog(typeof(T_ConfigDAL), ex); return(null); } }
public bool UpdateConfig(T_Config model) { try { return(configDal.UpdateConfig(model)); } catch (Exception ex) { LogHelper.WriteLog(typeof(T_ConfigBLL), ex); return(false); } }
/// <summary> /// 修改配置 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateConfig(T_Config model) { try { return(Db.Context_Sqlite.Update <T_Config>(model) > 0); } catch (Exception ex) { LogHelper.WriteLog(typeof(T_ConfigDAL), ex); return(false); } }
public MainViewModel() { var platform = DependencyService.Get <ISQLitePlatform>(); SQLiteConnection db = platform.GetConnection(); try { #region Verify Tables var resultTitem = db.GetTableInfo("T_Entry"); if (resultTitem.Count == 0) { db.CreateTable <T_Entry>(); } var resultTappuser = db.GetTableInfo("T_Appuser"); if (resultTappuser.Count == 0) { db.CreateTable <T_Appuser>(); } var resultTconfig = db.GetTableInfo("T_Config"); if (resultTconfig.Count == 0) { db.CreateTable <T_Config>(); T_Config t_Config = new T_Config { ItemsOrder = "IconTitle", FingerPrintAllow = false }; var resultDB = db.Insert(t_Config); if (resultDB != 1) { throw new Exception("No se pudo crear la configuración inicial."); } } #endregion } catch (SQLiteException sqlex) { Application.Current.MainPage.DisplayAlert("ERROR", "Ocurrió un error.", "Aceptar"); } instance = this; this.Login = new LoginViewModel(); this.Register = new RegisterViewModel(); this.HomePage = new HomePageViewModel(); this.HomePageMaster = new HomePageMasterViewModel(); this.HomePageDetail = new HomePageDetailViewModel(); this.AddItem = new AddItemViewModel(); this.ViewItem = new ViewItemViewModel(new Models.T_Entry()); this.EditItem = new EditItemViewModel(new Models.T_Entry()); this.Security = new SecurityViewModel(); this.Options = new OptionsViewModel(); }
public LoginViewModel() { var platform = DependencyService.Get <ISQLitePlatform>(); db = platform.GetConnection(); this.IsEnabled = true; //this.Password = "******"; try { GetFingerPrintAvailable(); if (fpisavailable) { IEnumerable <T_Config> getConfigApp = GetConfigApp(db); T_Config t_Config = getConfigApp.ToList <T_Config>()[0]; if (t_Config.FingerPrintAllow) { this.PasswordIsVisible = false; this.FingerPrintIsVisible = true; } else { this.PasswordIsVisible = true; this.FingerPrintIsVisible = false; } } else { IEnumerable <T_Config> getConfigApp = GetConfigApp(db); T_Config t_Config = getConfigApp.ToList <T_Config>()[0]; if (t_Config.FingerPrintAllow) { var changeData = new T_Config { Id = t_Config.Id, ItemsOrder = t_Config.ItemsOrder, FingerPrintAllow = false }; var resultDB = db.Update(changeData); } this.PasswordIsVisible = true; this.FingerPrintIsVisible = false; } } catch (SQLiteException sqlex) { Application.Current.MainPage.DisplayAlert(Languages.ExceptionLiteral1, Languages.ExceptionLiteral2, Languages.ExceptionLiteral3); return; } }
public SecurityViewModel() { var platform = DependencyService.Get <ISQLitePlatform>(); db = platform.GetConnection(); IsEnabled = true; try { IEnumerable <T_Appuser> getAppUser = GetAppUser(db, "ApplicationUser"); if (getAppUser.ToList <T_Appuser>().Count != 0) { t_Appuser = getAppUser.ToList <T_Appuser>()[0]; } GetFingerPrintAvailable(); if (fpisavailable) { IEnumerable <T_Config> getConfigApp = GetConfigApp(db); t_Config = getConfigApp.ToList <T_Config>()[0]; if (t_Config.FingerPrintAllow) { ScIsEnabled = true; SwIsEnabled = true; SwIsToggled = true; } else { ScIsEnabled = true; SwIsEnabled = true; SwIsToggled = false; } } else { SwIsToggled = false; SwIsEnabled = false; ScIsEnabled = false; } } catch (SQLiteException sqlex) { Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.ExceptionLiteral2, Languages.ExceptionLiteral3); return; } }
/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WatchWindow_Load(object sender, EventArgs e) { try { T_Config config = configBll.GetConfig(); cmb_IP.Items.AddRange(CommonHelper.GetLocIps()); cmb_IP.Text = config.Ip; _Lockpass = config.LockPass; txtB_Port.Text = config.Port.ToString(); btn_Start_Click(sender, e); } catch (Exception ex) { LogHelper.WriteLog(typeof(WatchWindow), ex); } }
private async void Save() { this.ScIsEnabled = false; try { var changeData = new T_Config { Id = t_Config.Id, ItemsOrder = t_Config.ItemsOrder, FingerPrintAllow = SwIsToggled }; var resultDB = db.Update(changeData); if (resultDB == 1) { this.ScIsEnabled = true; if (SwIsToggled) { await Application.Current.MainPage.DisplayAlert( Languages.AppLiteral1, Languages.SecurityLiteral4, Languages.ExceptionLiteral3); } else { await Application.Current.MainPage.DisplayAlert( Languages.AppLiteral1, Languages.SecurityLiteral5, Languages.ExceptionLiteral3); } } else { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.SecurityLiteral6, Languages.ExceptionLiteral3); return; } } catch (SQLiteException sqlex) { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.ExceptionLiteral2, Languages.ExceptionLiteral3); return; } }
/// <summary> /// 窗体加载完成 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetConfig_Load(object sender, EventArgs e) { _returnVal = false; _config = new T_Config(); if (_config != null) { string s = CommonHelper.GetLocIps()[0]; tB_IP.Text = string.IsNullOrEmpty(_config.Ip) ? s : _config.Ip; tB_Port.Text = _config.Port.ToString(); tB_Times.Text = _config.AutoCutTime.ToString(); tB_RecIP.Text = _config.RecIp; if (_config.IsAutoCut == 1) { cB_Auto.Checked = true; } else { cB_Auto.Checked = false; } } }