public async Task <ActionResult> CategoriesUpdateDetails(int?id, OperationType?operation) { if (operation == null || operation == OperationType.None) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var categoriesQuery = operation == OperationType.Modify ? db.CategoriesUpdates .Where(x => x.UpdateEventId == id && x.OperationType == operation && x.CategoryBackup.UpdateEventId == x.UpdateEventId) : db.CategoriesUpdates .Where(x => x.UpdateEventId == id && x.OperationType == operation); var viewModel = await db.UpdateEvents .Where(x => x.Id == id) .Select(x => new UpdateEventViewModels.CategoryUpdateDetailsViewModel { UpdateEventId = x.Id, OperationType = operation.Value, TrainingProviderName = x.TrainingProvider.Name, Categories = categoriesQuery.Select(c => new UpdateEventViewModels.CategoryUpdateListViewModel { CategoryId = c.CategoryId, Title = c.Category.Title, CategoryUrlName = c.Category.UrlName }).ToList() }).SingleOrDefaultAsync(); if (viewModel == null) { return(HttpNotFound()); } return(View(viewModel)); }
public AuthorizationError(ASTNode?node, ValidationContext context, string message, AuthorizationResult result, OperationType?operationType = null) : base(context.Document.Source, "6.1.1", message, node == null ? Array.Empty <ASTNode>() : new ASTNode[] { node }) { Code = "authorization"; AuthorizationResult = result; OperationType = operationType; }
/// <summary> /// Serializes the enum value. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="value">The object to serialize to JSON.</param> public static void Serialize(JsonWriter writer, OperationType?value) { switch (value) { case OperationType.Invalid: writer.WriteStringValue("Invalid"); break; case OperationType.PartitionDataLoss: writer.WriteStringValue("PartitionDataLoss"); break; case OperationType.PartitionQuorumLoss: writer.WriteStringValue("PartitionQuorumLoss"); break; case OperationType.PartitionRestart: writer.WriteStringValue("PartitionRestart"); break; case OperationType.NodeTransition: writer.WriteStringValue("NodeTransition"); break; default: throw new ArgumentException($"Invalid value {value.ToString()} for enum type OperationType"); } }
/// <summary> /// Condition to check Quorum(i.e. Strong) read with eventual account /// </summary> /// <param name="backendConsistency"></param> /// <param name="desiredConsistency"></param> /// <param name="operationType"></param> /// <param name="resourceType"></param> /// <returns>true/false</returns> private static bool IsLocalQuorumConsistency(Documents.ConsistencyLevel backendConsistency, Documents.ConsistencyLevel desiredConsistency, OperationType?operationType, ResourceType?resourceType) { if (backendConsistency != Documents.ConsistencyLevel.Eventual) { return(false); } if (desiredConsistency != Documents.ConsistencyLevel.Strong) { return(false); } if (!resourceType.HasValue || (resourceType.HasValue && resourceType != ResourceType.Document)) { return(false); } if (!operationType.HasValue || (operationType.HasValue && !(operationType == OperationType.Read || operationType == OperationType.ReadFeed))) { return(false); } return(true); }
private void CheckAuth( INode node, IProvideMetadata provider, ClaimsPrincipal user, ValidationContext context, OperationType?operationType) { if (provider == null || !provider.RequiresAuthorization()) { return; } // TODO: async -> sync transition var result = _evaluator .Evaluate(user, context.UserContext, context.Inputs, provider.GetPolicies()) .GetAwaiter() .GetResult(); if (result.Succeeded) { return; } string errors = string.Join("\n", result.Errors); context.ReportError(new ValidationError( context.Document.OriginalQuery, "authorization", $"You are not authorized to run this {operationType.ToString().ToLower()}.\n{errors}", node)); }
public async Task <IActionResult> GetOperations(OperationType?type) { var list = await _operationService.GetOperationsList(type); var result = Mapper.Map <ICollection <OperationViewModel> >(list); return(Json(result)); }
public async Task <ICollection <OperationModel> > GetOperationsList(OperationType?type) { var models = type.HasValue ? await _operationRepository.GetCustom(x => x.Where(w => w.Type == type)) : await _operationRepository.GetAll(); return(Mapper.Map <ICollection <OperationModel> >(models)); }
private void clear_Click(object sender, EventArgs e) { this.textBox1.Text = ""; this.input = string.Empty; this.operand1 = string.Empty; this.operand2 = string.Empty; operation = null; }
internal RestorableSqlDatabasePropertiesResource(string rid, OperationType?operationType, string eventTimestamp, string ownerId, string ownerResourceId, RestorableSqlDatabasePropertiesResourceDatabase database) { Rid = rid; OperationType = operationType; EventTimestamp = eventTimestamp; OwnerId = ownerId; OwnerResourceId = ownerResourceId; Database = database; }
private static string GetOperationType(OperationType?operationType) { return(operationType switch { Language.AST.OperationType.Query => "query", Language.AST.OperationType.Mutation => "mutation", Language.AST.OperationType.Subscription => "subscription", _ => "operation", });
private string GetOperationType(OperationType?operationType) { return(operationType switch { OperationType.Query => "query", OperationType.Mutation => "mutation", OperationType.Subscription => "subscription", _ => "operation", });
/// <summary> /// Initializes a new instance of the OperationStatus class. /// </summary> /// <param name="operationId">A GUID that identifies a call to this API. This is also passed into the corresponding /// GetProgress API.</param> /// <param name="state">The state of the operation. Possible values include: 'Invalid', 'Running', 'RollingBack', /// 'Completed', 'Faulted', 'Cancelled', 'ForceCancelled'</param> /// <param name="type">The type of the operation. Possible values include: 'Invalid', 'PartitionDataLoss', /// 'PartitionQuorumLoss', 'PartitionRestart', 'NodeTransition'</param> public OperationStatus( Guid?operationId = default(Guid?), OperationState?state = default(OperationState?), OperationType?type = default(OperationType?)) { this.OperationId = operationId; this.State = state; this.Type = type; }
internal RestorableSqlContainerPropertiesResource(string rid, OperationType?operationType, string eventTimestamp, string ownerId, string ownerResourceId, RestorableSqlContainerPropertiesResourceContainer container) { Rid = rid; OperationType = operationType; EventTimestamp = eventTimestamp; OwnerId = ownerId; OwnerResourceId = ownerResourceId; Container = container; }
private void ClickOperator(OperationType op) { if (operation != null) { calculate(); } operand1 = input; operation = op; input = string.Empty; }
public RiskConstraintsGroupConfiguration( OperationType?operationType, string blockchainType, string blockchainAssetId, IReadOnlyCollection <RiskConstraintConfiguration> constraints) { OperationType = operationType; BlockchainType = blockchainType; BlockchainAssetId = blockchainAssetId; Constraints = constraints; }
public async Task HasExpectedType(string method, string url, OperationType?type) { var request = new StartRequest(method, url); var sources = new List <string> { NuGetSourceUrl }; var context = await OperationParserContext.CreateAsync(sources); var operationInfo = OperationParser.Parse(context, request); Assert.Equal(type, operationInfo.Operation?.Type); }
public Task <RiskConstraintResolution> ApplyAsync( string blockchainType, string blockchainAssetId, OperationType?operationType, Operation operation) { var resolution = operation.Amount > _maxAmount ? RiskConstraintResolution.Violated($"Operation amount {operation.Amount} > {_maxAmount}") : RiskConstraintResolution.Passed; return(Task.FromResult(resolution)); }
private object GetEquipments(dynamic parameters) { int pageNumber = Int32.Parse(Request.Query["pageNumber"].Value); int pageSize = Int32.Parse(Request.Query["pageSize"].Value); OperationType?operationType = (OperationType)Int32.Parse(Request.Query["operationType"].Value); var equipments = _dbManager.GetEquipments(pageNumber, pageSize, operationType); var dtoEquipments = equipments.Select(e => _dtoConverter.ConvertEquipment(e)).ToList(); return(dtoEquipments); }
private static string GenerateMessage(OperationType?operationType, AuthorizationResult result) { var error = new StringBuilder(); AppendFailureHeader(error, operationType); foreach (var failure in result.Failure.FailedRequirements) { AppendFailureLine(error, failure); } return(error.ToString()); }
public async Task <decimal> GetAggregatedAmountForTheLastPeriodAsync( string blockchainType, string blockchainAssetId, OperationType?operationType, TimeSpan period) { var result = await BuildQuery(blockchainType, blockchainAssetId, operationType) .Match(e => e.Timestamp >= DateTime.UtcNow.Subtract(period)) .Group(e => 1, g => new { Amount = g.Sum(e => e.Amount) }) .SingleOrDefaultAsync(); return(result?.Amount ?? 0m); }
public async Task <long> GetOperationsCountForTheLastPeriodAsync( string blockchainType, string blockchainAssetId, OperationType?operationType, TimeSpan period) { var result = await BuildQuery(blockchainType, blockchainAssetId, operationType) .Match(e => e.Timestamp >= DateTime.UtcNow.Subtract(period)) .Count() .SingleOrDefaultAsync(); return(result?.Count ?? 0); }
public Pager <SysOperationLog> GetPager(PageSearchModel search, string source, string sourceId, TableSource?cat, OperationType?type, string q, string uname, DateTime?minTime, DateTime?maxTime) { var dynamicParams = new DynamicParameters(); var sqlStr = new StringBuilder(AdminQuery()); if (!string.IsNullOrEmpty(source)) { sqlStr.Append(" and DataSource like @source"); dynamicParams.Add("source", $"%{source}%"); } if (!string.IsNullOrEmpty(sourceId)) { sqlStr.Append(" and DataSouceId = @srcId"); dynamicParams.Add("srcId", sourceId); } if (cat.HasValue) { sqlStr.Append(" and LogCat = @cat"); dynamicParams.Add("cat", cat.Value); } if (type.HasValue) { sqlStr.Append(" and LogType = @type"); dynamicParams.Add("type", type.Value); } if (!string.IsNullOrEmpty(q)) { sqlStr.Append(" and LogTitle like @title"); dynamicParams.Add("title", $"%{q}%"); } if (!string.IsNullOrEmpty(uname)) { sqlStr.Append(" and CreateUserName = @uname"); dynamicParams.Add("uname", uname); } if (minTime.HasValue) { sqlStr.Append(" and CreateTime >= @minTime"); dynamicParams.Add("minTime", minTime.Value); } if (maxTime.HasValue) { sqlStr.Append(" and CreateTime <= @maxTime"); dynamicParams.Add("maxTime", maxTime.Value); } return(Pager(sqlStr.ToString(), dynamicParams, search)); }
public async Task <RiskConstraintResolution> ApplyAsync( string blockchainType, string blockchainAssetId, OperationType?operationType, Operation operation) { var operationsCount = await _statisticsRepository.GetOperationsCountForTheLastPeriodAsync( blockchainType, blockchainAssetId, operationType, _period); return(operationsCount + 1 > _maxOperationsCount ? RiskConstraintResolution.Violated($"Operations count {operationsCount} + 1 > {_maxOperationsCount} for the last {_period}") : RiskConstraintResolution.Passed); }
public async Task <RiskConstraintResolution> ApplyAsync( string blockchainType, string blockchainAssetId, OperationType?operationType, Operation operation) { var aggregatedAmount = await _statisticsRepository.GetAggregatedAmountForTheLastPeriodAsync( blockchainType, blockchainAssetId, operationType, _period); return(aggregatedAmount + operation.Amount > _maxAmount ? RiskConstraintResolution.Violated($"Aggregated operations amount {aggregatedAmount} + {operation.Amount} > {_maxAmount} for the last {_period}") : RiskConstraintResolution.Passed); }
public async Task <IReadOnlyCollection <MessageData> > GetAsync( int from = 0, int size = 50, OperationType?type = null, OperationStatus?status = null, Type message = null) { var search = new SearchDescriptor <MessageData>() .Index(_settings.Elasticsearch.Index) .From(from) .Size(size); if (type.HasValue) { search = search.Query(q => q .Match(m => m .Field(f => f.Type) .Query(((int)type).ToString()) ) ); } if (status.HasValue) { search = search.Query(q => q .Match(m => m .Field(f => f.Status) .Query(((int)status).ToString()) ) ); } if (message is not null) { search = search.Query(q => q .Match(m => m .Field(f => f.ClrType) .Query(message.AssemblyQualifiedName) ) ); } var data = await _client.SearchAsync <MessageData>(search); return(data.Documents); }
// GET: Operation/List public ActionResult List(string user, OperationType?operation, int?patient, string dateFrom, string dateTo, string operationData, string sorting, int?page) { //Sorting ViewBag.TimeSort = sorting == "time_a" ? "time_d" : "time_a"; ViewBag.UserSort = sorting == "user_a" ? "user_d" : "user_a"; ViewBag.OperationSort = sorting == "operation_a" ? "operation_d" : "operation_a"; ViewBag.PatientSort = sorting == "patient_a" ? "patient_d" : "patient_a"; //Pagination var pageNumber = (page ?? 1); var operations = _operationService.Search(user, operation, patient, dateFrom, dateTo, operationData, sorting, pageNumber, PageSize); return(View(operations)); }
static void AddValidationError(INode node, ValidationContext context, OperationType?operationType, AuthorizationResult result) { if (!result.Succeeded) { var error = new StringBuilder("You are not authorized to run this ") .Append(GetOperationType(operationType)) .Append("."); foreach (var failure in result.Failure.FailedRequirements) { AppendFailureLine(error, failure); } context.ReportError(new ValidationError(context.OriginalQuery, "6.1.1", error.ToString(), node == null ? Array.Empty <INode>() : new INode[] { node }) { Code = "authorization", }); } }
public virtual string GenerateMessage(OperationType?operationType, AuthorizationResult result) { if (result.Succeeded) { return("Success!"); } var error = new StringBuilder(); AppendFailureHeader(error, operationType); if (result.Failure != null) { foreach (var requirement in result.Failure.FailedRequirements) { AppendFailureLine(error, requirement); } } return(error.ToString()); }