public RESULT Invoke <RESULT>(IAPIContext context, params Header[] headers) { SmartRoute.WebApi4Grid.Result result; try { Message message = new Message(); message.Body = context.Request(); if (headers != null) { foreach (Header item in headers) { message.Headers[item.Name] = item.Value; } } string service = context.Path(); message.Api = service; SmartRoute.IMessage rmessage = mSwitch.Send(service, message); result = rmessage.GetBody <SmartRoute.WebApi4Grid.Result>(); } catch (Exception e_) { result = new Result(); result.ErrorCode = 501; result.Error = e_.Message; result.ErrorStackTrace = e_.StackTrace; } return(context.Response <RESULT>(result)); }
public DisableOrganizationCommandValidator(IAPIContext dbContext) { _dbContext = dbContext; RuleFor(x => x.Id).NotEmpty().MustAsync(IsExist); RuleFor(x => x.ModifyBy).NotEmpty(); RuleFor(x => x.CommandId).NotEmpty(); }
public CreateOrganizationCommandValidator(IAPIContext dbContext) { _dbContext = dbContext; RuleFor(x => x.Id).NotEmpty(); RuleFor(x => x.UniqueIdentifier).NotEmpty() .MustAsync(IsUnique); RuleFor(x => x.CommandId).NotEmpty(); RuleFor(x => x.CreatedBy).NotEmpty().WithMessage("Organization should have owner") .MustAsync(IsExistAndHavePermissions).WithMessage("This user already own organization"); }
public APIInfo(IAPIContext apiContext, MethodInfo method) { Method = method; APIContext = apiContext; var parameters = method.GetParameters(); Parameters = new Type[parameters.Length]; for (var i = 0; i < parameters.Length; i++) { Parameters[i] = parameters[i].ParameterType; } }
public CreateAndAddUserToOrganizationCommandValidator(IAPIContext dbContext) { _dbContext = dbContext; RuleFor(x => x.Id).NotEmpty(); RuleFor(x => x.Birthdate).NotEmpty(); RuleFor(x => x.FirstName).NotEmpty(); RuleFor(x => x.SecondName).NotEmpty(); RuleFor(x => x.SurName).NotEmpty(); RuleFor(x => x.OrganizationId).NotEmpty().MustAsync(OrganizationExist); RuleFor(x => x.CommandId).NotEmpty(); }
public static async Task RetryOnExceptionAsync <TException>(this IAPIContext context, int times, Func <Task> operation) where TException : Exception { if (times <= 0) { throw new ArgumentOutOfRangeException(nameof(times)); } var DelayPerAttemptInSeconds = new[] { (int)TimeSpan.FromSeconds(2).TotalSeconds, (int)TimeSpan.FromSeconds(30).TotalSeconds, (int)TimeSpan.FromMinutes(2).TotalSeconds, (int)TimeSpan.FromMinutes(10).TotalSeconds, (int)TimeSpan.FromMinutes(30).TotalSeconds }; var attempts = 0; do { try { attempts++; await operation(); break; } catch (TException e) { if (attempts == times) { throw; } var delay = attempts > DelayPerAttemptInSeconds.Length ? DelayPerAttemptInSeconds.Last() : DelayPerAttemptInSeconds[attempts]; await Task.Delay(delay); } } while (true); }
public UserProfileRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public ErrorController(IScopedLogger <ErrorController> logger, IAPIContext context) { _logger = logger; apiContext = context; }
public ProjectRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public RESULT Invoke <RESULT>(IAPIContext context) { return(Invoke <RESULT>(context, null)); }
public GetUserQueryValidator(IAPIContext dbContext) { _dbContext = dbContext; RuleFor(x => x.Id).NotEmpty().MustAsync(IsExist); }
public MainPageViewModel(IAPIContext apiContext) { _apiContext = apiContext; RefreshCommand = new DelegateCommand(ExecuteRefreshCommand); }
public MultiplicationCommandHandler(IAPIContext apiContext) { this.apiContext = apiContext; }
public static async Task <TR> ProcessRequest <TI, TR, TC>(this IRequestWithFluentValidator <TI, TR, TC> request, IAPIContext <TC> apiContext) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (apiContext == null) { throw new ArgumentNullException(nameof(apiContext)); } var decoratedFunc = request.ProcessRequestFunc.DecorateRequestWithFluentValidation(request.ValidationFunc) .DecorateWithExecutionTimeLogger(); var res = await decoratedFunc(new RequestWithContext <TI, TR, TC>(apiContext, request)).ConfigureAwait(false); var retVal = res.GetValueThrowExceptionIfExceptionPresent(); return(retVal); }
public GetUsersByOrganizationQueryValidator(IAPIContext dbContext) { _dbContext = dbContext; RuleFor(x => x.OrganizationId).NotEmpty().MustAsync(IsExist); }
public AccountSummaryRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public MeetingRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public static async Task RetryOnExceptionAsync(this IAPIContext context, int times, Func <Task> operation) { await context.RetryOnExceptionAsync <Exception>(times, operation); }
public MailRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public DivisionCommandHandler(IAPIContext apiContext) { this.apiContext = apiContext; }
public GetOrganizationsQueryHandler(IAPIContext dbContext, IMapper mapper) { _dbContext = dbContext; _mapper = mapper; }
public TransactionBehaviour(IAPIContext dbContext, ILogger <TransactionBehaviour <TRequest, TResponse> > logger) { _dbContext = dbContext ?? throw new ArgumentException(null, nameof(dbContext)); _logger = logger ?? throw new ArgumentException(null, nameof(logger)); }
public HomeController(IScopedLogger <HomeController> logger, IAPIContext context) { _logger = logger; apiContext = context; }
public GetUserQueryHandler(IAPIContext dbContext, IMapper mapper) { _dbContext = dbContext; _mapper = mapper; }
public ContentRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public AssignmentRepository(IAPIContext apiContext) { _apiContext = apiContext; }
public CreateUserCommandHandler(IAPIContext dbContext, IMapper mapper) { _dbContext = dbContext; _mapper = mapper; }
public Task <Model> Process(IAPIContext <ContosoContext> context) => this.ProcessRequest(context);
public ParentService(IAPIContext DbContext) : base(DbContext) { }
public TermRepository(IAPIContext apiContext) { _apiContext = apiContext; }