Exemple #1
0
		public override void Do(AutomationContext context)
		{
			GameServerManager gsm = AdminServer.TheInstance.GameServerManager;

			IList<GameServer> checkSuccessServerList = new List<GameServer>();
			IList<GameServer> allServerList = context.GetAllServers();

			foreach (GameServer server in allServerList)
			{
				switch (_checkType)
				{
					case CheckTypeConnected:
						{
							if (server.IsConnected)
							{
								checkSuccessServerList.Add(server);
							}
						}
						break;
					case CheckTypeDisconnected:
						{
							if (!server.IsConnected)
							{
								checkSuccessServerList.Add(server);
							}
						}
						break;
					case CheckTypeGameRunning:
						{
							if (server.GameServiceState == GameServer.ServiceState.Running)
							{
								checkSuccessServerList.Add(server);
							}
						}
						break;
					case CheckTypeGameNotRunning:
						{
							if (server.GameServiceState != GameServer.ServiceState.Running)
							{
								checkSuccessServerList.Add(server);
							}
						}
						break;
					case CheckTypeGameStopped:
						{
							if (server.GameServiceState == GameServer.ServiceState.ErrorStopped)
							{
								checkSuccessServerList.Add(server);
							}
						}						
						break;
				}
			}

			context.ClearAllServers();

			foreach (GameServer server in checkSuccessServerList)
			{
				context.ServerList.Add(server);
			}

			_state = AutomationState.Done;
			_result = AutomationResult.Success;
		}
Exemple #2
0
		public override void Do(AutomationContext context)
		{
			bool success = true;

			IList<GameServer> serverList = context.GetAllServers();
			foreach (GameServer server in serverList)
			{
				object outArg = null;
                //#########################################################
                if (!server.DoPlugInAction(SecurityManager.SystemAutomationId, GameServerControl.PlugInGuid, GameServerControl.ActionKeyUpdateGame, ref outArg, new object[] { _patchName }))
				{
					success = false;
				}
			}

			if (success)
				_result = AutomationResult.Success;
			else
				_result = AutomationResult.Failure;

			_state = AutomationState.Done;
		}
Exemple #3
0
		public override void Do(AutomationContext context)
		{
			try
			{
				switch (_state)
				{
					case AutomationState.Init:
						{
							_exeSysCmdCompleted = false;
							_completeCount = 0;

							IList<GameServer> serverList = context.GetAllServers();
							_unitList = new List<ExeSysCmdUnit>();
							foreach (GameServer server in serverList)
							{
								string script, input;
								if (CreateScript(server, out script, out input))
								{
									if (server.DoPlugInAction(
										SecurityManager.SystemAutomationId,
										GameServerControl.PlugInGuid,
										GameServerControl.ActionKeyExeSysCmd,
										script,
										input,
										FSEye.PlugIn.GameServerControl.GuardTask.DoNormalSysCmd,
										new GameServerControl.ExeSysCmdComplete(ExeSysCmdComplete)))
									{
										OnCommandSent(server);

										ExeSysCmdUnit exeunit = new ExeSysCmdUnit();
										exeunit.Server = server;
										_unitList.Add(exeunit);
									}
								}
							}

							_result = (_unitList.Count == serverList.Count) ? AutomationResult.Success : AutomationResult.Failure;
							if (_unitList.Count > 0)
								_state = AutomationState.Doing;
							else
								_state = AutomationState.Done;
						}
						break;
					case AutomationState.Doing:
						{
							if (_exeSysCmdCompleted)
							{
								bool allSuccess = true;
								StringBuilder exeCmdOuput = new StringBuilder();
								foreach (ExeSysCmdUnit unit in _unitList)
								{
									if (unit.Done)
									{
										exeCmdOuput.AppendLine(unit.Output);
										if (!unit.Success)
										{
											allSuccess = false;
										}
									}
								}

								context.Message = exeCmdOuput.ToString();

								if (!allSuccess)
									_result = AutomationResult.Failure;
								_state = AutomationState.Done;
							}
						}
						break;
				}
			}
			catch (Exception)
			{
				_result = AutomationResult.Failure;
				_state = AutomationState.Done;
			}
		}
Exemple #4
0
        public override void Do(AutomationContext context)
        {
            switch (_state)
            {
                case AutomationState.Init:
                    {
                        _createLordConfigUnitList = new List<CreateLordConfigUnit>();
                        IList<GameServer> serverList = context.GetAllServers();

                        FileStream fileStream = null;
                        string fileName = string.Empty;

                        foreach (GameServer server in serverList)
                        {
                            CreateLordConfigUnit unit = new CreateLordConfigUnit(server);
                            _createLordConfigUnitList.Add(unit);
                            try
                            {   
                                fileName = SystemConfig.Current.AdminServerUploadFileRootPath + unit.Server.Id + "_" + unit.Server.Name + "_guard.cfg";
                                fileStream = new FileStream(fileName, FileMode.OpenOrCreate);
                                server.LordConfig.WriteLordConfig(fileStream);
                                unit.IsDone = true;
                                unit.IsSuccess = true;
                            }
                            catch (Exception)
                            {
                                unit.IsDone = true;
                                unit.IsSuccess = false;
                            }
                            finally
                            {
                                if (fileStream != null) fileStream.Close();
                            }                            
                        }

                        _state = AutomationState.Doing;
                    }
                    break;
                case AutomationState.Doing:
                    {   
                        for (int i = _createLordConfigUnitList.Count - 1; i >= 0; i--)
                        {
                            if (_createLordConfigUnitList[i].IsDone)
                            {
                                if (!_createLordConfigUnitList[i].IsSuccess) ++_failCount;
                                _createLordConfigUnitList.RemoveAt(i);
                            }
                        }

                        if (_createLordConfigUnitList.Count == 0)
                        {
                            _state = AutomationState.Done;
                            if (_failCount == 0) _result = AutomationResult.Success;
                            else _result = AutomationResult.Failure;
                        }
                    }
                    break;
            }
        }
Exemple #5
0
        public override void Do(AutomationContext context)
        {
            switch (_state)
            {
                case AutomationState.Init:
                    _fileDownloadUnitHashtable = new Hashtable();
                    IList<GameServer> serverList = context.GetAllServers();
                    foreach (GameServer server in serverList)
                    {
                        FileDownloadUnit unit = new FileDownloadUnit(server);
                        _fileDownloadUnitHashtable.Add(server.Id, unit);

                        //生成一个Automation相关的FileDownloadTask然后加入File队列中,传输默认为覆盖选项。
                        server.AddFMTask(new FileDownloadTask(this, _sourceFileName, _targetFileName, true));                        
                    }

                    _state = AutomationState.Doing;
                    break;
                case AutomationState.Doing:
                    foreach (GameServer server in context.GetAllServers())
                    {
                        FileDownloadUnit unit = _fileDownloadUnitHashtable[server.Id] as FileDownloadUnit;
                        if (unit != null && unit.IsDone)
                        {
                            if (!unit.IsSuccess) ++_failCount;
                            _fileDownloadUnitHashtable.Remove(unit.Server.Id);
                        }
                    }

                    if (_fileDownloadUnitHashtable.Count == 0)
                    {
                        _state = AutomationState.Done;
                        if (_failCount == 0) _result = AutomationResult.Success;
                        else _result = AutomationResult.Failure;
                    }
                    break;
            }
        }
Exemple #6
0
		public override void Do(AutomationContext context)
		{
			IList<GameServer> toDelServerList = new List<GameServer>();
			IList<GameServer> servers = context.GetAllServers();
			foreach (GameServer server in servers)
			{
				bool matchGameState = true;
				bool matchServerState = true;
				if (_gameState != null && _gameState.Length > 0)
				{
					matchGameState = false;
					foreach (GameServer.ServiceState gameState in _gameState)
					{
						if (server.GameServiceState == gameState)
						{
							matchGameState = true;
							break;
						}
					}
				}
				if (_serverState != null && _serverState.Length > 0)
				{
					matchServerState = false;
					foreach (GameServer.ServerState serverState in _serverState)
					{
						if (server.GameServerState == serverState)
						{
							matchServerState = true;
							break;
						}
					}
				}

				if (!(matchServerState && matchGameState))
					toDelServerList.Add(server);
			}

			foreach (GameServer server in toDelServerList)
			{
				context.RemoveGameServer(server);
			}

			_result = AutomationResult.Success;
			_state = AutomationState.Done;
		}
Exemple #7
0
		public override void Do(AutomationContext context)
		{
			IList<GameServer> servers = context.GetAllServers();
			foreach(GameServer server in servers)
			{
                //################################################
                server.DoPlugInAction(SecurityManager.SystemAutomationId, LordControl.PlugInGuid, LordControl.ActionKeySayToWorld, _message);
			}

			_state = AutomationState.Done;
			_result = AutomationResult.Success;
		}
Exemple #8
0
		public override void Do(AutomationContext context)
		{
			switch (_state)
			{
				case AutomationState.Init:
					{
						_checkingGameServerList = new List<GetStackTraceUnit>();
						IList<GameServer> serverList = context.GetAllServers();
						foreach (GameServer server in serverList)
						{
							object outArg = null;
                            //#########################################################
                            if (server.DoPlugInAction(SecurityManager.SystemAutomationId, GameServerControl.PlugInGuid, GameServerControl.ActionKeyGetStackTrace, ref outArg))
							{
								GetStackTraceUnit unit = new GetStackTraceUnit(server);
								unit.StartTime = DateTime.Now;
								unit.IsDone = false;
								_checkingGameServerList.Add(unit);
							}
						}

						_state = AutomationState.Doing;
					}
					break;
				case AutomationState.Doing:
					{						
						foreach (GetStackTraceUnit unit in _checkingGameServerList)
						{
                            //################################################
							GameServerControl.GetStackTraceState getStackTraceState = (GameServerControl.GetStackTraceState)unit.Server.GetPlugInData(-1,GameServerControl.PlugInGuid, GameServerControl.DataKeyGetStackTraceState);
							if (getStackTraceState == GameServerControl.GetStackTraceState.Done)
							{
								unit.IsDone = true;
                                context.Message += string.Format("\nStackTrace of {0}:\n{1}", unit.Server.ToString(), unit.Server.GetPlugInData(-1,GameServerControl.PlugInGuid, GameServerControl.DataKeyStackTrace) as string);
							}
							else if (DateTime.Now.Subtract(unit.StartTime) > GetStackTraceTimeout)
							{
								unit.IsDone = true;
							}
						}

						for (int i = _checkingGameServerList.Count - 1; i >= 0; i--)
						{
							if (_checkingGameServerList[i].IsDone)
							{
								_checkingGameServerList.RemoveAt(i);
							}
						}

						if (_checkingGameServerList.Count == 0)
						{
							_state = AutomationState.Done;
							_result = AutomationResult.Success;
						}
					}
					break;
			}
		}
Exemple #9
0
		public override void Do(AutomationContext context)
		{
			IList<GameServer> serverList = context.GetAllServers();
			foreach (GameServer server in serverList)
			{
			}

			_state = AutomationState.Done;
			_result = AutomationResult.Success;
		}