コード例 #1
0
        public void Start()
        {
            while (!_isStopped)
            {
                try
                {
                    if (!_server.Ping().IsSuccess)
                    {
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    continue;
                }


                var result = _server.GetCommand(Environment.MachineName);

                if (result == null)
                {
                    continue;
                }

                if (!result.IsSuccess)
                {
                    continue;
                }

                var command = result.ResultObject;

                if (command == null)
                {
                    continue;
                }

                try
                {
                    Type t = AttributeHelper.GetTaskType(command.Type);

                    var task = _deserializerFactory.CreateJsonDeserializer().Deserialize(t, command.Params);

                    _commandProcessor.Process(task);

                    _server.Done(command.Id);
                }
                catch (Exception ex)
                {
                    _server.Fail(command.Id);
                }
            }
        }