public void UpdateGameFiles(GameFileFieldType ftWhere, GameFileFieldType ftSet, object fWhere, object fSet)
        {
            List <DbParameter> parameters = new List <DbParameter>();

            parameters.Add(DataAccess.DbAdapter.CreateParameter("set1", fSet == null ? DBNull.Value : fSet));
            parameters.Add(DataAccess.DbAdapter.CreateParameter("where1", fWhere == null ? DBNull.Value : fWhere));

            DataAccess.ExecuteNonQuery(string.Format(@"update GameFiles set {0} = @set1 where {1} = @where1", ftWhere.ToString("g"), ftSet.ToString("g")), parameters);
        }
示例#2
0
        public void UpdateGameFiles(GameFileFieldType ftWhere, GameFileFieldType ftSet, object fWhere, object fSet)
        {
            List <DbParameter> parameters = new List <DbParameter> {
                this.DataAccess.DbAdapter.CreateParameter("set1", (fSet == null) ? DBNull.Value : fSet),
                this.DataAccess.DbAdapter.CreateParameter("where1", (fWhere == null) ? DBNull.Value : fWhere)
            };

            this.DataAccess.ExecuteNonQuery($"update GameFiles set {ftWhere.ToString("g")} = @set1 where {ftSet.ToString("g")} = @where1", parameters);
        }
示例#3
0
 private bool AssertSet(CheckBox chk, List <GameFileFieldType> fields, GameFileFieldType field)
 {
     if ((!this.m_showCheckBoxes || !chk.Checked) && this.m_showCheckBoxes)
     {
         return(false);
     }
     fields.Add(field);
     return(true);
 }
        private bool AssertSet(CheckBox chk, List <GameFileFieldType> fields, GameFileFieldType field)
        {
            if ((m_showCheckBoxes && chk.Checked) || !m_showCheckBoxes)
            {
                fields.Add(field);
                return(true);
            }

            return(false);
        }
示例#5
0
        public void Pre_1_1_0()
        {
            DataTable table = this.DataAccess.ExecuteSelect("select name from sqlite_master where type='table' and name='Tags';").Tables[0];

            if (table.Rows.Count == 0)
            {
                string sql = "CREATE TABLE 'Tags' (\r\n\t            'TagID'\tINTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\r\n\t            'Name'\tTEXT NOT NULL,\r\n\t            'HasTab'\tINTEGER NOT NULL);";
                this.DataAccess.ExecuteSelect(sql);
                sql = "CREATE TABLE 'TagMapping' (\r\n\t            'FileID'\tINTEGER NOT NULL,\r\n\t            'TagID'\tINTEGER NOT NULL,\r\n\t            PRIMARY KEY(FileID,TagID));";
                this.DataAccess.ExecuteSelect(sql);
            }
            table = this.DataAccess.ExecuteSelect("pragma table_info(Tags);").Tables[0];
            if (table.Select("name = 'Color'").Count <DataRow>() == 0)
            {
                this.DataAccess.ExecuteNonQuery("alter table Tags add column 'HasColor' int;");
                this.DataAccess.ExecuteNonQuery("alter table Tags add column 'Color' int;");
            }
            table = this.DataAccess.ExecuteSelect("pragma table_info(GameFiles);").Tables[0];
            if (table.Select("name = 'MapCount'").Count <DataRow>() == 0)
            {
                new FileInfo("DoomLauncher.sqlite").CopyTo($"DoomLauncher_{Guid.NewGuid().ToString()}.sqlite.bak");
                this.DataAccess.ExecuteNonQuery("alter table GameFiles add column 'MapCount' int;");
                GameFileGetOptions options = new GameFileGetOptions();
                options.SelectFields = new GameFileFieldType[] { GameFileFieldType.GameFileID, GameFileFieldType.Map };
                IEnumerable <IGameFileDataSource> gameFiles = this.m_adapter.GetGameFiles(options);
                GameFileFieldType[] updateFields            = new GameFileFieldType[] { GameFileFieldType.MapCount };
                float num  = gameFiles.Count <IGameFileDataSource>();
                int   num2 = 0;
                foreach (IGameFileDataSource source in gameFiles)
                {
                    if (this.UpdateProgress != null)
                    {
                        this.ProgressPercent = Convert.ToInt32((float)((((float)num2) / num) * 100f));
                        this.UpdateProgress(this, new EventArgs());
                    }
                    if (source.Map != null)
                    {
                        source.MapCount = new int?(source.Map.Count <char>(x => (x == ',')) + 1);
                        this.m_adapter.UpdateGameFile(source, updateFields);
                    }
                    num2++;
                }
            }
            if (table.Select("name = 'SettingsSpecificFiles'").Count <DataRow>() == 0)
            {
                this.DataAccess.ExecuteNonQuery("alter table GameFiles add column 'SettingsSpecificFiles' TEXT;");
            }
            table = this.DataAccess.ExecuteSelect("select * from Configuration where Name = 'Version'").Tables[0];
            this.WriteVersion(AppVersion.Version_1_1_0);
            if (this.UpdateComplete != null)
            {
                this.UpdateComplete(this, new EventArgs());
            }
        }
示例#6
0
 public void UpdateGameFiles(GameFileFieldType ftWhere, GameFileFieldType ftSet, object fWhere, object fSet)
 {
     throw new NotImplementedException();
 }
        public void Pre_1_1_0()
        {
            DataTable dt = DataAccess.ExecuteSelect("select name from sqlite_master where type='table' and name='Tags';").Tables[0];

            //tag table update
            if (dt.Rows.Count == 0)
            {
                string query = @"CREATE TABLE 'Tags' (
	            'TagID'	INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	            'Name'	TEXT NOT NULL,
	            'HasTab'	INTEGER NOT NULL);"    ;
                DataAccess.ExecuteSelect(query);

                query = @"CREATE TABLE 'TagMapping' (
	            'FileID'	INTEGER NOT NULL,
	            'TagID'	INTEGER NOT NULL,
	            PRIMARY KEY(FileID,TagID));"    ;
                DataAccess.ExecuteSelect(query);
            }

            dt = DataAccess.ExecuteSelect("pragma table_info(Tags);").Tables[0];

            if (!dt.Select("name = 'Color'").Any())
            {
                DataAccess.ExecuteNonQuery("alter table Tags add column 'HasColor' int;");
                DataAccess.ExecuteNonQuery("alter table Tags add column 'Color' int;");
            }

            dt = DataAccess.ExecuteSelect("pragma table_info(GameFiles);").Tables[0];
            //GameFile map count update
            if (!dt.Select("name = 'MapCount'").Any())
            {
                CreateDatabaseBackup();

                DataAccess.ExecuteNonQuery("alter table GameFiles add column 'MapCount' int;");

                GameFileGetOptions options = new GameFileGetOptions();
                options.SelectFields = new GameFileFieldType[] { GameFileFieldType.GameFileID, GameFileFieldType.Map };
                IEnumerable <IGameFile> gameFiles = m_adapter.GetGameFiles(options);

                GameFileFieldType[] updateFields = new GameFileFieldType[] { GameFileFieldType.MapCount };
                float total = gameFiles.Count();
                int   count = 0;

                foreach (IGameFile gameFile in gameFiles)
                {
                    if (UpdateProgress != null)
                    {
                        ProgressPercent = Convert.ToInt32(count / total * 100);
                        UpdateProgress(this, new EventArgs());
                    }

                    if (gameFile.Map != null)
                    {
                        gameFile.MapCount = gameFile.Map.Count(x => x == ',') + 1;
                        m_adapter.UpdateGameFile(gameFile, updateFields);
                    }

                    count++;
                }
            }

            if (!dt.Select("name = 'SettingsSpecificFiles'").Any())
            {
                DataAccess.ExecuteNonQuery("alter table GameFiles add column 'SettingsSpecificFiles' TEXT;");
            }

            WriteVersion(AppVersion.Version_1_1_0);

            UpdateComplete?.Invoke(this, new EventArgs());
        }
示例#8
0
 public static bool IsDateTimeField(GameFileFieldType field) =>
 s_dateTimeFields.ToList <GameFileFieldType>().Contains(field);
示例#9
0
 public GameFileSearchField(GameFileFieldType type, GameFileSearchOp op, string search)
 {
     this.SearchFieldType = type;
     this.SearchText      = search;
     this.SearchOp        = op;
 }
示例#10
0
 public GameFileSearchField(GameFileFieldType type, string search)
 {
     this.SearchFieldType = type;
     this.SearchText      = search;
     this.SearchOp        = GameFileSearchOp.Equal;
 }
示例#11
0
 public static bool IsDateTimeField(GameFileFieldType field)
 {
     return(s_dateTimeFields.ToList().Contains(field));
 }