Beispiel #1
0
    // search by single bookinfo, this is for enlarge view
    public List<WhirlwindBeltInfo> Search(BookInfo inputInfo, int numBelts)
    {
        Debug.Assert(inputInfo != null);

        if (connectionSuccess) {
            List<WhirlwindBeltInfo> retVal = new List<WhirlwindBeltInfo>();

            List<BookInfo> b;
            WhirlwindBeltInfo wwbi;

            // search through the columns
            for (int i = 0; i < columns.Length; i++) {
                // make a query
                if (columns[i].Equals("subject")) {
                    b = connector.SearchBySubject(inputInfo.GetSubjects());
                } else {
                    b = connector.Search(inputInfo.GetData(columns[i]), columns[i]);
                }

         				// remove ones that are the same as the search term itself
         				for (int j = 0; j < b.Count; j++) {
         					if (b[j].FileName.Equals(inputInfo.FileName)) {
         						b.Remove(b[j]);
         						break;
         					}
         				}

         				// limits the items count
                b = b.GetRange(0, Mathf.Min(b.Count, maxItemsPerBelt));
                wwbi = new WhirlwindBeltInfo(b, columnTitles[i]);
                retVal.Add(wwbi);
            }

            // sort the search results by popularity
            retVal.Sort(delegate(WhirlwindBeltInfo b1, WhirlwindBeltInfo b2) { return b2.InfosCount.CompareTo(b1.InfosCount); });

            // return the top N results (pad if necessary)
            retVal = retVal.GetRange(0, numBelts);
            return retVal;
        } else {
            return OfflinePlaceHolderSearch(numBelts);
        }
    }