Esempio n. 1
0
 public static SchedulerAppProjectInfo GetSchedulerAppProjectInfo()
 {
     return
         (new SchedulerAppProjectInfo(
              "name",
              "artifacts_repository_name",
              new[] { "env_name" },
              "artifacts_repository_dir_name",
              true,
              "scheduler_app_dir_name",
              "scheduler_app_exe_name",
              new List <SchedulerAppTask>
     {
         new SchedulerAppTask(
             "task_name_1",
             "task_executable_name_1",
             "task_user_1",
             0,
             0,
             0,
             Repetition.CreatedDisabled()),
         new SchedulerAppTask(
             "task_name_2",
             "task_executable_name_2",
             "task_user_2",
             0,
             0,
             0,
             Repetition.CreateEnabled(
                 TimeSpan.FromMinutes(15.0),
                 TimeSpan.FromDays(1.0),
                 true)),
     }));
 }
        private static ProjectInfo CreateProjectInfo(ProjectInfoXml projectInfoXml)
        {
            List <string> allowedEnvironmentNames =
                (projectInfoXml.AllowedEnvironments ?? "")
                .Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .ToList();

            var uberDeployerAgentProjectInfoXml = projectInfoXml as UberDeployerAgentProjectInfoXml;

            if (uberDeployerAgentProjectInfoXml != null)
            {
                return
                    (new UberDeployerAgentProjectInfo(
                         uberDeployerAgentProjectInfoXml.Name,
                         uberDeployerAgentProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         uberDeployerAgentProjectInfoXml.ArtifactsRepositoryDirName,
                         uberDeployerAgentProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         uberDeployerAgentProjectInfoXml.NtServiceName,
                         uberDeployerAgentProjectInfoXml.NtServiceDirName,
                         uberDeployerAgentProjectInfoXml.NtServiceDisplayName,
                         uberDeployerAgentProjectInfoXml.NtServiceExeName,
                         uberDeployerAgentProjectInfoXml.NtServiceUserId));
            }

            var ntServiceProjectInfoXml = projectInfoXml as NtServiceProjectInfoXml;

            if (ntServiceProjectInfoXml != null)
            {
                return
                    (new NtServiceProjectInfo(
                         ntServiceProjectInfoXml.Name,
                         ntServiceProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         ntServiceProjectInfoXml.ArtifactsRepositoryDirName,
                         ntServiceProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         ntServiceProjectInfoXml.NtServiceName,
                         ntServiceProjectInfoXml.NtServiceDirName,
                         ntServiceProjectInfoXml.NtServiceDisplayName,
                         ntServiceProjectInfoXml.NtServiceExeName,
                         ntServiceProjectInfoXml.NtServiceUserId,
                         ntServiceProjectInfoXml.ExtensionsDirName,
                         ntServiceProjectInfoXml.DependentProjects));
            }

            var webAppProjectInfoXml = projectInfoXml as WebAppProjectInfoXml;

            if (webAppProjectInfoXml != null)
            {
                return
                    (new WebAppProjectInfo(
                         webAppProjectInfoXml.Name,
                         webAppProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         webAppProjectInfoXml.ArtifactsRepositoryDirName,
                         webAppProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         webAppProjectInfoXml.AppPoolId,
                         webAppProjectInfoXml.WebSiteName,
                         webAppProjectInfoXml.WebAppDirName,
                         webAppProjectInfoXml.WebAppName,
                         webAppProjectInfoXml.DependentProjects));
            }

            var schedulerAppProjectInfoXml = projectInfoXml as SchedulerAppProjectInfoXml;

            if (schedulerAppProjectInfoXml != null)
            {
                return
                    (new SchedulerAppProjectInfo(
                         schedulerAppProjectInfoXml.Name,
                         schedulerAppProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         schedulerAppProjectInfoXml.ArtifactsRepositoryDirName,
                         schedulerAppProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         schedulerAppProjectInfoXml.SchedulerAppDirName,
                         schedulerAppProjectInfoXml.SchedulerAppExeName,
                         schedulerAppProjectInfoXml.SchedulerAppTasks
                         .Select(
                             x =>
                             new SchedulerAppTask(
                                 x.Name,
                                 x.ExecutableName,
                                 x.UserId,
                                 x.ScheduledHour,
                                 x.ScheduledMinute,
                                 x.ExecutionTimeLimitInMinutes,
                                 x.Repetition.Enabled
                      ? Repetition.CreateEnabled(
                                     TimeSpan.Parse(x.Repetition.Interval),
                                     TimeSpan.Parse(x.Repetition.Duration),
                                     x.Repetition.StopAtDurationEnd)
                      : Repetition.CreatedDisabled())),
                         schedulerAppProjectInfoXml.DependentProjects));
            }

            var terminalAppProjectInfoXml = projectInfoXml as TerminalAppProjectInfoXml;

            if (terminalAppProjectInfoXml != null)
            {
                return
                    (new TerminalAppProjectInfo(
                         terminalAppProjectInfoXml.Name,
                         terminalAppProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         terminalAppProjectInfoXml.ArtifactsRepositoryDirName,
                         terminalAppProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         terminalAppProjectInfoXml.TerminalAppName,
                         terminalAppProjectInfoXml.TerminalAppDirName,
                         terminalAppProjectInfoXml.TerminalAppExeName,
                         terminalAppProjectInfoXml.DependentProjects));
            }

            var dbProjectInfoXml = projectInfoXml as DbProjectInfoXml;

            if (dbProjectInfoXml != null)
            {
                return
                    (new DbProjectInfo(
                         dbProjectInfoXml.Name,
                         dbProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         dbProjectInfoXml.ArtifactsRepositoryDirName,
                         dbProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         dbProjectInfoXml.DbName,
                         dbProjectInfoXml.DatabaseServerId,
                         dbProjectInfoXml.IsTransacional,
                         dbProjectInfoXml.DacpacFile,
                         dbProjectInfoXml.Users,
                         dbProjectInfoXml.DependentProjects));
            }

            var extensionProjectXml = projectInfoXml as ExtensionProjectInfoXml;

            if (extensionProjectXml != null)
            {
                return
                    (new ExtensionProjectInfo(
                         extensionProjectXml.Name,
                         extensionProjectXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         extensionProjectXml.ArtifactsRepositoryDirName,
                         true,
                         extensionProjectXml.ExtendedProjectName,
                         extensionProjectXml.DependentProjects));
            }

            var powerShellScriptProjectInfoXml = projectInfoXml as PowerShellScriptProjectInfoXml;

            if (powerShellScriptProjectInfoXml != null)
            {
                return
                    (new PowerShellScriptProjectInfo(
                         powerShellScriptProjectInfoXml.Name,
                         powerShellScriptProjectInfoXml.ArtifactsRepositoryName,
                         allowedEnvironmentNames,
                         powerShellScriptProjectInfoXml.ArtifactsRepositoryDirName,
                         powerShellScriptProjectInfoXml.ArtifactsAreNotEnvironmentSpecific,
                         ConvertTargetMachine(powerShellScriptProjectInfoXml.TargetMachine),
                         powerShellScriptProjectInfoXml.ScriptName,
                         powerShellScriptProjectInfoXml.IsRemote,
                         powerShellScriptProjectInfoXml.DependentProjects));
            }

            throw new NotSupportedException(string.Format("Project type '{0}' is not supported.", projectInfoXml.GetType()));
        }