void insertData() { Commands ic = new Commands(); UIService.Execute(async() => { if (HIOStaticValues.TPinStatus()) { int res = ic.Insert(EditingObject.Url, EditingObject.Username, EditingObject.Name, EditingObject.Password); try { HIOStaticValues.tmain?.AccountManager?.LoadData(); HIOStaticValues.tmain?.AccountManager?.OnPropertyChanged(nameof(TAccountManagerViewModel.IsAllChecked)); } catch { /*TODO: remove try catch*/ } if (res == 1) { System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (!IsClosed) { Close(); } })); } } }).Wait(); }
private void Apply() { //TODO:Validate data //TODO:Save Changes var isInvalid = false; if (HIOStaticValues.TPinStatus()) { if (EditingObject.Name.TrimStart() == "") { _Form.titleRequiredImage.Visibility = Visibility.Visible; EditingObject.Name = " "; isInvalid = true; } if (EditingObject.Url != null && EditingObject.Url.TrimStart() == "") { _Form.urlRequiredImage.Visibility = Visibility.Visible; EditingObject.Url = " "; isInvalid = true; } if (EditingObject.Password == null) { EditingObject.Password = ""; } if (isInvalid) { return; } HIOStaticValues.commandQ.Add(() => QUpdateUserAsync()); } }
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(); } }
public void CopyPassword() { Task.Run(() => { try { if (HIOStaticValues.TPinStatus()) { Commands ic = new Commands(); Converts conv = new Converts(); int userIdInt = Int32.Parse(UserID); byte[] rowidByteArray = BitConverter.GetBytes(userIdInt); while (true) { StatusPassword sp = ic.GetPassword(rowidByteArray); if (sp.statusWord != null && sp.statusWord.SequenceEqual(new byte[] { 0x69, 0x85 })) { var res = System.Windows.Application.Current.Dispatcher.Invoke(new Func <bool>(() => { return(HIOStaticValues.AdminExtention.Extention06a.Show()); })); if (!res) { return; } } else if (sp.statusWord.SequenceEqual(new byte[] { 0x90, 0x00 })) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { Clipboard.SetDataObject(sp.pass); })); break; } } } } catch (Exception ex) { } }); }
public async Task ExportUsersAsync(List <LoginFieldS> lf, string fileName) { string jsonData = ""; int counter = 0; await UIService.Execute(async() => { foreach (LoginFieldS user in lf) { try { counter++; if (user.rowid == "") { continue; } if (HIOStaticValues.TPinStatus()) { Commands ic = new Commands(); int rowidInt = Int32.Parse(user.rowid); byte[] rowidByteArray = BitConverter.GetBytes(rowidInt).ToArray(); while (true) { StatusPassword sp = ic.GetPassword(rowidByteArray); if (sp.statusWord != null && sp.statusWord.SequenceEqual(new byte[] { 0x69, 0x85 })) { var res = System.Windows.Application.Current.Dispatcher.Invoke(new Func <bool>(() => { return(HIOStaticValues.AdminExtention.Extention06a.Show()); })); if (!res) { return; } } else if (sp.statusWord.SequenceEqual(new byte[] { 0x90, 0x00 })) { System.Windows.Application.Current.Dispatcher.Invoke(new Func <bool>(() => { ProcessExport = counter * 100 / lf.Count + "%"; return(true); })); jsonData += $@"{{""username"": ""{user.userName}"",""password"": ""{sp.pass}"",""url"": ""{user.url}"",""title"": ""{user.title}"",""appid"": ""{user.appID}"",""counter"": ""{user.popularity}"",""last_used"":""{user.last_used}""}} "; break; } } } } catch (Exception ex) { continue; } } ProcessExport = ""; using (var file = new StreamWriter(fileName, true)) { file.WriteLine(jsonData); file.Close(); } }); }
private void OnSelectedItemChanged() { if (SelectedItem != null) { DataBase db = new DataBase(); Dictionary <string, string> dicData = new Dictionary <string, string>(); db.Update_LastUsed_User(SelectedItem.Id.ToString()); HIOStaticValues.username = SelectedItem.Description; byte[] rowidByteArray = BitConverter.GetBytes(SelectedItem.Id).ToArray(); ///////////////////////////////////////////// if (SelectedItem.Url == url) { if (GetPass) { if (HIOStaticValues.TPinStatus()) { string pass = HIOStaticValues.BaS.GetPassFromSwitch(rowidByteArray).pass; dicData.Add("CMD", "PASS"); dicData.Add("DATA", pass); HIOStaticValues.BaS.Write(dicData, Source, true); } } else { dicData.Add("CMD", "CHECKREADYUSER"); HIOStaticValues.username = SelectedItem.Description; HIOStaticValues.BaS.Write(dicData, Source, false); } } else { /////////////////////////////////////////////add user from another url if (GetPass) { if (HIOStaticValues.TPinStatus()) { string pass = HIOStaticValues.BaS.GetPassFromSwitch(rowidByteArray).pass; dicData.Add("CMD", "PASS"); dicData.Add("DATA", pass); HIOStaticValues.BaS.Write(dicData, Source, true); } } else { if (!db.CheckExistUser(SelectedItem.Description, url)) { if (HIOStaticValues.TPinStatus()) { if (HIOStaticValues.BaS.UpdateSwitch(SelectedItem.Id.ToString(), url, "", SelectedItem.Title, SelectedItem.Description, "", 0x0) == 0) { if (db.UpdateDBFromRowID(SelectedItem.Id.ToString(), url, "", SelectedItem.Title, SelectedItem.Description)) { HIOStaticValues.username = SelectedItem.Description; dicData.Add("CMD", "CHECKREADYUSER"); HIOStaticValues.BaS.Write(dicData, Source, false); } else { HIOStaticValues.popUp("Sorry,We have a problem while update record\nPlease try again."); } } else { HIOStaticValues.popUp("Sorry,We have a problem while update record\nPlease try again."); } } } else { HIOStaticValues.popUp("This user already exists,You can modify it in the Edit Form."); } } } Close(); } }