コード例 #1
0
 public void Update(Account currentAccount)
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.Update(currentAccount);
     }
 }
コード例 #2
0
 public void Add(Account acc)
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.Insert(acc);
     }
 }
コード例 #3
0
ファイル: AccountManager.cs プロジェクト: boubou10/HFR10
        async Task Initialize()
        {
            var accounts = accountDataRepository?.GetAccounts();
            if (accounts != null && accounts.Any())
            {
                Accounts = accounts;
                if (accounts.Count == 1)
                {
                    CurrentAccount = accounts[0];
#warning "Optimistic: any account/cookies is supposed valid, proper implementation needed (cookies timeout check)"
                    await ThreadUI.Invoke(() =>
                    {
                        Loc.NavigationService.Navigate(View.Connect);
                        Loc.Main.AccountManager.CurrentAccount.ConnectionErrorStatus = "Connecting";
                        Loc.Main.AccountManager.CurrentAccount.IsConnecting = true;
                    });
                    bool success = await CurrentAccount.BeginAuthentication(false);
                    if (success)
                    {
                        await ThreadUI.Invoke(() =>
                        {
                            Loc.Main.AccountManager.CurrentAccount.IsConnected = false;
                            Loc.NavigationService.Navigate(View.Main);
                        });
                    }
                    else
                    {
                        Debug.WriteLine("Login failed");
                    }
                }
                else
                {
                    // Handle selection of one of the multi accounts
                }
            }
            else
            {
                // navigate to connectpage
                await ThreadUI.Invoke(() =>
                {
                    CurrentAccount = new Account();
                    Loc.NavigationService.Navigate(View.Connect);
                    // Trying to detect login and password stored in RoamingSettings
                    if (ApplicationSettingsHelper.Contains(nameof(CurrentAccount.Pseudo), false) && ApplicationSettingsHelper.Contains(nameof(CurrentAccount.Password), false))
                    {
                        ToastHelper.Simple("Connexion automatique ...");
                        var pseudo = ApplicationSettingsHelper.ReadSettingsValue(nameof(CurrentAccount.Pseudo), false).ToString();
                        var password = ApplicationSettingsHelper.ReadSettingsValue(nameof(CurrentAccount.Password), false).ToString();
                        CurrentAccount.Pseudo = pseudo;
                        CurrentAccount.Password = password;
                        ConnectCommand.Execute(null);
                    }
                });
            }
        }
コード例 #4
0
ファイル: ConnectHelper.cs プロジェクト: FLKone/HFR4WinRT
        static async Task GetAvatar(Account account)
        {
            var html = await HttpClientHelper.Get(HFRUrl.ProfilePageUrl, Loc.Main.AccountManager.CurrentAccount.CookieContainer);
            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(html);

            string[] userAvatarFileArray = htmlDoc.DocumentNode.Descendants("img").Where(x => x.GetAttributeValue("src", "").Contains("http://forum-images.hardware.fr/images/mesdiscussions-")).Select(y => y.GetAttributeValue("src", "")).ToArray();

            if (userAvatarFileArray.Length != 0)
            {
                await ThreadUI.Invoke(() => account.AvatarId = userAvatarFileArray[0].Split('/')[4].Replace(".jpg", "").Replace("mesdiscussions-", ""));
            }
        }
コード例 #5
0
ファイル: AccountManager.cs プロジェクト: FLKone/HFR4WinRT
 async Task Initialize()
 {
     var accounts = accountDataRepository?.GetAccounts();
     if (accounts != null && accounts.Any())
     {
         Accounts = accounts;
         if (accounts.Count == 1)
         {
             CurrentAccount = accounts[0];
             bool success = await CurrentAccount.BeginAuthentication(false);
             if (success)
             {
                 await ThreadUI.Invoke(() =>
                 {
                     Loc.NavigationService.Navigate(Page.Main);
                 });
             }
             else
             {
                 Debug.WriteLine("Login failed");
             }
         }
         else
         {
             // Handle seletion of one of the multi accounts
         }
     }
     else
     {
         // navigate to connectpage
         await ThreadUI.Invoke(() =>
         {
             CurrentAccount = new Account();
             Loc.NavigationService.Navigate(Page.Connect);
         });
     }
 }