public async Task <bool> Update(ProcessDto model) { var artProcess = _mapper.Map <Process>(model); _repoProcess.Update(artProcess); return(await _repoProcess.SaveAll()); }
public void ProcessDtoToString(Priority priority) { var process = new ProcessDto(priority); var message = process.ToString(); Assert.Equal($"PID:{process.PID} Priority:{process.Priority} Create Date:{process.CreateDate}", message); }
private static void Print(ProcessDto dto) { Console.WriteLine("\t" + dto.Name); Console.WriteLine("\t" + dto.Responding); Console.WriteLine("\t" + dto.CPU + "%"); Console.WriteLine("\t" + dto.Memory + "MB"); Console.WriteLine(); }
public override void Configure(Container container) { // Global Configurations SetConfig(new HostConfig { DefaultContentType = MimeTypes.Json, EnableFeatures = Feature.Json, PreferredContentTypes = new List <string> { MimeTypes.Json }, MapExceptionToStatusCode = { { typeof(InabilityToProcessPayloadException), (int)HttpStatusCode.BadRequest }, } }); // Exception Handlers ServiceExceptionHandlers.Add((httpReq, request, exception) => { var message = exception.Message; Log.Error(message); Log.Error(exception.GetResponseBody()); Log.Info(httpReq.AbsoluteUri); return(exception is DeclinePaymentException ? new HttpResult( ProcessDto.GetErrorResponse(httpReq.AbsoluteUri, message, ((DeclinePaymentException)exception).ErrorCode), HttpStatusCode.OK) : new HttpResult(null, HttpStatusCode.BadRequest)); }); UncaughtExceptionHandlers.Add((req, res, operationName, ex) => { Log.Error(ex.GetResponseBody()); res.StatusCode = ex is SerializationException ? (int)HttpStatusCode.BadRequest : (int)HttpStatusCode.InternalServerError; res.EndRequest(true); }); // Global Filters PreRequestFilters.Add((req, res) => { Log.Info($"{HTTP_HEADER.HOST} : {req.UserHostAddress}"); Log.Info($"{HTTP_HEADER.USER_AGENT} : {req.UserAgent}"); Log.Info($"{HTTP_HEADER.CONTENT_LENGTH} : {req.ContentLength}"); Log.Info($"{HTTP_HEADER.CONTENT_TYPE} : {req.ContentType}"); Log.Info($"{HTTP_HEADER.ACCEPT} : {req.AcceptTypes}"); Simulate500Error.CallMqServer(); }); // Validations Plugins.Add(new ValidationFeature()); container.RegisterValidators(typeof(MerchantPaymentValidator).Assembly, typeof(MerchantPaymentAdviceValidator).Assembly, typeof(CashInValidator).Assembly, typeof(CashInAdviceValidator).Assembly, typeof(CashOutValidator).Assembly, typeof(CashOutAdviceValidator).Assembly); // IoC container.RegisterAutoWiredAs <AppSettings, IAppSettings>(); }
internal static Package FromDto(ProcessDto dto) { return(new Package { Id = dto.Id, IsActive = dto.IsActive, IsLatestVersion = dto.IsLatestVersion, Key = dto.Key, OldVersion = dto.OldVersion, Published = dto.Published, Title = dto.Title, Version = dto.Version, Description = dto.Description }); }
public void PriorityQueueWithLowPriority() { var taskManager = TaskManagerFactory.CreateTaskManager(CustomerName, 2); var p1 = new ProcessDto(Priority.Low); taskManager.Add(p1); taskManager.Add(new ProcessDto(Priority.Low)); var isAdded = taskManager.Add(new ProcessDto(Priority.Medium)); Assert.NotNull(isAdded); var processList = taskManager.List(); Assert.Null(processList.FirstOrDefault(m => m.PID == p1.PID)); }
/// <summary> /// Adds a new process to task-list /// </summary> public ProcessDto Add(ProcessDto processDto) { var process = new Process(processDto.Priority, _newTaskId); if (ProcessList.Count == ProcessList.Capacity) { if (!TryAddOverflow(process)) { return(null); } } ProcessList.Add(process); _newTaskId++; return(MapToDto(process)); }
public bool TryMapToDto(Process process, out ProcessDto processDto) { var result = true; try { processDto = MapToDto(process); } catch (Exception e) { result = false; processDto = null; var message = $"Process Mapping error. ProcessName: {process.ProcessName}; ProcessId: {process.Id}; Error Message:{e.Message}"; _logger.LogWarning(message); } return(result); }
private Task <ProcessDto> CreateProcessDto(ManagementObject managementObject, CancellationToken cancellationToken) { Process process; if (managementObject.TryGetProperty("ProcessId", out uint processId)) { try { process = Process.GetProcessById((int)processId); } catch (Exception) { return(null); } } else { return(null); } var processDto = new ProcessDto { ProcessId = (int)processId }; var isUpdate = _latestProcessIds?.Contains((int)processId) == true; foreach (var processValueProvider in _processValueProviders) { try { foreach (var property in processValueProvider.ProvideValues(managementObject, process, isUpdate)) { processDto.Add(property.Key, property.Value); } } catch (Exception) { // ignored } } return(Task.FromResult(processDto)); }
public void PriorityQueueWithHighPriority() { var taskManager = TaskManagerFactory.CreateTaskManager(CustomerName, 2); var pLowOld = new ProcessDto(Priority.Low); var pHigh = new ProcessDto(Priority.High); var pMedium = new ProcessDto(Priority.Medium); var pLowNew = new ProcessDto(Priority.Low); taskManager.Add(pLowOld); taskManager.Add(pHigh); taskManager.Add(pLowNew); var isAdded = taskManager.Add(pMedium); Assert.NotNull(isAdded); var processList = taskManager.List(); Assert.Null(processList.FirstOrDefault(m => m.PID == pLowOld.PID)); }
public void FifoTaskManagerOverFlowOldestWillBeKilled() { var taskManager = TaskManagerFactory.CreateTaskManager(CustomerName, 2); var p1 = new ProcessDto(Priority.Low); var p2 = new ProcessDto(Priority.Low); var p3 = new ProcessDto(Priority.Low); taskManager.Add(p1); taskManager.Add(p2); taskManager.Add(p3); var processList = taskManager.List(m => m.CreateDate); Assert.Null(processList.FirstOrDefault(m => m.PID == p1.PID)); var p4 = new ProcessDto(Priority.Low); taskManager.Add(p4); processList = taskManager.List(m => m.CreateDate); Assert.Null(processList.FirstOrDefault(m => m.PID == p2.PID)); }
public UnitySuccessAction(ProcessDto process, int unityLast, int unityMax) { Process = process; UnityLast = unityLast; UnityMax = unityMax; }
public MayaSuccessAction(ProcessDto process, int mayaLast, int mayaMax) { Process = process; MayaLast = mayaLast; MayaMax = mayaMax; }
public RetexturingSuccessAction(ProcessDto process, int retexturingLast, int retexturingMax) { Process = process; RetexturingLast = retexturingLast; RetexturingMax = retexturingMax; }
public ReconstructionSuccessAction(ProcessDto process, int reconstructionLast, int reconstructionMax) { Process = process; ReconstructionLast = reconstructionLast; ReconstructionMax = reconstructionMax; }
public CreateProcessSuccessAction(ProcessDto process) { Process = process; }
public void Create(ProcessDto request) { var domainRequest = this.processConverter.ConvertBack(request); this.processContainer.Add(domainRequest); }