Esempio n. 1
0
 public override TaskResult GetResult(System.Net.WebResponse response)
 {
     var result = new TaskResult();
     using(StreamReader reader = new StreamReader(response.GetResponseStream(), DefaultEncoding))
     {
         result.Message = reader.ReadToEnd();
         Regex regex = new Regex("<span class=\"cuti yanse_hongse\">(\\d+)</span>"); //get the code.
         result.IsSucceed = regex.IsMatch(result.Message);
         if (result.IsSucceed)
             result.Code = regex.Match(result.Message).Groups[1].Value;
     }
     return result;
 }
Esempio n. 2
0
 private static void SetTaskResult(ITask task, TaskResult taskResult)
 {
     taskList[task.TaskID].TaskResult = taskResult;
 }
Esempio n. 3
0
        void taskWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TaskWorkInfo taskInfo = e.Argument as TaskWorkInfo;
            TaskResult result = null;
            try
            {
                result = Core.Helper.RunTask(taskInfo.Task);
            }
            catch(Exception exception)
            {
                result = new TaskResult
                             {
                                 IsSucceed = false,
                                 Message = exception.Message
                             };
            }

            taskInfo.TaskResult = result;
            e.Result = taskInfo;
        }