public Yield GetTags(DreamContext context, DreamMessage request, Result <DreamMessage> response) { string type = DreamContext.Current.GetParam("type", ""); string fromStr = DreamContext.Current.GetParam("from", ""); string toStr = DreamContext.Current.GetParam("to", ""); bool showPages = DreamContext.Current.GetParam("pages", false); string partialName = DreamContext.Current.GetParam("q", ""); // parse type TagType tagType = TagType.ALL; if (!string.IsNullOrEmpty(type) && !SysUtil.TryParseEnum(type, out tagType)) { throw new DreamBadRequestException("Invalid type parameter"); } // check and validate from date DateTime from = (tagType == TagType.DATE) ? DateTime.Now : DateTime.MinValue; if (!string.IsNullOrEmpty(fromStr) && !DateTime.TryParse(fromStr, out from)) { throw new DreamBadRequestException("Invalid from date parameter"); } // check and validate to date DateTime to = (tagType == TagType.DATE) ? from.AddDays(30) : DateTime.MaxValue; if (!string.IsNullOrEmpty(toStr) && !DateTime.TryParse(toStr, out to)) { throw new DreamBadRequestException("Invalid to date parameter"); } // execute query var tagBL = new TagBL(); var tags = tagBL.GetTags(partialName, tagType, from, to); XDoc doc = tagBL.GetTagListXml(tags, "tags", null, showPages); response.Return(DreamMessage.Ok(doc)); yield break; }
public Yield GetTags(DreamContext context, DreamMessage request, Result<DreamMessage> response) { string type = DreamContext.Current.GetParam("type", ""); string fromStr = DreamContext.Current.GetParam("from", ""); string toStr = DreamContext.Current.GetParam("to", ""); bool showPages = DreamContext.Current.GetParam("pages", false); string partialName = DreamContext.Current.GetParam("q", ""); // parse type TagType tagType = TagType.ALL; if(!string.IsNullOrEmpty(type) && !SysUtil.TryParseEnum(type, out tagType)) { throw new DreamBadRequestException("Invalid type parameter"); } // check and validate from date DateTime from = (tagType == TagType.DATE) ? DateTime.Now : DateTime.MinValue; if(!string.IsNullOrEmpty(fromStr) && !DateTime.TryParse(fromStr, out from)) { throw new DreamBadRequestException("Invalid from date parameter"); } // check and validate to date DateTime to = (tagType == TagType.DATE) ? from.AddDays(30) : DateTime.MaxValue; if(!string.IsNullOrEmpty(toStr) && !DateTime.TryParse(toStr, out to)) { throw new DreamBadRequestException("Invalid to date parameter"); } // execute query var tagBL = new TagBL(); var tags = tagBL.GetTags(partialName, tagType, from, to); XDoc doc = tagBL.GetTagListXml(tags, "tags", null, showPages); response.Return(DreamMessage.Ok(doc)); yield break; }
public string[] GetTags(string prefixText, int count) { tagbl = new TagBL(); return(tagbl.GetTags(prefixText, count)); }
internal Hashtable SiteTags() { Hashtable result = new Hashtable(StringComparer.OrdinalIgnoreCase); var tagBL = new TagBL(); foreach(TagBE tag in tagBL.GetTags(null, TagType.ALL, DateTime.MinValue, DateTime.MaxValue)) { result[tag.PrefixedName] = MakeTagObject(tag); } return result; }