Esempio n. 1
0
 public OcrSdkTask()
 {
     Status = TaskStatus.Unknown;
     Id     = new TaskId("<unknown>");
 }
Esempio n. 2
0
 public OcrSdkTask(TaskId id, TaskStatus status)
 {
     Id     = id;
     Status = status;
 }
Esempio n. 3
0
        /// <summary>
        /// Get task data from xml node "task"
        /// </summary>
        private static OcrSdkTask getTaskInfo(XElement xTask)
        {
            TaskId     id     = new TaskId(xTask.Attribute("id").Value);
            TaskStatus status = statusFromString(xTask.Attribute("status").Value);

            OcrSdkTask task = new OcrSdkTask();

            task.Id     = id;
            task.Status = status;

            XAttribute xRegistrationTime = xTask.Attribute("registrationTime");

            if (xRegistrationTime != null)
            {
                DateTime time;
                if (DateTime.TryParse(xRegistrationTime.Value, out time))
                {
                    task.RegistrationTime = time;
                }
            }

            XAttribute xStatusChangeTime = xTask.Attribute("statusChangeTime");

            if (xStatusChangeTime != null)
            {
                DateTime time;
                if (DateTime.TryParse(xStatusChangeTime.Value, out time))
                {
                    task.StatusChangeTime = time;
                }
            }

            XAttribute xPagesCount = xTask.Attribute("filesCount");

            if (xPagesCount != null)
            {
                int pagesCount;
                if (Int32.TryParse(xPagesCount.Value, out pagesCount))
                {
                    task.PagesCount = pagesCount;
                }
            }

            XAttribute xCredits = xTask.Attribute("credits");

            if (xCredits != null)
            {
                int credits;
                if (Int32.TryParse(xCredits.Value, out credits))
                {
                    task.Credits = credits;
                }
            }

            XAttribute xDescription = xTask.Attribute("description");

            if (xDescription != null)
            {
                task.Description = xDescription.Value;
            }

            XAttribute xResultUrl = xTask.Attribute("resultUrl");

            if (xResultUrl != null)
            {
                task.DownloadUrls = new List <string> {
                    xResultUrl.Value
                };
                for (int i = 2; i < 10; i++)
                {
                    XAttribute xResultUrlI = xTask.Attribute("resultUrl" + i);
                    if (xResultUrlI != null)
                    {
                        task.DownloadUrls.Add(xResultUrlI.Value);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            XAttribute xError = xTask.Attribute("error");

            if (xError != null)
            {
                task.Error = xError.Value;
            }

            return(task);
        }