Beispiel #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);
                }
            }
        }
Beispiel #2
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();
                }
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }