public async void Delete() { Commands cmd = new Backend.Commands(); if (TMessageBox.Show("Are you sure you want to delete this account?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { while (true) { var res = cmd.AmISync(); if (res == SyncronizingStateEnum.Synced) { break; } else { HIOStaticValues.SyncOpration(); } } await UIService.Execute(async() => { Commands ic = new Commands(); ic.Delete(UserID); await Parent.LoadData(); }); Parent?.OnPropertyChanged(nameof(TAccountManagerViewModel.IsAllChecked)); } }
private void Apply() { if (NewPin?.Length != 6) { ErrorMessage = "Your pin code must be 6 characters."; return; } if (NewPin != ReEnterNewPin) { ErrorMessage = "Pins do not match, please retype."; return; } Backend.Commands cmd = new Backend.Commands(); int res = cmd.SetPin(NewPin); NewPin = null; ReEnterNewPin = null; ErrorOK(); switch (res) { case 1: // SecurityManager.DisablePersonalPin(); ErrorMessage = null; Parent.IsPinEnabled = true; AllSet = true; break; default: ErrorMessage = "Something went wrong!"; break; } }
private void Apply() { Backend.Commands cmd = new Backend.Commands(); if (CurrentPin?.Length != 6 || NewPin?.Length != 6) { ErrorMessage = "Your pin code must be 6 characters."; return; } if (NewPin != ReEnterNewPin) { ErrorMessage = "Pins do not match, please retype."; return; } //Validate Pin // Parent.ChangePersonalPin(NewPin); var changePinResult = cmd.ChangePin(CurrentPin, NewPin); CurrentPin = null; NewPin = null; ReEnterNewPin = null; ErrorOK(); var hioDisabledMessage = "HIO is disabled\nTry again in {TimeRemaining}"; ErrorMessageExpiry = null; switch (changePinResult) { case -1: ErrorMessageExpiry = TimeSpan.FromMinutes(1); ErrorMessage = hioDisabledMessage; return; case -2: ErrorMessageExpiry = TimeSpan.FromMinutes(5); ErrorMessage = hioDisabledMessage; return; case -3: ErrorMessageExpiry = TimeSpan.FromMinutes(10); ErrorMessage = hioDisabledMessage; return; case -4: ErrorMessageExpiry = TimeSpan.FromHours(1); ErrorMessage = hioDisabledMessage; return; case 0: ErrorMessage = "Wrong pincode"; return; case -5: ErrorMessage = "Something went wrong!"; return; } ErrorOK(); _Form.Close(); }
private void SubmitPersonalPin() { Commands cmd = new Backend.Commands(); var pinVerificationResult = cmd.SetPin(PersonalPin); PersonalPin = null; PersonalPinErrorMessage = null; if (pinVerificationResult == 1) { HIOStaticValues.tmain.IsPinRequired = false; ShowResetPersonalPin = false; if (SetupWizard != null) { SetupWizard.MoveNextPage(); } OnSubmit?.Invoke(this, EventArgs.Empty); } else { HIOStaticValues.tmain.IsPinRequired = true; PersonalPinErrorMessage = "Wrong pincode"; switch (pinVerificationResult) { case 0: PinLockEnd = null; break; case -1: PinLockEnd = DateTime.Now.AddMinutes(1); break; case -2: PinLockEnd = DateTime.Now.AddMinutes(5); break; case -3: PinLockEnd = DateTime.Now.AddMinutes(10); break; case -4: PinLockEnd = DateTime.Now.AddHours(1); break; default: PersonalPinErrorMessage = null; SetPersonalPinFooterErrorMessage("Something went wrong!"); HIOStaticValues.PinInputDashboardVM?.OnPropertyChanged(nameof(PersonalPinFooterErrorMessage)); HIOStaticValues.PinInputExtensionVM?.OnPropertyChanged(nameof(PersonalPinFooterErrorMessage)); PinLockEnd = null; break; } } }
private void Dt_CheckConnection(object sender, EventArgs e) { HIOStaticValues.commandQ.Add(() => { Commands rssiCheck = new Backend.Commands(); rssiCheck.IsConnection(); App.Current.Dispatcher.Invoke(new Action(() => { SignalValue = rssiCheck.GetSignalStatus(HIOStaticValues.blea.rssi); })); }); }
private void Add() { if (HIOStaticValues.TPinStatus()) { Commands cmd = new Backend.Commands(); cmd.Insert(_lf.url, Username, Title, Password); try { HIOStaticValues.tmain?.AccountManager?.LoadData(); HIOStaticValues.tmain?.AccountManager?.OnPropertyChanged(nameof(TAccountManagerViewModel.IsAllChecked)); } catch { /*TODO: remove try catch*/ } Close(); } }
private void ResetPersonalPinOK() { ShowResetPersonalPin = false; Commands cmd = new Backend.Commands(); if (!cmd.EraseAll()) { HIOStaticValues.popUp("Something went wrong!"); return; } if (SetupWizard != null) { SetupWizard.ActivePage = SetupWizard.Pages.First(t => t is TNewDeviceAddingPage1); } }
private async void Delete() { if (HIOStaticValues.CheckSyncingData()) { return; } if (TMessageBox.Show("Are you sure you want to delete these accounts?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Commands cmd = new Backend.Commands(); while (true) { var res = cmd.AmISync(); if (res == SyncronizingStateEnum.Synced) { break; } else { HIOStaticValues.SyncOpration(); } } await UIService.Execute(async() => { DataBase db = new DataBase(); foreach (var item in SourceItems.Where(t => t.IsChecked).ToArray()) { Commands ic = new Commands(); if (ic.Delete(item.UserID)) { App.Current.Dispatcher.BeginInvoke((Action)(() => { SourceItems.Remove(SourceItems.FirstOrDefault(i => i.UserID == item.UserID)); OnPropertyChanged(nameof(Items)); })); } } await LoadData(); }); OnPropertyChanged(nameof(IsAllChecked)); } }
private void Apply() { Backend.Commands cmd = new Backend.Commands(); int res = cmd.DisablePin(PersonalPin); var hioDisabledMessage = "HIO is disabled\nTry again in {TimeRemaining}"; ErrorMessageExpiry = null; PersonalPin = null; ErrorOK(); switch (res) { case -1: ErrorMessageExpiry = TimeSpan.FromMinutes(1); ErrorMessage = hioDisabledMessage; return; case -2: ErrorMessageExpiry = TimeSpan.FromMinutes(5); ErrorMessage = hioDisabledMessage; return; case -3: ErrorMessageExpiry = TimeSpan.FromMinutes(10); ErrorMessage = hioDisabledMessage; return; case -4: ErrorMessageExpiry = TimeSpan.FromHours(1); ErrorMessage = hioDisabledMessage; return; case 0: ErrorMessage = "Incorrect personal pin"; return; case -5: ErrorMessage = "Something went wrong!"; return; } ErrorOK(); SecurityManager.IsPinEnabled = false; _Form.Close(); }
public async Task LoadingAsync() { try { if (HIOStaticValues.CheckSyncingData()) { SyncronizingState = SyncronizingStateEnum.Syncronizing; Trace.WriteLine("SyncronizingState in dashboard:" + SyncronizingState); Trace.WriteLine("percent in dashboard:" + ProgressPercent); DispatcherTimer dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromSeconds(1); dt.Tick += Dt_Tick; dt.Start(); return; } App.Current.Dispatcher.Invoke(new Action(() => { SourceItems.Clear(); })); Converts conv = new Converts(); DataBase db = new DataBase(); // HIOStaticValues.commandQ.Add(()=> QBatteryandSignalCheckAsync()); Commands ic = new Commands(); HIOStaticValues.commandQ.Add(() => { BatteryValue = ic.GetBatteryStatus(); }); HIOStaticValues.commandQ.Add(() => { Commands cmd = new Backend.Commands(); cmd.GetRssi(); App.Current.Dispatcher.Invoke(new Action(() => { SignalValue = cmd.GetSignalStatus(HIOStaticValues.blea.rssi); })); }); HIOStaticValues.commandQ.Add(() => { App.Current.Dispatcher.Invoke(new Action(async() => { SyncronizingState = ic.AmISync(); if (SyncronizingState == SyncronizingStateEnum.NotSynced) { await Syncronize(); } })); }); App.Current.Dispatcher.Invoke(new Action(async() => { //READ DATA lp = await Task.Run(() => { return(db.ReadData()); }); if (lp != null) { ItemCounter = (lp.Count > 1) ? lp.Count + " Items" : lp.Count + " Item"; } //Note : lp may be null if (lp != null && lp.Any()) { #region Load Data List <TAccountItem> items = new List <TAccountItem>(); foreach (var item in lp) { DrawingImage tmpDraw = new DrawingImage(); if (item.imageData == null || item.imageData.Length == 0) { tmpDraw = HIOStaticValues.PutTextInImage(item.url.Substring(0, 1)); } else { tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(item.imageData)); } items.Add(new TAccountItem(this) { UserID = item.rowid, Name = item.title, Username = item.userName, Url = item.url, ImageData = tmpDraw, AppID = item.appID, SubTitle1 = item.userName, SubTitle2 = conv.GetPrettyDate(item.last_used), Popularity = item.popularity, Date = item.last_used }); // items.Add(new User() { Title = listlp[i].title, Username = listlp[i].userName, rowid = listlp[i].rowid }); } #endregion #region Sort Data if (SortByField.IsNullOrEmpty() || "Name".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderBy(t => t.Name).ToList(); } else if ("Date".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Date).ToList(); } else if ("Popularity".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Popularity).ToList(); } #endregion #region Add Data foreach (var item in items) { SourceItems.Add(item); } #endregion } OnPropertyChanged(nameof(Items)); })); } catch (Exception ex) { } finally { NotifyItemsChanged(); } }
private void QresetSync() { Commands cmd = new Backend.Commands(); cmd.ResetSync(); }
private async void StartImportingAsync() { if (HIOStaticValues.CheckSyncingData()) { return; } List <LoginFieldS> listUser = new List <LoginFieldS>(); try { if (HIOStaticValues.CONNECTIONBHIO == true) { Commands cmd = new Backend.Commands(); int userImported = 0; DataBase dbLocal = new DataBase(); LabelImport: if (cmd.AmISync() == SyncronizingStateEnum.Synced) { IsImporting = true; await Task.Run(() => { Backup bk = new Backup(); Chrome chrome = new Chrome(); Firefox firefox = new Firefox(); Edge edge = new Edge(); double progress = ImportProgressPercent; // var itemList = Items.Where(t => t.IsChecked); foreach (var item in Items.Where(t => t.IsChecked)) { if (item.Title == "Load Backup") { listUser.AddRange(bk.LoadBackup()); } if (item.Title == "Google Chrome") { listUser.AddRange(chrome.getDataFromChrome()); } if (item.Title == "Mozilla Firefox") { listUser.AddRange(firefox.FetchPassword()); } if (item.Title == "Edge") { listUser.AddRange(edge.ReadPasswords()); } } listUser = listUser.Distinct(new loginFieldsCompare()).ToList(); int rows = listUser.Count; // ImportVisible = true; try { HIOStaticValues.IMPORT_ON = true; if (rows == 0) { MessageErr = "No account exist in your browsers"; return; } for (int i = 0; i < rows; i++) { ImportProgressPercent = (progress == 0) ? (i * 100) / (rows) : progress + ((i * 100) / (rows)) / 2; int res = HIOStaticValues.BaS.InsertToSwitch(new LoginFieldS { password = listUser[i].password, userName = listUser[i].userName, title = listUser[i].title, url = listUser[i].url }); if (res <= 0) { if (res == -2) { throw new Exception($"Time out.\n {i} accounts are imported successfully from {rows} accounts"); } if (res == -3) { throw new Exception($"No space is available.\n {userImported} accounts are imported successfully"); } break; } userImported++; dbLocal.insertToDatabase(res.ToString(), listUser[i].url, (string)listUser[i].userName, "", listUser[i].title); } } catch (SQLiteException ex) when(ex.ErrorCode == 5) { MessageErr = $"HIO needs to close all browsers!{Environment.NewLine}Please save or close your Tabs if your are using any browsers."; return; } catch (Exception ex) { MessageErr = ex.Message; return; } HIOStaticValues.IMPORT_ON = false; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { IsImporting = false; ImportVisible = false; ImportProgressPercent = 0; IsComplete = true; // if (db_way2 != "") // System.IO.File.Delete(db_way2); })); }); if (Items.Any(t => t.IsChecked)) { MoveNextPage(); } } else { HIOStaticValues.popUp("You are not sync!\nPlease wait,We are syncing data..."); IsImporting = true; DispatcherTimer dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromSeconds(1); dt.Tick += Dt_Tick; dt.Start(); int res = await Task.Run(() => { DataBase db = new DataBase(); Commands resetCmd = new Backend.Commands(); resetCmd.ResetSync(); return(resetCmd.Sync()); }); dt.Stop(); if (res == 1) { goto LabelImport; } } } else { TMessageBox.Show("HIO is not connect!"); } } finally { IsImporting = false; HIOStaticValues.IMPORT_ON = false; } }