//************************************************************************* // Method: RunAVertexCommand() // /// <summary> /// Runs a vertex command. /// </summary> /// /// <param name="oCommandBarButton"> /// CommandBarButton whose Parameter property contains a vertex ID. /// </param> /// /// <param name="eVertexCommand"> /// Vertex command to run. /// </param> //************************************************************************* protected void RunAVertexCommand( CommandBarButton oCommandBarButton, VertexCommand eVertexCommand ) { Debug.Assert(oCommandBarButton != null); AssertValid(); RunVertexCommandEventHandler oRunVertexCommand = this.RunVertexCommand; if (oRunVertexCommand == null) { // There is no event handler, so the command can't be run. return; } // Retrieve the ID of the vertex that was right-clicked. This can be // NoRowID. Int32 iClickedVertexID = CommandBarButtonToClickedID(oCommandBarButton); oRunVertexCommand( this, new RunVertexCommandEventArgs(iClickedVertexID, eVertexCommand) ); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var cosmosConfig = new CosmosConfig( _settings.CosmosSettings.DatabaseName, _settings.CosmosSettings.EndpointUri, _settings.CosmosSettings.PrimaryKey, _settings.CosmosSettings.RequestTimeoutInSeconds ); var cosmosContainers = new List <ContainerInfo>() { new ContainerInfo() { Name = "salesorderdetail", PartitionKey = "/PartitionKey" }, new ContainerInfo() { Name = "purchaseorderdetail", PartitionKey = "/PartitionKey" }, new ContainerInfo() { Name = "lineitemdetail", PartitionKey = "/PartitionKey" }, new ContainerInfo() { Name = "rmas", PartitionKey = "/PartitionKey" }, new ContainerInfo() { Name = "shipmentdetail", PartitionKey = "/PartitionKey" }, new ContainerInfo() { Name = "productdetail", PartitionKey = "/PartitionKey" } }; var avalaraConfig = new AvalaraConfig() { BaseApiUrl = _settings.AvalaraSettings.BaseApiUrl, AccountID = _settings.AvalaraSettings.AccountID, LicenseKey = _settings.AvalaraSettings.LicenseKey, CompanyCode = _settings.AvalaraSettings.CompanyCode, CompanyID = _settings.AvalaraSettings.CompanyID }; var currencyConfig = new BlobServiceConfig() { ConnectionString = _settings.StorageAccountSettings.ConnectionString, Container = _settings.StorageAccountSettings.BlobContainerNameExchangeRates }; var assetConfig = new BlobServiceConfig() { ConnectionString = _settings.StorageAccountSettings.ConnectionString, Container = "assets", AccessType = BlobContainerPublicAccessType.Container }; var flurlClientFactory = new PerBaseUrlFlurlClientFactory(); var smartyStreetsUsClient = new ClientBuilder(_settings.SmartyStreetSettings.AuthID, _settings.SmartyStreetSettings.AuthToken).BuildUsStreetApiClient(); var orderCloudClient = new OrderCloudClient(new OrderCloudClientConfig { ApiUrl = _settings.OrderCloudSettings.ApiUrl, AuthUrl = _settings.OrderCloudSettings.ApiUrl, ClientId = _settings.OrderCloudSettings.MiddlewareClientID, ClientSecret = _settings.OrderCloudSettings.MiddlewareClientSecret, Roles = new[] { ApiRole.FullAccess } }); AvalaraCommand avalaraCommand = null; VertexCommand vertexCommand = null; TaxJarCommand taxJarCommand = null; switch (_settings.EnvironmentSettings.TaxProvider) { case TaxProvider.Avalara: avalaraCommand = new AvalaraCommand(avalaraConfig, _settings.EnvironmentSettings.Environment.ToString()); break; case TaxProvider.Taxjar: taxJarCommand = new TaxJarCommand(_settings.TaxJarSettings); break; case TaxProvider.Vertex: vertexCommand = new VertexCommand(_settings.VertexSettings); break; default: break; } services.AddMvc(o => { o.Filters.Add(new ordercloud.integrations.library.ValidateModelAttribute()); o.EnableEndpointRouting = false; }) .ConfigureApiBehaviorOptions(o => o.SuppressModelStateInvalidFilter = true) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); options.SerializerSettings.Converters.Add(new StringEnumConverter()); }); services .AddCors(o => o.AddPolicy("integrationcors", builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); })) .AddSingleton <ISimpleCache, LazyCacheService>() // Replace LazyCacheService with RedisService if you have multiple server instances. .AddOrderCloudUserAuth() .AddOrderCloudWebhookAuth(opts => opts.HashKey = _settings.OrderCloudSettings.WebhookHashKey) .InjectCosmosStore <LogQuery, OrchestrationLog>(cosmosConfig) .InjectCosmosStore <ReportTemplateQuery, ReportTemplate>(cosmosConfig) .AddCosmosDb(_settings.CosmosSettings.EndpointUri, _settings.CosmosSettings.PrimaryKey, _settings.CosmosSettings.DatabaseName, cosmosContainers) .Inject <IPortalService>() .Inject <ISmartyStreetsCommand>() .Inject <ICheckoutIntegrationCommand>() .Inject <IShipmentCommand>() .Inject <IOrderCommand>() .Inject <IPaymentCommand>() .Inject <IOrderSubmitCommand>() .Inject <IEnvironmentSeedCommand>() .Inject <IHSProductCommand>() .Inject <ILineItemCommand>() .Inject <IMeProductCommand>() .Inject <IDiscountDistributionService>() .Inject <IHSCatalogCommand>() .Inject <ISendgridService>() .Inject <IHSSupplierCommand>() .Inject <ICreditCardCommand>() .Inject <ISupportAlertService>() .Inject <ISupplierApiClientHelper>() .AddSingleton <ISendGridClient>(x => new SendGridClient(_settings.SendgridSettings.ApiKey)) .AddSingleton <IFlurlClientFactory>(x => flurlClientFactory) .AddSingleton <DownloadReportCommand>() .Inject <IRMARepo>() .Inject <IZohoClient>() .AddSingleton <IZohoCommand>(z => new ZohoCommand(new ZohoClient( new ZohoClientConfig() { ApiUrl = "https://books.zoho.com/api/v3", AccessToken = _settings.ZohoSettings.AccessToken, ClientId = _settings.ZohoSettings.ClientId, ClientSecret = _settings.ZohoSettings.ClientSecret, OrganizationID = _settings.ZohoSettings.OrgID }, flurlClientFactory), orderCloudClient)) .AddSingleton <IOrderCloudIntegrationsExchangeRatesClient, OrderCloudIntegrationsExchangeRatesClient>() .AddSingleton <IAssetClient>(provider => new AssetClient(new OrderCloudIntegrationsBlobService(assetConfig), _settings)) .AddSingleton <IExchangeRatesCommand>(provider => new ExchangeRatesCommand(new OrderCloudIntegrationsBlobService(currencyConfig), flurlClientFactory, provider.GetService <ISimpleCache>())) .AddSingleton <ITaxCodesProvider>(provider => { return(_settings.EnvironmentSettings.TaxProvider switch { TaxProvider.Avalara => avalaraCommand, TaxProvider.Taxjar => taxJarCommand, TaxProvider.Vertex => new NotImplementedTaxCodesProvider(), _ => avalaraCommand // Avalara is default }); })
RunAVertexCommand ( CommandBarButton oCommandBarButton, VertexCommand eVertexCommand ) { Debug.Assert(oCommandBarButton != null); AssertValid(); // Retrieve the ID of the vertex that was right-clicked. This can be // NoRowID. Int32 iClickedVertexID = CommandBarButtonToClickedID(oCommandBarButton); CommandDispatcher.SendCommand( this, new RunVertexCommandEventArgs(iClickedVertexID, eVertexCommand) ); }