Пример #1
0
        public async Task <Response> ExecuteAsync(CreateTenantCommand command, Response previousResult)
        {
            var execution = new Response();

            string path = await _artifactService.GetScriptsAsync();

            _templateService = new TemplateService(Path.Combine(path, Environment.GetEnvironmentVariable("InternalClientDeployFile")), command.Name, command.Password, command.OvcId);

            if (path.Length > 0)
            {
                try
                {
                    string client = command.Name;

                    string siteName = $"{client} RED 2.0 Site";

                    Tenant tenant = new Tenant();

                    tenant = await _tableauService.NewTableauSiteAsync(command.Name, siteName);

                    if (!string.IsNullOrEmpty(tenant.Message))
                    {
                        execution.TenantDetails = tenant;
                    }
                    else
                    {
                        execution.TenantDetails = tenant;

                        var yamlObject = _templateService.PrepareTemplate();

                        foreach (YamlJob job in from job in yamlObject.Jobs
                                 select job)
                        {
                            var sfTenant = await ProcessInternalAsync(job, client);

                            // scriptExecutions.Add(se);
                        }

                        // pr.Steps = scriptExecutions;
                    }


                    // provisioningResults.Add(pr);

                    /*
                     * var r = await t.CreateSiteAsync(logIn, siteName, command.Name);
                     *
                     * var project = await t.CreateProjectAsync(r);
                     *
                     * string password = command.Password;//Helper.PasswordStore.GeneratePassword(16, 5);
                     * string rootFolder = Path.Combine(path, Environment.GetEnvironmentVariable("WorkingDirectory"));
                     * string yamlFile = Path.Combine(path, Environment.GetEnvironmentVariable("InternalClientDeployFile"));
                     *
                     * var result = await ProcessYaml.ProcessInternalAsync(yamlFile, command.Name, password, command.OvcId);
                     *
                     * yamlFile = Path.Combine(path, Environment.GetEnvironmentVariable("ReaderClientDeployFile"));
                     *
                     * var clientMsgs = new List<ScriptExecution>();
                     *
                     * System.Threading.Thread.Sleep(5000);
                     *
                     * clientMsgs = await ProcessYaml.ProcessShareAsync(yamlFile, command.Name, password, result.Client.Locator);
                     *
                     * foreach (var item in clientMsgs)
                     * {
                     *  result.Steps.Add(item);
                     * }
                     *
                     * r1.Add(result);
                     *
                     * result.Client.SiteId = r.Site.Id;
                     * result.Client.ProjectId = project.Id;
                     *
                     */
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    // throw ex;
                }
            }

            return(execution);
        }