private async Task ResetAsync()
        {
            if (HIOStaticValues.CheckSyncingData())
            {
                return;
            }
            HIOStaticValues.tmain.AccountManager.SourceItems.Clear();
            await UIService.Execute(async() =>
            {
                if (HIOStaticValues.CheckSyncingData())
                {
                    return;
                }
                if (HIOStaticValues.CONNECTIONBHIO == true)
                {
                    Commands ic = new Commands();
                    if (!ic.EraseAll())
                    {
                        HIOStaticValues.popUp("Something went wrong!");
                    }
                }
                else
                {
                    HIOStaticValues.popUp("HIO is not connect!");
                }
            });

            //Application.Current.Dispatcher.Invoke(new Action(() =>
            //{
            //    AddNewDevice();
            //}));
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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 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));
            }
        }
 public async Task LoadPage()
 {
     try
     {
         if (HIOStaticValues.CheckSyncingData())
         {
             return;
         }
         await UIService.Execute(async() =>
         {
             if (HIOStaticValues.CONNECTIONBHIO == false)
             {
                 Exapnder = true;
             }
             else
             {
                 Exapnder = false;
             }
             if (HIOStaticValues.CheckSyncingData())
             {
                 return;
             }
             Commands ic   = new Commands();
             Converts conv = new Converts();
             if (HIOStaticValues.CONNECTIONBHIO == true)
             {
                 HIOStaticValues.commandQ.Add(() =>
                 {
                     //Get VersioN
                     ic.GetVersion();
                     //  await Task.Run(() => { ic.GetVersion(); });
                     MyHIOTitle   = Encoding.UTF8.GetString(HIOStaticValues.blea.name).Replace("\0", "");
                     MyHIOVersion = "Version: " + HIOStaticValues.blea.ver;
                     MyHIOMac     = "MAC: " + conv.ByteToChar(HIOStaticValues.blea.mac[0]) + ":" + conv.ByteToChar(HIOStaticValues.blea.mac[1]) + ":" + conv.ByteToChar(HIOStaticValues.blea.mac[2]) + ":" + conv.ByteToChar(HIOStaticValues.blea.mac[3]) + ":" + conv.ByteToChar(HIOStaticValues.blea.mac[4]) + ":" + conv.ByteToChar(HIOStaticValues.blea.mac[5]);
                 });
                 //IsConnecting = true;
             }
         });
     }
     catch (Exception ex)
     {
     }
     finally { }
 }
        private void Save(object obj)
        {
            if (AccountItem.Name == null || AccountItem.Name.TrimStart() == "")
            {
                //   _form.titleRequiredImage.Visibility =Visibility.Visible;

                //   AccountItem.Name = " ";
                return;
            }
            if (AccountItem.Url == null || AccountItem.Url.TrimStart() == "")
            {
                //  _form. urlRequiredImage.Visibility = Visibility.Visible;

                //     AccountItem.Url = " ";
                return;
            }
            if (AccountItem.Password == null || AccountItem.Password.TrimStart() == "")
            {
                // _form. passRequiredImage.Visibility = Visibility.Visible;

                return;
            }

            HIOStaticValues.CheckingData(AccountItem);

            HIOStaticValues.commandQ.Add(async() =>
            {
                await UIService.Execute(async() =>
                {
                    Commands ic = new Commands();
                    if (ic.Insert(AccountItem.Url, AccountItem.Username, AccountItem.Name, AccountItem.Password) == 1)
                    {
                        Parent.LoadData();
                        Close();
                    }
                });
            });
        }
 async Task QUpdateUserAsync()
 {
     try
     {
         await UIService.Execute(() =>
         {
             Commands ic = new Commands();
             HIOStaticValues.CheckingData(EditingObject);
             bool res = ic.UpdateUser(EditingObject.UserID, EditingObject.Url, EditingObject.AppID, EditingObject.Name, EditingObject.Username, EditingObject.Password, flagPass);
             if (res)
             {
                 Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                 {
                     IsSaving = true;
                     EditingObject.EndEdit();
                     if (_Form?.Owner == null) /*from extension*/
                     {
                         try
                         {
                             HIOStaticValues.tmain?.AccountManager?.LoadData();
                             HIOStaticValues.tmain?.AccountManager?.OnPropertyChanged(nameof(TAccountManagerViewModel.IsAllChecked));
                         }
                         catch { /*TODO: remove try catch*/ }
                     }
                     if (_Form.IsVisible)
                     {
                         _Form.Close();
                     }
                 }));
             }
         });
     }
     finally
     {
         IsSaving = false;
     }
 }
        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();
                }
            });
        }