Esempio n. 1
0
        private ApiResponse <object> RunCalculation()
        {
            var parameters = new Calculation();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var vaultComponents  = _componentsApi.GetVaultComponentsWithHttpInfo(CommonParameters.VaultDefaultDocument);
            var vaultComponentId = vaultComponents.Data.Keys.First();

            var vaultAccount  = new VaultIdentifier(CommonParameters.VaultDefaultAccount);
            var vaultAccount2 = new VaultIdentifier(CommonParameters.VaultMultiCalcAccount);

            var vaultDates = new VaultDateParameters(CommonParameters.VaultStartDate, CommonParameters.VaultEndDate, CommonParameters.VaultFrequency);

            var vaultConfiguration   = _configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultDefaultAccount);
            var vaultConfigurationId = vaultConfiguration.Data.Keys.First();

            var vaultConfiguration2 =
                _configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultMultiCalcAccount);
            var vaultConfiguration2Id = vaultConfiguration2.Data.Keys.First();

            var vaultCalculation  = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfigurationId);
            var vaultCalculation2 = new VaultCalculationParameters(vaultComponentId, vaultAccount2, vaultDates, vaultConfiguration2Id);

            parameters.Vault = new Dictionary <string, VaultCalculationParameters> {
                { "3", vaultCalculation }, { "4", vaultCalculation2 }
            };

            var response = _calculationsApi.RunCalculationWithHttpInfo(parameters);

            return(response);
        }
        public static void Main(string[] args)
        {
            try
            {
                // Build Vault Engine calculation parameters
                var componentsApi = new ComponentsApi(GetEngineApiConfiguration());

                var componentsResponse = componentsApi.GetVaultComponentsWithHttpInfo(VaultDefaultDocument);

                var vaultComponentId = componentsResponse.Data.FirstOrDefault(component =>
                                                                              (component.Value.Name == VaultComponentName &&
                                                                               component.Value.Category == VaultComponentCategory))
                                       .Key;
                Console.WriteLine($"Vault Component Id : {vaultComponentId}");

                var vaultAccount = new VaultIdentifier(VaultDefaultAccount);
                var vaultDates   = new VaultDateParameters(VaultStartDate, VaultEndDate, VaultFrequency);

                var configurationApi = new ConfigurationsApi(GetEngineApiConfiguration());

                var configurationResponse = configurationApi.GetVaultConfigurationsWithHttpInfo(vaultAccount.Id);
                var vaultConfiguration    = configurationResponse.Data.First().Key;

                var vaultCalculation = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfiguration);

                var calculationApi = new VaultCalculationsApi(GetEngineApiConfiguration());

                var runCalculationResponse = calculationApi.RunVaultCalculationWithHttpInfo(vaultCalculation);

                var calculationId = string.Empty;

                while (runCalculationResponse.StatusCode == HttpStatusCode.Accepted)
                {
                    if (string.IsNullOrWhiteSpace(calculationId))
                    {
                        runCalculationResponse.Headers.TryGetValue("Location", out var location);
                        calculationId = location?[0].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                    }

                    if (runCalculationResponse.Headers.ContainsKey("Cache-Control") &&
                        runCalculationResponse.Headers["Cache-Control"][0] is var maxAge &&
                        !string.IsNullOrWhiteSpace(maxAge))
                    {
                        var age = int.Parse(maxAge.Replace("max-age=", ""));
                        Console.WriteLine($"Sleeping for {age} seconds");
                        Thread.Sleep(age * 1000);
                    }
                    else
                    {
                        Console.WriteLine("Sleeping for 2 seconds");
                        // Sleep for at least 2 seconds.
                        Thread.Sleep(2000);
                    }

                    runCalculationResponse = calculationApi.GetVaultCalculationByIdWithHttpInfo(calculationId);
                }
Esempio n. 3
0
        private ApiResponse <object> RunCalculation()
        {
            var parameters = new Calculation();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var paComponents        = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument);
            var paComponentId       = paComponents.Data.Keys.First();
            var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50);
            var paAccounts          = new List <PAIdentifier> {
                paAccountIdentifier
            };
            var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkR1000);
            var paBenchmarks          = new List <PAIdentifier> {
                paBenchmarkIdentifier
            };

            var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks);

            parameters.Pa = new Dictionary <string, PACalculationParameters> {
                { "1", paCalculation }
            };

            var sparComponents        = _componentsApi.GetSPARComponentsWithHttpInfo(CommonParameters.SPARDefaultDocument);
            var sparComponentId       = sparComponents.Data.Keys.First();
            var sparAccountIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkR1000, CommonParameters.SPARBenchmarkRussellReturnType, CommonParameters.SPARBenchmarkRussellPrefix);
            var sparAccounts          = new List <SPARIdentifier> {
                sparAccountIdentifier
            };
            var sparBenchmarkIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkRussellPR2000, CommonParameters.SPARBenchmarkRussellReturnType, CommonParameters.SPARBenchmarkRussellPrefix);

            var sparCalculation = new SPARCalculationParameters(sparComponentId, sparAccounts, sparBenchmarkIdentifier);

            parameters.Spar = new Dictionary <string, SPARCalculationParameters> {
                { "2", sparCalculation }
            };

            var vaultComponents  = _componentsApi.GetVaultComponentsWithHttpInfo(CommonParameters.VaultDefaultDocument);
            var vaultComponentId = vaultComponents.Data.Keys.First();

            var vaultAccount = new VaultIdentifier(CommonParameters.VaultDefaultAccount);
            var vaultDates   = new VaultDateParameters(CommonParameters.VaultStartDate, CommonParameters.VaultEndDate, CommonParameters.VaultFrequency);

            var vaultConfiguration   = _configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultDefaultAccount);
            var vaultConfigurationId = vaultConfiguration.Data.Keys.First();

            var vaultCalculation = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfigurationId);

            parameters.Vault = new Dictionary <string, VaultCalculationParameters> {
                { "3", vaultCalculation }
            };

            var response = _calculationsApi.RunCalculationWithHttpInfo(parameters);

            return(response);
        }
Esempio n. 4
0
        private ApiResponse <object> RunCalculation()
        {
            var vaultComponents = _componentsApi.GetVaultComponentsWithHttpInfo(CommonParameters.VaultDefaultDocument);

            var vaultComponentId       = vaultComponents.Data.Keys.First();
            var vaultAccountIdentifier = new VaultIdentifier(CommonParameters.VaultDefaultAccount);
            var vaultDates             = new VaultDateParameters(CommonParameters.VaultStartDate, CommonParameters.VaultEndDate, CommonParameters.VaultFrequency);
            var vaultConfiguration     = _configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultDefaultAccount);
            var vaultConfigurationId   = vaultConfiguration.Data.Keys.First();

            var paCalculation = new VaultCalculationParameters(vaultComponentId, vaultAccountIdentifier, vaultDates, vaultConfigurationId);

            var response = _calculationsApi.RunVaultCalculationWithHttpInfo(paCalculation);

            return(response);
        }
        private static VaultCalculationParameters GetVaultCalculationParameters2()
        {
            var componentsApi = new ComponentsApi(GetApiConfiguration());

            var componentsResponse = componentsApi.GetVaultComponents(VaultDefaultDocument);

            var vaultComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == VaultPerformanceOverTimeComponentName && component.Value.Category == VaultComponentCategory)).Key;

            Console.WriteLine($"Vault Component Id : {vaultComponentId}");

            var vaultAccount = new VaultIdentifier(VaultDefaultAccount);
            var vaultDates   = new VaultDateParameters(VaultStartDate, VaultEndDate, VaultFrequency);

            var configurationApi      = new ConfigurationsApi(GetApiConfiguration());
            var configurationResponse = configurationApi.GetVaultConfigurationsWithHttpInfo(vaultAccount.Id);
            var vaultConfigurationId  = configurationResponse.Data.Data.Keys.First();

            var vaultCalculation = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfigurationId);

            return(vaultCalculation);
        }
Esempio n. 6
0
        private ApiResponse <object> RunCalculation()
        {
            var vaultComponents  = componentsApi.GetVaultComponentsWithHttpInfo(CommonParameters.VaultDefaultDocument);
            var vaultComponentId = vaultComponents.Data.Data.Keys.First();

            var vaultConfigurations   = configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultDefaultAccount);
            var vaultConfigurationsId = vaultConfigurations.Data.Data.Keys.First();

            var vaultAccount = new VaultIdentifier(CommonParameters.VaultDefaultAccount);
            var vaultDates   = new VaultDateParameters(CommonParameters.VaultStartDate, CommonParameters.VaultEndDate, "Monthly");

            var vaultCalculationParameters = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfigurationsId);

            var parameters = new VaultCalculationParametersRoot
            {
                Data = new Dictionary <string, VaultCalculationParameters> {
                    { "1", vaultCalculationParameters }, { "2", vaultCalculationParameters }
                }
            };

            var response = vaultCalculationsApi.PostAndCalculateWithHttpInfo(null, "max-stale=0", parameters);

            return(response);
        }