public async Task <ActionResult <DeleteResult> > Delete([FromBody] DeleteRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, GatherManager.PermissionsList)) { return(Unauthorized()); } await _ruleRepository.DeleteAsync(request.RuleId); var rules = await _ruleRepository.GetRulesAsync(request.SiteId); foreach (var rule in rules) { var gatherUrlList = GatherUtils.GetGatherUrlList(rule); if (gatherUrlList != null && gatherUrlList.Count > 0) { var url = gatherUrlList[0]; rule.Set("gatherUrl", url); } } return(new DeleteResult { Rules = rules }); }
public async Task <ActionResult <SubmitResult> > Submit([FromBody] SubmitRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, GatherManager.PermissionsList)) { return(Unauthorized()); } var rule = await _ruleRepository.GetAsync(request.RuleId); //var regexListArea = GatherUtils.GetRegexArea(rule.ListAreaStart, rule.ListAreaEnd); //var regexContentUrl = GatherUtils.GetRegexUrl(rule.ContentUrlStart, rule.ContentUrlEnd); //var regexImageUrl = string.Empty; //if (rule.ImageSource == ImageSource.List) //{ // regexImageUrl = GatherUtils.GetRegexUrl(rule.ImageUrlStart, rule.ImageUrlEnd); //} var items = await GatherUtils.GetItemsAsync(request.GatherUrl, rule); return(new SubmitResult { Items = items }); //var urls = GatherUtils.GetContentAndImageUrls(request.GatherUrl, rule.Charset, rule.CookieString, regexListArea, regexContentUrl, regexImageUrl); //return new SubmitResult //{ // ContentUrls = urls.contentUrls, // ImageUrls = urls.imageUrls //}; }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, GatherManager.PermissionsList)) { return(Unauthorized()); } var rule = await _ruleRepository.GetAsync(request.RuleId); var gatherUrls = GatherUtils.GetGatherUrlList(rule); return(new GetResult { Rule = rule, GatherUrls = gatherUrls }); }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, GatherManager.PermissionsList)) { return(Unauthorized()); } var rule = await _ruleRepository.GetAsync(request.RuleId); var items = await GatherUtils.GetItemsAsync(request.ListUrl, rule); var item = items.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(x.Url, request.ContentUrl)); var attributes = await GatherUtils.GetContentNameValueCollectionAsync(rule, item); var list = new List <KeyValuePair <string, string> >(); //var contentAttributes = Context.ContentApi.GetInputStyles(siteId, rule.ChannelId); foreach (var attributeName in attributes.AllKeys) { var value = attributes[attributeName]; if (string.IsNullOrEmpty(value)) { continue; } if (StringUtils.EqualsIgnoreCase(nameof(SSCMS.Models.Content.ImageUrl), attributeName)) { var imageUrl = GatherUtils.GetUrlByBaseUrl(value, request.ContentUrl); list.Add(new KeyValuePair <string, string>(attributeName, imageUrl)); } else { list.Add(new KeyValuePair <string, string>(attributeName, value)); } } return(new GetResult { Attributes = list }); }