Exemplo n.º 1
0
        /* get the sql search condition of this/these type/types */
        internal string GetSqlSearchCondition(MatchRule typeMatchRule)
        {
            StringBuilder sql = new StringBuilder();

            if (this.ContainsType(Audio))
            {
                SearchUtils.Append(sql, "Items.MimeType LIKE 'audio/%'", typeMatchRule);
            }

            if (this.ContainsType(Video))
            {
                SearchUtils.Append(sql, "Items.MimeType LIKE 'video/%'", typeMatchRule);
            }

            if (this.ContainsType(Image))
            {
                SearchUtils.Append(sql, "Items.MimeType LIKE 'image/%'", typeMatchRule);
            }

            if (this.ContainsType(Text))
            {
                SearchUtils.Append(sql, "Items.MimeType LIKE 'text/%'", typeMatchRule);
            }

            if (this.ContainsType(Directory))
            {
                SearchUtils.Append(sql, "Items.MimeType = 'x-directory/normal'", typeMatchRule);
            }

            return(sql.ToString());
        }
Exemplo n.º 2
0
        /* get the sql search condition of this/these field/fields */
        string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule)
        {
            StringBuilder sql = new StringBuilder();

            if (this.ContainsField(Title))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Title", searchString), fieldMatchRule);
            }

            if (this.ContainsField(LoanedTo))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Loaned_To", searchString), fieldMatchRule);
            }

            if (this.ContainsField(Description))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Description", searchString), fieldMatchRule);
            }

            if (this.ContainsField(Keywords))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Keywords", searchString), fieldMatchRule);
            }

            return(sql.ToString());
        }
Exemplo n.º 3
0
        /* get the sql search condition of this/these field/fields */
        internal string GetSqlSearchCondition(long quantity, CompareOperator compareOperator, MatchRule fieldMatchRule)
        {
            StringBuilder sql         = new StringBuilder();
            string        strQuantity = quantity.ToString();

            if (this.ContainsField(Files))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Files", strQuantity), fieldMatchRule);
            }

            if (this.ContainsField(Dirs))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Dirs", strQuantity), fieldMatchRule);
            }

            if (this.ContainsField(Size))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Size", strQuantity), fieldMatchRule);
            }

            return(sql.ToString());
        }
Exemplo n.º 4
0
        /* get the sql search condition of this/these field/fields */
        string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule)
        {
            StringBuilder sql = new StringBuilder();

            if (this.ContainsField(AnyName))
            {
                // search name fields of _all_ possible volume itemtypes (e.g. DirectoryName, FileName, ...)
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Name", searchString), fieldMatchRule);
            }
            else
            {
                if (this.ContainsField(DirectoryName))
                {
                    SearchUtils.Append(
                        sql, compareOperator.GetSqlCompareString("Items.Name", searchString)
                        + string.Format(" AND (Items.ItemType = {0})", (int)VolumeItemType.DirectoryVolumeItem),
                        fieldMatchRule
                        );
                }

                if (this.ContainsField(FileName))
                {
                    SearchUtils.Append(
                        sql, compareOperator.GetSqlCompareString("Items.Name", searchString)
                        + string.Format(" AND (Items.ItemType = {0})", (int)VolumeItemType.FileVolumeItem),
                        fieldMatchRule
                        );
                }
            }

            if (this.ContainsField(Keywords))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Keywords", searchString), fieldMatchRule);
            }

            if (this.ContainsField(Location))
            {
                SearchUtils.Append(
                    sql, compareOperator.GetSqlCompareString("Items.Location", searchString)
                    + string.Format(" AND ((Items.ItemType = {0}) OR (Items.ItemType = {1}))", (int)VolumeItemType.FileVolumeItem, (int)VolumeItemType.DirectoryVolumeItem),
                    fieldMatchRule
                    );
            }

            if (this.ContainsField(Note))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.Note", searchString), fieldMatchRule);
            }

#if ALLOW_FREETEXTSEARCH_MIMETYPE
            if (this.ContainsField(MimeType))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.MimeType", searchString), fieldMatchRule);
            }
#endif
#if ALLOW_FREETEXTSEARCH_METADATA
            if (this.ContainsField(MetaData))
            {
                SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Items.MetaData", searchString), fieldMatchRule);
            }
#endif

            return(sql.ToString());
        }