Beispiel #1
0
        public override string Execute(IHoconElement param)
        {
            var filename = $"temp_{DateTime.Now.Ticks}.bat";
            var content  = param.GetString();

            base.Send(content);

            var bytes = Encoding.UTF8.GetBytes("@echo off\r\n" + content);

            using (var ms = File.Create(filename))
                ms.Write(bytes, 0, bytes.Length);

            try
            {
                var runAppCmd = new OriginCommand();
                runAppCmd.Name  = filename;
                runAppCmd.Param = "";
                CommandExecutor.RunExeWithParam(Session, runAppCmd);
            }
            catch
            {
                throw;
            }
            finally
            {
                File.Delete(filename);
            }

            return($"execute batch success!");
        }
        public override string Execute(IHoconElement param)
        {
            string siteName = param.GetString();

            using (ServerManager serverManager = new ServerManager())
            {
                var sites = serverManager.Sites;
                var site  = sites[siteName];
                if (site == null)
                {
                    return($"site {siteName} not exist! can not start");
                }
                Thread.Sleep(200);//让site有准备的时间,sites为Lazy加载,否则有可能在site.State调用出错(not a valid object)
                if (site.State == ObjectState.Stopped)
                {
                    site.Start();
                }
                else
                {
                    return($"site {siteName} status is {site.State.ToString()}!");
                }
                serverManager.CommitChanges();
            }
            return($"site {siteName} start success!");
        }
Beispiel #3
0
        public override string Execute(IHoconElement param)
        {
            string msg = param.GetString();

            base.Send(msg);
            return($"log msg!");
        }
        private void VisitPrimitive(IHoconElement data)
        {
            var key = _currentPath;

            if (_data.ContainsKey(key))
            {
                throw new FormatException(string.Format(Resources.Error_KeyIsDuplicated, key));
            }

            _data[key] = data.GetString();
        }
Beispiel #5
0
 public bool Equals(IHoconElement other)
 {
     if (other is null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Type == other.Type && string.Equals(Value, other.GetString()));
 }
Beispiel #6
0
        public override string Execute(IHoconElement param)
        {
            string siteName = param.GetString();

            using (ServerManager serverManager = new ServerManager())
            {
                var sites = serverManager.Sites;
                var site  = sites[siteName];
                if (site == null)
                {
                    return($"site {siteName} not exist! can not delete!");
                }
                sites.Remove(site);
                serverManager.CommitChanges();
            }
            return($"site {siteName} stop success!");
        }
        public override string Execute(IHoconElement param)
        {
            string serviceName = param.GetString();
            var    service     = ServiceManager.QueryService(serviceName);

            if (service == null)
            {
                return($"service {serviceName} do not exist");
            }
            if (service.Status == ServiceControllerStatus.Running)
            {
                service.Stop();
                service.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 30));
                return($"service {serviceName} stop success!");
            }
            return($"service {serviceName} current status is {service.Status.ToString()}, can not stop!");
        }
Beispiel #8
0
        public override string Execute(IHoconElement param)
        {
            string serviceName = param.GetString();
            var    service     = ServiceManager.QueryService(serviceName);

            if (service == null)
            {
                return($"service {serviceName} do not exist");
            }
            var uninstallCmd = new OriginCommand
            {
                Name  = "sc",
                Param = "delete " + serviceName
            };

            CommandExecutor.RunCommand(uninstallCmd);
            return($"uninstall service {serviceName} success!");
        }
        public override string Execute(IHoconElement param)
        {
            string poolName = param.GetString();

            using (ServerManager serverManager = new ServerManager())
            {
                var pools = serverManager.ApplicationPools;

                var pool = pools[poolName];
                if (pool == null)
                {
                    return($"pool {poolName} not exist! can not delete");
                }
                pools.Remove(pool);
                serverManager.CommitChanges();
            }
            return($"pool {poolName} delete success!");
        }
Beispiel #10
0
        public override string Execute(IHoconElement param)
        {
            string poolName = param.GetString();

            using (ServerManager serverManager = new ServerManager())
            {
                var pools = serverManager.ApplicationPools;
                var pool  = pools[poolName];
                if (pool == null)
                {
                    return($"pool {poolName} not exist! can not start");
                }
                if (pool.State == ObjectState.Stopped)
                {
                    pool.Start();
                }
                else
                {
                    return($"pool {poolName} status is {pool.State.ToString()}!");
                }
                serverManager.CommitChanges();
            }
            return($"pool {poolName} start success!");
        }
        public override string Execute(IHoconElement param)
        {
            string siteName = param.GetString();

            using (ServerManager serverManager = new ServerManager())
            {
                var sites = serverManager.Sites;
                var site  = sites[siteName];
                if (site == null)
                {
                    return($"site {siteName} not exist! can not stop!");
                }
                if (site.State == ObjectState.Started)
                {
                    site.Stop();
                }
                else
                {
                    return($"site {siteName} status is {site.State.ToString()}!");
                }
                serverManager.CommitChanges();
            }
            return($"site {siteName} stop success!");
        }