/// <summary>
 /// Deprecated Method for adding a new object to the TaskResults EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTaskResults(TaskResult taskResult)
 {
     base.AddObject("TaskResults", taskResult);
 }
 /// <summary>
 /// Create a new TaskResult object.
 /// </summary>
 /// <param name="taskResultId">Initial value of the TaskResultId property.</param>
 /// <param name="taskId">Initial value of the TaskId property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="errorCode">Initial value of the ErrorCode property.</param>
 /// <param name="errorMessage">Initial value of the ErrorMessage property.</param>
 /// <param name="info">Initial value of the Info property.</param>
 public static TaskResult CreateTaskResult(global::System.Int32 taskResultId, global::System.Int32 taskId, global::System.String status, global::System.Int32 errorCode, global::System.String errorMessage, global::System.String info)
 {
     TaskResult taskResult = new TaskResult();
     taskResult.TaskResultId = taskResultId;
     taskResult.TaskId = taskId;
     taskResult.Status = status;
     taskResult.ErrorCode = errorCode;
     taskResult.ErrorMessage = errorMessage;
     taskResult.Info = info;
     return taskResult;
 }
Beispiel #3
0
        private void ProcessReplies(CheckerEntities db)
        {
            lock (replies)
            {
                if (replies.Count > 0)
                {
                    foreach (CmdServerReply reply in replies)
                    {
                        // notify thread server to free process
                        OnCmdReplyProcessed(reply);

                        // increasing availabel process counter
                        availableProcesses++;

                        var task = db.Tasks.FirstOrDefault(t => t.TaskId == reply.id);
                        if (task != null)
                        {
                            task.IsCompleted = true;

                            TaskResult result = new TaskResult
                            {
                                TaskId = task.TaskId,
                                Status = reply.status,
                                Info = string.IsNullOrEmpty(reply.info) ? string.Empty : reply.info,
                                ErrorCode = reply.code.HasValue ? reply.code.Value : 0,
                                ErrorMessage = reply.fail
                            };

                            db.TaskResults.AddObject(result);
                        }
                        else
                        {
                            Logger.AddInformation(string.Format("Failed to receive task from database with id = {0}", reply.id));
                        }
                    }

                    db.SaveChanges();

                    // updating processed reply count
                    OnCmdProcessed(replies.Count);

                    // cleaning replies
                    replies.Clear();
                }
            }
        }