コード例 #1
0
        public static void init()
        {
            ProgramSetting = LiteDBHelper.RGHGetData();
            var asse    = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
            var version = $"{asse.Major}.{asse.Minor}.{asse.Build}";

            Version = version;
        }
コード例 #2
0
 private static void Log(ErrorEntity errorEntity)
 {
     System.Diagnostics.Debug.WriteLine(errorEntity.ToString());
     if (RGHSettings.LogLevel >= errorEntity.ErrorLevel)
     {
         LiteDBHelper.Save(errorEntity);
     }
 }
コード例 #3
0
        public static void Save()
        {
            var ftplst = ProgramSetting.FtpSettingList.FirstOrDefault(s => s.Id == ProgramSetting.SelectedFtpSetting.Id);

            if (ftplst != null)
            {
                ftplst.Name        = ProgramSetting.SelectedFtpSetting.Name;
                ftplst.FtpHost     = ProgramSetting.SelectedFtpSetting.FtpHost;
                ftplst.FtpUserName = ProgramSetting.SelectedFtpSetting.FtpUserName;
                ftplst.FtpPassword = ProgramSetting.SelectedFtpSetting.FtpPassword;
            }
            LiteDBHelper.RGHSetData(ProgramSetting);
            ProgramSetting.Dirty = false;
        }
コード例 #4
0
 public static ILiteQueryable <ErrorEntity> GetErrors(ErrorLevel?ErrorLevel    = null,
                                                      DateTime?StartDateTime   = null,
                                                      DateTime?EndDateTime     = null,
                                                      string ValueInMessage    = null,
                                                      string ValueInError      = null,
                                                      string ValueInStackTrace = null)
 {
     return(LiteDBHelper.Load <ErrorEntity>().Where(e =>
                                                    (!ErrorLevel.HasValue || (ErrorLevel.HasValue && e.ErrorLevel == ErrorLevel)) &&
                                                    (!StartDateTime.HasValue || (StartDateTime.HasValue && e.DateTime >= StartDateTime)) &&
                                                    (!EndDateTime.HasValue || (EndDateTime.HasValue && e.DateTime <= EndDateTime)) &&
                                                    (
                                                        (ValueInMessage == null || (ValueInMessage != null && e.Message.Contains(ValueInMessage))) ||
                                                        (ValueInError == null || (ValueInError != null && e.Error.Contains(ValueInError))) ||
                                                        (ValueInStackTrace == null || (ValueInStackTrace != null && e.StackTrace.Contains(ValueInStackTrace)))
                                                    )
                                                    ));
 }
コード例 #5
0
 public static void init()
 {
     Instance = new LiteDBHelper();
     Instance.connect();
 }
コード例 #6
0
        public async static void init()
        {
            try
            {
                Mac = GetMACAddress();

                #region Platforms

                var dataEntity = LiteDBHelper.Load <DataModel>().FirstOrDefault() ?? new DataModel()
                {
                    Id = 1, ScrapGuid = "", ScrapEmail = ""
                };
                //var burl = await GetGame("¤", 1, false, dataEntity.ScrapGuid);
                //BaseUrls = burl.BaseUrls;

                var tmp = await LiteDBHelper.LoadAsync <PlatformResponse>();

                platforms = tmp.FirstOrDefault()?.data.Platforms.Select(p => p) ?? null;
                platforms = null;
                Dictionary <int, List <string> > extensions;
                extensions = await Task.Run(() => JsonHandler.DownloadSerializedJsonData <EmuExtensionsEntity>("http://timeonline.se/RGHandler/EmulatorSupportList.json").Extensions.ToDictionary(em => em.id, em => em.extensoins));

                if (platforms == null)
                {
                    PlatformResponse p = null;
                    var headers        = new Dictionary <string, string>();

                    headers.Add("secret", RGHSettings.ProgGuid);
                    headers.Add("version", RGHSettings.Version);
                    await Task.Run(() => p = JsonHandler.DownloadSerializedJsonData <PlatformResponse>(PlatformApiPath, headers));

                    if (p != null)
                    {
                        await Task.Run(() =>
                        {
                            platforms = p.data?.Platforms;/*?.Select(i => i.Value);*/

                            foreach (var pl in platforms)
                            {
                                pl.Extensions = extensions.ContainsKey(pl.Id) && !extensions[pl.Id].Any(s => s == "?") ? extensions[pl.Id] : new List <string>();
                                var icon      = pl.Icon;
                                var url       = PlatformImagePath + icon;
                                if (LiteDBHelper.FileExists("platform/images", icon))
                                {
                                    continue;
                                }
                                using (WebClient client = new WebClient())
                                {
                                    byte[] data = client.DownloadData(url);
                                    using (MemoryStream mem = new MemoryStream(data))
                                    {
                                        LiteDBHelper.SaveFile("platform/images", icon, mem);
                                    }
                                }
                            }
                        });

                        LiteDBHelper.Save(p);
                    }
                }
                else
                {
                    foreach (var pl in platforms)
                    {
                        pl.Extensions = extensions.ContainsKey(pl.Id) && !extensions[pl.Id].Any(s => s == "?") ? extensions[pl.Id] : new List <string>();
                    }
                }

                foreach (var pl in platforms)
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        LiteDBHelper.LoadFile("platform/images", pl.Icon, mem);
                        PlatformModels.Add(new PlatformModel(pl, LoadImage(mem)));
                    }
                }

                #endregion Platforms
            }
            catch (Exception ex)
            {
                ErrorHandler.Error(ex);
                throw;
            }
        }
コード例 #7
0
        //LiteDBHelper.Load<DataModel>().FirstOrDefault() ?? new DataModel() { Id = 1, ScrapGuid = "", ScrapEmail = "" };

        public static ILiteQueryable <ErrorEntity> GetAllErrors() => LiteDBHelper.Load <ErrorEntity>();