예제 #1
0
 public SubTask(int subTaskID, int taskID, int?childTaskID, string title, TaskDetail childTask)
 {
     this.SubTaskID   = subTaskID;
     this.TaskID      = taskID;
     this.ChildTaskID = childTaskID;
     this.Title       = title;
     this.ChildTask   = childTask;
 }
예제 #2
0
        internal SubTask(ApiModels.SubTaskApi subTaskApi, ApiModels.JobDataApi jobDataApi)
        {
            this.SubTaskID   = subTaskApi.SubTaskID;
            this.TaskID      = subTaskApi.TaskID;
            this.ChildTaskID = subTaskApi.ChildTaskID;
            this.Title       = subTaskApi.Title;

            if (subTaskApi.ChildTask != null)
            {
                this.ChildTask = new TaskDetail(subTaskApi.ChildTask, jobDataApi);
            }
        }
예제 #3
0
        public TaskDetail GetTaskDetail(TaskReference taskReference, RetryPolicy retryPolicy = null)
        {
            //Url: /Task/TaskDetail?clientNickname={clientNickname}&jobNumber={jobNumber}&taskNumber={taskNumber}

            retryPolicy = GetRetryPolicy(retryPolicy);

            var url = new Uri(this.ServiceUrl, $"/Task/TaskDetail?jobNumber={taskReference.JobNumber}&taskNumber={taskReference.TaskNumber}&clientNickname={taskReference.ClientNickname}");

            for (int attempt = 1; attempt <= retryPolicy.MaxAttempts; attempt++)
            {
                try
                {
                    var client = new Utils.JsonWebClient(this.UserAgent);
                    client.Headers.Add("__identifier", this.AccessKey);

                    var json = client.GetReturnString(url);

                    var response = Utils.JsonHelper.Deserialize <ApiModels.TaskDetailResponseApi>(json);

                    var taskDetail = new TaskDetail(response.TaskData, response.JobData);
                    return(taskDetail);
                }
                catch (System.Exception ex)
                {
                    if (Utils.Application.IsExceptionWithoutRetry(ex))
                    {
                        throw;
                    }

                    if (attempt == retryPolicy.MaxAttempts)
                    {
                        throw new TaskrowException($"Error getting Task Detail after {retryPolicy.MaxAttempts} attempt(s) -- Url: {url} -- Error: {ex.Message} -- TimeOut: {retryPolicy.TimeOutSeconds} seconds", ex);
                    }
                }
            }

            throw new TaskrowException("Unexpected error in attempts control");
        }