Example #1
0
        private async void btnTest_Click(object sender, RoutedEventArgs e)
        {
            TimeOnline.GameRoot game = null;

            try
            {
                game = await TheGamesDbHandler.GetGame(txbName.Text, _platformId, false, _dataModel.ScrapGuid);

                if (game == null || game.Games == null)
                {
                    searchResult.ItemsSource = new string[0];
                    MessageBox.Show("Found no games");
                    return;
                }

                searchResult.ItemsSource = game.Games.Select(g => g.GameTitle);
            }
            catch (Exception)
            {
            }
            finally
            {
                if (game != null)
                {
                    _dataModel.ScrapGuid = game.UserInfo.NewGuid;
                    LiteDBHelper.Save(_dataModel);
                }
            }
        }
        private void ChangePassword_Click(object sender, RoutedEventArgs e)
        {
            if (passwordRetype.Password != password2.Password)
            {
                txInfo.Text = "Password is not the same!";
                return;
            }
            var url     = RGHSettings.ScrapPath + "changepassword";
            var headers = new Dictionary <string, string>();

            headers.Add("email", email2.Text);
            headers.Add("password", password2.Password);
            headers.Add("secret", RGHSettings.ProgGuid);
            var info = JsonHandler.DownloadSerializedJsonData <Info>(url, headers);

            if (info.Error.Code > 299)
            {
                txInfo.Text = info.Error.Message;
                ErrorHandler.Warning(info.Error.Message);
            }
            else
            {
                txInfo.Text = info.Error.Message;;
            }
            brdInfo.Visibility = Visibility.Visible;
            data.ScrapEmail    = email.Text;
            data.ScrapGuid     = info.Guid;
            LiteDBHelper.Save(data);
        }
        private async void btnTest_Click(object sender, RoutedEventArgs e)
        {
            TimeOnline.GameRoot game = null;
            if (GeneralFunctions.IsFilenameInvalid(txbName.Text))
            {
                MessageBox.Show("Sorry Name Contains Invalid Chars!", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            try
            {
                game = await TheGamesDbHandler.GetGame(txbName.Text, _platformId, false, _dataModel.ScrapGuid);

                if (game == null || game.Games == null)
                {
                    MessageBox.Show("Found no games");
                    return;
                }
                var listGames = game.Games.Select(g => g.GameTitle);
                MessageBox.Show($"Found {game.Games.Count()} games.\n[{string.Join("],\n[", listGames.Take(5))}]{(listGames.Count() > 5 ? "\n...\nThe result is large, please improve the game name" : "")}", "Result", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception)
            {
            }
            finally
            {
                if (game != null)
                {
                    _dataModel.ScrapGuid = game.UserInfo.NewGuid;
                    LiteDBHelper.Save(_dataModel);
                }
            }
        }
Example #4
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);
            }
        }
Example #5
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);
            }
        }
        private void btnActivation_Click(object sender, RoutedEventArgs e)
        {
            var url     = RGHSettings.ScrapPath + "activate";
            var headers = new Dictionary <string, string>();

            headers.Add("email", email2.Text);
            headers.Add("activationcode", acctivationCode.Text);
            headers.Add("secret", RGHSettings.ProgGuid);
            var info = JsonHandler.DownloadSerializedJsonData <Info>(url, headers);

            if (info.Error.Code == 200)
            {
                data.ScrapGuid  = info.Guid;
                data.ScrapEmail = email.Text;
                ErrorHandler.Info(info.Error.Message);
                LiteDBHelper.Save(data);
                MessageBox.Show(info.Error.Message, "Result", MessageBoxButton.OK, MessageBoxImage.Information);
                this.DialogResult = true;
            }
            txInfo.Text = info.Error.Message;
        }
Example #7
0
        private async void MenuItem_Click_Search(object sender, RoutedEventArgs e)
        {
            var sendr = (MenuItem)sender;
            var dc    = (CollectionViewGroup)sendr.DataContext;
            var nm    = dc.Name.ToString();

            var item = (DownloadImageModel)dc.Items[0];// _vieModel.FtpListItem.Items.FirstOrDefault(s => s.Name.StartsWith(nm));

            if (item == null)
            {
                return;
            }
            var rnView = new SearchView(data, _vieModel.SelectedPlatform.Id);

            rnView.Title = $" Search for game";
            rnView.Owner = Window.GetWindow(this);
            rnView.Icon  = _vieModel.SelectedPlatform.BitmapImage;
            rnView.DownloadImageModel = item;
            var res = rnView.ShowDialog();

            if (res.HasValue && res.Value)
            {
                var ftpItem = FindFtpItem(_vieModel.FtpListItem.Items.FirstOrDefault(s => s.FullName == item.FullName || item.FullName.Contains(s.FullName)));

                if (ftpItem == null)
                {
                    return;
                }
                ftpItem.Name = item.Name;
                //item.FullName = item.FullName.Replace(Path.GetFileNameWithoutExtension(ftpItem.Name), item.Name);
                var PlatformId = _vieModel.SelectedPlatform.Id;
                await ScrapItem(ftpItem, PlatformId, false, true);

                LiteDBHelper.Save(data);
                await UpdateChar();

                var ch = new char[] { '!' };
                await updateDownloadImageList(true, ch);
            }
        }
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            var url     = RGHSettings.ScrapPath + "login";
            var headers = new Dictionary <string, string>();

            headers.Add("email", email.Text);
            headers.Add("password", password.Password);
            headers.Add("secret", RGHSettings.ProgGuid);
            var info = JsonHandler.DownloadSerializedJsonData <Info>(url, headers);

            if (info.Error.Code == 200)
            {
                data.ScrapGuid  = info.Guid;
                data.ScrapEmail = email.Text;
                LiteDBHelper.Save(data);
                this.DialogResult = true;
                ErrorHandler.Info(info.Error.Message);
                MessageBox.Show(info.Error.Message, "info", MessageBoxButton.OK, MessageBoxImage.Information);
                Close();
            }
            txInfo.Text        = info.Error.Message;
            brdInfo.Visibility = Visibility.Visible;
        }