Ejemplo n.º 1
0
        public TaskBox(ITaskBoxStorage storage,
                       ITaskLogProvider logProvider,
                       int threadNum)
        {
            this.Storage      = storage;
            this.Log          = logProvider;
            this._threadNum   = threadNum;
            this._taskManager = new TaskQueue(this);

            //记录日志
            //this.TaskStateChanged += this.Log.LogTaskState;
        }
Ejemplo n.º 2
0
        public TaskBox(ITaskBoxStorage storage,
            ITaskLogProvider logProvider,
            int threadNum)
        {
            this.Storage = storage;
            this.Log = logProvider;
            this._threadNum = threadNum;
            this._taskManager = new TaskQueue(this);

            //��¼��־
            //this.TaskStateChanged += this.Log.LogTaskState;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 开启服务
        /// </summary>
        public void Start(TaskBoxHandler handler, ITaskBoxStorage storage, ITaskLogProvider logProvider)
        {
            if (_isBooted == true)
            {
                throw new Exception("服务已经启动!");
            }

            if (_box == null)
            {
                if (storage == null)
                {
                    storage = new TaskBoxDbStorage();
                }

                if (logProvider == null)
                {
                    logProvider = new TaskLogProvider(storage);
                }


                _box = new TaskBox(storage, logProvider, 3);

                if (handler != null)
                {
                    handler(_box);
                }

                //if (String.IsNullOrEmpty(_server)
                //    || String.IsNullOrEmpty(_token))
                //    throw new ArgumentNullException("请使用RegistServer注册任务服务器信息!");
                //HttpSyncClient client = new HttpSyncClient(_server, _token);

                //if (client.TestConnect())
                //{
                //    //注册事件
                //    _box.OnTaskPosting += client.Post;
                //}
                //else
                //{
                //    throw new Exception("任务服务器连接失败");
                //}
            }

            _isBooted = true;
            _box.StartWork();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// �������
        /// </summary>
        public void Start(TaskBoxHandler handler, ITaskBoxStorage storage, ITaskLogProvider logProvider)
        {
            if (_isBooted == true)
                throw new Exception("�����Ѿ����!");

            if (_box == null)
            {
                if (storage == null)
                {
                    storage = new TaskBoxDbStorage();
                }

                if (logProvider == null)
                {
                    logProvider = new TaskLogProvider(storage);
                }

                _box = new TaskBox(storage, logProvider, 3);

                if (handler != null)
                {
                    handler(_box);
                }

                //if (String.IsNullOrEmpty(_server)
                //    || String.IsNullOrEmpty(_token))
                //    throw new ArgumentNullException("��ʹ��RegistServerע�������������Ϣ!");
                //HttpSyncClient client = new HttpSyncClient(_server, _token);

                //if (client.TestConnect())
                //{
                //    //ע���¼�
                //    _box.OnTaskPosting += client.Post;
                //}
                //else
                //{
                //    throw new Exception("�������������ʧ��");
                //}
            }

            _isBooted = true;
            _box.StartWork();
        }
Ejemplo n.º 5
0
 public TaskLogProvider(ITaskBoxStorage storage)
 {
     this.Storage = storage;
 }
Ejemplo n.º 6
0
 public TaskBox(ITaskBoxStorage storage, int threadNum)
     : this(storage, null, threadNum)
 {
 }
Ejemplo n.º 7
0
 public TaskBox(ITaskBoxStorage storage)
     : this(storage, null, 5)
 {
 }
Ejemplo n.º 8
0
 public TaskLogProvider(ITaskBoxStorage storage)
 {
     this.Storage = storage;
 }
Ejemplo n.º 9
0
 public TaskBox(ITaskBoxStorage storage, int threadNum)
     : this(storage, null, threadNum)
 {
 }
Ejemplo n.º 10
0
 public TaskBox(ITaskBoxStorage storage)
     : this(storage, null, 5)
 {
 }