/// <summary> /// 过滤条件 /// </summary> /// <param name="documentIds"></param> /// <param name="storeIndex"></param> /// <param name="result"></param> /// <param name="searchQuery"></param> protected virtual void FilterDocuments(IList <long> documentIds, StoreIndexInfo storeIndex, SearchResultInfo result, SearchQueryInfo searchQuery) { foreach (var documentId in documentIds) { var document = Documentor.GetInfo(storeIndex, documentId); if (document == null || document.Feilds == null) { continue; } if (searchQuery.Conditions.ContainsKey("IsCustom") && document.Feilds.Count > 6 && !document.Feilds[6].Text.Convert <bool>() != searchQuery.Conditions["IsCustom"].Convert <bool>()) { continue; } if (searchQuery.Conditions.ContainsKey("StartCost") && document.Feilds.Count > 4 && document.Feilds[4].Text.Convert <decimal>() < searchQuery.Conditions["StartCost"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("EndCost") && document.Feilds.Count > 4 && document.Feilds[4].Text.Convert <decimal>() > searchQuery.Conditions["EndCost"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("StartPrice") && document.Feilds.Count > 5 && document.Feilds[5].Text.Convert <decimal>() < searchQuery.Conditions["StartPrice"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("EndPrice") && document.Feilds.Count > 5 && document.Feilds[5].Text.Convert <decimal>() > searchQuery.Conditions["EndPrice"].Convert <decimal>()) { continue; } if (searchQuery.Conditions.ContainsKey("Sku") && document.Feilds.Count > 3 && !string.IsNullOrEmpty(document.Feilds[3].Text)) { var texts = searchQuery.Conditions["Sku"].ToString().Split(','); var values = document.Feilds[3].Text.Split(','); var rev = texts.All(text => CheckValue(values, text)); if (rev) { continue; } } result.Documents.Add(document); } }
public PropertyName(string name, Documentor documentor) { SourceName = name; if (SourceName.Contains(":") || SourceName.Contains(".")) { documentor.AddDocumentationLine($"Property name has been quoted because of special characters in JsonProperty attribute."); Name = $"\"{SourceName}\""; } else { Name = SourceName; } }
/// <summary> /// 删除索引 /// </summary> /// <param name="name"></param> public virtual void Delete(string name) { if (!StoreIndexs.ContainsKey(name)) { return; } var storeIndex = StoreIndexs[name]; if (storeIndex == null) { return; } Worder.Clear(storeIndex); Documentor.Clear(storeIndex); }
/// <summary> /// 添加行 /// </summary> /// <param name="storeIndex"></param> /// <param name="searchQuery"></param> /// <param name="result"></param> /// <param name="documentIds"></param> protected virtual void AddSearchDocuments(StoreIndexInfo storeIndex, SearchQueryInfo searchQuery, SearchResultInfo result, IList <long> documentIds) { if (searchQuery.PageSize > 0) { documentIds = documentIds.Skip(searchQuery.PageIndex * searchQuery.PageSize).Take(searchQuery.PageSize).ToList(); } foreach (var documentId in documentIds) { var document = Documentor.GetInfo(storeIndex, documentId); if (document != null) { result.Documents.Add(document); } } }
public IHttpActionResult GetHelp(string ts) { // Step 1. Create Documentor instance. Documentor documentor = new Documentor(); // Step 2. Define methods groups. documentor.AddMethodGroup("persons", "Persons", "Describes methods to work with Person objects", 1); documentor.AddMethodGroup("pets", "Pets", "Describes methods to work with Pet objects", 2); // Step 3. Create template set according to requiested documentation output type (simple or Bootstrap-based). BasicTemplateSet templateSet = null; if (String.Equals(ts, "simple")) { templateSet = new SimpleTemplateSet() { Title = "Radish Demo" } } ; else if (String.Equals(ts, "bootstrap")) { templateSet = new BootstrapTemplateSet() { Title = "Radish Demo" } } ; // Step 4. Specify template set for the documentor. documentor.TemplateSet = templateSet; // Step 5. Get the help content. string helpContent = documentor.Content; HttpResponseMessage message = new HttpResponseMessage() { Content = new StringContent(helpContent, Encoding.UTF8, "text/html") }; return(new ResponseMessageResult(message)); } }
/// <summary> /// 保存文档 /// </summary> /// <param name="storeIndex"></param> /// <param name="document"></param> /// <returns></returns> protected virtual IDictionary <int, IList <TermInfo> > SaveDocument(StoreIndexInfo storeIndex, DocumentInfo document) { var feildTerms = new Dictionary <int, IList <TermInfo> >(); var i = 0; foreach (var feild in document.Feilds) { var storeFeild = storeIndex.GetStoreField(i); if (storeFeild != null && storeFeild.StoreType != FieldIndexType.OnlyStore) { var terms = Analyzer.Resolve(feild.Text); feildTerms.Add(i, terms ?? new List <TermInfo>()); } if (storeFeild != null && storeFeild.StoreType == FieldIndexType.OnlyIndex) { document.Feilds[i] = null; } i++; } Documentor.Insert(storeIndex, document); return(feildTerms); }
/// <summary> /// 初始化文档 /// </summary> public virtual void InitlizeDocumentIndex() { Documentor.InitlizeIndex(StoreIndexs.Values.ToList()); }