Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
0
        /// <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;
                }
            }
        }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
0
        /// <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;
                }
            }
        }
Ejemplo n.º 6
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();
                }
            }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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();
                }
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        /// <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);
        }
Ejemplo n.º 12
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;
			}
		}
Ejemplo n.º 13
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;
			}
		}
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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();
                }
            }
        }
Ejemplo n.º 16
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);
                }
            }
        }
Ejemplo n.º 17
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);
        }