コード例 #1
0
ファイル: LiteDBService.cs プロジェクト: wbtsai/DailyHome
 public LiteDBService(string connString)
 {
     LiteDBHelper.Open(connString, db =>
     {
         DataList = db.GetCollection <T>(Table);
     });
 }
コード例 #2
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);
                }
            }
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: JaoHundred/ANT
        protected async override void OnStart()
        {
            if (liteDB == null)
            {
                LiteDBHelper.StartLiteDB();
            }

            if (liteErrorLogDB == null)
            {
                LiteDBHelper.StartErrorLogLiteDB();
            }

            LiteDBHelper.MigrateLiteDB();

            // Handle when your app starts
            await ThemeManager.LoadThemeAsync();

            Jikan = new Jikan(useHttps: true);

            SettingsPreferences settings = StartSettings();

            if (settings.NotificationsIsOn && Device.RuntimePlatform == Device.Android)
            {
                await RunJobAsync(typeof(NotificationJob), WorkManagerConsts.AnimesNotificationWorkId);
            }


            //TODO: repetir o mesmo procedimento acima para essa parte, para o work de atualização de animes na lista de favoritos
            //(repetir também no BootBroadcastReceiver)
        }
コード例 #4
0
ファイル: LiteDBService.cs プロジェクト: wbtsai/DailyHome
 public LiteDBService()
 {
     LiteDBHelper.Open(db =>
     {
         DataList = db.GetCollection <T>(Table);
     });
 }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
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);
            }
        }
コード例 #8
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;
     });
 }
コード例 #9
0
        /// <summary>
        /// Salva resultados da exceção em log liteDB
        /// </summary>
        /// <param name="exception"></param>
        public static void SaveExceptionData(this System.Exception exception)
        {
            var error = new ErrorLog()
            {
                Message           = exception.Message,
                Source            = exception.Source,
                StackTrace        = exception.StackTrace,
                ExceptionDate     = DateTime.Now,
                ExceptionTypeName = exception.GetType().ToString(),
            };

            switch (exception)
            {
            case JikanRequestException ex:

                string responseCode = $"{ex.ResponseCode} { (int)ex.ResponseCode}";
#if DEBUG
                Console.WriteLine($"Problema encontrado em :{responseCode}");
#endif
                DependencyService.Get <IToast>().MakeToastMessageLong(responseCode);

                error.AdditionalInfo = responseCode;

                break;

            case System.Exception exc:
#if DEBUG
                Console.WriteLine($"Problema encontrado em :{exc.Message}");
#endif
                DependencyService.Get <IToast>().MakeToastMessageLong(Lang.Lang.Error);

                break;
            }

            if (App.liteErrorLogDB == null)
            {
                LiteDBHelper.StartErrorLogLiteDB();
            }

            var errorLogCollection = App.liteErrorLogDB.GetCollection <ErrorLog>();
            errorLogCollection.Insert(error);

#if DEBUG
            foreach (var exc in errorLogCollection.FindAll())
            {
                Console.WriteLine($"exceção encontrada em: {exc.Id} {exc.ExceptionTypeName} {exc.Message}");
            }
#endif
        }
コード例 #10
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);
            }
        }
コード例 #11
0
        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;
        }
コード例 #12
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);
            }
        }
コード例 #13
0
        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;
        }
コード例 #14
0
        public MainWindow()
        {
            InitializeComponent();
            ControllImages.Init();
            LiteDBHelper.init();
            TheGamesDbHandler.init();
            // Assembly.GetEntryAssembly().GetName().Version.ToString() + "-beta";
            RGHSettings.init();
            VersionText.Text = RGHSettings.Version;
            PageHandler.AddPage(new firstPage());
            PageHandler.AddPage(new RetroResorcesView());
            PageHandler.AddPage(new StartView());
            PageHandler.AddPage(new FtpSettingsView());
            PageHandler.AddPage(new OptionsView());
            PageHandler.AddPage(new ScrapFolderView());
            PageHandler.AddPage(new NotePad());
            PageHandler.AddPage(new LogView());
            PageHandler.AddPage(new AboutView());

            this.DataContext = PageHandler.Instance;
            PageHandler.SelectedPage <firstPage>();
            //PageHandler.SelectedPage<LogView>();
            ConsoleIconHelper.Init();
            ConsoleIconHelper.Close += (s, e) =>
            {
                this.Close();
            };
            ConsoleIconHelper.OpenConsole += (s, e) =>
            {
                this.WindowState = WindowState.Normal;
            };
            //PageHandler.ThePageChanged += (s, e) =>
            //{
            //    ContentControl.Content = PageHandler.Instans.Page;
            //};
            //PageHandler.SelectedPage<FtpSettingsView>();
        }
コード例 #15
0
 public Respository()
 {
     conStr = LiteDBHelper.GetConString();
 }
コード例 #16
0
ファイル: ModuleInfoDAL.cs プロジェクト: radtek/ToolManager
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(ModuleInfo model)
 {
     return(LiteDBHelper <ModuleInfo> .Update(LocalConfig.SettingDataFileName, model, TABLE_NAME));
 }
コード例 #17
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(GenerateConfig model)
 {
     return(LiteDBHelper <GenerateConfig> .Update(LocalConfig.SettingDataFileName, model, TABLE_NAME));
 }
コード例 #18
0
        public ActionResult Index()
        {
            //下载
            string url = "http://11185gz.com.cn/security/jcaptcha.jpg";
            int qty = 30;
            string type = "nubia";
            Task[] tasks = new Task[qty];
            List<Image> imgs = new List<Image>();
            for (int i = 0; i < qty; i++)
            {
                tasks[i] = Task.Factory.StartNew(() =>
                {
                    var result = new HttpHelper().GetHtml(new HttpItem()
                    {
                        URL = url.Contains("?") ? string.Format("{0}&t={1}", url, DateTime.Now.ToString("yyyyMMddHHmmsssss")) : string.Format("{0}?t={1}", url, DateTime.Now.ToString("yyyyMMddHHmmsssss")),
                        Method = "Get",
                        ResultType = ResultType.Byte
                    });
                    using (MemoryStream ms = new MemoryStream(result.ResultByte))
                    {
                        ms.Write(result.ResultByte, 0, result.ResultByte.Length);
                        imgs.Add(Image.FromStream(ms, true));
                    }
                });
            }
            Task.WaitAll(tasks);

            List<VCodeBinary> vCodeBinarys = new List<VCodeBinary>();
            Dictionary<string, Image> dictCutImgs = new Dictionary<string, Image>();
            foreach (var img in imgs)
            {
                try
                {
                    var imgList = ImageProcessHelper.PreProcess(img, 1, img.Width / 4, img.Height);
                    foreach (var cutImg in imgList)
                    {
                        string id = Guid.NewGuid().ToString("N");
                        vCodeBinarys.Add(new VCodeBinary()
                        {
                            Id = id,
                            Code = ImageProcessHelper.GetBinaryCode(cutImg),
                            Text = string.Empty,
                            Type = type,
                            CreateTime = DateTime.Now
                        });
                        dictCutImgs.Add(id, cutImg);
                        //cutImg.Save(string.Format(@"D:\USER\luojun\Desktop\vCode\{0}.jpg", id));
                        //cutImg.Dispose();
                    }
                    img.Dispose();
                }
                catch (Exception ex)
                {
                    LogHelper.Log(ex);
                }
            }
            var liteDBHelper = new LiteDBHelper("VCode.db");
            liteDBHelper.Insert<VCodeBinary>(vCodeBinarys);

            //相似分组
            int rate = 85;
            Dictionary<string, List<VCodeBinary>> dictVCodeBinarys = new Dictionary<string, List<VCodeBinary>>();
            foreach (var vCodeBinaryA in vCodeBinarys)
            {
                try
                {
                    var codes = new List<VCodeBinary>() {
                    vCodeBinaryA
                    };
                    foreach (var vCodeBinaryB in vCodeBinarys)
                    {
                        int thisRate = ImageProcessHelper.CalcRate(vCodeBinaryA.Code, vCodeBinaryB.Code);
                        if (thisRate >= rate)
                        {
                            codes.Add(vCodeBinaryB);
                        }
                    }
                    dictVCodeBinarys.Add(vCodeBinaryA.Id, codes);
                }
                catch (Exception ex)
                {
                    LogHelper.Log(ex);
                }
            }

            foreach (var key in dictVCodeBinarys.Keys)
            {
                string savePath = string.Format(@"H:\VCode\{0}", key);
                Directory.CreateDirectory(savePath);
                foreach (var vCodeBinary in dictVCodeBinarys[key])
                {
                    string imgFullName = Path.Combine(savePath, string.Format("{0}.jpg", vCodeBinary.Id));
                    dictCutImgs[vCodeBinary.Id].Save(imgFullName);
                    //dictCutImgs[vCodeBinary.Id].Dispose();
                }
            }
            return View();
        }
コード例 #19
0
 public PeopleRepository(IPlatformInfoService dbpathService)
 {
     _db = LiteDBHelper.GetInstance(dbpathService.GetLiteDBFilePath());
 }