public async Task <ExecutionResult> Execute(ExecuteContext <TestArguments> context) { return(context.CompletedWithVariables(new { ToBeRemoved = (string)null })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IDeletePartnerPlatformUserArguments> context) { var arguments = context.Arguments; var office365User = await _office365DbUserService.GetOffice365DatabaseUserWithLicensesAndOfferAsync(arguments.UserPrincipalName); var office365Customer = await _office365DbCustomerService.GetOffice365CustomerWithIncludesAsync(arguments.CompanyId); if (office365User == null) { throw new ArgumentException($"No Office 365 User with User Principal Name: {arguments.UserPrincipalName}"); } if (office365Customer == null) { throw new ArgumentException($"No Office 365 Customer with Comapny Id: {arguments.CompanyId}"); } await _office365UserService.DeleteOffice365UserAsync(office365User.Office365UserId, office365Customer.Office365CustomerId); return(context.CompletedWithVariables(new DeletePartnerPlatformUserLog { Office365UserId = office365User.Office365UserId, Office365CustomerId = office365Customer.Office365CustomerId }, new { office365User.Licenses.FirstOrDefault()?.Office365Offer.CloudPlusProductIdentifier })); }
public async Task <ExecutionResult> Execute(ExecuteContext <EmptyParameters> context) { var result = await _busPublisher.SendRequest <ICreateUser, IIdentifierResult>(new CreateUser { EmailAddress = "*****@*****.**", FullName = "Default Administrator Account", Id = Guid.NewGuid(), IsAdministrator = true, IsActive = true }); if (!result.Successful) { throw result.ToException(); } var userId = result.Id.Value; return(context.CompletedWithVariables(new GuidLog { Id = userId }, new UserIdParameters() { UserId = userId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <Activity2Args> context) { if (context.Arguments.Name.Contains("error")) { throw new Exception("Unknown error..."); } if (context.Arguments.Name.Contains("test")) { var endpoint = await context.GetSendEndpoint(context.Arguments.ResponseAddress); await endpoint.Send <ISimpleFailResponse>(new { Reason = "Something went wrong..." }); throw new Exception("Something went wrong error..."); } Console.WriteLine("Completing Activity2..."); return(context.CompletedWithVariables( new { CustomerDetails = new CustomerDetails() { Name = "Hello " + context.Arguments.Name } })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreateOrderWithMultiItemsArguments> context) { var arguments = context.Arguments; var offers = await _office356DbOfferService.GetOffice365OffersAsync(); var orderwithDetails = new Office365OrderWithDetailsModel { Office365CustomerId = arguments.Office365CustomerId, Office365OrderDetailsModels = offers.Where( o => arguments.CloudPlusProductIdentifiers.Any(x => x.Key == o.CloudPlusProductIdentifier)) .Select(x => new Office365OrderDetailsModel() { FriendlyName = x.OfferName, Office365OfferId = x.Office365Id, Quantity = arguments.CloudPlusProductIdentifiers.Where(c => c.Key == x.CloudPlusProductIdentifier).FirstOrDefault().Value }).ToList() }; var subscriptions = await _office365SubscriptionService.CreateMultiPartnerPlatformSubscriptionsAsync(orderwithDetails); return(context.CompletedWithVariables(new CreateOrderWithMultiItemsLog { Office365CustomerId = arguments.Office365CustomerId, Office365Subscriptions = subscriptions.office365SubscriptionModels.Select(x => x.Office365SubscriptionId).ToList() }, new { Office365Subscriptions = subscriptions.office365SubscriptionModels.Select(x => x.Office365SubscriptionId).ToList(), Office365OrderId = subscriptions.OrderId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <TParams> context) { var inconsistenciesIds = await FindAsync(context.Arguments); var anotherRunRequired = false; if (inconsistenciesIds != null) { foreach (var inconsistentId in inconsistenciesIds) { anotherRunRequired = true; try { await RemedyAsync(context.Arguments, inconsistentId); } catch (Exception e) { _logger.LogError(e, $"Could not remedy inconsistency with ID {inconsistentId}"); return(context.Faulted(e)); } } } var addition = anotherRunRequired ? 1 : 0; return(context.CompletedWithVariables(new ConsistencyRemediationVariables { RerunRequiredTimes = context.Arguments.RerunRequiredTimes + addition } )); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreateTempPartnerPlatformAdminUserArguments> context) { var args = context.Arguments; var customerDefaultMicrosoftDomain = await _office365CustomerService.GetCustomerDefaultDomainAsync(args.Office365CustomerId); var tempAdminUser = new Office365SdkUser { Office365CustomerId = args.Office365CustomerId, DisplayName = NewId.NextGuid().ToString("N"), FirstName = "TempAdmin", LastName = "TempAdmin", Password = _configurationManager.GetByKey("Office365TempPassword"), UsageLocation = "US", UserPrincipalName = $"{NewId.NextGuid():N}@{customerDefaultMicrosoftDomain}" }; await _office365UserService.CreateOffice365UserAsync(tempAdminUser); return(context.CompletedWithVariables(new { AdminUserName = tempAdminUser.UserPrincipalName, AdminPassword = tempAdminUser.Password, tempAdminUser.UserPrincipalName, UserRoles = new List <string> { "Company Administrator" } })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreateDatabaseCompanyArguments> context) { try { var company = context.Arguments.Company; company.CompanyOu = context.Arguments.CompanyOu; var dbCompany = await _companyService.CreateCompany(company); return(context.CompletedWithVariables(new CreateDatabaseCompanyLog { CompanyId = dbCompany.Id }, new { CompanyId = dbCompany.Id })); } catch (Exception ex) { this.Log().Error("Error executing CreateDatabaseCompanyActivity", ex); throw; } }
public async Task <ExecutionResult> Execute(ExecuteContext <UserIdParameters> context) { var result = await _busPublisher.SendRequest <ICreateAuthenticationMeans, IIdentifierResult>( new CreateAuthenticationMeans { Id = Guid.NewGuid(), Method = "password", ValidSince = DateTimeOffset.UtcNow, Value = "AQAAAAEAACcQAAAAEMBltRflZWAQYQiGzPsZ6Hp4x10Pv4d4uJP1GSr5DOdwYuhqXzUmTyAX8FgUuPssig==" } ); if (!result.Successful) { throw result.ToException(); } var meansId = result.Id.Value; return(context.CompletedWithVariables(new GuidLog { Id = meansId }, new UserIdMeansIdParameters { UserId = context.Arguments.UserId, MeansId = meansId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreateActiveDirectoryCompanyArguments> context) { try { var companyOu = await _activeDirectoryService.GenerateCompanyOuIdAsync(); await _activeDirectoryService.CreateCompany(new ActiveDirectoryCompany { CompanyOu = companyOu }); return(context.CompletedWithVariables(new CreateActiveDirectoryCompanyLog { CompanyOu = companyOu }, new { CompanyOu = companyOu })); } catch (System.Exception ex) { this.Log().Error("Error executing CreateActiveDirectoryComapnyActivity", ex); throw; } }
public async Task <ExecutionResult> Execute(ExecuteContext <CardPaymentArguments> context) { var paymentDue = context.Arguments.PaymentDue; if (paymentDue == null) { throw new ArgumentNullException(nameof(PaymentDue)); } string transactionId = "123456"; var receipt = await MessageInitializerCache <PaymentReceipt> .InitializeMessage(new { Source = "Credit Card", paymentDue.Amount, }); return(context.CompletedWithVariables <CardPaymentLog>(new { TransactionId = transactionId, paymentDue.Amount }, new { PaymentReceipt = receipt })); }
public async Task <ExecutionResult> Execute(ExecuteContext <CreateOrderModel> context) { logger.LogInformation("创建订单"); await Task.Delay(100); //throw new CommonActivityExecuteFaildException("当日订单已达到上限"); return(context.CompletedWithVariables(new CreateOrderResult { OrderId = "111122", Message = "创建订单成功" })); }
public Task <ExecutionResult> Execute(ExecuteContext <ApplyCouponArguments> context) { if (context.Arguments.Quantity < 5) { return(Task.FromResult(context.Faulted())); } this.logger.LogInformation($"Applied discount of $10"); return(Task.FromResult(context.CompletedWithVariables(new { Discount = 10 }))); }
public async Task <ExecutionResult> Execute(ExecuteContext <CreateTaskArguments> context) { var arguments = context.Arguments; return(context.CompletedWithVariables(new { NumberOfTasks = 10, Tenant = "aaaa" })); }
public async Task <ExecutionResult> Execute(ExecuteContext <CreateProductModel> context) { logger.LogInformation("创建产品成功"); await Task.Delay(100); //throw new CommonActivityExecuteFaildException("当日产品创建已达到上限"); return(context.CompletedWithVariables(new CreateProductResult { ProductId = "110", Message = "创建产品成功" })); }
public async Task <ExecutionResult> Execute(ExecuteContext <SetVariableArguments> context) { if (context.Arguments == null) { throw new RoutingSlipException("The arguments for execution were null"); } return(context.CompletedWithVariables(new Dictionary <string, object> { { context.Arguments.Key, context.Arguments.Value } })); }
public Task <ExecutionResult> Execute(ExecuteContext <EnviaTransacao> context) { ///fake if (context.Arguments.Descricao.Contains("poison", StringComparison.InvariantCultureIgnoreCase)) { throw new InvalidOperationException("Rejeitado pelo banco central"); } var result = context.CompletedWithVariables(new { SPBId = Guid.NewGuid() }); return(Task.FromResult(result)); }
public async Task <ExecutionResult> Execute(ExecuteContext <DressBeefBurgerArguments> context) { var arguments = context.Arguments; var patty = arguments.Patty; if (patty == null) { throw new ArgumentNullException(nameof(arguments.Patty)); } _logger.LogDebug("Dressing Burger: {OrderId} {Ketchup} {Lettuce}", arguments.OrderId, arguments.Ketchup, arguments.Lettuce); if (arguments.Lettuce) { throw new InvalidOperationException("No lettuce available"); } if (arguments.OnionRing) { Guid?onionRingId = arguments.OnionRingId ?? NewId.NextGuid(); _logger.LogDebug("Ordering Onion Ring: {OrderId}", onionRingId); Response <OnionRingsCompleted> response = await _onionRingClient.GetResponse <OnionRingsCompleted>(new { arguments.OrderId, OrderLineId = onionRingId, Quantity = 1 }, context.CancellationToken); } var burger = new Burger <BeefPatty, BeefCondiments> { BurgerId = arguments.BurgerId, //Weight = patty.Weight, Patty = patty, Condiments = new BeefCondiments { //Cheese = patty.Cheese, Lettuce = arguments.Lettuce, Onion = arguments.Onion, Pickle = arguments.Pickle, //Ketchup = arguments.Ketchup, Mustard = arguments.Mustard, BarbecueSauce = arguments.BarbecueSauce, OnionRing = arguments.OnionRing } }; return(context.CompletedWithVariables(new { burger })); }
public async Task <ExecutionResult> Execute(ExecuteContext <DownloadImageArguments> execution) { DownloadImageArguments args = execution.Arguments; string imageSavePath = Path.Combine(args.WorkPath, execution.TrackingNumber.ToString()); //await _httpClient.GetAndSave(args.ImageUri, imageSavePath); //1 //return execution.Completed<DownloadImageLog>(new { ImageSavePath = imageSavePath }); //2 return(execution.CompletedWithVariables(new { ImagePath = imageSavePath })); }
public async Task <ExecutionResult> Execute(ExecuteContext <TestArguments> context) { if (context.Arguments.Value == null) { throw new ArgumentNullException("value"); } return(context.CompletedWithVariables <TestLog>(new { OriginalValue = context.Arguments.Value }, new { Value = "Hello, World!", NullValue = (string)null, })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IMultiPartnerPlatformCustomerSubscriptionArguments> context) { var arguments = context.Arguments; var filteredProductIdentifiers = arguments.ProductItems .Where(p => !p.Admin && !p.Delete && !p.RemoveLicenses && !p.KeepLicenses).ToList(); var groupedProductIdentifiers = filteredProductIdentifiers .GroupBy(i => i.RecommendedProductItem.CloudPlusProductIdentifier).Select(c => c.Key); var offers = await _office356DbOfferService.GetOffice365OffersAsync(); var createdSubscriptions = new List <Office365SubscriptionModel>(); foreach (var identifier in groupedProductIdentifiers) { var offer = offers.FirstOrDefault(o => o.CloudPlusProductIdentifier == identifier); if (offer == null) { continue; } var quantity = filteredProductIdentifiers.Count(i => i.RecommendedProductItem.CloudPlusProductIdentifier == identifier); var subscription = await _office365SubscriptionService.CreatePartnerPlatformSubscriptionAsync( arguments.Office365CustomerId, offer.Office365Id, quantity); if (subscription == null) { continue; } subscription.Office365Offer = new Office365OfferModel { CloudPlusProductIdentifier = identifier, Office365Id = offer.Office365Id }; createdSubscriptions.Add(subscription); } return(context.CompletedWithVariables(new MultiPartnerPlatformCustomerSubscriptionLog { Subscriptions = createdSubscriptions }, new { Subscriptions = createdSubscriptions })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IActivateSoftDeletedDatabaseUserArguments> context) { var arguments = context.Arguments; var office365User = await _office365DbUserService.ActivateOffice365DatabaseUserAsync(arguments.UserPrincipalName); return(context.CompletedWithVariables(new ActivateSoftDeletedDatabaseUserLog { UserPrincipalName = arguments.UserPrincipalName }, new { office365User.Licenses.FirstOrDefault()?.Office365Offer.CloudPlusProductIdentifier })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IPartnerPlatformCustomerSubscriptionArguments> context) { var arguments = context.Arguments; var office365Customer = await _office365DbCustomerService.GetOffice365CustomerWithIncludesAsync(arguments.CompanyId); var subscription = office365Customer.Office365Subscriptions .FirstOrDefault(s => s.Office365Offer.CloudPlusProductIdentifier == arguments.CloudPlusProductIdentifier); if (subscription == null || string.IsNullOrWhiteSpace(subscription.Office365SubscriptionId)) { // Create or Activate suspended subscription var offer = await _office356DbOfferService.GetOffice365OfferAsync(arguments.CloudPlusProductIdentifier); var partnerPortalSubscription = await _office365SubscriptionService .GetPartnerPlatformSubscriptionByOfferAsync(office365Customer.Office365CustomerId, offer.Office365Id); if (partnerPortalSubscription == null) { subscription = await _office365SubscriptionService.CreatePartnerPlatformSubscriptionAsync( office365Customer.Office365CustomerId, offer.Office365Id); } else { subscription = await _office365SubscriptionService.ActivateSuspendedPartnerPlatformSubscriptionAsync( office365Customer.Office365CustomerId, partnerPortalSubscription.Office365SubscriptionId); } } else { // Update subscription await _office365SubscriptionService.IncreasePartnerPlatformSubscriptionQuantityAsync( office365Customer.Office365CustomerId, subscription.Office365SubscriptionId); } return(context.CompletedWithVariables(new PartnerPlatformCustomerSubscriptionLog { Office365CustomerId = office365Customer.Office365CustomerId, Office365SubscriptionId = subscription.Office365SubscriptionId, Quantity = subscription.Quantity }, new { subscription.Office365SubscriptionId, subscription.Office365OrderId, subscription.Office365FriendlyName, subscription.Quantity, office365Customer.Office365CustomerId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IGetCustomerDomainTxtRecordsArguments> context) { var arguments = context.Arguments; var txtRecords = await _office365ApiService.GetCustomerDomainTxtRecordsAsync(new Office365CustomerDomainModel { Domain = arguments.Domain, Office365CustomerId = arguments.Office365CustomerId }); return(context.CompletedWithVariables(new { TxtRecords = txtRecords })); }
public async Task <ExecutionResult> Execute(ExecuteContext <EventRegistrationArguments> context) { _log.InfoFormat("Registering for event: {0} ({1})", context.Arguments.EventId, context.Arguments.ParticipantEmailAddress); var registrationTotal = 25.00m; var registrationId = NewId.NextGuid(); _log.InfoFormat("Registered for event: {0} ({1})", registrationId, context.Arguments.ParticipantEmailAddress); return(context.CompletedWithVariables(new Log(registrationId, context.Arguments.ParticipantEmailAddress), new { Amount = registrationTotal })); }
public async Task <ExecutionResult> Execute(ExecuteContext <TestArguments> context) { if (context.Arguments.Value == null) { throw new ArgumentNullException("value"); } TestLog log = new TestLogImpl(context.Arguments.Value); return(context.CompletedWithVariables(log, new { Value = "Hello, World!", NullValue = (string)null, })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ILicenseVerificationArguments> context) { WriteLine("Verifying license: {0}", context.Arguments.LicenseNumber); // verify license with remote service if (context.Arguments.LicenseNumber == "8675309") { throw new RoutingSlipException($"The license number is invalid: {context.Arguments.LicenseNumber}"); } var expirationDate = DateTime.Today + TimeSpan.FromDays(90); return(context.CompletedWithVariables(new { LicenseExpirationDate = expirationDate })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreatePartnerPlatformUserArguments> context) { var arguments = context.Arguments; var office365Customer = await _office365DbCustomerService.GetOffice365CustomerWithIncludesAsync(arguments.CompanyId); if (office365Customer == null) { throw new ArgumentException($"No Office 365 Customer in database with Comapny Id: {arguments.CompanyId}"); } string office365UserId = null; var existingOffice365UserId = await _office365UserService.GetOffice365UserIdAsync(arguments.UserPrincipalName, office365Customer.Office365CustomerId); if (existingOffice365UserId == null) { office365UserId = await _office365ApiService.CreateOffice365UserAsync(new Office365ApiUserModel { Office365CustomerId = office365Customer.Office365CustomerId, UserPrincipalName = arguments.UserPrincipalName, DisplayName = arguments.DisplayName, FirstName = arguments.FirstName, LastName = arguments.LastName, UsageLocation = arguments.UsageLocation, City = arguments.City, Country = arguments.Country, PhoneNumber = arguments.PhoneNumber, PostalCode = arguments.PostalCode, State = arguments.State, StreetAddress = arguments.StreetAddress, Password = arguments.Password }); } return(context.CompletedWithVariables(new CreatePartnerPlatformUserLog { Office365CustomerId = office365Customer.Office365CustomerId, UserPrincipalName = arguments.UserPrincipalName }, new { office365Customer.Office365CustomerId, Office365UserId = office365UserId ?? existingOffice365UserId })); }
public async Task <ExecutionResult> Execute(ExecuteContext <IGetUserRolesArguments> context) { var arguments = context.Arguments; var office365Customer = await _office365DbCustomerService.GetOffice365CustomerAsync(arguments.CompanyId); var roles = await _office365ApiService.GetUserRoles(new Office365UserRolesModel { Office365CustomerId = office365Customer.Office365CustomerId, UserPrincipalName = arguments.UserPrincipalName }); return(context.CompletedWithVariables(new { office365Customer.Office365CustomerId, CurrentAssignedRoles = roles })); }
public async Task <ExecutionResult> Execute(ExecuteContext <ICreateOrderArguments> context) { var arguments = context.Arguments; var offer = await _office356DbOfferService.GetOffice365OfferAsync(arguments.CloudPlusProductIdentifier); var subscription = await _office365SubscriptionService.CreatePartnerPlatformSubscriptionAsync(arguments.Office365CustomerId, offer.Office365Id, arguments.Quantity); return(context.CompletedWithVariables(new CreateOrderLog { Office365CustomerId = arguments.Office365CustomerId, Office365SubscriptionId = subscription.Office365SubscriptionId }, new { subscription.Office365SubscriptionId, subscription.Office365OrderId })); }