public async Task <ExecutionResult> Execute(ExecuteContext <IVerifyCustomerDomainArguments> context) { var arguments = context.Arguments; var domainVerified = await _office365DomainService.IsDomainVerified(new Office365CustomerDomainModel { Office365CustomerId = arguments.Office365CustomerId, Domain = arguments.DomainName }); if (domainVerified) { return(context.Completed()); } var verifyDomain = await _office365DomainService.VerifyCustomerDomain(new Office365CustomerDomainModel { Office365CustomerId = arguments.Office365CustomerId, Domain = arguments.DomainName }); if (!verifyDomain) { throw new Office365VerifyDomainException( $"Could not verify domain {arguments.DomainName} for office 365 customer id {arguments.Office365CustomerId}"); } return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <IFederateCustomerDomainArguments> context) { var arguments = context.Arguments; var domainFederated = await _office365ApiService.IsDomainfederated(new Office365CustomerDomainModel { Office365CustomerId = arguments.Office365CustomerId, Domain = arguments.DomainName }); if (domainFederated) { return(context.Completed()); } await _office365ApiService.FederateCustomerDomainAsync(new Office365CustomerDomainModelWithCredentials { AdminUserName = arguments.AdminUserName, AdminPassword = arguments.AdminPassword, Office365CustomerId = arguments.Office365CustomerId, Domain = arguments.DomainName }); return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <Coding> context) { _db.Coding.Add(context.Arguments); await _db.SaveChangesAsync(); return(context.Completed <Coding>(context.Arguments)); }
public async Task <ExecutionResult> Execute(ExecuteContext <AllocateInventoryArguments> context) { var orderId = context.Arguments.OrderId; var itemNumber = context.Arguments.ItemNumber; if (string.IsNullOrEmpty(itemNumber)) { throw new ArgumentNullException(nameof(itemNumber)); } var quantity = context.Arguments.Quantity; if (quantity <= 0) { throw new ArgumentNullException(nameof(quantity)); } var allocationId = NewId.NextGuid(); var response = await _requestClient.GetResponse <InventoryAllocated>(new InventoryAllocated { AllocationId = allocationId, ItemNumber = itemNumber, Quantity = quantity }); return(context.Completed(new AllocateInventoryLogs { AllocationId = allocationId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IBookFlightActivityArguments> context) { this._logger.LogInformation($"Executing {nameof(BookFlightActivity)} activity" + $"\r\nPayload: {JsonConvert.SerializeObject(context.Arguments)}"); var(accepted, rejected) = await this._flightBookingClient .GetResponse <IBookFlightAccepted, IBookFlightRejected>(new { context.Arguments.AirportId, context.Arguments.DepartureDate, context.Arguments.DestinationId, context.Arguments.ReturnDate, context.Arguments.ReturnId }); var test = accepted.IsCompletedSuccessfully(); if (accepted.IsCompletedSuccessfully()) { var result = await accepted; return(context.Completed <IBookFlightActivityLog>(new { result.Message.DepartureFlightId, result.Message.ReturnFLightId })); } else { var result = await rejected; return(context.Faulted()); } }
public async Task <ExecutionResult> Execute(ExecuteContext <IDecreaseDatabaseCustomerSubscriptionArguments> context) { var arguments = context.Arguments; var subscription = await _office365DbSubscriptionService.GetSubscriptionAsyc(arguments.Office365SubscriptionId); if (subscription == null) { throw new ArgumentException($"Could not find subscription for Office 365 Subscription Id: {arguments.Office365SubscriptionId}"); } if (subscription.Quantity == 1) { await _office365DbSubscriptionService.DeleteSubscription(arguments.Office365SubscriptionId); } else { await _office365DbSubscriptionService.DecreaseSubscription(arguments.Office365SubscriptionId); } return(context.Completed(new DecreaseDatabaseCustomerSubscriptionLog { Office365CustomerId = subscription.Office365CustomerId, CloudPlusProductIdentifier = arguments.CloudPlusProductIdentifier, Office365SubscriptionId = subscription.Office365SubscriptionId, Office365OrderId = subscription.Office365OrderId, Office365FriendlyName = subscription.Office365FriendlyName })); }
public Task <ExecutionResult> Execute(ExecuteContext <DbStockInput> context) { //return Task.FromResult(context.Completed()); return(Task.FromResult(context.Completed(new DbStockStockLog { OrderId = context.Arguments.OrderId }))); }
public async Task <ExecutionResult> Execute(ExecuteContext <PaymentArguments> context) { var paymentCardNumber = context.Arguments.PaymentCardNumber; _logger.LogInformation("{PaymentCardNumber} 에 대하여 결재가 진행중입니다", paymentCardNumber); if (string.IsNullOrEmpty(paymentCardNumber)) { throw new ArgumentNullException(nameof(paymentCardNumber)); } await Task.Delay(5000); // allocation 해제가 바로 일어나지는 않게... if (paymentCardNumber.StartsWith("5999")) { _logger.LogError("5999 로 시작하는 PaymentCardNumber 는 사용불가함", paymentCardNumber); throw new InvalidOperationException($"5999 로 시작하는 PaymentCardNumber 는 사용불가함"); } await Task.Delay(2000); _logger.LogInformation("{PaymentCardNumber} 에 대하여 결재가 완료되었습니다", paymentCardNumber); return(context.Completed <PaymentLog>(new { AuthorizationCode = $"{context.Arguments.PaymentCardNumber}-OK", PaymentCardNumber = paymentCardNumber })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IAssignCatalogArguments> context) { try { var arguments = context.Arguments; if (!arguments.ParentId.HasValue) { throw new Exception("Catalog cannot be assigned to master company"); } if (arguments.CatalogId.HasValue) { await _companyCatalogService.AssignCatalogToCompany(arguments.ParentId.Value, arguments.CompanyId, arguments.CatalogId.Value); } else { await _companyCatalogService.AssignDefaultCatalogToCompany(arguments.ParentId.Value, arguments.CompanyId); } await _companyCatalogService.GenerateDefaultCompanyCatalog(arguments.CompanyId); return(context.Completed()); } catch (Exception ex) { this.Log().Error("Error executing CreateCompanyPriceCatalogActivity", ex); throw; } }
public async Task <ExecutionResult> Execute(ExecuteContext <AllocateInventoryArguments> context) { var orderId = context.Arguments.OrderId; var itemNumber = context.Arguments.ItemNumber; if (string.IsNullOrEmpty(itemNumber)) { throw new NoNullAllowedException($"{nameof(itemNumber)}"); } var quantity = context.Arguments.Quantity; if (quantity <= 0) { throw new ArgumentOutOfRangeException($"{nameof(quantity)}"); } var allocationId = NewId.NextGuid(); var response = await _client.GetResponse <InventoryAllocatedResponse>(new { AllocationId = allocationId, ItemNumber = itemNumber, Quantity = quantity }); // this publishes RoutingSlipCompleted event, thus IConsumer<RoutingSlipCompleted> can consume the message, // in this case, RoutingSlipConsumer return(context.Completed <AllocateInventoryLog>(new { response.Message.AllocationId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IRentCarActivityArguments> context) { this._logger.LogInformation($"Executing {nameof(RentCarActivity)} activity" + $"\r\nPayload: {JsonConvert.SerializeObject(context.Arguments)}"); var(accepted, rejected) = await this._rentCarClient.GetResponse <ICarRentalAccepted, ICarRentalRejected>(new { context.Arguments.CarId, context.Arguments.RentFrom, context.Arguments.RentTo }); var test = accepted.IsCompletedSuccessfully(); if (accepted.IsCompletedSuccessfully()) { var result = await accepted; return(context.Completed <IRentCarActivityLog>(new { result.Message.CarRentalId })); } else { var result = await rejected; return(context.Faulted()); } }
public async Task<ExecutionResult> Execute(ExecuteContext<IMultiDatabaseCustomerSubscriptionArguments> context) { var arguments = context.Arguments; var Subscriptions = new List<Models.Office365.Subscription.Office365SubscriptionModel>(); foreach (var CloudPlusProductIdentifier in arguments.CloudPlusProductIdentifiers) { var model = new Models.Office365.Subscription.Office365SubscriptionModel { Office365CustomerId = arguments.Office365CustomerId, Office365FriendlyName = string.Empty, Office365Offer = new Models.Office365.Offer.Office365OfferModel { CloudPlusProductIdentifier = CloudPlusProductIdentifier.Key }, Quantity = CloudPlusProductIdentifier.Value, SubscriptionState = Enums.Office365.Office365SubscriptionState.OperationInProgress }; await _office365DbSubscriptionService.CreateSubscription(model); Subscriptions.Add(model); } return context.Completed(new MultiDatabaseCustomerSubscriptionLog { Subscriptions = Subscriptions }); }
public async Task <ExecutionResult> Execute(ExecuteContext <ConsentArguments> context) { var sourceAddress = context.Arguments.Address; _logger.InfoFormat("Consent Content: {0}", sourceAddress); try { var routingSlip = GetRoutingSlip(context); var compensateLogs = routingSlip.Message.CompensateLogs; var a = compensateLogs[0].Data["localFilePath"]; throw new Exception("There is a fault in Consent Activity!"); return(context.Completed <ConsentLog>(new Log("ConsentParam"))); } catch (Exception exception) { var preMessage = exception.GetType() == typeof(HttpRequestException) ? "Exception from HttpClient: " : "Exception: "; _logger.Error(preMessage, exception.InnerException ?? exception); return(context.Faulted(exception)); } }
public async Task <ExecutionResult> Execute(ExecuteContext <TCommand> context) { try { IAggregateRoot aggregateRoot = await _handler.ExecuteAsync(context.Arguments); _eventFactory.Make(aggregateRoot.Events); await aggregateRoot.CommitAsync(_aggregateStore); foreach (var composite in aggregateRoot.Events) { await context.Publish(composite.Event, composite.Event.GetType()); } return(context.Completed()); } catch (ValidationException ex) { return(context.Faulted(ex)); } catch (TelegramClientException ex) { return(context.Faulted(ex)); } catch (Exception ex) { return(context.Faulted(ex)); } }
public async Task <ExecutionResult> Execute(ExecuteContext <SubmitOrderArgument> context) { logger.LogInformation($"Submit Order Courier called for order {context.Arguments.OrderId}"); var order = await orderService.SubmitOrder(context.Arguments.OrderId); return(context.Completed(new { OrderId = order.Id })); }
public async Task <ExecutionResult> Execute(ExecuteContext <CloseAccountArguments> context) { var args = context.Arguments; await Console.Out.WriteLineAsync($"Closing the account for {args.Username}."); return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <IUpdateDatabaseCustomerSubscriptionArguments> context) { var arguments = context.Arguments; var subscription = await _office365DbSubscriptionService .GetSubscriptionByProductIdentifierAsync(arguments.Office365CustomerId, arguments.CloudPlusProductIdentifier); if (subscription == null) { throw new NullReferenceException($"Could not find subscription for customer {arguments.Office365CustomerId}, " + $"identifier: {arguments.CloudPlusProductIdentifier}"); } if (string.IsNullOrWhiteSpace(subscription.Office365SubscriptionId)) { await _office365DbSubscriptionService.AddPartnerPlatformDataToSubscription( new Office365SubscriptionModel { Office365CustomerId = arguments.Office365CustomerId, Office365SubscriptionId = arguments.Office365SubscriptionId, Office365OrderId = arguments.Office365OrderId, Office365Offer = new Office365OfferModel { CloudPlusProductIdentifier = arguments.CloudPlusProductIdentifier } }); } return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <IReserveProducts> context) { _logger.LogInformation($"Reserve Products called for order {context.Arguments.OrderId}"); var orderItems = await _orderService.GetCartItemsAsync(context.Arguments.OrderId); IList <ICartItem> items = orderItems .Select(i => (ICartItem) new CartItemDto { ProductId = i.ProductId, Quantity = i.Quantity }) .ToList(); var response = await _reserveProductsClient.GetResponse <IReserveProductsResult>(new { CorrelationId = context.Arguments.CorrelationId, OrderId = context.Arguments.OrderId, Items = items }); if (!response.Message.Success) { throw new InvalidOperationException(); } return(context.Completed(new { context.Arguments.CorrelationId, context.Arguments.OrderId, response.Message.ReserveId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ObjectGraphActivityArguments> context) { int intValue = context.Arguments.Outer.IntValue; string stringValue = context.Arguments.Outer.StringValue; decimal decimalValue = context.Arguments.Outer.DecimalValue; string[] names = context.Arguments.Names; IDictionary <string, string> argumentsDictionary = context.Arguments.ArgumentsDictionary; Console.WriteLine("TestActivity: Execute: {0}, {1}, {2}, [{3}],[{4}]", intValue, stringValue, decimalValue, string.Join(",", names), string.Join(",", argumentsDictionary.Select(x => $"{x.Key} => {x.Value}"))); if (_intValue != intValue) { throw new ArgumentException("intValue"); } if (_stringValue != stringValue) { throw new ArgumentException("stringValue"); } if (_decimalValue != decimalValue) { throw new ArgumentException("dateTimeValue"); } return(context.Completed <TestLog>(new { OriginalValue = stringValue })); }
public async Task <ExecutionResult> Execute(ExecuteContext <AllocateInventoryArguments> context) { var oderId = context.Arguments.OrderId; string itemNumber = context.Arguments.ItemNumber ?? throw new ArgumentNullException(nameof(itemNumber)); var quantity = context.Arguments.Quantity; if (quantity <= 0.0m) { throw new ArgumentNullException(nameof(quantity)); } var allocationId = NewId.NextGuid(); Console.WriteLine("here"); var response = await _client.GetResponse <InventoryAllocated>(new { AllocationId = allocationId, ItemNumber = itemNumber, Quantity = quantity }); return(context.Completed(new { AllocationId = allocationId, })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreateSecurityGroupMemberArguments> context) { var args = context.Arguments; foreach (var user in args.Users) { List <Office365SecurityGroupMemberModel> SecurityGroup = await _office365DbUserGroupService.GetOffice365SecurityGroupUserAsync(user.UserPrincipalName); var InsertSecurityGroup = args.SecurityGroupName.Where(x => !SecurityGroup.Select(y => y.SecurityGroupName).Contains(x)); foreach (var s in InsertSecurityGroup) { var Domain = user.UserPrincipalName.Split('@').ToList(); if (Domain.Count > 1) { await _office365ApiService.AddSecurityGroupMembersAsync(new Office365ApiSecurityGroupMemberModel { CustomerO365Domain = Domain[1], SecurityGroupName = s, UserSMTPAddress = user.UserPrincipalName }); } } } return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <ChargeAllOpenInvoicesArguments> context) { var args = context.Arguments; await Console.Out.WriteLineAsync($"Charging all open invoices for {args.Username}."); return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <ObjectGraphActivityArguments> context) { int intValue = context.Arguments.Outer.IntValue; string stringValue = context.Arguments.Outer.StringValue; decimal decimalValue = context.Arguments.Outer.DecimalValue; string[] names = context.Arguments.Names; Console.WriteLine("TestActivity: Execute: {0}, {1}, {2}, [{3}]", intValue, stringValue, decimalValue, string.Join(",", names)); if (_intValue != intValue) { throw new ArgumentException("intValue"); } if (_stringValue != stringValue) { throw new ArgumentException("stringValue"); } if (_decimalValue != decimalValue) { throw new ArgumentException("dateTimeValue"); } TestLog log = new TestLogImpl(stringValue); return(context.Completed(log)); }
public async Task <ExecutionResult> Execute(ExecuteContext <ISendUserSetupEmailArguments> context) { try { var sendEndpoint = await context.GetSendEndpoint(NotificationServiceConstants.SendEmailNotificationUri); var args = context.Arguments; var bcc = new List <string> { _office365ServiceSettings.CloudPlusSupportEmail, _office365ServiceSettings.CloudPlusEngineeringEmail }; await sendEndpoint.Send <ISendEmailCommand>( new { UserName = args.UserPrincipalName, To = args.UserPrincipalName, EmailTemplateType = EmailTemplateType.Office365UserSetUp, BCC = bcc }); } catch (Exception ex) { this.Log().Error("Error executing SendUserSetupEmailActivity", ex); } return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <GenerateFinalProratedInvoiceArguments> context) { var args = context.Arguments; await Console.Out.WriteLineAsync($"Generated final prorated invoice for {args.Username}."); return(context.Completed()); }
public async Task <ExecutionResult> Execute(ExecuteContext <IBookHotelActivityArguments> context) { this._logger.LogInformation($"Executing {nameof(BookHotelActivity)} activity" + $"\r\nPayload: {JsonConvert.SerializeObject(context.Arguments)}"); var(accepted, rejected) = await this._hotelBookingClient.GetResponse <IHotelBookingAccepted, IHotelBookingRejected>(new { context.Arguments.HotelId, context.Arguments.RoomId, context.Arguments.CheckIn, context.Arguments.CheckOut, }); if (accepted.IsCompletedSuccessfully()) { var result = await accepted; return(context.Completed <IBookHotelActivityLog>(new { result.Message.BookingId })); } else { var result = await rejected; this._logger.LogWarning($"Execution of {nameof(BookHotelActivity)} activity failded. " + $"\r\nPayload: {JsonConvert.SerializeObject(context.Message)}" + $"\r\nReason: {result.Message.Reason}"); return(context.Faulted()); } }
public Task <ExecutionResult> Execute(ExecuteContext <RedisStockInput> context) { var orderId = context.Arguments.OrderId; return(Task.FromResult(context.Completed(new RedisStockLog { OrderId = context.Arguments.OrderId, Msg = "" }))); }
public async Task <ExecutionResult> Execute(ExecuteContext <TestArguments> context) { Console.WriteLine("FaultyCompensateActivity: Execute: {0}", context.Arguments.Value); TestLog log = new TestLogImpl(context.Arguments.Value); return(context.Completed(log)); }
public async Task <ExecutionResult> Execute(ExecuteContext <OwnershipAssignmentParameters> context) { var result = await _busPublisher.SendRequest <CreateAccountingGroupOwnership, IParentChildIdentifierResult>( new CreateAccountingGroupOwnership(context.Arguments.AccountingGroupId, context.Arguments.OwnerUserId) ); return(result.Successful ? context.Completed() : context.Faulted(new Exception(result.ErrorCode))); }
public async Task <ExecutionResult> Execute(ExecuteContext <ProcessImageArguments> context) { var path = context.Arguments.ImagePath; //Process something return(context.Completed()); }