Beispiel #1
0
        public static List <IISTreeNode> Build()
        {
            var rootName = $"{Environment.MachineName}({Environment.UserDomainName}\\{Environment.UserName})";
            var rootNode = new IISTreeNode {
                Id = -1, Text = rootName, HasContextMenu = false, Nodes = new List <IISTreeNode>()
            };

            var controller = IISController.GetController();

            var appPools    = controller.GetAllPoolInfos();
            var appPoolNode = new IISTreeNode {
                Id = -2, Text = "Application Pools", State = new { Expanded = false }, HasContextMenu = false, Nodes = new List <IISTreeNode>()
            };

            appPoolNode.Nodes.AddRange(appPools.Data.Select((a, i) => new IISTreeNode {
                Id = appPoolNode.Id - i - 1, Text = a.Name, HasContextMenu = false
            }));
            rootNode.Nodes.Add(appPoolNode);

            var sites    = controller.GetAllSites();
            var siteNode = new IISTreeNode {
                Id = 0, Text = "Web Sites", HasContextMenu = false, Nodes = new List <IISTreeNode>()
            };

            siteNode.Nodes.AddRange(sites.Data.Select(s => new IISTreeNode {
                Id = s.ID, Text = s.Name, HasContextMenu = true, IsSite = true, Status = (int)s.State
            }));
            rootNode.Nodes.Add(siteNode);

            var nodes = new List <IISTreeNode>();

            nodes.Add(rootNode);
            return(nodes);
        }
Beispiel #2
0
        private dynamic ExecSiteCommand()
        {
            var cmd        = Context.Request.Form["cmd"].Value;
            var id         = long.Parse(Context.Request.Form["id"].Value);
            var controller = IISController.GetController();

            if (cmd != "start" && cmd != "stop")
            {
                return(Response.AsJson <dynamic>(new { success = false, message = "Invalid command." }));
            }
            if (cmd == "start")
            {
                controller.StartSite(new Core.Domain.IISStartInfo {
                    ParentID = id
                });
                return(Response.AsJson <dynamic>(new { success = true, status = 2 }));
            }
            else
            {
                controller.StopSite(new Core.Domain.IISStartInfo {
                    ParentID = id
                });
                return(Response.AsJson <dynamic>(new { success = true, status = 4 }));
            }
        }