示例#1
0
        /// <summary>
        /// 开启服务
        /// </summary>
        public void StartService(User user)
        {
            try
            {
                lock (this)
                {
                    if (!_isRunning)
                    {
                        _gameServerManager.Startup();
                        _messageEngine.Startup();
                        _connectionManager.ClientConnect    += new ClientConnectEventHandler(_gameServerManager.GameServerConnected);
                        _connectionManager.ClientDisconnect += new ClientDisconnectEventHandler(_gameServerManager.GameServerDisconnected);
                        try
                        {
                            _connectionManager.Startup(SystemConfig.Current.AdminServerListenPort, SystemConfig.Current.MaxConnectionCount);
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                        _FTPClient.Startup();

                        _gameServerMonitor.Start();

                        //从Initialize中移动到这里
                        _strategyManager.Load();
                        _scheduledTaskManager.Load();
                        _batchTaskManager.Load();

                        _automationManager.Working = true;
                        _strategyManager.On        = true;
                        _scheduledTaskManager.On   = true;
                        //插件信息初始化
                        ServerPlugInFactory.Initialize();

                        if (SystemConfig.Current.EnablePaysys)
                        {
                            _paysysAgent.Start();
                        }

                        if (user != null)
                        {
                            FSEyeObject serviceSwitch = SecurityManager.Get(SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + SecurityObjectServiceSwitch);
                            LogSystem.TheInstance.WriteLog(user.SecurityObject.Id, OpType.WRITE, serviceSwitch.Id, string.Format(StringDef.LogMessageStartService, user.UserName));
                        }
                        _isRunning = true;
                    }
                }
            }
            catch (Exception e)
            {
                Util.DebugLog(e.Message);
                Util.DebugLog(e.StackTrace);
            }
        }
示例#2
0
    protected void UpdatePlugIn_Click(object sender, EventArgs e)
    {
        try
        {
            //判断MessageLog插件,不能让同一文件为多个服务器配置日志文件
            if (GameServerCheckBoxList.SelectedGameServers.Length != 1)
            {
                CheckBox mesLogCheckBox = TablePlugIns.Rows[(int)ServerPlugInFactory.PlugInList.MessageLog].Cells[0].Controls[0] as CheckBox;
                if (mesLogCheckBox.Checked)
                {
                    throw new Exception(StringDef.FileReusedError);
                }
            }
            foreach (GameServer server in GameServerCheckBoxList.SelectedGameServers)
            {
                ArrayList PlugInsToInsert = new ArrayList();
                ArrayList PlugInsToDelete = new ArrayList();
                ArrayList PlugInsToEdit   = new ArrayList();

                //判断要Edit的,要Delete的,还有要Add的插件
                for (int index = 0; index != TablePlugIns.Rows.Count; ++index)
                {
                    CheckBox tempCheck = TablePlugIns.Rows[index].Cells[0].Controls[0] as CheckBox;
                    if (tempCheck == null)
                    {
                        return;
                    }

                    bool isEdit = false;
                    bool isAdd  = true;
                    foreach (IPlugIn oldPlug in server.InstalledPlugInList)
                    {
                        if (tempCheck.Text.Equals(oldPlug.Name))
                        {
                            //设置标记位
                            isAdd = false;
                            //Edit
                            if (tempCheck.Checked)
                            {
                                //IPlugIn newPlug = ServerPlugInFactory.GetDefaultPlugIn(index);
                                //object[] data = new object[(int)newPlug.Parameters[0] + 1];
                                //data[0] = newPlug.Parameters[0];
                                for (int j = 0; j != oldPlug.Parameters.Length - 1; ++j)
                                {
                                    TextBox temp = TablePlugIns.Rows[index].Cells[2 + j * 2].Controls[0] as TextBox;
                                    if (temp != null)
                                    {
                                        //判断有无修改
                                        //data[j + 1] = temp.Text;
                                        if (temp.Text.Equals(oldPlug.Parameters[j + 1].ToString()))
                                        {
                                            continue;
                                        }
                                        //更新参数
                                        object[] parameters = oldPlug.Parameters;
                                        parameters[j + 1]  = temp.Text;
                                        oldPlug.Parameters = parameters;
                                        isEdit             = true;
                                    }
                                }
                                if (!isEdit)
                                {
                                    break;
                                }
                                //再做一点修改2007-4-11修改的话,重设参数即可,不用再进行卸除和安装操作,只更新一下数据库就可以了
                                //newPlug.Parameters = data;
                                //oldPlug.Parameters = data;
                                //卸掉旧插件
                                //server.UnInstallPlugIn(oldPlug);
                                PlugInsToEdit.Add(oldPlug);
                                break;
                            }
                            //Delete
                            else
                            {
                                PlugInsToDelete.Add(oldPlug);
                                break;
                            }
                        }
                    }
                    //Add
                    //有一定的问题,我是用默认构造函数构造而后修改参数的
                    //最好直接用带参构造,但类名不知
                    if (isAdd && tempCheck.Checked)
                    {
                        IPlugIn newPlug = ServerPlugInFactory.GetDefaultPlugIn(index);
                        //object[] data = new object[(int)newPlug.Parameters[0] + 1];
                        //data[0] = newPlug.Parameters[0];
                        for (int k = 0; k != newPlug.Parameters.Length - 1; ++k)
                        {
                            TextBox temp = TablePlugIns.Rows[index].Cells[2 + 2 * k].Controls[0] as TextBox;
                            if (temp != null)
                            {
                                //判断有无修改
                                //newPlug.Parameters[k + 1] = temp.Text;
                                object[] parameters = newPlug.Parameters;
                                parameters[k + 1]  = temp.Text;
                                newPlug.Parameters = parameters;
                            }
                        }
                        PlugInsToInsert.Add(newPlug);
                    }
                }
                if (PlugInsToInsert.Count != 0)
                {
                    AdminServer.TheInstance.GameServerManager.InsertPlugIn(server, PlugInsToInsert);
                }
                if (PlugInsToDelete.Count != 0)
                {
                    AdminServer.TheInstance.GameServerManager.DeletePlugIn(server, PlugInsToDelete);
                }
                if (PlugInsToEdit.Count != 0)
                {
                    AdminServer.TheInstance.GameServerManager.EditPlugIn(server, PlugInsToEdit);
                }

                server.Disconnect();
            }

            ShowMessage(StringDef.OperationSucceed, MessageType.Success);
        }
        catch (Exception ex)
        {
            if (ex.Message.Equals(StringDef.FileReusedError))
            {
                serverText.Text = StringDef.OperationFail + StringDef.Colon + StringDef.FileReusedError;
                //ShowMessage(StringDef.OperationFail + StringDef.Colon + FileReusedError, MessageType.Failure);
                return;
            }
        }
        LoadState();
    }