public Task <T> GetDataAsync <T>(IDataRequest <T> request) { IORequest <T> ir = new IORequest <T>(request); manager.ioRequested.OnNext(new Tuple <NodeJob, IIORequest>(this, ir)); return(ir.WaitTask); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public OpdsItems GetItems(IDataRequest request) { var result = new OpdsItems(); // 取主分类 if (request.Id == null) { result.Items = GetItems(dbContext.Categories.Where(c => c.Parent == null)); } else { var current = dbContext.Categories.Include(c => c.SubCategories).Single(c => c.Id == new Guid(request.Id)); // 取子分类 if (current.SubCategories != null && current.SubCategories.Any()) { result.Items = GetItems(dbContext.Categories.Where(c => c.Parent != null && c.Parent.Id == new Guid(request.Id))); } // 无子分类,则取书 current = dbContext.Categories.Include(c => c.Books).Single(c => c.Id == new Guid(request.Id)); if (current.Books.Any()) { result.Items = GetItems(current.Books).Concat(result.Items).ToList(); } } return(result); }
public Detector() { _dataRequest = ContainerHolder.Container.Resolve <IDataRequest>(); _mailNotifier = ContainerHolder.Container.Resolve <IMailNotifier>(); _dataRequest.NewDataReceived += onNewDataReceived; _dataRequest.SetInterval(TimeSpan.FromMinutes(1)); }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodModelStateValidatedLogEntry" /> class. /// </summary> /// <param name="method">The method being invoked.</param> /// <param name="request">The request being executed on the method.</param> /// <param name="modelState">the model dictionary created by the controller.</param> public ActionMethodModelStateValidatedLogEntry( IGraphMethod method, IDataRequest request, InputModelStateDictionary modelState) : base(LogEventIds.ControllerModelValidated) { this.PipelineRequestId = request.Id; this.ControllerName = method.Parent.ObjectType?.FriendlyName(true) ?? method.Parent.Name; this.ActionName = method.Name; this.FieldPath = method.Route.Path; this.ModelDataIsValid = modelState.IsValid; _shortControllerName = method.Parent.ObjectType?.FriendlyName() ?? method.Parent.Name; this.ModelItems = null; if (modelState.Values != null && modelState.Values.Any()) { var entries = new List <ModelStateEntryLogItem>(); foreach (var item in modelState.Values) { if (item.ValidationState == InputModelValidationState.Invalid) { entries.Add(new ModelStateEntryLogItem(item)); } } this.ModelItems = entries; } }
/// <summary> /// Initializes a new instance of the <see cref="ResolutionContext" /> class. /// </summary> /// <param name="parentContext">The parent context from which this resolution context should /// extract is base data values.</param> /// <param name="request">The resolution request to carry with the context.</param> /// <param name="arguments">The arguments to be passed to the resolver when its executed.</param> protected ResolutionContext( IGraphMiddlewareContext parentContext, IDataRequest request, IExecutionArgumentCollection arguments) : base(parentContext) { this.Request = Validation.ThrowIfNullOrReturn(request, nameof(request)); this.Arguments = Validation.ThrowIfNullOrReturn(arguments, nameof(arguments)); }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodInvocationCompletedLogEntry" /> class. /// </summary> /// <param name="method">The method being invoked.</param> /// <param name="request">The request being executed on the method.</param> /// <param name="result">The result that was generated.</param> public ActionMethodInvocationCompletedLogEntry(IGraphMethod method, IDataRequest request, object result) : base(LogEventIds.ControllerInvocationCompleted) { this.PipelineRequestId = request.Id; this.ControllerName = method.Parent.InternalFullName; this.ActionName = method.InternalName; this.FieldPath = method.Route.Path; this.ResultTypeName = result?.GetType().FriendlyName(true); _shortControllerName = method.Parent.InternalName; }
private T PostRequest <T>(string requestQuery, IDataRequest requestData) { var request = new RestRequest(requestQuery) .AddJsonBody(requestData); var result = _client.Post <T>(request); CheckRequestResult(result); return(result.Data); // TODO: Add try-catch with logs }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodUnhandledExceptionLogEntry" /> class. /// </summary> /// <param name="method">The method being invoked.</param> /// <param name="request">The request being executed on the method.</param> /// <param name="exception">The exception that was thrown.</param> public ActionMethodUnhandledExceptionLogEntry( IGraphMethod method, IDataRequest request, Exception exception) : base( LogEventIds.ControllerUnhandledException, method, request, exception) { }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodInvocationExceptionLogEntry" /> class. /// </summary> /// <param name="method">The method being invoked.</param> /// <param name="request">The request being executed on the method.</param> /// <param name="exception">The exception that was thrown.</param> public ActionMethodInvocationExceptionLogEntry( IGraphMethod method, IDataRequest request, Exception exception) : base( LogEventIds.ControllerInvocationException, method, request, exception) { }
/// <inheritdoc /> public virtual void ActionMethodModelStateValidated(IGraphMethod action, IDataRequest request, InputModelStateDictionary modelState) { if (!this.IsEnabled(LogLevel.Trace)) { return; } var entry = new ActionMethodModelStateValidatedLogEntry(action, request, modelState); this.LogEvent(LogLevel.Trace, entry); }
/// <summary> /// Initializes a new instance of the <see cref="ActionMethodInvocationStartedLogEntry" /> class. /// </summary> /// <param name="method">The method being invoked.</param> /// <param name="request">The request being executed on the method.</param> public ActionMethodInvocationStartedLogEntry(IGraphMethod method, IDataRequest request) : base(LogEventIds.ControllerInvocationStarted) { this.PipelineRequestId = request.Id; this.ControllerName = method.Parent.InternalFullName; this.ActionName = method.Name; this.FieldPath = method.Route.Path; this.SourceObjectType = method.ObjectType?.ToString(); this.IsAsync = method.IsAsyncField; _shortControllerName = method.Parent.InternalName; }
/// <inheritdoc /> public virtual void ActionMethodUnhandledException(IGraphMethod action, IDataRequest request, Exception exception) { if (!this.IsEnabled(LogLevel.Error)) { return; } var entry = new ActionMethodUnhandledExceptionLogEntry(action, request, exception); this.LogEvent(LogLevel.Error, entry); }
/// <inheritdoc /> public virtual void ActionMethodInvocationCompleted(IGraphMethod action, IDataRequest request, object result) { if (!this.IsEnabled(LogLevel.Trace)) { return; } var entry = new ActionMethodInvocationCompletedLogEntry(action, request, result); this.LogEvent(LogLevel.Trace, entry); }
/// <summary> /// Initializes a new instance of the <see cref="BaseActionMethodExceptionLogEntry" /> class. /// </summary> /// <param name="eventId">The event identifier.</param> /// <param name="method">The method being invoked.</param> /// <param name="request">The request being executed on the method.</param> /// <param name="exception">The exception that was thrown.</param> protected BaseActionMethodExceptionLogEntry( EventId eventId, IGraphMethod method, IDataRequest request, Exception exception) : base(eventId) { this.PipelineRequestId = request.Id; this.ControllerTypeName = method.Parent.InternalFullName; this.ActionName = method.Name; this.Exception = new ExceptionLogItem(exception); }
private void DeleteRequest(string requestQuery, IDataRequest requestData = null) { var request = new RestRequest(requestQuery); if (requestData != null) { request.AddJsonBody(requestData); } var result = _client.Delete(request); CheckRequestResult(result); }
public Int32 GetCount(ApplicationMetadata application, [CanBeNull] IDataRequest request) { SearchRequestDto searchDto = null; if (request is DataRequestAdapter && request != null) { searchDto = ((DataRequestAdapter)request).SearchDTO; } else if (request is SearchRequestDto) { searchDto = (SearchRequestDto)request; } searchDto = searchDto ?? new SearchRequestDto(); var entityMetadata = MetadataProvider.SlicedEntityMetadata(application); searchDto.BuildProjection(application.Schema); return(_maximoConnectorEngine.Count(entityMetadata, searchDto)); }
protected void DataRequested(IDataRequest dataRequest) { // Find the first page element that implements IShareable and forward the data request INavigationEntry currentPage = navigationManager.CurrentPage; bool hasRequestBeenProcessed = false; if (currentPage != null) { foreach (object element in currentPage.GetElements()) { if (element is IShareable) { ((IShareable)element).ShareRequested(dataRequest); hasRequestBeenProcessed = true; } } } // If there is nothing to share and their is a default failure text specified then return this if (!hasRequestBeenProcessed && !string.IsNullOrEmpty(DefaultFailureText)) dataRequest.FailWithDisplayText(DefaultFailureText); }
/// <summary> /// Used to read data from a data request /// </summary> /// <returns>All the data as a string</returns> public string ReadData(IDataRequest request) { return(request.RequestData()); }
public IApplicationResponse Get(ApplicationMetadata application, InMemoryUser user, IDataRequest request) { var adapter = request as DataRequestAdapter; if (adapter != null) { if (adapter.SearchDTO != null) { request = adapter.SearchDTO; } else if (adapter.Id != null) { request = DetailRequest.GetInstance(application, adapter); } } if (request is PaginatedSearchRequestDto) { return(GetList(application, (PaginatedSearchRequestDto)request)); } if (request is DetailRequest) { try { return(GetApplicationDetail(application, user, (DetailRequest)request)); } catch (InvalidOperationException e) { return(new ApplicationDetailResult(null, null, application.Schema, null, ((DetailRequest)request).Id)); } } if (application.Schema.Stereotype == SchemaStereotype.List) { return(GetList(application, PaginatedSearchRequestDto.DefaultInstance(application.Schema))); } if (application.Schema.Stereotype == SchemaStereotype.Detail || request.Key.Mode == SchemaMode.input) { //case of detail of new items return(GetApplicationDetail(application, user, DetailRequest.GetInstance(application, adapter))); } throw new InvalidOperationException("could not determine which operation to take upon request"); }
public abstract bool TryGetData(IDataRequest dataRequest, IDataCollectionContext context, out object result);
private readonly IDataRequest _dataRequest; // экземпляр интерфейса получения данных из других сервисов public Report(IDataRequest dataRequest) { _dataRequest = dataRequest; // получаем все данные }
public CityWeatherClient(IDataRequest dataRequest, string serviceBaseUrl) { _dataRequest = dataRequest; _serviceBaseUrl = serviceBaseUrl; }
private List <DataViewModel> dataviews = new List <DataViewModel>(); //View модель для отображения результата /*получаем данные из контейнера зависимостей*/ public DataController(IGetValue values, IDataRequest dataRequest) { _values = values; _dataRequests = dataRequest; }
// *** Methods *** public new void DataRequested(IDataRequest dataRequest) { base.DataRequested(dataRequest); }
// *** Methods *** public void ShareRequested(IDataRequest dataRequest) { DataRequests.Add(dataRequest); }
public IORequest(IDataRequest <T> request) { this.request = request; }
public override bool TryGetData(IDataRequest request, IDataCollectionContext cx, out object result) { try { result = null; if (request.Data == "Application.Version") { if (ApplicationIsNetworkDeployed) { result = ApplicationDeployment.CurrentDeployment.CurrentVersion; return true; } var entryAssembly = Assembly.GetEntryAssembly(); if (entryAssembly != null) { result = entryAssembly.GetName().Version; return true; } } //# Current Thread if (request.Data == "Thread.Id") { result = cx.CurrentThread.ManagedThreadId; return true; } if (request.Data == "Thread.Name") { result = cx.CurrentThread.Name; return true; } if (request.Data == "Thread.ThreadState") { result = cx.CurrentThread.ThreadState; return true; } if (request.Data == "Thread.IsBackground") { result = cx.CurrentThread.IsBackground; return true; } if (request.Data == "Thread.UICulture") { result = CultureInfo.CurrentUICulture.EnglishName; return true; } if (request.Data == "Thread.Culture") { result = CultureInfo.CurrentCulture.EnglishName; return true; } //# Time if (request.Data == "DateTime.Utc") { result = DateTime.UtcNow; return true; } if (request.Data == "DateTime.Local") { result = DateTime.Now; return true; } //# Environment if (request.Data == "Environment.CommandLineArgs") { result = string.Join( " ", Environment.GetCommandLineArgs() .Select(s => { if (s.Contains(" ")) return string.Format("\"{0}\"", s); else return s; })); return true; } if (request.Data == "Environment.Version") { result = Environment.Version; return true; } if (request.Data == "Environment.HasShutdownStarted") { result = Environment.HasShutdownStarted; return true; } if (request.Data == "Environment.OSVersion") { result = Environment.OSVersion; return true; } if (request.Data == "Environment.OSVersion.Platform") { result = Environment.OSVersion.Platform; return true; } if (request.Data == "Environment.OSVersion.ServicePack") { result = Environment.OSVersion.ServicePack; return true; } if (request.Data == "Environment.OSVersion.Version") { result = Environment.OSVersion.Version; return true; } if (request.Data == "Environment.CurrentDirectory") { result = Environment.CurrentDirectory; return true; } if (request.Data == "Environment.SystemDirectory") { result = Environment.SystemDirectory; return true; } if (request.Data == "Environment.Is64BitOperatingSystem") { result = Environment.Is64BitOperatingSystem; return true; } if (request.Data == "Environment.Is64BitProcess") { result = Environment.Is64BitProcess; return true; } if (request.Data == "Environment.MachineName") { result = Environment.MachineName; return true; } if (request.Data == "Environment.ProcessorCount") { result = Environment.ProcessorCount; return true; } if (request.Data == "Environment.SystemPageSizeMB") { result = Environment.SystemPageSize.ToMegaBytes(); return true; } if (request.Data == "Environment.SystemPageSizeMiB") { result = Environment.SystemPageSize.ToMebiBytes(); return true; } if (request.Data == "Environment.UserDomainName") { result = Environment.UserDomainName; return true; } if (request.Data == "Environment.UserName") { result = Environment.UserName; return true; } if (request.Data == "Environment.UserInteractive") { result = Environment.UserInteractive; return true; } //# Current Process if (request.Data == "Process.Id") { result = cx.CurrentProcess.Id; return true; } if (request.Data == "Process.PagedMemorySize (MB)") { result = cx.CurrentProcess.PagedMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.MaxWorkingSet (MB)") { result = cx.CurrentProcess.MaxWorkingSet.ToInt64().ToMegaBytes(); return true; } if (request.Data == "Process.NonpagedSystemMemorySize (MB)") { result = cx.CurrentProcess.NonpagedSystemMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.PagedSystemMemorySize (MB)") { result = cx.CurrentProcess.PagedSystemMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.PrivateMemorySize (MB)") { result = cx.CurrentProcess.PrivateMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.VirtualMemorySize (MB)") { result = cx.CurrentProcess.VirtualMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.WorkingSet (MB)") { result = cx.CurrentProcess.WorkingSet64.ToMegaBytes(); return true; } if (request.Data == "Process.PagedMemorySize (MiB)") { result = cx.CurrentProcess.PagedMemorySize64.ToMebiBytes(); return true; } if (request.Data == "Process.PagedMemorySize (MB)") { result = cx.CurrentProcess.PagedMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.MaxWorkingSet (MiB)") { result = cx.CurrentProcess.MaxWorkingSet.ToInt64().ToMebiBytes(); return true; } if (request.Data == "Process.NonpagedSystemMemorySize (MiB)") { result = cx.CurrentProcess.NonpagedSystemMemorySize64.ToMebiBytes(); return true; } if (request.Data == "Process.NonpagedSystemMemorySize (MB)") { result = cx.CurrentProcess.NonpagedSystemMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.PagedSystemMemorySize (MiB)") { result = cx.CurrentProcess.PagedSystemMemorySize64.ToMebiBytes(); return true; } if (request.Data == "Process.PagedSystemMemorySize (MB)") { result = cx.CurrentProcess.PagedSystemMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.PrivateMemorySize (MiB)") { result = cx.CurrentProcess.PrivateMemorySize64.ToMebiBytes(); return true; } if (request.Data == "Process.PrivateMemorySize (MB)") { result = cx.CurrentProcess.PrivateMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.VirtualMemorySize (MiB)") { result = cx.CurrentProcess.VirtualMemorySize64.ToMebiBytes(); return true; } if (request.Data == "Process.VirtualMemorySize (MB)") { result = cx.CurrentProcess.VirtualMemorySize64.ToMegaBytes(); return true; } if (request.Data == "Process.WorkingSet (MiB)") { result = cx.CurrentProcess.WorkingSet64.ToMebiBytes(); return true; } if (request.Data == "MemoryStatus.MemoryLoad") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.MemoryLoad; return true; } if (request.Data == "MemoryStatus.AvailablePageFile (MB)") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.AvailablePageFile.ToMegaBytes(); return true; } if (request.Data == "MemoryStatus.AvailablePhysical (MB)") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.AvailablePhysical.ToMegaBytes(); return true; } if (request.Data == "MemoryStatus.AvailableVirtual (MB)") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.AvailableVirtual.ToMegaBytes(); return true; } if (request.Data == "MemoryStatus.TotalPageFile (MB)") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.TotalPageFile.ToMegaBytes(); return true; } if (request.Data == "MemoryStatus.TotalPhysical (MB)") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.TotalPhysical.ToMegaBytes(); return true; } if (request.Data == "MemoryStatus.TotalVirtual (MB)") { if (!this.MemoryStatus.IsOSSupported) return false; this.MemoryStatus.Refresh(TimeSpan.FromSeconds(1)); result = MemoryStatus.TotalVirtual.ToMegaBytes(); ; return true; } if (request.Data == "Process.UpTime") { result = ((TimeSpan)(DateTime.Now - cx.CurrentProcess.StartTime)).ToString(); return true; } if (request.Data == "Deployment.IsNetworkDeployed") { result = ApplicationIsNetworkDeployed; return true; } if (request.Data == "Deployment.ActivationUri") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.ActivationUri; return true; } if (request.Data == "Deployment.CurrentVersion") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.CurrentVersion; return true; } if (request.Data == "Deployment.DataDirectory") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.DataDirectory; return true; } if (request.Data == "Deployment.IsFirstRun") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.IsFirstRun; return true; } if (request.Data == "Deployment.TimeOfLastUpdateCheck") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.TimeOfLastUpdateCheck; return true; } if (request.Data == "Deployment.UpdatedApplicationFullName") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.UpdatedApplicationFullName; return true; } if (request.Data == "Deployment.UpdatedVersion") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.UpdatedVersion; return true; } if (request.Data == "Deployment.UpdateLocation") { if (!ApplicationIsNetworkDeployed) return false; result = ApplicationDeployment.CurrentDeployment.UpdateLocation; return true; } if (request.Data == "System.Processes (Top 10 by Memory)") { result = (from p in Process.GetProcesses() orderby p.WorkingSet64 descending select new { Name = p.ProcessName, WorkingSetMB = p.WorkingSet64.ToMegaBytes() }) .Take(10) .ToList(); return true; } // TODO: //result.TryAddProperty("Process.IsElevated", () => shell32.IsUserAnAdmin()); //result.TryAddProperty("Process.IntegrityLevel", () => advapi32.GetProcessIntegrityLevel()); } catch (Exception ex) { //DiagnosticLogger.Global.in // TODO: log warning } result = null; return false; }