Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            int errorCode = ErrorCode.Succeed;

            try
            {
                if (args.Length <= 1)
                {
                    errorCode = ErrorCode.InvalidParameter;
                    Console.WriteLine("Invalid Parameters.");
                }
                else
                {
                    var util = UtilFactory.GetUtil();
                    if (util != null)
                    {
                        switch (args[0].ToUpper())
                        {
                        //新建站点
                        case "CREATESITE":
                            errorCode = CreateSite(util, args);
                            break;

                        //移除站点
                        case "REMOVESITE":
                            errorCode = RemoveSite(util, args);
                            break;

                        //新建应用程序池
                        case "CREATEAPPPOOL":
                            errorCode = CreateAppPool(util, args);
                            break;

                        //移除应用程序池
                        case "REMOVEAPPPOOL":
                            errorCode = RemoveAppPool(util, args);
                            break;

                        //新建虚拟目录
                        case "CREATEDIR":
                            errorCode = CreateDir(util, args);
                            break;

                        //移除虚拟目录
                        case "REMOVEDIR":
                            errorCode = RemoveDir(util, args);
                            break;

                        //创建应用程序
                        case "CREATEAPP":
                            errorCode = CreateApp(util, args);
                            break;

                        //移除应用程序
                        case "REMOVEAPP":
                            errorCode = RemoveApp(util, args);
                            break;

                        //站点是否存在
                        case "SITEEXIST":
                            errorCode = SiteExist(util, args);
                            break;

                        //变更站点证书
                        case "SETCERT":
                            errorCode = SetCertificate(util, args);
                            break;

                        //变更站点端口
                        case "SETPORT":
                            errorCode = SetPort(util, args);
                            break;
                        }
                    }
                    else
                    {
                        //IIS版本未知
                        errorCode = ErrorCode.UnknownIISVer;
                    }
                }
            }
            catch (Exception ex)
            {
                errorCode = ErrorCode.Unknown;
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Execute Result: {0}", errorCode);
            return(errorCode);
        }
Ejemplo n.º 2
0
        public static List <SiteInfo> GetSiteInfos()
        {
            var sites = UtilFactory.GetUtil().GetSites();

            return(sites);
        }