protected void ButtonMoveToGroup_Click(object sender, EventArgs e)
    {
        //需要在GameServerManager上有Write的权限
        if (!WebUtil.CheckPrivilege(TheAdminServer.GameServerManager.SecurityObject, OpType.WRITE, Session))
        {
            LabelOpMsg.Text    = StringDef.NotEnoughPrivilege;
            LabelOpMsg.Visible = true;
            return;
        }

        object selectedObj = GetSelectedObject();

        if (selectedObj != null && selectedObj.GetType() == typeof(GameServer))
        {
            try
            {
                GameServer  server = selectedObj as GameServer;
                ServerGroup group  = ServerGroupDropDownList.SelectedServerGroup;

                TheAdminServer.GameServerManager.MoveToServerGroup(server, group);
                ServerGroupDropDownList.Refresh();
                CreateServerGroupTree();

                LabelSuccess.Text    = StringDef.OperationSucceed + StringDef.Colon + "服务器 " + server.Name + " 成功移动到组 " + group.Name;
                LabelSuccess.Visible = true;
            }
            catch (Exception ex)
            {
                LabelOpMsg.Text    = StringDef.OperationFail + StringDef.Colon + ex.Message;
                LabelOpMsg.Visible = true;
                return;
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (!WebUtil.CheckPrivilege(WebConfig.FunctionGameServerAddServerGroupSimplified, OpType.READ, Session))
            {
                Response.Redirect(WebConfig.PageNotEnoughPrivilege, true);
            }
            TextBoxFSEyeIp.Text = SystemConfig.Current.AdminServerListenIP;
            int defaultPort = SystemConfig.Current.AdminServerListenPort;
            TextBoxFSEyePort.Text = Convert.ToString(defaultPort);

            ServerGroupDropDownList.ListEmptyServerGroups();
            FtpDropDownList.ListFtpByType(FTPServer.FTPServerType.ServerUpdate);
        }

        CreateConfigParametersTableByXml();
    }
    protected void ButtonDeleteServerGroup_Click(object sender, EventArgs e)
    {
        //需要在GameServerManager上有Write的权限
        if (!WebUtil.CheckPrivilege(TheAdminServer.GameServerManager.SecurityObject, OpType.WRITE, Session))
        {
            LabelOpMsg.Text    = StringDef.NotEnoughPrivilege;
            LabelOpMsg.Visible = true;
            return;
        }

        try
        {
            object selectedObj = GetSelectedObject();
            if (selectedObj != null && selectedObj.GetType() == typeof(ServerGroup))
            {
                ServerGroup group           = selectedObj as ServerGroup;
                string      serverGroupName = group.Name;

                //此段代码为额外的检验代码
                //防止客户端意外传回错误数据导致误删除
                if (group.List.Count != 0)
                {
                    LabelOpMsg.Text    = StringDef.OperationFail + StringDef.Colon + "服务器组 " + serverGroupName + " 不为空,不允许删除操作";
                    LabelOpMsg.Visible = true;
                    return;
                }

                TheAdminServer.GameServerManager.DeleteServerGroup(group.Id);
                ServerGroupDropDownList.Refresh();
                CreateServerGroupTree();

                LabelSuccess.Text    = StringDef.OperationSucceed + StringDef.Colon + "服务器组 " + serverGroupName + " 删除成功";
                LabelSuccess.Visible = true;
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text    = StringDef.OperationFail + StringDef.Colon + ex.Message;
            LabelOpMsg.Visible = true;
            return;
        }
    }
    protected void ButtonCreateServerGroup_Click(object sender, EventArgs e)
    {
        //需要在GameServerManager上有Write的权限
        if (!WebUtil.CheckPrivilege(TheAdminServer.GameServerManager.SecurityObject, OpType.WRITE, Session))
        {
            LabelOpMsg.Text    = StringDef.NotEnoughPrivilege;
            LabelOpMsg.Visible = true;
            return;
        }

        string serverGroupName = TextBoxServerGroupName.Text.Trim();

        if (serverGroupName.Length == 0)
        {
            LabelOpMsg.Text    = "服务器组名不能为空";
            LabelOpMsg.Visible = true;
            return;
        }

        string serverGroupComment = TextBoxServerGroupComment.Text.Trim();

        if (serverGroupComment == String.Empty)
        {
            serverGroupComment = "服务器组添加时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }

        string serverGroupCabinet;

        if (DropDownListCabinet.SelectedIndex == 0)
        {
            serverGroupCabinet = String.Empty;
        }
        else
        {
            serverGroupCabinet = DropDownListCabinet.SelectedItem.Text;
        }

        try
        {
            ServerGroup parentGroup = null;
            object      selectedObj = GetSelectedObject();
            if (selectedObj != null)
            {
                if (selectedObj.GetType() == typeof(ServerGroup))
                {
                    parentGroup = selectedObj as ServerGroup;
                    TheAdminServer.GameServerManager.AddServerGroup(
                        serverGroupName,
                        serverGroupComment,
                        ServerGroup.Type.Group,
                        parentGroup,
                        serverGroupCabinet);
                    ServerGroupDropDownList.Refresh();
                    CreateServerGroupTree();
                }
                else
                {
                    FSEyeObject fsObject = selectedObj as FSEyeObject;
                    if (fsObject != null && fsObject.FullPath.Equals(SecurityObjectGameServerList))
                    {
                        TheAdminServer.GameServerManager.AddServerGroup(
                            serverGroupName,
                            serverGroupComment,
                            ServerGroup.Type.Group,
                            parentGroup,
                            serverGroupCabinet);
                        ServerGroupDropDownList.Refresh();
                        CreateServerGroupTree();
                    }
                }

                //if (TextBoxCabinet.Text.Trim() != string.Empty)
                //{
                //    if (!AdminServer.TheInstance.GameServerManager.CabinetList.Contains(TextBoxCabinet.Text.Trim()))
                //    {
                //        AdminServer.TheInstance.GameServerManager.CabinetList.Add(TextBoxCabinet.Text.Trim());
                //    }
                //}

                LabelSuccess.Text    = StringDef.OperationSucceed + StringDef.Colon + "服务器组 " + serverGroupName + " 添加成功";
                LabelSuccess.Visible = true;
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text    = StringDef.OperationFail + StringDef.Colon + ex.Message;
            LabelOpMsg.Visible = true;
            return;
        }
    }