Exemplo n.º 1
0
        public virtual IISResultInfo ReStartSite(IISStartInfo info)
        {
            var result = StopSite(info);

            if (result.Success)
            {
                result = StartSite(info);
            }
            return(result);
        }
Exemplo n.º 2
0
        private DirectoryEntry GetByPath(IISStartInfo info)
        {
            if (info.ParentID < 1)
            {
                return(null);
            }
            var webPath = IISWebPath + "/" + info.ParentID.ToString();
            var root    = new DirectoryEntry(webPath);

            return(root);
        }
Exemplo n.º 3
0
        public override IISResultInfo StopSite(IISStartInfo info)
        {
            var ret = new IISResultInfo();

            try
            {
                var siteEntry = GetByPath(info);
                if (siteEntry == null)
                {
                    return(ret.SetError("站点不存在", 404));
                }
                siteEntry.Invoke("Stop", null);
                siteEntry.Dispose();
            }
            catch (Exception e)
            {
                ret.SetError(e.Message, 500);
            }
            return(ret);
        }
Exemplo n.º 4
0
        public override IISResultInfo StartSite(IISStartInfo info)
        {
            var data = new IISResultInfo();

            try
            {
                using (var iisManager = new ServerManager())
                {
                    var site = iisManager.Sites.FirstOrDefault(p => p.Id == info.ParentID);
                    if (site == null)
                    {
                        return(data.SetError("site not found", 404));
                    }
                    switch (site.State)
                    {
                    case ObjectState.Starting:
                        break;

                    case ObjectState.Started:
                        break;

                    case ObjectState.Stopping:
                    case ObjectState.Stopped:
                    case ObjectState.Unknown:
                        site.Start();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
            catch (Exception e)
            {
                data.SetError(e);
            }
            return(data);
        }
Exemplo n.º 5
0
 public abstract IISResultInfo StopSite(IISStartInfo info);