Ejemplo n.º 1
0
    private string GetGroupFullName(ServerGroup group,string groupPath)
    {
        FSEyeObject groupParent = group.SecurityObject.Parent;
        while (groupParent.Parent != null )        
        {
            ServerGroup parentGroup = TheAdminServer.GameServerManager.GetGameServerGroup(groupParent.Id);
            if (parentGroup == null) break;
            groupPath = parentGroup.Name + "/" + groupPath;
            groupParent = parentGroup.SecurityObject.Parent;
        }

        return groupPath;
    }
Ejemplo n.º 2
0
    TreeNode CreateServerGroupNode(ServerGroup group)
    {
        if (group != null)
        {
            if (group.List.Count == 0)
            {
                return null;
            }
            TreeNode node = new TreeNode();
            node.Text = group.Name;
            node.Value = group.Id.ToString();

            if (group.GroupType == ServerGroup.Type.Group)
            {
                foreach (ServerGroup childGroup in group.List)
                {
                    TreeNode childNode = CreateServerGroupNode(childGroup);
                    if (childNode != null)
                    {
                        node.ChildNodes.Add(childNode);
                    }
                }

            }
            else if (group.GroupType == ServerGroup.Type.Server)
            {
                 node.NavigateUrl = "~/GameServer/ServerList.aspx?serverGroupId=" + node.Value;
                 node.Value ="g" + group.Id.ToString();

                // 显示group和下面的server
                //foreach (GameServer childServer in group.List)
                //{
                //    TreeNode childNode = new TreeNode();
                //    childNode.Text = childServer.Name;
                //    childNode.Value = 's' + childServer.Id.ToString();
                //    if (childNode != null)
                //    {
                //        node.ChildNodes.Add(childNode);
                //    }
                //}
            }

            return node;
        }

        return null;
    }
Ejemplo n.º 3
0
    private void AddServerGroup(ServerGroup group,string cabinetName)
    {
        if (group == null) return;

        if (group.GroupType == ServerGroup.Type.Server)
        {
            if (group.Cabinet != string.Empty)
            {                
                if (cabinetName != string.Empty && cabinetName == group.Cabinet)
                {
                    ListBoxCabinet.Items.Add(new ListItem(group.Name, group.Id.ToString()));
                }
            }
            else
            {
                ListBoxGroup.Items.Add(new ListItem(group.Name, group.Id.ToString()));
            }
        }
        else
        {
            foreach (ServerGroup childGroup in group.List)
            {
                if (childGroup.GroupType == ServerGroup.Type.Server)
                {
                    if (childGroup.Cabinet != string.Empty)
                    {                       
                        if (cabinetName != string.Empty && cabinetName == childGroup.Cabinet)
                        {
                            ListBoxCabinet.Items.Add(new ListItem(childGroup.Name, childGroup.Id.ToString()));
                        }
                    }
                    else
                    {
                        ListBoxGroup.Items.Add(new ListItem(childGroup.Name, childGroup.Id.ToString()));
                    }
                }
                else
                {
                    AddServerGroup(childGroup, cabinetName);
                }
            }
        }
    }
Ejemplo n.º 4
0
		/// <summary>
		/// 修改游戏服务器
		/// </summary>
		/// <param name="server">服务器</param>
		/// <param name="name">服务器名</param>
		/// <param name="comment">服务器描述</param>
		/// <param name="ipAddress">IP地址</param>
		/// <param name="macAddress">MAC地址</param>
		/// <param name="gameDir">游戏目录</param>
		/// <param name="newGroup">服务器组</param>
		/// <param name="lordConfig">Lord配置</param>
		public bool ModifyGameServer(
			GameServer server,
			string name,
			string comment,
			string ipAddress,
			string gameDir,
			ServerGroup newGroup,
			LordConfig lordConfig,
            GameServer.ConfigGuardState configState,
            string cfgContent,
			//bool hasBeenConfigGuard,
			GameServer.ServerType serverType,
            int ftpServer
		)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (name == null)
				throw new ArgumentNullException("name");
			if (comment == null)
				throw new ArgumentNullException("comment");
			if (ipAddress == null)
				throw new ArgumentNullException("ipAddress");
			if (gameDir == null)
				throw new ArgumentNullException("gameDir");
			if (newGroup == null)
				throw new ArgumentNullException("newGroup");
            if (cfgContent == null)
                throw new ArgumentNullException("cfgContent");
			IBlazeDatabase db = null;
			try
			{
				SecurityManager sm = AdminServer.TheInstance.SecurityManager;

				db = DbFactory.GetDatabase();
				db.BeginTrans();

				FSEyeObject serverObject = server.SecurityObject;
				serverObject.Name = name;
				serverObject.Comment = comment;
				sm.Set(serverObject, db);
                //游戏服务器配置值
				string[] gameServerFields = null;
				object[] gameServerValues = null;

				if (lordConfig == null)
				{
					gameServerFields = new string[] { 
						TableString.GameServerFieldNetAddress,
						TableString.GameServerFieldGameDir,
						TableString.GameServerFieldHasBeenConfigGuard,
						TableString.GameServerFieldServerType,
                        TableString.GameServerFieldCfgString,
                        TableString.GameServerFieldFtpDownloadServer
					};

					gameServerValues = new object[] {
						ipAddress,
						gameDir,
						(int)configState,
						(int)serverType,
                        cfgContent,
                        ftpServer
					};
				}
				else
				{
                    ArrayList gameServerFieldList = new ArrayList();
                    ArrayList gameServerValueList = new ArrayList();

                    //TODO: HUANGBIAO 2008-1-20 下面代码可能没用
                    //gameServerFieldList.Add(TableString.GameServerFieldNetAddress);
                    //gameServerFieldList.Add(TableString.GameServerFieldGameDir);
                    //gameServerFieldList.Add(TableString.GameServerFieldLordPort);
                    //gameServerFieldList.Add(TableString.GameServerFieldMaxPlayer);
                    //gameServerFieldList.Add(TableString.GameServerFieldIntranetMask);
                    //gameServerFieldList.Add(TableString.GameServerFieldInternetMask);

                    //gameServerValueList.Add(ipAddress);
                    //gameServerValueList.Add(gameDir);
                    //gameServerValueList.Add(lordConfig.ServerCount);
                    //gameServerValueList.Add(lordConfig.MaxPlayer);
                    //gameServerValueList.Add(lordConfig.IntranetMask);
                    //gameServerValueList.Add(lordConfig.InternetMask);

                    //Payasys是否配置
                    if (lordConfig.PaysysIp != null && lordConfig.PaysysIp.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysIp);
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysPort);
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysLoginName);
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysLoginPwd);

                        gameServerValueList.Add(lordConfig.PaysysIp);
                        gameServerValueList.Add(lordConfig.PaysysPort);
                        gameServerValueList.Add(lordConfig.PaysysLoginName);
                        gameServerValueList.Add(lordConfig.PaysysLoginPwd);
                    }

                    if (cfgContent.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldCfgString);
                        gameServerValueList.Add(cfgContent);
                    }

                    //Db是否配置
                    if (lordConfig.DbHost != null && lordConfig.DbHost.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldDbHost);
                        gameServerFieldList.Add(TableString.GameServerFieldDbName);
                        gameServerFieldList.Add(TableString.GameServerFieldDbLoginName);
                        gameServerFieldList.Add(TableString.GameServerFieldDbLoginPwd);
                        gameServerFieldList.Add(TableString.GameServerFieldDbBackupDir);

                        gameServerValueList.Add(lordConfig.DbHost);
                        gameServerValueList.Add(lordConfig.DbName);
                        gameServerValueList.Add(lordConfig.DbLoginName);
                        gameServerValueList.Add(lordConfig.DbLoginPwd);
                        gameServerValueList.Add(lordConfig.DbBackupPath);
                    }

                    //是否配置GMCIp和GMCAccount这两个字段
                    if (lordConfig.GMCIp != null && lordConfig.GMCIp.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldGmcIp);
                        gameServerValueList.Add(lordConfig.GMCIp);
                    }
                    if (lordConfig.GMCAccount != null && lordConfig.GMCAccount.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldGmcAccount);
                        gameServerValueList.Add(lordConfig.GMCAccount);
                    }

                    gameServerFieldList.Add(TableString.GameServerFieldFSEyeIp);
                    gameServerFieldList.Add(TableString.GameServerFieldFSEyePort);
                    gameServerFieldList.Add(TableString.GameServerFieldHasBeenConfigGuard);
                    gameServerFieldList.Add(TableString.GameServerFieldServerType);

                    gameServerValueList.Add(lordConfig.FSEyeIp);
                    gameServerValueList.Add(lordConfig.FSEyePort);
                    gameServerValueList.Add((int)configState);
                    gameServerValueList.Add((int)serverType);

                    gameServerFields = (string[])gameServerFieldList.ToArray(typeof(string));
                    gameServerValues = (object[])gameServerValueList.ToArray();
				}

				IBlazeTable gameServerTable = db.GetTable(TableString.GameServerTableName);
				gameServerTable.Set(gameServerFields, gameServerValues, FilterFactory.CreateEqualFilter(TableString.GameServerFieldId, server.Id));

				server.SecurityObject.Name = name;
				server.SecurityObject.Comment = comment;

				server.IpAddress = ipAddress;
				server.GameDir = gameDir;
				server.ConfigState = configState;
				server.Type = serverType;
                server.ConfigContent = cfgContent;
                server.FtpServer = ftpServer;

				if (lordConfig != null)
				{
					server.LordConfig.Copy(lordConfig);					
				}

				ServerGroup oldGroup = server.Group;
				if (oldGroup != null && newGroup != null)
				{					
					oldGroup.List.Remove(server);
					oldGroup.SecurityObject.RemoveChild(server.SecurityObject.Name);
					sm.Set(oldGroup.SecurityObject, db);

					newGroup.List.Add(server);
					newGroup.SecurityObject.AddChild(server.SecurityObject);
					sm.Set(newGroup.SecurityObject, db);

					server.Group = newGroup;
				}

				sm.Set(serverObject, db);

				db.CommitTrans();

				return true;
			}
			catch (Exception)
			{
				if (db != null)
					db.RollbackTrans();
			}
			finally
			{
				if (db != null)
					db.Close();
			}
			
			return false;
		}
Ejemplo n.º 5
0
		/// <summary>
		/// 添加服务器组
		/// </summary>
		/// <param name="groupName">名称</param>
		/// <param name="groupComment">描述</param>
		/// <param name="parentGroup">所属服务器组</param>
		/// <returns></returns>
		public ServerGroup AddServerGroup(string groupName, string groupComment, ServerGroup.Type grouptype, ServerGroup parentGroup, string cabinet)
		{
			if (groupName == null)
				throw new ArgumentNullException("groupName");
			if (groupComment == null)
				throw new ArgumentNullException("groupComment");
			if (parentGroup != null && parentGroup.GroupType != ServerGroup.Type.Group && parentGroup.List.Count > 0)
				throw new Exception(string.Format("Server group {0} contains game servers.", parentGroup.Name));

			using (IBlazeDatabase db = DbFactory.GetDatabase())
			{
				try
				{
					db.BeginTrans();
					SecurityManager sm = AdminServer.TheInstance.SecurityManager;

					IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
					ServerGroup newGroup = new ServerGroup();
					newGroup.GroupType = grouptype;
                    newGroup.Cabinet = cabinet;

					FSEyeObject parentObject = null;
					FSEyeObject newServerGroupObject = null;
					if (parentGroup == null)
					{
						parentObject = sm.Get(SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + "GameServerList");

                        //各个顶层服务器组之间不允许重名
                        foreach (ServerGroup group in _topServerGroupList)
                        {
                            if (group.Name == groupName)
                                throw new Exception(String.Format("Group with name {0} already exist.", groupName));
                        }

						//添加到顶层服务器组列表中
						_topServerGroupList.Add(newGroup);
					}
					else
					{
						parentObject = parentGroup.SecurityObject;

						//同一个父服务器组下的子服务器组不能重名
						foreach (ServerGroup group in parentGroup.List)
						{
							if (group.Name == groupName)
								throw new Exception(String.Format("Group with name {0} already exist.", groupName));
						}
												
						//服务器组如果不是Group类型的,必须改为Group类型的
						if (parentGroup.GroupType != ServerGroup.Type.Group)
						{
							parentGroup.GroupType = ServerGroup.Type.Group;
							serverGroupTable.Set(TableString.ServerGroupFieldType, (int)parentGroup.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, parentGroup.Id));
						}
						//添加到父服务器组的服务器组列表中
						parentGroup.List.Add(newGroup);						
					}

					if (parentObject != null)
					{
						//创建并存储安全对象
						newServerGroupObject = sm.Get(parentObject.FullPath + SecurityManager.ObjectPathDelimiter + groupName, db);
						newServerGroupObject.Comment = groupComment;
						sm.Set(newServerGroupObject);

						newGroup.SecurityObject = newServerGroupObject;

						//添加新的服务器组对象到服务器组列表中
						_gameServerGroupList.Add(newGroup);

						//添加服务器组记录到服务器组表						
						string[] fields = new string[] {
							TableString.ServerGroupFieldId,
							TableString.ServerGroupFieldType,
                            TableString.ServerGroupFieldCabinet                            
						};
						object[] values = new object[] {
							newServerGroupObject.Id,
							(int)grouptype,
                            cabinet                            
						};
						serverGroupTable.Add(fields, values);

                        /*2008-07-16 GameServer的权限不再单独控制,而是统一由GameServerManager控制,所以就不再复制父一级的权限过来了。
                         * 
                        //设置权限
                        AdminServer.TheInstance.SecurityManager.CopyAce(newServerGroupObject.Parent, newServerGroupObject, true);
                         *
                         */

						db.CommitTrans();
						return newGroup;
					}
				}
				catch (Exception ex)
				{
					if (db != null)
						db.RollbackTrans();

					throw ex;
				}
			}

			return null;
		}
Ejemplo n.º 6
0
		/// <summary>
		/// 载入服务器组
		/// </summary>
		void LoadServerGroups()
		{
			SecurityManager sm = AdminServer.TheInstance.SecurityManager;
			_gameServerGroupList.Clear();

			using (IBlazeDatabase db = DbFactory.GetDatabase())
			{
				IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
				DataSet dataSet = new DataSet();
				serverGroupTable.Get(dataSet);			

				DataRowCollection rows = dataSet.Tables[TableString.ServerGroupTableName].Rows;
				foreach (DataRow row in rows)
				{
					int groupId = (int)row[TableString.ServerGroupFieldId];
					ServerGroup.Type groupType = (ServerGroup.Type)row[TableString.ServerGroupFieldType];

					ServerGroup group = new ServerGroup();
					group.SecurityObject = sm.Get(groupId);
					group.GroupType = groupType;
                    group.group_enable = (ServerGroup.GroupEnable)Enum.Parse(typeof(ServerGroup.GroupEnable), row[TableString.ServerGroupFieldGroupEnable].ToString());
                    group.MaxPlayer = (int)row[TableString.ServerGroupFieldMaxPlayers];
                    group.MaxPlayerLogTime = DateTime.Now;
                    group.Cabinet = row[TableString.ServerGroupFieldCabinet].ToString();
                    group.GroupVer = row[TableString.ServerGroupFieldGroupVersion].ToString();

                    if (group.MaxPlayer > 0)
                    {
                        string maxPlayerTime = row[TableString.ServerGroupFieldMaxPlayersLogTime].ToString();
                        if (maxPlayerTime != string.Empty)
                        {
                            group.MaxPlayerLogTime = DateTime.Parse(maxPlayerTime);
                        }
                    }
					_gameServerGroupList.Add(group);
				}
			}

			OrganizeServerGroups();
		}
Ejemplo n.º 7
0
 public void CreateServerList(ServerGroup serverGroup, GameServer.ServerType serverType)
 {        
         this.Items.Clear();
         foreach (GameServer server in serverGroup.List)
         {
             if (server.Type == serverType)
             {
                 ListItem item = new ListItem(server.Name, server.Id.ToString());
                 this.Items.Add(item);
             }
         }        
 }
Ejemplo n.º 8
0
        private int ChildGroupPlayCount(ServerGroup group)
        {
            if (group==null) return 0;

            int midGroupPlayCount = 0;            

            foreach (ServerGroup childGroup in group.List)
            {
                if (childGroup.GroupType == ServerGroup.Type.Server)
                {
                    midGroupPlayCount += childGroup.NowPlayers;
                }
                else
                {
                    midGroupPlayCount  += ChildGroupPlayCount(childGroup);
                }
            }

            if (midGroupPlayCount > group.MaxPlayer)
            {
                group.SetGroupMaxPlays(midGroupPlayCount);
            }

            group.NowPlayers = midGroupPlayCount;
            return midGroupPlayCount;
        }
Ejemplo n.º 9
0
        private void GroupInCabinet(ServerGroup group, string cabinetName, IList groupInCabinetList)
        {
            if (group == null) return;

            if (group.GroupType == ServerGroup.Type.Server)
            {
                if (group.Cabinet.Trim().ToLower() == cabinetName.Trim().ToLower())
                    groupInCabinetList.Add(group);
            }
            else
            {
                foreach (ServerGroup childGroup in group.List)
                {
                    if (childGroup.GroupType == ServerGroup.Type.Server)
                    {
                        if (childGroup.Cabinet.Trim().ToLower() == cabinetName.Trim().ToLower())
                            groupInCabinetList.Add(childGroup);
                    }
                    else
                    {
                        GroupInCabinet(childGroup,cabinetName, groupInCabinetList);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 对服务器或是服务器组的操作写日志,返回此次操作的流水号(内部自动生成的)
        /// targetId = -2表示对多个组开始进行操作,多个组名存在description字段中
        /// </summary>
        public Int64 WriteServerOperationLog(int userId, ServerGroup.Type targetType, int targetId, GameServer.ServerOperationType operationType, bool operationSuccessful, string description,string region)
        {
            System.Random random = new Random(new RNGCryptoServiceProvider().GetHashCode());
            Int64 OperationID = Int64.Parse(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString() + random.Next(1, 100));
            random = null;

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table = db.GetTable(TableString.ServerOperationLogTableName);

                string[] fieldNames = {
					        TableString.ServerOperationLogFieldOperationId,
					        TableString.ServerOperationLogFieldUserId,
					        TableString.ServerOperationLogFieldServerOrGroup,
                            TableString.ServerOperationLogFieldTargetId,
                            TableString.ServerOperationLogFieldOperationType,
                            TableString.ServerOperationLogFieldOperationResult,
                            TableString.ServerOperationLogFieldDescription,
                            TableString.ServerOperationLogFieldLogTime,
                            TableString.ServerOperationLogFieldFatherRegion
				    };

                object[] fieldValues = {
				        OperationID,
				        userId,
				        (Int16)targetType,
                        targetId,
                        (Int16)operationType,
                        Convert.ToInt16(operationSuccessful),
                        description,
                        DateTime.Now,
                        region
			        };

                //添加此次的操作日志
                table.Add(fieldNames, fieldValues);                

                return OperationID;
            }
        }
Ejemplo n.º 11
0
		/// <summary>
		/// 清空上下文中所有的服务器
		/// </summary>
		public void ClearAllServers()
		{
			if (Server != null)
			{
				Server = null;
			}

			if (ServerList != null)
			{
				ServerList.Clear();
			}

			if (Group != null)
			{
				Group = null;
			}

			if (ServerGroupList != null)
			{
				ServerGroupList.Clear();
			}
		}
Ejemplo n.º 12
0
 private void SetFlagCheckBoxListByGroupEnabled(CheckBoxList list, ServerGroup group)        
 {
     ListItem item = list.Items.FindByValue(((int)ServerMap.ServerMapFlag.Hide).ToString());
     if (group.group_enable == ServerGroup.GroupEnable.Close)
     {
         item.Selected = true;
         item.Enabled = false;
     }
     else
     {
         item.Selected = false;
         item.Enabled = true;
     }
 }
Ejemplo n.º 13
0
 //添加一个服务器函数
 protected Boolean addServer(string name, string comment, string ip, string gameDir, ServerGroup group, GameServer.ConfigGuardState configGuardState, string serverConfigFile, GameServer.ServerType serverType,int ftpServerID)
 {
     if (TheAdminServer.GameServerManager.AddGameServer(name, comment, ip, gameDir, group, configGuardState, serverConfigFile, serverType,ftpServerID))
     {
         LabelSuccess.Visible = true;
         LabelSuccess.Text = StringDef.AddGameServer + StringDef.Colon + StringDef.Success;
         return true;
     }
     else
     {
         LabelOpMsg.Text = StringDef.AddGameServer + StringDef.Colon + StringDef.Failure;
         return false;
     }
 }
Ejemplo n.º 14
0
	TreeNode CreateServerGroupNode(ServerGroup group)
	{
		if (group != null)
		{
			TreeNode node = new TreeNode();
			node.Text = group.Name;
			node.Value = 'g' + group.Id.ToString();
			if (group.GroupType == ServerGroup.Type.Group)
			{
				foreach (ServerGroup childGroup in group.List)
				{
					TreeNode childNode = CreateServerGroupNode(childGroup);
					if (childNode != null)
						node.ChildNodes.Add(childNode);
				}
			}
			else if (group.GroupType == ServerGroup.Type.Server)
			{
				foreach (GameServer childServer in group.List)
				{
					TreeNode childNode = new TreeNode();
					childNode.Text = childServer.Name;
					childNode.Value = 's' + childServer.Id.ToString();
					if (childNode != null)
						node.ChildNodes.Add(childNode);
				}
			}

			return node;
		}

		return null;
	}
Ejemplo n.º 15
0
    //选出最后一层组
    private void LastGroup(ServerGroup group, string groupPath, bool onlyShowEmptyGroup)
    {
        if (group != null)
        {
            if (group.GroupType == ServerGroup.Type.Group)
            {
                if (group.List.Count == 0)
                {
                    DropDownListServerGroup.Items.Add(new ListItem(groupPath + group.Name, group.Id.ToString()));
                }
                else
                {
                    foreach (ServerGroup childGroup in group.List)
                    {
                        LastGroup(childGroup, groupPath + group.Name.ToString() + "/", onlyShowEmptyGroup);
                    }
                }
            }
            else if (group.GroupType == ServerGroup.Type.Server)
            {
                if ((onlyShowEmptyGroup) && (group.List.Count != 0))
                    return;                

                DropDownListServerGroup.Items.Add(new ListItem(groupPath + group.Name, group.Id.ToString()));                
            }
        }
    }
Ejemplo n.º 16
0
		private void GetServerInGroup(ServerGroup group, IList<GameServer> serverList)
		{
			if (group.GroupType == ServerGroup.Type.Group)
			{
				foreach (ServerGroup servergroup in group.List)
				{
					GetServerInGroup(servergroup, serverList);
				}
			}
			else if (group.GroupType == ServerGroup.Type.Server)
			{
				foreach (GameServer server in group.List)
				{
					serverList.Add(server);
				}
			}
		}
Ejemplo n.º 17
0
		/// <summary>
		/// 修改服务器组
		/// </summary>
		/// <param name="modifyGroup">修改的服务器组</param>
		/// <param name="newParentGroup">新的所属服务器组</param>
		/// <returns></returns>
		public bool ModifyServerGroup(ServerGroup modifyGroup, ServerGroup newParentGroup)
		{
			if (modifyGroup == null)
				throw new ArgumentNullException("modifyGroup");

			using (IBlazeDatabase db = DbFactory.GetDatabase())
			{
				try
				{
					db.BeginTrans();

					SecurityManager sm = AdminServer.TheInstance.SecurityManager;
					FSEyeObject serverGroupListObject = sm.Get(SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + "GameServerList");
					FSEyeObject originalParentObject = modifyGroup.SecurityObject.Parent;
					FSEyeObject modifyGroupObject = modifyGroup.SecurityObject;

					//没有父服务器组,即修改为顶层服务器组;否则,则保留原有父服务器组或设置新的父服务器组
					if (newParentGroup == null)
					{
						//本来不是顶层服务器组;否则,不需要改变
						if (originalParentObject != serverGroupListObject)
						{
							//操作安全对象
							originalParentObject.RemoveChild(modifyGroupObject.Name);
							serverGroupListObject.AddChild(modifyGroupObject);

							//从原来的服务器组中删除
							ServerGroup originalParent = GetGameServerGroup(originalParentObject.Id);
							originalParent.List.Remove(modifyGroup);

							//添加到顶层服务器组列表中
							_topServerGroupList.Add(modifyGroup);
						}
					}
					else
					{						
						FSEyeObject newParentObject = newParentGroup.SecurityObject;
						//父服务器组发生了变化;否则,不需要改变
						if (originalParentObject != newParentObject)
						{
							originalParentObject.RemoveChild(modifyGroupObject.Name);
							newParentObject.AddChild(modifyGroupObject);

							//原来不是顶层服务器组,从原来的父服务器组中删除;否则,从顶层服务器组列表中删除
							if (originalParentObject != serverGroupListObject)
							{
								ServerGroup originalParent = GetGameServerGroup(originalParentObject.Id);
								originalParent.List.Remove(modifyGroup);
							}
							else
							{
								_topServerGroupList.Remove(modifyGroup);
							}

							//添加到新的父服务器组中
							newParentGroup.List.Add(modifyGroup);

							//保存父服务器组的安全对象
							sm.Set(newParentObject, db);
						}
					}

					//保存其他安全对象
					sm.Set(serverGroupListObject, db);
					sm.Set(originalParentObject, db);
					sm.Set(modifyGroupObject, db);

					db.CommitTrans();
					return true;
				}
				catch (Exception ex)
				{
					if (db != null)
						db.RollbackTrans();

					throw ex;
				}
			}
		}
Ejemplo n.º 18
0
		bool ExistDisplayServer(ServerGroup regionGroup, IList<GameServer> displayServerList)
		{
			if (regionGroup.GroupType == ServerGroup.Type.Server)
			{
				IList serverList = regionGroup.List;

				foreach (GameServer server in serverList)
				{
					if (displayServerList.Contains(server))
					{
						return true;
					}
				}

				return false;
			}

			return false;
		}
Ejemplo n.º 19
0
		/// <summary>
		/// 移动到服务器组
		/// </summary>
		/// <param name="group"></param>
		public void MoveToServerGroup(GameServer server, ServerGroup newGroup)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (newGroup == null)
				throw new ArgumentNullException("newGroup");
			if (newGroup.GroupType == ServerGroup.Type.Group && newGroup.List.Count > 0)
				throw new Exception(string.Format("ServerGroup {0} contains server groups.", newGroup.Name));

			ServerGroup oldGroup = server.Group;
			if (oldGroup != null)
			{
				using (IBlazeDatabase db = DbFactory.GetDatabase())
				{
					try
					{
						db.BeginTrans();
						SecurityManager sm = AdminServer.TheInstance.SecurityManager;						

						oldGroup.List.Remove(server);
						oldGroup.SecurityObject.RemoveChild(server.SecurityObject.Name);
						sm.Set(oldGroup.SecurityObject, db);

                        //如果该server所在的group没有server了就把组设为Group型的
                        if (oldGroup.SecurityObject.Children.Length == 0)
                        {
                            oldGroup.GroupType = ServerGroup.Type.Group;                            
                            db.GetTable(TableString.ServerGroupTableName).Set(TableString.ServerGroupFieldType, (int)oldGroup.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, oldGroup.Id));
                        }

						if (newGroup.GroupType == ServerGroup.Type.Group)
						{
							newGroup.GroupType = ServerGroup.Type.Server;
						}

						IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
						serverGroupTable.Set(TableString.ServerGroupFieldType, (int)newGroup.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, newGroup.Id));

                        newGroup.List.Add(server);
						newGroup.SecurityObject.AddChild(server.SecurityObject);
						sm.Set(newGroup.SecurityObject, db);

						server.Group = newGroup;

						sm.Set(server.SecurityObject, db);
						db.CommitTrans();
					}
					catch (Exception ex)
					{
						if (db != null)
							db.RollbackTrans();

                        throw ex;
					}
				}
			}
		}
Ejemplo n.º 20
0
 protected Boolean modifyServer(GameServer server, string name, string comment, string ip, string gameDir, ServerGroup group, LordConfig lordConfig, GameServer.ConfigGuardState ConfigState, string serverConfigFile, GameServer.ServerType serverType, int ftpServerID)
 {
     if (TheAdminServer.GameServerManager.ModifyGameServer(server, name, comment, ip, gameDir, group, lordConfig, server.ConfigState, serverConfigFile, serverType, ftpServerID))
     {
         LabelSuccess.Visible = true;
         LabelSuccess.Text = StringDef.ModifyServer + StringDef.Colon + StringDef.Success;
         return true;
     }
     return false;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// 对服务器或是服务器组的操作写日志,参数中要指定操作流水号
        /// </summary>
        public void WriteServerOperationLog(Int64 operationId, int userId, ServerGroup.Type targetType, int targetId, GameServer.ServerOperationType operationType, bool operationSuccessful, string description, string region)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table = db.GetTable(TableString.ServerOperationLogTableName);

                string[] fieldNames = {
					        TableString.ServerOperationLogFieldOperationId,
					        TableString.ServerOperationLogFieldUserId,
					        TableString.ServerOperationLogFieldServerOrGroup,
                            TableString.ServerOperationLogFieldTargetId,
                            TableString.ServerOperationLogFieldOperationType,
                            TableString.ServerOperationLogFieldOperationResult,
                            TableString.ServerOperationLogFieldDescription,
                            TableString.ServerOperationLogFieldLogTime,
                            TableString.ServerOperationLogFieldFatherRegion
				    };

                object[] fieldValues = {
                        operationId,
                        userId,
				        (Int16)targetType,
                        targetId,
                        (Int16)operationType,
                        Convert.ToInt16(operationSuccessful),
                        description,
                        DateTime.Now,
                        region
			        };

                //添加此次的操作日志
                table.Add(fieldNames, fieldValues);
            }
        }
Ejemplo n.º 22
0
    //递归检查服务器名称
    private bool recursiveServerNameConflict(ServerGroup targetGroup, string serverName)
    {
        if (targetGroup.GroupType == ServerGroup.Type.Group)
        {
            IList childGroupList = targetGroup.List;
            foreach (ServerGroup childGroup in childGroupList)
            {
                if (childGroup.GroupType == ServerGroup.Type.Server)
                {
                    foreach (GameServer server in childGroup.List)
                    {
                        if (server.Name == serverName)
                        {
                            return true;
                        }
                    }
                }
                else if (childGroup.GroupType == ServerGroup.Type.Group)
                {
                    if ((recursiveServerNameConflict(childGroup, serverName)))
                    {
                        return true;
                    }
                }
            }
        }
        else if (targetGroup.GroupType == ServerGroup.Type.Server)
        {
            foreach (GameServer server in targetGroup.List)
            {
                if (server.Name == serverName)
                {
                    return true;
                }
            }
        }

        return false;
    }
Ejemplo n.º 23
0
        private void InitMaxPlayer(ServerGroup group)
        {
            if (group == null) return;

            group.MaxPlayer = 0;

            if (group.List.Count == 0 || group.GroupType == ServerGroup.Type.Server) return;

            foreach (ServerGroup childGroup in group.List)
            {
                if (childGroup.GroupType == ServerGroup.Type.Server)
                {
                    childGroup.MaxPlayer = 0;
                }
                else
                {
                    InitMaxPlayer(childGroup);
                }
            }
        }
Ejemplo n.º 24
0
	public GameServerGroupFilter(ServerGroup group)
	{
		_group = group;
	}
Ejemplo n.º 25
0
        private int ChildGroupOfflineCount(ServerGroup group)
        {
            if (group == null) return 0;

            int midGroupOfflineCount = 0;

            foreach (ServerGroup childGroup in group.List)
            {
                if (childGroup.GroupType == ServerGroup.Type.Server)
                {
                    midGroupOfflineCount += childGroup.OfflinePlayer;
                }
                else
                {
                    midGroupOfflineCount += ChildGroupPlayCount(childGroup);
                }
            }

           
            group.OfflinePlayer = midGroupOfflineCount;
            return midGroupOfflineCount;
        }
Ejemplo n.º 26
0
 //选出最后一层组含有gamecenter的组
 private void LastGroup(ServerGroup group)
 {
     if (group != null)
     {
         if (group.GroupType == ServerGroup.Type.Group)
         {
             if (group.List.Count == 0)
             {
                 //GameCenterList.Items.Add(new ListItem(group.Name, group.Id.ToString()));
             }
             else
             {
                 foreach (ServerGroup childGroup in group.List)
                 {
                     LastGroup(childGroup);
                 }
             }
         }
         else if (group.GroupType == ServerGroup.Type.Server)
         {
             foreach (GameServer childServer in group.List)
             {
                 //GameServer server = AdminServer.TheInstance.GameServerManager.GetGameServer(childServer.Id);
                 if (childServer.Type == GameServer.ServerType.gamecenter)
                 {
                     //显示区名,value为该区的gamecenter.id
                     GameCenterList.Items.Add(new ListItem(group.Name, childServer.Id.ToString()));
                     break;
                 }
             }
             
         }
     }
 }
Ejemplo n.º 27
0
        private void GetDistinctCabinet(ServerGroup group)
        {
            if (group == null) return;

            if (group.GroupType == ServerGroup.Type.Server)
            {
                if (group.Cabinet != string.Empty && !_cabinetList.Contains(group.Cabinet)) _cabinetList.Add(group.Cabinet);
            }
            else
            {
                foreach (ServerGroup childGroup in group.List)
                {
                    if (childGroup.GroupType == ServerGroup.Type.Server)
                    {
                        if (childGroup.Cabinet != string.Empty && !_cabinetList.Contains(childGroup.Cabinet)) _cabinetList.Add(childGroup.Cabinet);
                    }
                    else
                    {
                        GetDistinctCabinet(childGroup);
                    }
                }
            }
        }
Ejemplo n.º 28
0
		/// <summary>
		/// 添加游戏服务器
		/// </summary>
		/// <param name="name">服务器名</param>
		/// <param name="comment">服务器描述</param>
		/// <param name="ipAddress">IP地址</param>
		/// <param name="macAddress">MAC地址</param>
		/// <param name="gameDir">游戏目录</param>
		/// <param name="group">服务器组</param>
		public bool AddGameServer(
			string name,
			string comment,
			string ipAddress,
			string gameDir,
			ServerGroup group,
			GameServer.ConfigGuardState configState,
			//bool hasBeenConfigGuard,
            string cfgContent,
			GameServer.ServerType serverType,
            int ftpServer
		)
		{
			if (name == null)
				throw new ArgumentNullException("name");
			if (comment == null)
				throw new ArgumentNullException("comment");
			if (ipAddress == null)
				throw new ArgumentNullException("ipAddress");
			if (gameDir == null)
				throw new ArgumentNullException("gameDir");
			if (group == null)
				throw new ArgumentNullException("group");
            if (cfgContent == null)
                throw new ArgumentNullException("cfgContent");
			IBlazeDatabase db = null;
			try
			{
				db = DbFactory.GetDatabase();
				db.BeginTrans();

				SecurityManager sm = AdminServer.TheInstance.SecurityManager;

				//构造相关安全对象
				string newGameServerObjPath = group.SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + name;
				FSEyeObject newGameServerObj = sm.Get(newGameServerObjPath, db);
				newGameServerObj.Comment = comment;
				sm.Set(newGameServerObj);
                
                //2008-07-16 为了改善性能和简化权限配置,不再生成这些object了
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Console, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo, db);				
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.PlugIn, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Process, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.NetCard, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.BasicInfo, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Cpu, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Disk, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.FMTask, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Memory, db);
				
				//插入数据到服务器表
				string[] fields = new string[] { 
					TableString.GameServerFieldId,
					TableString.GameServerFieldNetAddress,
					TableString.GameServerFieldGameDir,
					TableString.GameServerFieldHasBeenConfigGuard,
					TableString.GameServerFieldServerType,
                    TableString.GameServerFieldCfgString,
                    TableString.GameServerFieldFtpDownloadServer
				};
                
				object[] values = new object[] {
					newGameServerObj.Id,
					ipAddress,
					gameDir,
					(int)configState,
					(int)serverType,
                    cfgContent,
                    ftpServer
				};
				IBlazeTable serverTable = db.GetTable(TableString.GameServerTableName);
				serverTable.Add(fields, values);

				GameServer server = new GameServer();
				server.SecurityObject = newGameServerObj;
				server.IpAddress = ipAddress;
				server.GameDir = gameDir;
				server.ConfigState = configState;
				server.Type = serverType;
                server.ConfigContent = cfgContent;
                server.FtpServer = ftpServer;
                server.GameServiceState = GameServer.ServiceState.OKStopped;
				group.AddGameServer(server, db);

                //如果group的Type是Group必须将其变为Server型的
                if (group.GroupType == ServerGroup.Type.Group)
                {
                    group.GroupType = ServerGroup.Type.Server;
                    IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
                    serverGroupTable.Set(TableString.ServerGroupFieldType, (int)group.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, group.Id));
                }

                /*2008-07-16 GameServer的权限不再单独控制,而是统一由GameServerManager控制,所以就不再复制父一级的权限过来了。
                 * 
                 * 
                //加入默认权限,即其直接父亲的权限
                AdminServer.TheInstance.SecurityManager.CopyAce(newGameServerObj.Parent, newGameServerObj, true);
                 */

				db.CommitTrans();

				_gameServerList.Add(server);
				server.Initialize();
				_systemTickTimer.Elapsed += new System.Timers.ElapsedEventHandler(server.OnTick);

				return true;
			}
			catch (Exception)
			{
				if (db != null)
					db.RollbackTrans();
			}
			finally
			{
				if (db != null)
					db.Close();
			}

			return false;
		}
Ejemplo n.º 29
0
        private void SortActualServerGroup(ServerGroup netGroup)
        {
            if (netGroup.List.Count > 0)
            {
                //对netGroup.List进行排序,以.Id属性进行排序                          
                IComparer myComparer = new ByServerGroupIdComparer();
                ArrayList tempArrayList = ArrayList.Adapter(netGroup.List);
                tempArrayList.Sort(myComparer);
                netGroup.List = (IList)tempArrayList;

                foreach (ServerGroup group in netGroup.List)
                {
                    if (group.GroupType == ServerGroup.Type.Group)
                    {
                        SortActualServerGroup(group);
                    }
                }
            }
        }
Ejemplo n.º 30
0
 public void CreateServerList(ServerGroup serverGroup)
 {
     if (serverGroup != null)
     {
         ServerList.Items.Clear();
         FSEyeObject[] obj = AdminServer.TheInstance.SecurityManager.Get(serverGroup.Id).Children;
         if (obj.Length != 0)
         {
             bool SelecteConnect = false;
             foreach (FSEyeObject serverObj in obj)
             {
                 ListItem item = new ListItem(serverObj.Name, serverObj.Id.ToString());
                 ServerList.Items.Add(item);
                 if (!SelecteConnect)
                 {
                     GameServer server = AdminServer.TheInstance.GameServerManager.GetGameServer(serverObj.Id);                        
                     if(server!=null && server.IsConnected)
                     {
                         item.Selected = true;
                         SelecteConnect = true;
                     }
                 }
             }
         }
     }
 }