예제 #1
0
        protected override bool DoProcess(object obj)
        {
            try
            {
                if (!Directory.Exists(SVN_UPDATE_ROOT))
                {
                    Directory.CreateDirectory(SVN_UPDATE_ROOT);
                }
                if (string.IsNullOrEmpty(ip))
                {
                    ip = GetServerIP();
                }
                var list = SvnProcesser.DeployList(ip);
                foreach (var projectAction in list)
                {
                    Logger.SaveLog(projectAction.Id + "Deploy the project begins...");
                    try
                    {
                        switch (projectAction.Type)
                        {
                        case 1:
                            StartIIS(projectAction, IIS_VERSION);
                            break;

                        case 2:
                            StopIIS(projectAction, IIS_VERSION);
                            break;

                        case 3:
                            SvnUpdate(projectAction);
                            break;

                        case 4:
                            Deploy(projectAction);
                            break;

                        case 5:
                            Cleanup(projectAction);
                            break;

                        case 6:
                            SvnCheckOut(projectAction);
                            break;

                        case 7:
                            QuickDeploy(projectAction, IIS_VERSION);
                            break;

                        case 8:
                            DeployPython(projectAction);
                            break;

                        case 11:
                            //创建计划任务
                            CreateSchTasks(projectAction);
                            break;

                        case 12:
                            //删除计划任务
                            DeleteSchTasks(projectAction);
                            break;

                        case 13:
                            //创建计划任务
                            StartSchTasks(projectAction);
                            break;

                        case 14:
                            StopSchTasks(projectAction);
                            break;

                        case 15:
                            //重启IIS或任务计划
                            ReStart(projectAction, IIS_VERSION);
                            break;

                        default:
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.SaveLog(string.Format("SvnDeploy Execution [{0}] command error:", projectAction.Id), ex);
                        SvnProcesser.UpdateDeployStatus(projectAction.Id, 2, ex.ToString());
                    }
                    Logger.SaveLog(projectAction.Id + " the end of the project deployment");
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.SaveLog(ex);
                return(false);
            }
        }