public Task <ActionResult> Update([FromBody] AspNetCoreWebApi.Entity.Request newObj) { Console.WriteLine("Dedicated implement of route {0}", this.RouteData.ToString()); String serviceName = CaseConvert.UnderscoreToCamel(newObj.GetType().Name, false); // TODO : validar se entity.getState() é um State com antecessor e precedente validos. return(RequestFilter.GetObject <AspNetCoreWebApi.Entity.Request>(this.User.Identity, this.Request, this.entityManager, serviceName).ContinueWith <ActionResult>(taskOldObj => { return RequestFilter.ProcessUpdate(this.User.Identity, this.Request, this.entityManager, serviceName, newObj).ContinueWith <ActionResult>(taskResponse => { ActionResult response = taskResponse.Result; if (response is OkResult) { RequestState stateOld = RequestProductEndpoint.GetRequestState(this.entityManager, taskOldObj.Result.State); RequestState state = RequestProductEndpoint.GetRequestState(this.entityManager, newObj.State); List <RequestProduct> list = DbUtils.Find <RequestProduct>(this.entityManager, null, QueryMap.Create().AddNext("crudGroupOwner", newObj.CrudGroupOwner).AddNext("request", newObj.Id), null, null, null).Result; foreach (RequestProduct requestProduct in list) { } } return response; }).Result; })); }
/// <summary> /// Filter out the requests by the specified filters /// </summary> /// <param name="requestFilter"></param> /// <returns></returns> public IEnumerable <HttpRequest> FilterRequests(RequestFilter requestFilter) { IQueryable <HttpRequest> requestsLocal = _requests.AsQueryable(); if (requestFilter.AuthenticationTypes != null) { requestsLocal = requestsLocal.Where(request => requestFilter.AuthenticationTypes.Any(x => request.AuthenticationTypes.Contains(x))); } if (requestFilter.TestTypes != null) { requestsLocal = requestsLocal.Where(request => requestFilter.TestTypes.Any(x => request.TestTypes.Contains(x))); } if (requestFilter.EndpointNameWhitelist != null) { requestsLocal = requestsLocal.Where(request => requestFilter.EndpointNameWhitelist.Any(x => x == request.OperationId)); } if (requestFilter.HttpMethodsWhitelist != null) { requestsLocal = requestsLocal.Where(request => requestFilter.HttpMethodsWhitelist.Any(x => x == request.Method)); } if (requestFilter.GeneralContains != null) { requestsLocal = requestsLocal.Where(request => requestFilter.GeneralContains.Any(x => (request.Summary != null && request.Summary.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0) || (request.Description != null && request.Description.IndexOf(x, StringComparison.OrdinalIgnoreCase) >= 0) || (request.Tags != null && request.Tags.Contains(x, StringComparer.InvariantCultureIgnoreCase)))); } return(requestsLocal.ToList()); }
// ---------[ UPDATE VIEW ]--------- public void DisplayMod(ModProfile profile, ModStatistics statistics, IEnumerable <ModTagCategory> tagCategories, bool isModSubscribed, bool isModEnabled) { // TODO(@jackson): Remove if (profile == null) { return; } this.profile = profile; this.statistics = statistics; this.isModSubscribed = isModSubscribed; this.isModEnabled = isModEnabled; if (modView != null) { modView.DisplayMod(profile, statistics, tagCategories, isModSubscribed, isModEnabled); if (modView.mediaContainer != null) { ModMediaCollection media = profile.media; bool hasMedia = media != null; hasMedia &= ((media.youTubeURLs != null && media.youTubeURLs.Length > 0) || (media.galleryImageLocators != null && media.galleryImageLocators.Length > 0)); modView.mediaContainer.gameObject.SetActive(hasMedia); } } if (selectedMediaPreview != null) { selectedMediaPreview.DisplayLogo(profile.id, profile.logoLocator); } // - version history - if (versionHistoryContainer != null && versionHistoryItemPrefab != null) { foreach (Transform t in versionHistoryContainer) { GameObject.Destroy(t.gameObject); } RequestFilter modfileFilter = new RequestFilter(); modfileFilter.sortFieldName = ModIO.API.GetAllModfilesFilterFields.dateAdded; modfileFilter.isSortAscending = false; APIClient.GetAllModfiles(profile.id, modfileFilter, new APIPaginationParameters() { limit = 20 }, (r) => PopulateVersionHistory(profile.id, r.items), WebRequestError.LogAsWarning); } }
[Test] public void RankOrder() { RequestFilter filter = new RequestFilter(); filter.OrderBy.Add("RankOrder"); Assert.Less(-1, Instance.Get.Requests(filter).Count); }
public Task <ActionResult> Remove() { Console.WriteLine("Dedicated implement of route {0}", this.RouteData.ToString()); // TODO : validar se entity.getState() é um State de status iniciais que permite exclusão. String serviceName = "request"; return(RequestFilter.GetObject <AspNetCoreWebApi.Entity.Request>(this.User.Identity, this.Request, this.entityManager, serviceName).ContinueWith <ActionResult>(taskOldObj => { var obj = taskOldObj.Result; return RequestFilter.ProcessDelete <AspNetCoreWebApi.Entity.Request> (this.User.Identity, this.Request, this.entityManager, serviceName).ContinueWith <ActionResult> (taskResponse => { ActionResult response = taskResponse.Result; if (response is OkResult) { RequestState stateOld = RequestProductEndpoint.GetRequestState(this.entityManager, obj.State); RequestState state = RequestProductEndpoint.GetRequestState(this.entityManager, obj.State); List <RequestProduct> list = DbUtils.Find <RequestProduct> (this.entityManager, null, QueryMap.Create().AddNext("crudGroupOwner", obj.CrudGroupOwner).AddNext("request", obj.Id), null, null, null).Result; foreach (RequestProduct requestProduct in list) { } } return response; }).Result; })); }
public IHttpActionResult GetRequestFilter() { return(execute(delegate() { long userId = User.Identity.GetUserId <long>(); RequestFilter filter = new RequestFilter() { ArchiveMonths = dateTimeService.GetListMonth(), ArchiveYears = requestService.GetListArchiveYear(userId).ToList() }; filter.ArchiveYears.Insert(0, new Year() { Ord = 0, Name = "Все" }); filter.ArchiveMonths.Insert(0, new Month() { Ord = 0, Name = "Все" }); result = Json(new { success = true, data = filter }); })); }
public static async Task <List <analytic> > FetchAnalyticsForPeriodAsync(RequestFilter filter) { earnanalyticsEntities dbContext = new earnanalyticsEntities(); var baseQuery = FetchAnalyticsQuery(filter, dbContext); return(await baseQuery.ToListAsync()); }
// ---------[ UI FUNCTIONALITY ]--------- /// <summary>Sets the value of the input field based on the value in the RequestFilter.</summary> public virtual void UpdateInputField(RequestFilter requestFilter) { string filterValue = string.Empty; List <IRequestFieldFilter> fieldFilterList; if (requestFilter != null && requestFilter.fieldFilterMap.TryGetValue(ModIO.API.GetAllModsFilterFields.fullTextSearch, out fieldFilterList) && fieldFilterList != null && fieldFilterList.Count > 0) { IRequestFieldFilter fieldFilter = fieldFilterList[0]; switch (fieldFilter.filterMethod) { case FieldFilterMethod.Equal: { filterValue = ((EqualToFilter <string>)fieldFilter).filterValue; } break; case FieldFilterMethod.LikeString: { filterValue = ((StringLikeFilter)fieldFilter).likeValue; } break; } } this.UpdateInputField(filterValue); }
public async Task <FriendshipStatus> FriendshipStatus(string id1, string id2) { UserDTO user1 = await GetUserById(id1); UserDTO user2 = await GetUserById(id2); FriendshipFilter FriendFilter = new FriendshipFilter { Account = user1, Account2 = user2 }; if ((GetQuery(FriendFilter).Execute()).Any()) { return(ENUM.User.FriendshipStatus.Friend); } RequestFilter requestFilter = new RequestFilter { Sender = user1, Receiver = user2, Status = ENUM.Request.RequestStatus.Sended }; if ((GetQuery(requestFilter).Execute()).Any()) { return(ENUM.User.FriendshipStatus.Follower); } requestFilter = new RequestFilter { Sender = user2, Receiver = user1, Status = ENUM.Request.RequestStatus.Sended }; if ((GetQuery(requestFilter).Execute()).Any()) { return(ENUM.User.FriendshipStatus.SendRequest); } return(ENUM.User.FriendshipStatus.Unknown); }
// ---------[ UI FUNCTIONALITY ]--------- /// <summary>Displays the tags for a given RequestFilter.</summary> public void DisplayInArrayFilterTags(RequestFilter filter) { List <IRequestFieldFilter> tagsFilterList = null; if (filter != null) { filter.fieldFilterMap.TryGetValue(ModIO.API.GetAllModsFilterFields.tags, out tagsFilterList); } string[] tags = null; if (tagsFilterList != null) { MatchesArrayFilter <string> tagsFilter = null; for (int i = 0; i < tagsFilterList.Count && tagsFilter == null; ++i) { IRequestFieldFilter f = tagsFilterList[i]; if (f.filterMethod == FieldFilterMethod.EquivalentCollection) { tagsFilter = f as MatchesArrayFilter <string>; } } if (tagsFilter != null) { tags = tagsFilter.filterValue; } } this.container.DisplayTags(tags); }
// ---------[ FUNCTIONALITY ]--------- /// <summary>Displays the sort option for a request filter.</summary> public void DisplaySortOption(RequestFilter filter) { if (filter != null) { this.DisplaySortOption(filter.sortFieldName, filter.isSortAscending); } }
public async Task OriginalGetRequestsForAutoProcessor() { //If there are more than 10 pending requests within the last 30 days that are possible for autoprocessing, only the first 10 will be retrieved var datamartIDs = _networkSetting.DataMartList .Where(dm => dm.AllowUnattendedOperation && (dm.NotifyOfNewQueries || dm.ProcessQueriesAndNotUpload || dm.ProcessQueriesAndUploadAutomatically)) .Select(dm => dm.DataMartId).ToArray(); if (datamartIDs.Length == 0) { throw new NotSupportedException("No datamarts enabled for autoprocessing."); } var requestFilter = new RequestFilter { Statuses = new[] { DTO.DataMartClient.Enums.DMCRoutingStatus.Submitted, DTO.DataMartClient.Enums.DMCRoutingStatus.Resubmitted }, DataMartIds = datamartIDs }; int batchSize = 10; var requests = from list in DnsServiceManager.GetRequestList("AutoProcessor", _networkSetting, 0, batchSize, requestFilter, null, null) from rl in list.Segment.EmptyIfNull().ToObservable() where rl.AllowUnattendedProcessing from r in RequestCache.ForNetwork(_networkSetting).LoadRequest(rl.ID, rl.DataMartID) select r; var rq = await requests.ToArray(); foreach (var r in rq) { _logger.Debug($"{ r.DataMartName }: { r.Source.Name} [ { r.Source.Identifier } ]"); } }
/// <summary> /// Returns the json of this request /// We need to build it manually because it needs a specific structure /// TODO: Maybe there's a better way? /// </summary> /// <returns></returns> public string ToJson() { var parameters = new JArray(); parameters.Add(Params); // Add attributes if any exist if (Attributes.Any()) { parameters.Add(Attributes); } // Get JSON from filter if (RequestFilter.HasElements()) { // We need to add an empty attributes array if there are no attributes so that the filter parameter is respected if (!Attributes.Any()) { parameters.Add(new JArray()); } parameters.Add(RequestFilter.ToJson()); } var request = new JObject(new JProperty("method", Method), new JProperty("params", parameters), new JProperty("id", Id)); return(request.ToString()); }
// ---------[ UTILITY ]--------- public void ClearAllFilters() { // Check if already cleared if (this.nameFieldFilter == null && this.tagMatchFieldFilter == null && this.GetSortMethod().Equals(this.defaultSortMethod)) { return; } // Clear this.m_requestFilter = new RequestFilter() { sortFieldName = this.defaultSortMethod.fieldName, isSortAscending = this.defaultSortMethod.ascending, }; this.Refresh(); // notify if (this.onRequestFilterChanged != null) { this.onRequestFilterChanged.Invoke(this.m_requestFilter); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CrudContext entityManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseWebSockets(); app.UseMiddleware <RequestFilter> (); app.UseMvc(); String root = Path.Combine(Directory.GetCurrentDirectory(), "src/main/webapp"); if (Directory.Exists(root)) { app.UseFileServer(new FileServerOptions { FileProvider = new PhysicalFileProvider(root) }); } else { Console.WriteLine("Directory fail : " + root); } // app.UseResponseCompression(); // app.UseMvcWithDefaultRoute(); RequestFilter.UpdateCrudServices(entityManager); }
/// <summary> /// Requests associated with this Issue. /// </summary> public ICollection <Request> GetRequests(RequestFilter filter) { filter = filter ?? new RequestFilter(); filter.Issues.Clear(); filter.Issues.Add(this); return(Instance.Get.Requests(filter)); }
/// <summary> /// Creates a new resource loader. /// </summary> /// <param name="context">The context to use.</param> /// <param name="filter">The optional request filter to use.</param> public BaseLoader(IBrowsingContext context, RequestFilter filter) { _context = context; _filter = filter ?? ((c, f) => true); _downloads = new List <IDownload>(); MaxRedirects = 50; }
// ---------[ INITIALIZATION ]--------- /// <summary>Initializes private members.</summary> protected virtual void Awake() { this.m_requestFilter = new RequestFilter() { sortFieldName = this.defaultSortMethod.fieldName, isSortAscending = this.defaultSortMethod.ascending, }; }
private IQuery <RequestDTO> GetQuery(RequestFilter filter) { var query = new RequestListQuery((UnitOfWork)Database); query.ClearSortCriterias(); query.Filter = filter; return(query); }
public IHttpActionResult GetList([FromUri] RequestFilter filter, [FromUri] OrderInfo orderInfo, [FromUri] PageInfo pageInfo) { return(execute(delegate() { long userId = User.Identity.GetUserId <long>(); IEnumerable <RequestDTO> list = requestService.GetList(userId, filter, orderInfo, pageInfo); result = Json(new { success = true, data = list, totalCount = pageInfo.TotalCount, count = pageInfo.Count }); })); }
public async Task <RequestDTO> GetRequestBySenderReceiver(UserDTO sender, UserDTO receiver) { RequestFilter requestFilter = new RequestFilter { Sender = sender, Receiver = receiver }; var query = GetQuery(requestFilter); query.AddSortCriteria(req => req.Time, SortDirection.Descending); return(query.Execute().FirstOrDefault()); }
public Task <ActionResult> Query() { Console.WriteLine("Dedicated implement of route {0}", this.RouteData.ToString()); // TODO : verificar as condições para carregar as requests encerradas String serviceName = "request"; return(RequestFilter.ProcessQuery <AspNetCoreWebApi.Entity.Request>(this.User.Identity, this.Request, this.entityManager, serviceName).ContinueWith <ActionResult> (taskResponse => { return taskResponse.Result; })); }
/// <summary>Append the response page to the cached data.</summary> public virtual void CacheRequestPage(RequestFilter filter, RequestPage <ModProfile> page) { // early out if shouldn't cache if (!this.isCachingPermitted) { return; } // asserts Debug.Assert(filter != null); Debug.Assert(page != null); // cache request string filterString = filter.GenerateFilterString(); RequestPageData cachedData; if (this.requestCache.TryGetValue(filterString, out cachedData)) { cachedData.resultTotal = page.resultTotal; this.requestCache[filterString] = RequestPageData.Append(cachedData, page.resultOffset, Utility.MapProfileIds(page.items)); } else { cachedData = new RequestPageData() { resultOffset = page.resultOffset, resultTotal = page.resultTotal, modIds = Utility.MapProfileIds(page.items), }; this.requestCache.Add(filterString, cachedData); } // cache profiles foreach (ModProfile profile in page.items) { this.profileCache[profile.id] = profile; } // store if (this.storeIfSubscribed) { IList <int> subMods = ModManager.GetSubscribedModIds(); foreach (ModProfile profile in page.items) { if (subMods.Contains(profile.id)) { CacheClient.SaveModProfile(profile); } } } }
/// <summary> /// Returns all objects specified by a request filter /// </summary> /// <param name="requestFilter"></param> /// <returns></returns> public async Task <List <TResultObject> > GetAllAsync(RequestFilter requestFilter) { List <TResultObject> resultObjects = await GetAllAsyncInternalAsync(requestFilter).ConfigureAwait(false); if (!resultObjects.Any()) { throw new OpsiClientRequestException($"Cannot find objects on interface {InterfaceName} with request filter {requestFilter.ToJson()}"); } return(resultObjects); }
public void RequestFilterStartsWithSingleString() { var request = new RequestFilter { AndOr = RequestFilterAndOr.And, Operation = "StartsWith", Prop = "UserName", Value = "ste" }; Assert.Equal("UserName LIKE \"%ste\"", request.FilterSql()); }
private void SetDateFilterSelectedItem(RequestFilter filter) { if (filter.DateRange == DateRangeKind.RecentDays) { cmbDates.SelectedItem = _dates.FirstOrDefault(d => d.IsDaysBack && d.DaysBack == filter.RecentDaysToShow); } else { cmbDates.Items.Insert(0, new DateFilterItem(filter.FromDate ?? DateTime.UtcNow.AddDays(-30), filter.ToDate ?? DateTime.UtcNow)); cmbDates.SelectedIndex = 0; } }
public void RequestFilterLikeSingleString() { var request = new RequestFilter { AndOr = RequestFilterAndOr.And, Operation = "contains", Prop = "UserName", Value = "ste" }; Assert.Equal("UserName LIKE \"%ste%\"", request.FilterSql()); }
public void RequestFilterLessThanToSingleNumber() { var request = new RequestFilter { AndOr = RequestFilterAndOr.And, Operation = "LessThan", Prop = "UserId", Value = 15 }; Assert.Equal("UserId < 15", request.FilterSql()); }
public void RequestFilterEqualToSingleString() { var request = new RequestFilter { AndOr = RequestFilterAndOr.And, Operation = "Equals", Prop = "UserName", Value = "steven" }; Assert.Equal("UserName == \"steven\"", request.FilterSql()); }
public void RequestFilterCleanProp() { var request = new RequestFilter { AndOr = RequestFilterAndOr.And, Operation = "Equals", Prop = "; DROP ALL TABLES; --", Value = 15 }; Assert.Throws <RequestException>(() => request.FilterSql()); }
public static string GetAccessTeamFilter() { string filter = ""; List<int> openEnums = new List<int>(); openEnums.Add((int)RequestState.Open); openEnums.Add((int)RequestState.Pending); openEnums.Add((int)RequestState.Change_Requested); RequestFilter newFilter = new RequestFilter(); List<Filter> newFilters = new List<Filter>(); Filter PendingAcknowledgementFilter = new Filter(); Filter PendingWorkflowFilter = new Filter(); Filter PendingTicketFilter = new Filter(); Filter PendingProvisioningFilter = new Filter(); Filter ChangeRequestedFilter = new Filter(); Filter InWorkflowFilter = new Filter(); List<int> PendingAcknowledgementList = new List<int>(); List<int> PendingWorkflowList = new List<int>(); List<int> PendingTicketList = new List<int>(); List<int> PendingProvisioningList = new List<int>(); List<int> ChangeRequestedList = new List<int>(); List<int> InWorkflowList = new List<int>(); using (var db = new SNAPDatabaseDataContext()) { var filterCounts = from r in db.SNAP_Requests join w in db.SNAP_Workflows on r.pkId equals w.requestId join ws in db.SNAP_Workflow_States on w.pkId equals ws.workflowId join a in db.SNAP_Actors on w.actorId equals a.pkId where a.pkId == AccessTeamActorId && openEnums.Contains(r.statusEnum) && ws.completedDate == null group r by new { r.pkId, r.ticketNumber, ws.workflowStatusEnum } into grp select new { requestId = grp.Key.pkId, ticketNumber = grp.Key.ticketNumber, workflowStatusEnum = grp.Key.workflowStatusEnum }; if(filterCounts != null) { foreach(var row in filterCounts) { switch (row.workflowStatusEnum) { case (int)WorkflowState.Pending_Acknowledgement: PendingAcknowledgementList.Add(row.requestId); break; case (int)WorkflowState.Pending_Workflow: PendingWorkflowList.Add(row.requestId); break; case (int)WorkflowState.Approved: case (int)WorkflowState.Pending_Provisioning: if (row.ticketNumber == null) { PendingTicketList.Add(row.requestId); } else { PendingProvisioningList.Add(row.requestId); } break; case (int)WorkflowState.Workflow_Created: InWorkflowList.Add(row.requestId); break; case (int)WorkflowState.Change_Requested: ChangeRequestedList.Add(row.requestId); break; } } PendingAcknowledgementFilter.FilterName = "Ack"; PendingAcknowledgementFilter.RequestIds = PendingAcknowledgementList; PendingWorkflowFilter.FilterName = "WrkFl"; PendingWorkflowFilter.RequestIds = PendingWorkflowList; PendingTicketFilter.FilterName = "Tkt"; PendingTicketFilter.RequestIds = PendingTicketList; PendingProvisioningFilter.FilterName = "Prov"; PendingProvisioningFilter.RequestIds = PendingProvisioningList; ChangeRequestedFilter.FilterName = "Chng Req"; ChangeRequestedFilter.RequestIds = ChangeRequestedList; InWorkflowFilter.FilterName = "In WrkFl"; InWorkflowFilter.RequestIds = InWorkflowList; newFilters.Add(PendingAcknowledgementFilter); newFilters.Add(PendingWorkflowFilter); newFilters.Add(PendingTicketFilter); newFilters.Add(PendingProvisioningFilter); newFilters.Add(ChangeRequestedFilter); newFilters.Add(InWorkflowFilter); newFilter.Filters = newFilters; DataContractJsonSerializer serializer = new DataContractJsonSerializer(newFilter.GetType()); using (MemoryStream ms = new MemoryStream()) { serializer.WriteObject(ms, newFilter); string retVal = Encoding.Default.GetString(ms.ToArray()); filter = retVal; } } } return filter; }
public RequestListModel(RequestFilter filter) { Filter = filter; }