Пример #1
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();
        }
Пример #2
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();
        }