예제 #1
0
        /// <summary>
        /// 删除任务
        /// </summary>
        public bool DeleteTask(int taskId)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                try
                {
                    BatchTask task = this.GetBatchTask(taskId);
                    if (task == null)
                    {
                        return(false);
                    }

                    db.BeginTrans();

                    AdminServer.TheInstance.SecurityManager.Delete(taskId, db);

                    IBlazeTable batchTaskTable = db.GetTable(TableString.BatchTaskTableName);
                    batchTaskTable.Delete(FilterFactory.CreateEqualFilter(TableString.BatchTaskId, taskId));

                    _batchTaskList.Remove(task);

                    db.CommitTrans();
                    return(true);
                }
                catch (Exception)
                {
                    if (db != null)
                    {
                        db.RollbackTrans();
                    }
                    return(false);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 添加玩家数量信息
        /// </summary>
        void AddPlayerCountInfo(PlayerCountStatisticInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table      = db.GetTable(TableString.PlayerCountTableName);
                string[]    fieldNames =
                {
                    TableString.PlayerCountFieldServerId,
                    TableString.PlayerCountFieldRecordTime,
                    TableString.PlayerCountFieldMaxPlayerCount,
                    TableString.PlayerCountFieldMinPlayerCount,
                    TableString.PlayerCountFieldAveragePlayerCount
                };
                object[] fieldValues =
                {
                    _server.Id,
                    info.Time,
                    info.MaxCount,
                    info.MinCount,
                    info.AverageCount
                };
                table.Add(fieldNames, fieldValues);
            }
        }
예제 #3
0
        /// <summary>
        /// 得到玩家数量信息
        /// </summary>
        PlayerCountStatisticInfo[] GetPlayerCountInfo(DateTime startTime, DateTime endTime)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table = db.GetTable(TableString.PlayerCountTableName);
                DataSet     ds    = new DataSet();
                table.Get(ds,
                          FilterFactory.CreateAndFilter(
                              FilterFactory.CreateEqualFilter(TableString.PlayerCountFieldServerId, _server.Id),
                              FilterFactory.CreateAndFilter(
                                  FilterFactory.CreateLargerEqualFilter(TableString.PlayerCountFieldRecordTime, startTime),
                                  FilterFactory.CreateLesserEqualFilter(TableString.PlayerCountFieldRecordTime, endTime)
                                  )
                              )
                          );

                DataTable dt       = ds.Tables[TableString.PlayerCountTableName];
                int       rowCount = dt.Rows.Count;
                PlayerCountStatisticInfo[] infos = new PlayerCountStatisticInfo[rowCount];
                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dt.Rows[i];
                    PlayerCountStatisticInfo info = new PlayerCountStatisticInfo();
                    info.Time         = (DateTime)row[TableString.PlayerCountFieldRecordTime];
                    info.MaxCount     = (int)row[TableString.PlayerCountFieldMaxPlayerCount];
                    info.MinCount     = (int)row[TableString.PlayerCountFieldMinPlayerCount];
                    info.AverageCount = (int)row[TableString.PlayerCountFieldAveragePlayerCount];
                    infos[i]          = info;
                }

                return(infos);
            }
        }
예제 #4
0
        public bool DeleteScript(int scriptId)
        {
            IBlazeDatabase db = null;

            try
            {
                db = DbFactory.GetDatabase();
                IBlazeTable ibShopTable = db.GetTable(TableString.IbShopTableName);

                db.BeginTrans();

                ibShopTable.Delete(FilterFactory.CreateEqualFilter(TableString.IbShopFieldId, scriptId));

                db.CommitTrans();

                return(true);
            }
            catch (Exception ex)
            {
                if (db != null)
                {
                    db.RollbackTrans();
                }
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 得到已保存的帐号密码
        /// </summary>
        public string GetSavedPassword(string accountName)
        {
            IBlazeDatabase db = null;

            try
            {
                db = DbFactory.GetDatabase();
                DataSet dataSet = new DataSet();

                IBlazeTable accountTable = db.GetTable(TableString.AccountInfoTableName);
                accountTable.Get(dataSet, FilterFactory.CreateEqualFilter(TableString.AccountInfoFieldName, accountName));
                DataRowCollection rows = dataSet.Tables[TableString.AccountInfoTableName].Rows;
                if (rows.Count != 0)
                {
                    return(rows[0][TableString.AccountInfoFieldPassword] as string);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
        }
예제 #6
0
파일: Strategy.cs 프로젝트: uvbs/FullSource
        /// <summary>
        /// 更新策略
        /// </summary>
        public void Update(int strategyId, Strategy newStrategy, string name, string comment)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                try
                {
                    db.BeginTrans();

                    SecurityManager sm             = AdminServer.TheInstance.SecurityManager;
                    FSEyeObject     strategyObject = sm.Get(strategyId);
                    strategyObject.Name    = name;
                    strategyObject.Comment = comment;
                    sm.Set(strategyObject, db);
                    newStrategy.SecurityObject = strategyObject;

                    IBlazeTable table        = db.GetTable(TableString.StrategyTableName);
                    DataSet     strategyData = new DataSet();
                    table.Get(strategyData);
                    DataTable         strategyTable = strategyData.Tables[TableString.StrategyTableName];
                    AutomationManager am            = AdminServer.TheInstance.AutomationManager;

                    byte[]    strategyBytes = am.Save(newStrategy.Automation);
                    DataRow[] rows          = strategyTable.Select(TableString.StrategyFieldId + "=" + strategyId);
                    if (rows != null && rows.Length > 0)
                    {
                        DataRow row = rows[0];
                        row[TableString.StrategyFieldEvent]      = (int)newStrategy.Event;
                        row[TableString.StrategyFieldEnabled]    = (newStrategy.Enabled ? 1 : 0);
                        row[TableString.StrategyFieldAutomation] = strategyBytes;

                        table.Set(strategyTable);
                    }

                    for (int i = 0; i < _strategyList.Count; i++)
                    {
                        Strategy strategy = _strategyList[i] as Strategy;
                        if (strategy.SecurityObject.Id == strategyId)
                        {
                            _strategyList.RemoveAt(i);
                            _strategyList.Add(newStrategy);
                            break;
                        }
                    }

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

                    throw ex;
                }
            }
        }
예제 #7
0
        /// <summary>
        /// 更新计划任务
        /// </summary>
        public void Update(int taskId, IScheduledTask newTask, string name, string comment)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                try
                {
                    db.BeginTrans();

                    SecurityManager sm         = AdminServer.TheInstance.SecurityManager;
                    FSEyeObject     taskObject = sm.Get(taskId);
                    taskObject.Name    = name;
                    taskObject.Comment = comment;
                    sm.Set(taskObject, db);
                    newTask.SecurityObject = taskObject;

                    using (MemoryStream taskDataStream = new MemoryStream())
                    {
                        IFormatter formatter = new BinaryFormatter();
                        formatter.Serialize(taskDataStream, newTask);
                        byte[]      taskData           = taskDataStream.ToArray();
                        DataSet     ds                 = new DataSet();
                        IBlazeTable scheduledTaskTable = db.GetTable(TableString.ScheduledTaskTableName);
                        scheduledTaskTable.Get(ds);
                        DataTable table = ds.Tables[TableString.ScheduledTaskTableName];
                        DataRow[] rows  = table.Select(TableString.ScheduledTaskFieldId + "=" + newTask.SecurityObject.Id);
                        if (rows.Length > 0)
                        {
                            DataRow row = rows[0];
                            row[TableString.ScheduledTaskFieldTaskData] = taskData;
                            scheduledTaskTable.Set(table);
                        }
                    }

                    foreach (ScheduledTaskUnit unit in _taskList)
                    {
                        if (unit.Task.SecurityObject.Id == taskId)
                        {
                            unit.AvoidCheckTimeout = 0;
                            unit.Task = newTask;
                            break;
                        }
                    }

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

                    throw ex;
                }
            }
        }
예제 #8
0
파일: Strategy.cs 프로젝트: uvbs/FullSource
        /// <summary>
        /// 添加策略
        /// </summary>
        public bool Add(Strategy strategy, string name, string comment)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                try
                {
                    db.BeginTrans();

                    SecurityManager sm            = AdminServer.TheInstance.SecurityManager;
                    FSEyeObject     newObject     = sm.Get(SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + name, db);
                    byte[]          strategyBytes = AdminServer.TheInstance.AutomationManager.Save(strategy.Automation);

                    if (newObject != null && strategyBytes != null)
                    {
                        newObject.Comment = comment;
                        sm.Set(newObject);
                        strategy.SecurityObject = newObject;

                        IBlazeTable table        = db.GetTable(TableString.StrategyTableName);
                        DataSet     strategyData = new DataSet();
                        table.Get(strategyData);
                        DataTable strategyTable = strategyData.Tables[TableString.StrategyTableName];

                        DataRow newRow = strategyTable.NewRow();
                        newRow[TableString.StrategyFieldId]         = newObject.Id;
                        newRow[TableString.StrategyFieldEvent]      = (int)strategy.Event;
                        newRow[TableString.StrategyFieldAutomation] = strategyBytes;
                        newRow[TableString.StrategyFieldEnabled]    = (strategy.Enabled ? 1 : 0);
                        strategyTable.Rows.Add(newRow);
                        table.Set(strategyTable);

                        //设置权限
                        AdminServer.TheInstance.SecurityManager.CopyAce(newObject.Parent, newObject, true);

                        _strategyList.Add(strategy);

                        db.CommitTrans();

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

                    throw ex;
                }
            }
        }
예제 #9
0
        /// <summary>
        /// 保存帐号密码
        /// </summary>
        public bool SaveAccountPassword(string accountName, string accountPassword)
        {
            IBlazeDatabase db = null;

            try
            {
                db = DbFactory.GetDatabase();
                IBlazeTable accountTable = db.GetTable(TableString.AccountInfoTableName);

                //插入数据到服务器表
                string[] fields = new string[] {
                    TableString.AccountInfoFieldName,
                    TableString.AccountInfoFieldPassword,
                };
                object[] values = new object[] {
                    accountName,
                    accountPassword
                };

                db.BeginTrans();
                if (GetSavedPassword(accountName) != null)
                {
                    //Update
                    accountTable.Set(TableString.AccountInfoFieldPassword, accountPassword,
                                     FilterFactory.CreateEqualFilter(TableString.AccountInfoFieldName, accountName));
                }
                else
                {
                    //Insert
                    accountTable.Add(fields, values);
                }
                db.CommitTrans();

                return(true);
            }
            catch (Exception ex)
            {
                if (db != null)
                {
                    db.RollbackTrans();
                }
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
        }
예제 #10
0
        public bool EditUpdateServer(FTPServer server)
        {
            IBlazeDatabase db = null;

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

                IBlazeTable table    = db.GetTable(TableString.UpdateServerTableName);
                DataSet     taskData = new DataSet();
                table.Get(taskData);
                DataTable taskTable = taskData.Tables[TableString.UpdateServerTableName];

                foreach (DataRow row in taskTable.Rows)
                {
                    if ((int)row[TableString.UpdateServerFieldId] == server.ID)
                    {
                        row.BeginEdit();
                        row[TableString.UpdateServerFieldAddress]  = server.Address;
                        row[TableString.UpdateServerFieldPort]     = server.Port;
                        row[TableString.UpdateServerFieldUsername] = server.UserName;
                        row[TableString.UpdateServerFieldPassword] = server.Password;
                        row[TableString.UpdateServerFieldLiteral]  = server.Literal;
                        row.EndEdit();
                        break;
                    }
                }
                table.Set(taskTable);
                db.CommitTrans();

                return(true);
            }
            catch (Exception)
            {
                if (db != null)
                {
                    db.RollbackTrans();
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
            return(false);
        }
예제 #11
0
        public bool Load()
        {
            this.SecurityObject = AdminServer.TheInstance.SecurityManager.Get(SecurityObjectBatchTaskManager);
            this._batchTaskList.Clear();

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table            = db.GetTable(TableString.BatchTaskTableName);
                DataSet     batchTaskDataSet = new DataSet();
                table.Get(batchTaskDataSet);
                DataTable         batchTaskTable = batchTaskDataSet.Tables[TableString.BatchTaskTableName];
                StrategyManager   sm             = AdminServer.TheInstance.StrategyManager;
                AutomationManager am             = AdminServer.TheInstance.AutomationManager;
                foreach (DataRow row in batchTaskTable.Rows)
                {
                    int batchTaskId = (int)row[TableString.BatchTaskId];

                    try
                    {
                        BatchTask batchTask = new BatchTask();
                        batchTask.Step       = (int)row[TableString.BatchTaskStep];
                        batchTask.Automation = am.Load((byte[])row[TableString.BatchTaskAutomation]);
                        string serverIds = SystemConfig.Current.DefaultEncoding.GetString((byte[])row[TableString.BatchTaskServerIds]);
                        foreach (string serverIdText in serverIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            int        serverId = int.Parse(serverIdText);
                            GameServer server   = AdminServer.TheInstance.GameServerManager.GetGameServer(serverId);
                            if (server != null)
                            {
                                batchTask.AddServer(serverId);
                            }
                        }

                        FSEyeObject secObj = AdminServer.TheInstance.SecurityManager.Get(batchTaskId);
                        if (secObj != null)
                        {
                            batchTask.SecurityObject = secObj;
                            _batchTaskList.Add(batchTask);
                        }
                    }
                    catch (Exception e)
                    {
                        Util.DebugLog(e.StackTrace);
                        continue;
                    }
                }
                return(true);
            }
        }
예제 #12
0
        public bool DeleteUpdateServer(FTPServer server)
        {
            IBlazeDatabase db = null;

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

                IBlazeTable table    = db.GetTable(TableString.UpdateServerTableName);
                DataSet     taskData = new DataSet();
                table.Get(taskData);
                DataTable taskTable = taskData.Tables[TableString.UpdateServerTableName];

                foreach (DataRow row in taskTable.Rows)
                {
                    if ((int)row[TableString.UpdateServerFieldId] == server.ID)
                    {
                        row.Delete();
                        break;
                    }
                }
                table.Set(taskTable);

                AdminServer.TheInstance.SecurityManager.Delete(server.ID, db);

                db.CommitTrans();

                this._FTPServerList.Remove(server);

                return(true);
            }
            catch (Exception)
            {
                if (db != null)
                {
                    db.RollbackTrans();
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
            return(false);
        }
예제 #13
0
        /// <summary>
        /// 载入计划任务
        /// </summary>
        public void Load()
        {
            this.SecurityObject = AdminServer.TheInstance.SecurityManager.Get(SecurityObjectScheduledTaskManager);
            _taskList.Clear();

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable scheduledTaskTable = db.GetTable(TableString.ScheduledTaskTableName);
                DataSet     ds = new DataSet();
                scheduledTaskTable.Get(ds);
                DataTable table = ds.Tables[TableString.ScheduledTaskTableName];
                foreach (DataRow row in table.Rows)
                {
                    try
                    {
                        int    id       = (int)row[TableString.ScheduledTaskFieldId];
                        byte[] taskData = (byte[])row[TableString.ScheduledTaskFieldTaskData];

                        MemoryStream   taskDataStream = new MemoryStream(taskData);
                        IFormatter     formatter      = new BinaryFormatter();
                        IScheduledTask task           = (IScheduledTask)formatter.Deserialize(taskDataStream);
                        if (task != null)
                        {
                            FSEyeObject secObj = AdminServer.TheInstance.SecurityManager.Get(id);
                            if (secObj != null)
                            {
                                task.SecurityObject = secObj;

                                ScheduledTaskUnit unit = new ScheduledTaskUnit();
                                unit.Task = task;
                                unit.AvoidCheckTimeout = 0;
                                _taskList.Add(unit);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Util.DebugLog(e.StackTrace);
                        continue;
                    }
                }
            }
        }
예제 #14
0
        public bool SaveScript(string script, out long scriptId)
        {
            IBlazeDatabase db = null;

            try
            {
                db = DbFactory.GetDatabase();
                IBlazeTable ibShopTable = db.GetTable(TableString.IbShopTableName);

                //插入数据到服务器表
                string[] fields = new string[] {
                    TableString.IbShopFieldTimeStamp,
                    TableString.IbShopFieldScript,
                };
                object[] values = new object[] {
                    DateTime.Now,
                    script
                };

                db.BeginTrans();
                scriptId = ibShopTable.Add(fields, values);
                db.CommitTrans();

                return(true);
            }
            catch (Exception ex)
            {
                if (db != null)
                {
                    db.RollbackTrans();
                }
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
        }
예제 #15
0
        public bool LoadUpdateServer()
        {
            lock (this)
            {
                IBlazeDatabase db = null;
                try
                {
                    db = DbFactory.GetDatabase();
                    IBlazeTable table = db.GetTable(TableString.UpdateServerTableName);

                    DataSet data = new DataSet();
                    table.Get(data);
                    DataRowCollection rows = data.Tables[TableString.UpdateServerTableName].Rows;
                    foreach (DataRow row in rows)
                    {
                        int    id       = (int)row[TableString.UpdateServerFieldId];
                        string address  = row[TableString.UpdateServerFieldAddress] as string;
                        int    port     = (int)row[TableString.UpdateServerFieldPort];
                        string username = row[TableString.UpdateServerFieldUsername] as string;
                        string password = row[TableString.UpdateServerFieldPassword] as string;
                        string literal  = row[TableString.UpdateServerFieldLiteral] as string;
                        FTPServer.FTPServerType type = (FTPServer.FTPServerType)Enum.Parse(typeof(FTPServer.FTPServerType), row[TableString.UpdateServerFieldUpdateServerType].ToString());
                        FTPServer server             = new FTPServer(id, address, port, username, password, literal, type);
                        server.SecurityObject = AdminServer.TheInstance.SecurityManager.Get(id);
                        _FTPServerList.Add(server);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
                finally
                {
                    if (db != null)
                    {
                        db.Close();
                    }
                }
            }
            return(true);
        }
예제 #16
0
        /// <summary>
        /// 删除计划任务
        /// </summary>
        /// <param name="taskId">计划任务ID</param>
        public bool Delete(int taskId)
        {
            for (int i = 0; i < _taskList.Count; i++)
            {
                ScheduledTaskUnit unit = _taskList[i] as ScheduledTaskUnit;
                if (unit.Task.SecurityObject.Id == taskId)
                {
                    using (IBlazeDatabase db = DbFactory.GetDatabase())
                    {
                        try
                        {
                            db.BeginTrans();

                            AdminServer.TheInstance.SecurityManager.Delete(taskId, db);

                            IBlazeTable scheduledTaskTable = db.GetTable(TableString.ScheduledTaskTableName);
                            scheduledTaskTable.Delete(FilterFactory.CreateEqualFilter(TableString.ScheduledTaskFieldId, taskId));

                            AdminServer.TheInstance.SecurityManager.Delete(taskId, db);

                            _taskList.RemoveAt(i);

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

                            throw ex;
                        }
                    }
                }
            }

            return(false);
        }
예제 #17
0
파일: Strategy.cs 프로젝트: uvbs/FullSource
        /// <summary>
        /// 载入策略配置
        /// </summary>
        public void Load()
        {
            this.SecurityObject = AdminServer.TheInstance.SecurityManager.Get(SecurityObjectStrategyManager);
            _strategyList.Clear();

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table        = db.GetTable(TableString.StrategyTableName);
                DataSet     strategyData = new DataSet();
                table.Get(strategyData);
                DataTable         strategyTable = strategyData.Tables[TableString.StrategyTableName];
                StrategyManager   sm            = AdminServer.TheInstance.StrategyManager;
                AutomationManager am            = AdminServer.TheInstance.AutomationManager;
                foreach (DataRow row in strategyTable.Rows)
                {
                    int strategyId = (int)row[TableString.StrategyFieldId];

                    try
                    {
                        Strategy strategy = new Strategy();
                        strategy.Event      = (FSEyeEvent)row[TableString.StrategyFieldEvent];
                        strategy.Automation = am.Load((byte[])row[TableString.StrategyFieldAutomation]);
                        strategy.Enabled    = ((int)row[TableString.StrategyFieldEnabled]) == 0 ? false : true;

                        FSEyeObject secObj = AdminServer.TheInstance.SecurityManager.Get(strategyId);
                        if (secObj != null)
                        {
                            strategy.SecurityObject = secObj;
                            _strategyList.Add(strategy);
                        }
                    }
                    catch (Exception e)
                    {
                        Util.DebugLog(e.StackTrace);
                        continue;
                    }
                }
            }
        }
예제 #18
0
파일: Strategy.cs 프로젝트: uvbs/FullSource
        /// <summary>
        /// 删除策略
        /// </summary>
        /// <param name="strategyId">策略ID</param>
        public bool Delete(int strategyId)
        {
            for (int i = 0; i < _strategyList.Count; i++)
            {
                Strategy strategy = _strategyList[i] as Strategy;
                if (strategy.SecurityObject.Id == strategyId)
                {
                    using (IBlazeDatabase db = DbFactory.GetDatabase())
                    {
                        try
                        {
                            db.BeginTrans();

                            AdminServer.TheInstance.SecurityManager.Delete(strategyId, db);

                            IBlazeTable strategyTable = db.GetTable(TableString.StrategyTableName);
                            strategyTable.Delete(FilterFactory.CreateEqualFilter(TableString.StrategyFieldId, strategyId));

                            _strategyList.RemoveAt(i);

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

                            throw ex;
                        }
                    }
                }
            }

            return(false);
        }
예제 #19
0
        /// <summary>
        /// 获取某日的最大人数
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        int GetDayMaxPlayer(DateTime day)
        {
            DateTime startTime = DateTime.Parse(day.ToShortDateString() + " 00:00:00");
            DateTime endTime   = DateTime.Parse(day.ToShortDateString() + " 23:59:59");
            int      maxPlayer = 0;
            int      rowMax    = 0;

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table = db.GetTable(TableString.PlayerCountTableName);
                DataSet     ds    = new DataSet();
                table.Get(ds,
                          FilterFactory.CreateAndFilter(
                              FilterFactory.CreateEqualFilter(TableString.PlayerCountFieldServerId, _server.Id),
                              FilterFactory.CreateAndFilter(
                                  FilterFactory.CreateLargerEqualFilter(TableString.PlayerCountFieldRecordTime, startTime),
                                  FilterFactory.CreateLesserEqualFilter(TableString.PlayerCountFieldRecordTime, endTime)
                                  )
                              )
                          );

                DataTable dt = ds.Tables[TableString.PlayerCountTableName];

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow row = dt.Rows[i];
                    PlayerCountStatisticInfo info = new PlayerCountStatisticInfo();

                    rowMax = (int)row[TableString.PlayerCountFieldMaxPlayerCount];
                    if (maxPlayer < rowMax)
                    {
                        maxPlayer = rowMax;
                    }
                }

                return(maxPlayer);
            }
        }
예제 #20
0
        public IList <IBShopScript> GetScript()
        {
            IBlazeDatabase       db         = null;
            IList <IBShopScript> resultList = new List <IBShopScript>();

            try
            {
                db = DbFactory.GetDatabase();
                DataSet dataSet = new DataSet();

                IBlazeTable ibShopTable = db.GetTable(TableString.IbShopTableName);
                ibShopTable.Get(dataSet);

                DataRowCollection rows = dataSet.Tables[TableString.IbShopTableName].Rows;
                foreach (DataRow row in rows)
                {
                    IBShopScript ibShopScript = new IBShopScript();
                    ibShopScript.ID        = (int)row[TableString.IbShopFieldId];
                    ibShopScript.TimeStamp = (DateTime)row[TableString.IbShopFieldTimeStamp];
                    ibShopScript.Script    = Encoding.Default.GetString(row[TableString.IbShopFieldScript] as byte[]);
                    resultList.Add(ibShopScript);
                }
                return(resultList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
        }
예제 #21
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        private void InitializeDatabase(bool rebuild)
        {
            DbFactory.DbConnectionString = SystemConfig.Current.DbConnectionString;
            DbFactory.DefaultDbName      = SystemConfig.Current.DefaultDbName;

            ColumnConfiguration[] colCfgsObj = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ObjectFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ObjectFieldOwner, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ObjectFieldParentId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ObjectFieldName, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.ObjectFieldComment, BlazeDbType.STRING)
            };
            ColumnConfiguration[] colCfgsUser = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.UserFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.UserFieldUserName, BlazeDbType.SHORT_STRING, false, true),
                new ColumnConfiguration(TableString.UserFieldRealName, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.UserFieldPassword, BlazeDbType.STRING)
            };
            ColumnConfiguration[] colCfgsGroup = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.UserGroupFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.UserGroupFieldGroupName, BlazeDbType.SHORT_STRING, false, true)
            };
            ColumnConfiguration[] colCfgsUserGroup = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.UserInGroupFieldUserId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.UserInGroupFieldGroupId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.UserInGroupFieldEstablishDatetime, BlazeDbType.DATETIME)
            };
            ColumnConfiguration[] colCfgsAce = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.AceFieldAceId, BlazeDbType.INT4, false, true, true, true, null),
                new ColumnConfiguration(TableString.AceFieldObjectId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.AceFieldOperatorId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.AceFieldOperation, BlazeDbType.INT4),
            };
            ColumnConfiguration[] colCfgsGameServer = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.GameServerFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.GameServerFieldNetAddress, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldGameDir, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.GameServerFieldLordPort, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldMaxPlayer, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldIntranetMask, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldInternetMask, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldPaysysIp, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldPaysysPort, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldPaysysLoginName, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldPaysysLoginPwd, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.GameServerFieldDbHost, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldDbName, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldDbLoginName, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldDbLoginPwd, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.GameServerFieldDbBackupDir, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.GameServerFieldFSEyeIp, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.GameServerFieldFSEyePort, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldHasBeenConfigGuard, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldServerType, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldCfgString, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.GameServerFieldFtpDownloadServer, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameServerFieldGmcIp, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.GameServerFieldGmcAccount, BlazeDbType.STRING)
            };
            ColumnConfiguration[] colCfgsServerGroup = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ServerGroupFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ServerGroupFieldType, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerGroupFieldGroupEnable, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.ServerGroupFieldMaxPlayers, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerGroupFieldMaxPlayersLogTime, BlazeDbType.DATETIME),
                new ColumnConfiguration(TableString.ServerGroupFieldCabinet, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.ServerGroupFieldGroupVersion, BlazeDbType.STRING)
            };
            ColumnConfiguration[] colCfgsServerRegion = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ServerRegionFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ServerRegionFieldMaxPlayers, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerRegionFieldMaxPlayersLogTime, BlazeDbType.DATETIME),
                new ColumnConfiguration(TableString.ServerRegionFieldRegionName, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.ServerRegionFieldRegionType, BlazeDbType.INT2)
            };
            ColumnConfiguration[] colCfgsGameLog = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.GameLogFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.GameLogFieldGameServerId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GameLogFieldDate, BlazeDbType.DATE),
                new ColumnConfiguration(TableString.GameLogFieldTotalMoney, BlazeDbType.INT8),
                new ColumnConfiguration(TableString.GameLogFieldTotalMoneyInBox, BlazeDbType.INT8)
            };
            ColumnConfiguration[] colCfgsServerPlugIn = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ServerPlugInFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ServerPlugInFieldGameServerId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerPlugInFieldPlugInGuid, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.ServerPlugInFieldParameter1, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.ServerPlugInFieldParameter2, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.ServerPlugInFieldParameter3, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.ServerPlugInFieldPlugInName, BlazeDbType.STRING)
            };
            ColumnConfiguration[] strategy = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.StrategyFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.StrategyFieldEvent, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.StrategyFieldAutomation, BlazeDbType.BLOB),
                new ColumnConfiguration(TableString.StrategyFieldEnabled, BlazeDbType.INT2)
            };
            ColumnConfiguration[] scheduledTask = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ScheduledTaskFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ScheduledTaskFieldTaskData, BlazeDbType.BLOB)
            };
            //ColumnConfiguration[] task = new ColumnConfiguration[] {
            //    new ColumnConfiguration( TableString.TaskFieldId, BlazeDbType.INT4, true ),
            //    new ColumnConfiguration( TableString.TaskFieldName, BlazeDbType.STRING),
            //    new ColumnConfiguration( TableString.TaskFieldAutomation, BlazeDbType.BLOB),
            //    new ColumnConfiguration( TableString.TaskFieldInterval,BlazeDbType.INT4),
            //    new ColumnConfiguration( TableString.TaskFieldPeriodUnit, BlazeDbType.INT4),
            //    new ColumnConfiguration( TableString.TaskFieldStart, BlazeDbType.DATETIME),
            //    new ColumnConfiguration( TableString.TaskFieldEnd, BlazeDbType.DATETIME),
            //    new ColumnConfiguration( TableString.TaskFieldSelectedDay, BlazeDbType.STRING),
            //    new ColumnConfiguration( TableString.TaskFieldSelectedMonth, BlazeDbType.STRING),
            //    new ColumnConfiguration( TableString.TaskFieldRepeatPeriod, BlazeDbType.INT4),
            //    new ColumnConfiguration( TableString.TaskFieldRepeatPersistenceTime, BlazeDbType.INT4),
            //    new ColumnConfiguration( TableString.StrategyFieldEnabled, BlazeDbType.INT2)
            //};
            ColumnConfiguration[] updateServer = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.UpdateServerFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.UpdateServerFieldAddress, BlazeDbType.SHORT_STRING),
                new ColumnConfiguration(TableString.UpdateServerFieldPort, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.UpdateServerFieldUsername, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.UpdateServerFieldPassword, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.UpdateServerFieldLiteral, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.UpdateServerFieldUpdateServerType, BlazeDbType.INT2)
            };
            ColumnConfiguration[] playerCount = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.PlayerCountFieldServerId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.PlayerCountFieldRecordTime, BlazeDbType.DATETIME, true),
                new ColumnConfiguration(TableString.PlayerCountFieldMaxPlayerCount, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.PlayerCountFieldMinPlayerCount, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.PlayerCountFieldAveragePlayerCount, BlazeDbType.INT2)
            };

            ColumnConfiguration[] gmOpLog = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.GMOpLogFieldId, BlazeDbType.INT4, false, true, true, true, null),
                new ColumnConfiguration(TableString.GMOpLogFieldUserId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GMOpLogFieldOperation, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.GMOpLogFieldTarget, BlazeDbType.BLOB),
                new ColumnConfiguration(TableString.GMOpLogFieldServerId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.GMOpLogFieldDescription, BlazeDbType.BLOB),
                new ColumnConfiguration(TableString.GMOpLogFieldLogTime, BlazeDbType.DATETIME),
                new ColumnConfiguration(TableString.GMOpLogFieldTargetType, BlazeDbType.INT2)
            };

            ColumnConfiguration[] accountInfo = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.AccountInfoFieldId, BlazeDbType.INT4, false, true, true, true, null),
                new ColumnConfiguration(TableString.AccountInfoFieldName, BlazeDbType.STRING, false, true, false, false, null),
                new ColumnConfiguration(TableString.AccountInfoFieldPassword, BlazeDbType.STRING)
            };

            ColumnConfiguration[] ibShop = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.IbShopFieldId, BlazeDbType.INT4, false, true, true, true, null),
                new ColumnConfiguration(TableString.IbShopFieldTimeStamp, BlazeDbType.DATETIME),
                new ColumnConfiguration(TableString.IbShopFieldScript, BlazeDbType.BLOB)
            };

            ColumnConfiguration[] batchTask = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.BatchTaskId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.BatchTaskAutomation, BlazeDbType.BLOB),
                new ColumnConfiguration(TableString.BatchTaskStep, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.BatchTaskServerIds, BlazeDbType.BLOB)
            };

            ColumnConfiguration[] serverEvent = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ServerEventFieldServerId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ServerEventFieldEventTime, BlazeDbType.DATETIME, true),
                new ColumnConfiguration(TableString.ServerEventFieldEventType, BlazeDbType.INT2)
            };

            ColumnConfiguration[] serverOperationLog = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ServerOperationLogFieldId, BlazeDbType.INT8, false, true, true, true, null),
                new ColumnConfiguration(TableString.ServerOperationLogFieldOperationId, BlazeDbType.INT8),
                new ColumnConfiguration(TableString.ServerOperationLogFieldUserId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerOperationLogFieldServerOrGroup, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.ServerOperationLogFieldTargetId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerOperationLogFieldOperationType, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.ServerOperationLogFieldOperationResult, BlazeDbType.INT2),
                new ColumnConfiguration(TableString.ServerOperationLogFieldDescription, BlazeDbType.LONG_STRING),
                new ColumnConfiguration(TableString.ServerOperationLogFieldLogTime, BlazeDbType.DATETIME),
                new ColumnConfiguration(TableString.ServerOperationLogFieldFatherRegion, BlazeDbType.LONG_STRING)
            };

            ColumnConfiguration[] serverMap = new ColumnConfiguration[] {
                new ColumnConfiguration(TableString.ServerMapFieldId, BlazeDbType.INT4, true),
                new ColumnConfiguration(TableString.ServerMapFieldParentId, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerMapFieldName, BlazeDbType.STRING),
                new ColumnConfiguration(TableString.ServerMapFieldMapType, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerMapFieldIndex, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerMapFieldFlag, BlazeDbType.INT4),
                new ColumnConfiguration(TableString.ServerMapFieldMapServerId, BlazeDbType.INT4)
            };

            DbConfiguration dbCfg = new DbConfiguration(
                DbFactory.DefaultDbName,
                new TableConfiguration[] {
                new TableConfiguration(TableString.ObjectTableName, colCfgsObj),
                new TableConfiguration(TableString.UserTableName, colCfgsUser),
                new TableConfiguration(TableString.UserGroupTableName, colCfgsGroup),
                new TableConfiguration(TableString.UserInGroupTableName, colCfgsUserGroup),
                new TableConfiguration(TableString.AceTableName, colCfgsAce),
                new TableConfiguration(TableString.GameServerTableName, colCfgsGameServer),
                new TableConfiguration(TableString.ServerGroupTableName, colCfgsServerGroup),
                new TableConfiguration(TableString.ServerRegionTableName, colCfgsServerRegion),
                new TableConfiguration(TableString.GameLogTableName, colCfgsGameLog),
                new TableConfiguration(TableString.ServerPlugInTableName, colCfgsServerPlugIn),
                new TableConfiguration(TableString.StrategyTableName, strategy),
                new TableConfiguration(TableString.ScheduledTaskTableName, scheduledTask),
                new TableConfiguration(TableString.UpdateServerTableName, updateServer),
                new TableConfiguration(TableString.PlayerCountTableName, playerCount),
                new TableConfiguration(TableString.GMOpLogTableName, gmOpLog),
                new TableConfiguration(TableString.AccountInfoTableName, accountInfo),
                new TableConfiguration(TableString.IbShopTableName, ibShop),
                new TableConfiguration(TableString.BatchTaskTableName, batchTask),
                new TableConfiguration(TableString.ServerEventTableName, serverEvent),
                new TableConfiguration(TableString.ServerOperationLogTableName, serverOperationLog),
                new TableConfiguration(TableString.ServerMapTableName, serverMap)
            }
                );

            IBlazeDatabase db = DbFactory.GetDatabase();

            db.InitDatabase(dbCfg, rebuild);
        }
예제 #22
0
        /// <summary>
        /// 添加计划任务
        /// </summary>
        public void Add(IScheduledTask task, string name, string comment)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (comment == null)
            {
                throw new ArgumentNullException("comment");
            }

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

                    SecurityManager sm             = AdminServer.TheInstance.SecurityManager;
                    FSEyeObject     newObject      = sm.Get(SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + name, db);
                    byte[]          automationData = AdminServer.TheInstance.AutomationManager.Save(task.Automation);

                    MemoryStream taskDataStream = new MemoryStream();
                    IFormatter   formatter      = new BinaryFormatter();
                    formatter.Serialize(taskDataStream, task);
                    byte[] taskData = taskDataStream.ToArray();
                    if (newObject != null && automationData != null && taskData != null)
                    {
                        newObject.Comment = comment;
                        sm.Set(newObject);
                        task.SecurityObject = newObject;

                        IBlazeTable scheduledTaskTable = db.GetTable(TableString.ScheduledTaskTableName);
                        DataSet     ds = new DataSet();
                        scheduledTaskTable.Get(ds);
                        DataTable table = ds.Tables[TableString.ScheduledTaskTableName];
                        DataRow   row   = table.NewRow();
                        row[TableString.ScheduledTaskFieldId]       = newObject.Id;
                        row[TableString.ScheduledTaskFieldTaskData] = taskData;
                        table.Rows.Add(row);
                        scheduledTaskTable.Set(table);

                        ScheduledTaskUnit unit = new ScheduledTaskUnit();
                        unit.Task = task;
                        unit.AvoidCheckTimeout = 0;
                        _taskList.Add(unit);

                        //设置权限
                        AdminServer.TheInstance.SecurityManager.CopyAce(newObject.Parent, newObject, true);

                        db.CommitTrans();
                    }
                }
                catch (Exception)
                {
                    db.RollbackTrans();
                }
            }
        }
예제 #23
0
    //按照filter来查询数据库,并对结果处理,将各个int值转化为对应的可读的string信息,
    //并且使其结构于页面中的ResultDataGrid一致。
    //将处理后生成的datatable返回,ResultDataGrid只须与其绑定即可。
    private DataTable QueryAndReturnResultDataTable(DbFilter filter)
    {
        //开始查询了
        using (IBlazeDatabase db = DbFactory.GetDatabase())
        {
            IBlazeTable table = db.GetTable(TableString.ServerOperationLogTableName);
            DataSet     ds    = new DataSet();
            table.Get(ds, filter);
            DataTable dt = ds.Tables[TableString.ServerOperationLogTableName];

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            //按照log_time升序进行排序
            dt.DefaultView.Sort = TableString.ServerOperationLogFieldLogTime + " ASC";

            DataTable finalDataTable = new DataTable();
            finalDataTable.Columns.Add(new DataColumn("operation_id", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("user_name", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("target_type", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("target_name", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("operation_type", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("operation_result", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("description", typeof(String)));
            finalDataTable.Columns.Add(new DataColumn("log_time", typeof(DateTime)));


            foreach (DataRow row in dt.Rows)
            {
                //新的datarow,要加入到finalDataTable中去的
                DataRow newRow = finalDataTable.NewRow();

                //设置显示结果中的操作流水号
                Int64 opId = (Int64)row[TableString.ServerOperationLogFieldOperationId];
                if (opId <= 0)
                {
                    newRow["operation_id"] = "不合法的操作流水号:必须为正整数";
                }
                else
                {
                    newRow["operation_id"] = opId.ToString();
                }

                //设置平台用户名
                int userId = (int)row[TableString.ServerOperationLogFieldUserId];
                FSEye.Security.User user = AdminServer.TheInstance.SecurityManager.GetUser(userId);
                if (user == null)
                {
                    newRow["user_name"] = "无此用户";
                }
                else
                {
                    newRow["user_name"] = user.UserName;
                }

                //设置操作对象类型和操作对象名称
                //targetId = -2表示对多个组开始进行操作,多个组名存在description字段中
                int isServerGroup = (int)row[TableString.ServerOperationLogFieldServerOrGroup];
                int targetId      = (int)row[TableString.ServerOperationLogFieldTargetId];
                if (isServerGroup == 1)
                {
                    newRow["target_type"] = "服务器组";
                    if (targetId == -2)
                    {
                        newRow["target_name"] = "";
                    }
                    else
                    {
                        ServerGroup serverGroup = AdminServer.TheInstance.GameServerManager.GetGameServerGroup(targetId);
                        if (serverGroup == null)
                        {
                            newRow["target_name"] = "无此服务器组";
                        }
                        else
                        {
                            newRow["target_name"] = serverGroup.Name;
                        }
                    }
                }
                else if (isServerGroup == 0)
                {
                    newRow["target_type"] = "服务器";
                    GameServer server = AdminServer.TheInstance.GameServerManager.GetGameServer(targetId);
                    if (server == null)
                    {
                        newRow["target_name"] = "无此服务器";
                    }
                    else
                    {
                        newRow["target_name"] = server.Name;
                    }
                }
                else
                {
                    newRow["target_type"] = "不合法的对象类型";
                    newRow["target_name"] = "不合法的操作对象";
                }

                //设置操作类型
                int opTypeInt = (int)row[TableString.ServerOperationLogFieldOperationType];
                GameServer.ServerOperationType opTypeEnum = (GameServer.ServerOperationType)Enum.Parse(typeof(GameServer.ServerOperationType), opTypeInt.ToString());
                switch (opTypeEnum)
                {
                case GameServer.ServerOperationType.Start:
                    newRow["operation_type"] = "启动";
                    break;

                case GameServer.ServerOperationType.Close:
                    newRow["operation_type"] = "关闭";
                    break;

                case GameServer.ServerOperationType.Update:
                    newRow["operation_type"] = "更新";
                    break;

                case GameServer.ServerOperationType.Download:
                    newRow["operation_type"] = "下载更新包";
                    break;

                case GameServer.ServerOperationType.UpdateConfigFile:
                    newRow["operation_type"] = "上传配置文件";
                    break;

                default:
                    newRow["operation_type"] = "未知操作类型";
                    break;
                }

                //设置操作结果
                int resultSuccess = (int)row[TableString.ServerOperationLogFieldOperationResult];
                if (resultSuccess == 1)
                {
                    newRow["operation_result"] = "成功";
                }
                else if (resultSuccess == 0)
                {
                    newRow["operation_result"] = "失败";
                }
                else
                {
                    newRow["operation_result"] = "不合法的操作结果";
                }

                //设置操作描述
                newRow["description"] = (String)row[TableString.ServerOperationLogFieldDescription];


                //设置日志记录时间
                newRow["log_time"] = (DateTime)row[TableString.ServerOperationLogFieldLogTime];

                //将newrow加入到finaldatatable中
                finalDataTable.Rows.Add(newRow);
            }

            return(finalDataTable);
        }
    }
예제 #24
0
        public bool AddUpdateServer(FTPServer server)
        {
            IBlazeDatabase db = null;

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

                SecurityManager sm = AdminServer.TheInstance.SecurityManager;

                //构造相关安全对象
                string newUpdateServerObjPath = sm.Root.FullName + SecurityManager.ObjectPathDelimiter + SecurityObjectSystem + SecurityManager.ObjectPathDelimiter + SecurityObjectUpdateManagement + SecurityManager.ObjectPathDelimiter
                                                + SecurityObjectUpdateServer + SecurityManager.ObjectPathDelimiter + server.Literal;
                FSEyeObject newUpdateServerObj = sm.Get(newUpdateServerObjPath, db);
                sm.Set(newUpdateServerObj);

                AddFatherAce(newUpdateServerObj.Parent, newUpdateServerObj, true);

                //IBlazeTable table = db.GetTable(TableString.UpdateServerTableName);
                //DataSet taskData = new DataSet();
                //table.Get(taskData);
                //DataTable taskTable = taskData.Tables[TableString.UpdateServerTableName];

                //DataRow addRow = taskTable.Rows.Add(newUpdateServerObj.Id,
                //                                    server.Address,
                //                                    server.Port,
                //                                    server.UserName,
                //                                    server.Password,
                //                                    server.Literal);
                //table.Set(taskTable);

                //插入数据到服务器表
                string[] fields = new string[] {
                    TableString.UpdateServerFieldId,
                    TableString.UpdateServerFieldAddress,
                    TableString.UpdateServerFieldPort,
                    TableString.UpdateServerFieldUsername,
                    TableString.UpdateServerFieldPassword,
                    TableString.UpdateServerFieldLiteral,
                    TableString.UpdateServerFieldUpdateServerType
                };
                object[] values = new object[] {
                    newUpdateServerObj.Id,
                    server.Address,
                    server.Port,
                    server.UserName,
                    server.Password,
                    server.Literal,
                    (Int16)server.FtpServerType
                };

                IBlazeTable serverTable = db.GetTable(TableString.UpdateServerTableName);
                serverTable.Add(fields, values);

                db.CommitTrans();

                server.SecurityObject = newUpdateServerObj;
                this._FTPServerList.Add(server);

                return(true);
            }
            catch (Exception ex)
            {
                Util.DebugLog(ex.ToString());

                if (db != null)
                {
                    db.RollbackTrans();
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }
            return(false);
        }
예제 #25
0
		/// <summary>
		/// 添加游戏服务器
		/// </summary>
		public void AddGameServer(GameServer server, IBlazeDatabase db)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (db == null)
				throw new ArgumentNullException("db");
			if (_type != Type.Server && _list.Count > 0)
				throw new Exception("GameServerGroup width Type=" + _type + " does not support this operation.");

			try
			{
				db.BeginTrans();

				this.SecurityObject.AddChild(server.SecurityObject);
				AdminServer.TheInstance.SecurityManager.Set(this.SecurityObject, db);
				AdminServer.TheInstance.SecurityManager.Set(server.SecurityObject, db);

				db.CommitTrans();

				if (_type != Type.Server)
				{
					_type = Type.Group;
				}
				IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
				serverGroupTable.Set(TableString.ServerGroupFieldType, (int)_type, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, this.Id));

				_list.Add(server);
				server.Group = this;
			}
			catch (Exception ex)
			{
				db.RollbackTrans();
				throw ex;
			}
		}
예제 #26
0
        /// <summary>
        /// 修改任务
        /// </summary>
        public bool EditTask(int taskId, int step, IAutomation automation, GameServer[] servers, string name, string comment)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                try
                {
                    BatchTask task = this.GetBatchTask(taskId);
                    if (task == null)
                    {
                        return(false);
                    }

                    db.BeginTrans();

                    SecurityManager sm         = AdminServer.TheInstance.SecurityManager;
                    FSEyeObject     taskObject = sm.Get(taskId);
                    taskObject.Name    = name;
                    taskObject.Comment = comment;
                    sm.Set(taskObject, db);

                    StringBuilder serverIdText = new StringBuilder();
                    foreach (GameServer server in servers)
                    {
                        serverIdText.Append(server.Id);
                        serverIdText.Append(',');
                    }

                    IBlazeTable batchTaskTable   = db.GetTable(TableString.BatchTaskTableName);
                    DataSet     batchTaskDataSet = new DataSet();
                    batchTaskTable.Get(batchTaskDataSet);
                    DataTable taskTable = batchTaskDataSet.Tables[TableString.BatchTaskTableName];
                    DataRow[] taskRows  = taskTable.Select(string.Concat(TableString.BatchTaskId, "=", taskId));
                    if (taskRows != null && taskRows.Length > 0)
                    {
                        taskRows[0][TableString.BatchTaskStep]       = step;
                        taskRows[0][TableString.BatchTaskAutomation] = AdminServer.TheInstance.AutomationManager.Save(automation);
                        taskRows[0][TableString.BatchTaskServerIds]  = SystemConfig.Current.DefaultEncoding.GetBytes(serverIdText.Length == 0 ? string.Empty : serverIdText.ToString(0, serverIdText.Length - 1));
                        batchTaskTable.Set(taskTable);
                    }

                    //修改内存中数据
                    task.Step       = step;
                    task.Automation = automation;
                    task.ClearServers();
                    foreach (GameServer server in servers)
                    {
                        task.AddServer(server.Id);
                    }

                    db.CommitTrans();
                    return(true);
                }
                catch (Exception)
                {
                    if (db != null)
                    {
                        db.RollbackTrans();
                    }
                    return(false);
                }
            }
        }
예제 #27
0
        /// <summary>
        /// 添加任务
        /// </summary>
        public bool AddTask(BatchTask task, string name, string comment)
        {
            if (!_batchTaskList.Contains(task))
            {
                using (IBlazeDatabase db = DbFactory.GetDatabase())
                {
                    try
                    {
                        db.BeginTrans();

                        SecurityManager sm                  = AdminServer.TheInstance.SecurityManager;
                        FSEyeObject     newObject           = sm.Get(SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + name, db);
                        byte[]          taskAutomationBytes = AdminServer.TheInstance.AutomationManager.Save(task.Automation);

                        if (newObject != null && taskAutomationBytes != null)
                        {
                            IBlazeTable table       = db.GetTable(TableString.BatchTaskTableName);
                            DataSet     taskDataSet = new DataSet();
                            table.Get(taskDataSet);
                            DataTable taskTable = taskDataSet.Tables[TableString.BatchTaskTableName];

                            DataRow newRow = taskTable.NewRow();
                            newRow[TableString.BatchTaskId]         = newObject.Id;
                            newRow[TableString.BatchTaskAutomation] = taskAutomationBytes;
                            newRow[TableString.BatchTaskStep]       = task.Step;

                            StringBuilder serverIdText = new StringBuilder();
                            foreach (int serverId in task.Servers)
                            {
                                serverIdText.Append(serverId);
                                serverIdText.Append(',');
                            }

                            newRow[TableString.BatchTaskServerIds] = SystemConfig.Current.DefaultEncoding.GetBytes(serverIdText.Length == 0 ? string.Empty : serverIdText.ToString(0, serverIdText.Length - 1));
                            taskTable.Rows.Add(newRow);
                            table.Set(taskTable);

                            //设置权限并更新SecurityObject
                            AdminServer.TheInstance.SecurityManager.CopyAce(newObject.Parent, newObject, true);
                            newObject.Comment = comment;
                            sm.Set(newObject);
                            task.SecurityObject = newObject;

                            _batchTaskList.Add(task);

                            db.CommitTrans();
                            return(true);
                        }
                    }
                    catch (Exception)
                    {
                        if (db != null)
                        {
                            db.RollbackTrans();
                        }
                        return(false);
                    }
                }
            }
            return(false);
        }
예제 #28
0
		/// <summary>
		/// 删除游戏服务器
		/// </summary>
		public void DeleteGameServer(GameServer server, IBlazeDatabase db)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (db == null)
				throw new ArgumentNullException("db");

			try
			{
				db.BeginTrans();

				this.SecurityObject.RemoveChild(server.SecurityObject.Name);
				AdminServer.TheInstance.SecurityManager.Set(this.SecurityObject, db);
				AdminServer.TheInstance.SecurityManager.Set(server.SecurityObject, db);

				db.CommitTrans();

				this.List.Remove(server);
				server.Group = null;
			}
			catch (Exception ex)
			{
				db.RollbackTrans();
				throw ex;
			}
		}
예제 #29
0
    private string CreateStatisticMoneyImage(GameServer server, string dateFrom, string dateTo, ChartType type, bool showSymbol)
    {
        using (IBlazeDatabase db = DbFactory.GetDatabase())
        {
            IBlazeTable gameLogTable = db.GetTable(TableString.GameLogTableName);
            DataSet     data         = new DataSet();

            gameLogTable.Get(
                data,
                FilterFactory.CreateAndFilter(
                    FilterFactory.CreateEqualFilter(TableString.GameLogFieldGameServerId, server.Id),
                    FilterFactory.CreateAndFilter(
                        FilterFactory.CreateLargerEqualFilter(TableString.GameLogFieldDate, dateFrom),
                        FilterFactory.CreateLesserEqualFilter(TableString.GameLogFieldDate, dateTo)
                        )
                    )
                );

            DataTable table = data.Tables[0];

            int      count      = table.Rows.Count;
            double[] money      = new double[count];
            double[] moneyInBox = new double[count];
            double[] moneyTotal = new double[count];
            double[] date       = new double[count];
            for (int i = 0; i < count; i++)
            {
                DataRow row = table.Rows[i];
                money[i]      = (long)row[TableString.GameLogFieldTotalMoney];
                moneyInBox[i] = (long)row[TableString.GameLogFieldTotalMoneyInBox];
                moneyTotal[i] = money[i] + moneyInBox[i];
                DateTime currentDate = (DateTime)row[TableString.GameLogFieldDate];
                date[i] = new XDate(currentDate.Year, currentDate.Month, currentDate.Day);
            }

            bool success = true;

            if (success)
            {
                //»æÖÆͼ±í
                GraphPane graphPane = new GraphPane();

                graphPane.Title.Text = StringDef.MoneyStatistic;
                graphPane.Fill       = new Fill(WebConfig.GraphPaneBgColor);

                graphPane.Legend.Fill.IsVisible   = false;
                graphPane.Legend.Border.IsVisible = false;

                graphPane.XAxis.Title.Text          = StringDef.Date;
                graphPane.XAxis.MajorGrid.Color     = WebConfig.GraphXAxisGridColor;
                graphPane.XAxis.Type                = AxisType.DateAsOrdinal;
                graphPane.XAxis.MinorTic.Size       = 0;
                graphPane.XAxis.Scale.MajorStep     = 1;
                graphPane.XAxis.Scale.MajorUnit     = DateUnit.Day;
                graphPane.XAxis.Scale.FontSpec.Size = 12;
                graphPane.XAxis.Scale.Format        = "M-d";

                graphPane.YAxis.Title.Text          = StringDef.Money;
                graphPane.YAxis.MajorGrid.IsVisible = true;
                graphPane.YAxis.MajorGrid.DashOff   = 0;
                graphPane.YAxis.MajorGrid.Color     = Color.Gray;
                graphPane.YAxis.MinorGrid.IsVisible = true;
                graphPane.YAxis.MinorGrid.Color     = Color.LightGray;
                graphPane.YAxis.MinorGrid.DashOff   = 0;

                if (type == ChartType.Bar)
                {
                    graphPane.BarSettings.Type = BarType.Stack;

                    BarItem barItemMoney      = graphPane.AddBar(StringDef.Money, date, money, Colors[0]);
                    BarItem barItemMoneyInBox = graphPane.AddBar(StringDef.MoneyInBox, date, moneyInBox, Colors[1]);
                    barItemMoney.Bar.Fill      = new Fill(Colors[0]);
                    barItemMoneyInBox.Bar.Fill = new Fill(Colors[1]);
                }
                else if (type == ChartType.Line)
                {
                    LineItem lineItemMoney      = graphPane.AddCurve(StringDef.Money, date, money, Colors[0], (showSymbol ? WebConfig.GraphSymbols[0] : SymbolType.None));
                    LineItem lineItemMoneyInBox = graphPane.AddCurve(StringDef.MoneyInBox, date, moneyInBox, Colors[1], (showSymbol ? WebConfig.GraphSymbols[1] : SymbolType.None));
                    LineItem lineItemMoneyTotal = graphPane.AddCurve(StringDef.MoneyTotal, date, moneyTotal, Colors[2], (showSymbol ? WebConfig.GraphSymbols[2] : SymbolType.None));
                }

                Bitmap bitmap = new Bitmap(1, 1);
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    graphPane.AxisChange(g);
                }

                bitmap = graphPane.GetImage(WebConfig.StatisticRoleCountByLevelGraphWidth, WebConfig.StatisticRoleCountByLevelGraphHeight, 75.0f);
                string imageName = WebUtil.CreateRandomName("Statistic", WebConfig.GraphFileSuffix);
                string file      = WebConfig.WebsiteRootPath + WebConfig.TempGraphPath + imageName;
                try
                {
                    bitmap.Save(file, WebConfig.GraphImageFormat);
                    TempFileManager.TheInstance.AddTempFile(file, 5000 * WebConfig.TempGraphDeleteDelayMultiple);

                    return(imageName);
                }
                catch (Exception)
                {
                    //TODO ¼Ç¼´íÎó
                    return(null);
                }
            }

            return(null);
        }
    }