コード例 #1
0
        public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options, ITagData tag)
        {
            DataTable dt;
            string    selectColumns = "GameFiles.*";
            string    join          = string.Empty;

            string where = string.Empty;

            if (tag != null)
            {
                join  = "join TagMapping on TagMapping.FileID = GameFiles.GameFileID";
                where = string.Format("TagMapping.TagID = {0}", tag.TagID);
            }

            if (options.SelectFields != null)
            {
                selectColumns = GetSelectFieldString(options.SelectFields);
            }

            if (options.SearchField != null)
            {
                string op = s_opLookup[(int)options.SearchField.SearchOp];

                if (op == "like")
                {
                    options.SearchField.SearchText = string.Format("{0}{1}{0}", "%", options.SearchField.SearchText);
                }

                string searchCol   = options.SearchField.SearchFieldType.ToString("g");
                string searchParam = "@search";

                if (DataAccess.DbAdapter is SqliteDatabaseAdapter && GameFileSearchField.IsDateTimeField(options.SearchField.SearchFieldType)) //sqlite datetime comparison hack
                {
                    searchParam = string.Format("Datetime('{0}')", DateTime.Parse(options.SearchField.SearchText).ToString("yyyy-MM-dd"));
                }

                if (where != string.Empty)
                {
                    where = string.Format("and {0}", where);
                }

                string query = string.Format("select {2} from GameFiles {5} where {0} {1} {3} {4} {6}",
                                             searchCol, op, selectColumns, searchParam, GetLimitOrderString(options), join, where);
                dt = DataAccess.ExecuteSelect(query, new DbParameter[] { DataAccess.DbAdapter.CreateParameter("search", options.SearchField.SearchText) }).Tables[0];
            }
            else
            {
                if (where != string.Empty)
                {
                    where = string.Format("where {0}", where);
                }

                string query = string.Format("select {0} from GameFiles {2} {3} {1}", selectColumns, GetLimitOrderString(options), join, where);
                dt = DataAccess.ExecuteSelect(query).Tables[0];
            }

            return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>());
        }
コード例 #2
0
        public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options, ITagDataSource tag)
        {
            DataTable table;
            string    selectFieldString = "GameFiles.*";
            string    str2 = string.Empty;
            string    str3 = string.Empty;

            if (tag != null)
            {
                str2 = "join TagMapping on TagMapping.FileID = GameFiles.GameFileID";
                str3 = $"TagMapping.TagID = {tag.TagID}";
            }
            if (options.SelectFields != null)
            {
                selectFieldString = this.GetSelectFieldString(options.SelectFields);
            }
            if (options.SearchField != null)
            {
                string str4 = s_opLookup[(int)options.SearchField.SearchOp];
                if (str4 == "like")
                {
                    options.SearchField.SearchText = string.Format("{0}{1}{0}", "%", options.SearchField.SearchText);
                }
                string str5 = options.SearchField.SearchFieldType.ToString("g");
                string str6 = "@search";
                if ((this.DataAccess.DbAdapter is SqliteDatabaseAdapter) && GameFileSearchField.IsDateTimeField(options.SearchField.SearchFieldType))
                {
                    str6 = $"Datetime('{DateTime.Parse(options.SearchField.SearchText).ToString("yyyy-MM-dd")}')";
                }
                if (str3 != string.Empty)
                {
                    str3 = $"and {str3}";
                }
                string        sql        = string.Format("select {2} from GameFiles {5} where {0} {1} {3} {4} {6}", new object[] { str5, str4, selectFieldString, str6, GetLimitOrderString(options), str2, str3 });
                DbParameter[] parameters = new DbParameter[] { this.DataAccess.DbAdapter.CreateParameter("search", options.SearchField.SearchText) };
                table = this.DataAccess.ExecuteSelect(sql, parameters).Tables[0];
            }
            else
            {
                if (str3 != string.Empty)
                {
                    str3 = $"where {str3}";
                }
                string str8 = string.Format("select {0} from GameFiles {2} {3} {1}", new object[] { selectFieldString, GetLimitOrderString(options), str2, str3 });
                table = this.DataAccess.ExecuteSelect(str8).Tables[0];
            }
            return(Util.TableToStructure(table, typeof(GameFileDataSource)).Cast <IGameFileDataSource>());
        }
コード例 #3
0
        public IEnumerable <IGameFile> GetGameFilesByName(string fileName)
        {
            GameFileSearchField sf = new GameFileSearchField(GameFileFieldType.Filename, fileName);

            return(GetGameFiles(new GameFileGetOptions(sf)));
        }
コード例 #4
0
        public IGameFile GetGameFile(string fileName)
        {
            GameFileSearchField sf = new GameFileSearchField(GameFileFieldType.Filename, fileName);

            return(GetGameFiles(new GameFileGetOptions(sf)).FirstOrDefault());
        }
コード例 #5
0
 public GameFileGetOptions(GameFileFieldType[] selectFields, GameFileSearchField searchField)
 {
     this.SelectFields = selectFields;
     this.SearchField  = searchField;
 }
コード例 #6
0
 public GameFileGetOptions(GameFileSearchField sf)
 {
     this.SearchField = sf;
 }