コード例 #1
0
        private async void btnScrap_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                spPbScraping.Visibility    = Visibility.Visible;
                btnScrap.IsEnabled         = false;
                spUploadSettings.IsEnabled = false;
                _vieModel.DownloadList.Clear();
                _countAll = 0;
                data      = LiteDBHelper.Load <DataModel>().FirstOrDefault() ?? new DataModel()
                {
                    Id = 1, ScrapGuid = "", ScrapEmail = ""
                };
                var burl = await TheGamesDbHandler.GetGame("timeonlin9022", 1, false, data.ScrapGuid);

                if (errorHandling(burl.Error, 0))
                {
                    spPbScraping.Visibility    = Visibility.Collapsed;
                    status.Text                = "";
                    percent.Text               = "";
                    btnScrap.IsEnabled         = true;
                    spUploadSettings.IsEnabled = true;
                    return;
                }
                else
                {
                    data.ScrapGuid             = burl.UserInfo.NewGuid;
                    TheGamesDbHandler.BaseUrls = burl.BaseUrls;
                }
                //
                _cancelScrap      = false;
                getExistingImages = FtpHandler.Instance.List(_vieModel.FtpListItem.mFullName + "/media").Where(f => f.Name.EndsWith(".png")).Select(f => Path.GetFileNameWithoutExtension(f.Name));
                skipIfexists      = cbSkipExist.IsChecked.Value;
                //_ = Dispatcher.BeginInvoke((Action)(() => skipIfexists = cbSkipExist.IsChecked.Value));
                await ScrapingSearch(_vieModel.FtpListItem, cbUseDirectory.IsChecked.Value);

                spPbScraping.Visibility    = Visibility.Collapsed;
                status.Text                = "";
                percent.Text               = "";
                btnScrap.IsEnabled         = true;
                spUploadSettings.IsEnabled = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.Error(ex);
                Debug.WriteLine(ex);
            }
            finally
            {
                LiteDBHelper.Save(data);
            }
        }
コード例 #2
0
 public LoginView()
 {
     InitializeComponent();
     //this.DialogResult = false;
     this.Loaded += ((s, e) =>
     {
         data = LiteDBHelper.Load <DataModel>().FirstOrDefault() ?? new DataModel()
         {
             Id = 1, ScrapGuid = "", ScrapEmail = ""
         };
         email.Text = data.ScrapEmail;
         email2.Text = data.ScrapEmail;
     });
 }
コード例 #3
0
        private bool Login(int count = 0)
        {
            try
            {
                if (count >= 3)
                {
                    return(false);
                }
                var login = new LoginView();
                login.ShowDialog();
                if (!login.DialogResult.Value)
                {
                    return(false);
                }
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    data = LiteDBHelper.Load <DataModel>().FirstOrDefault() ?? new DataModel()
                    {
                        Id = 1, ScrapGuid = "", ScrapEmail = ""
                    };
                    var burl = new GameRoot();
                    var task = Task.Run(async() =>
                    {
                        burl = await TheGamesDbHandler.GetGame("¤", 1, false, data.ScrapGuid);
                    });
                    task.Wait();

                    _ = errorHandling(burl.Error, count);

                    data.ScrapGuid = burl.UserInfo.NewGuid;
                    LiteDBHelper.Save(data);
                    TheGamesDbHandler.BaseUrls = burl.BaseUrls;
                }));
                return(true);
            }
            catch (Exception ex)
            {
                ErrorHandler.Error(ex);
                return(false);
            }
        }