Example #1
0
 /// <summary>
 /// Create a new OpsChecklist object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="version">Initial value of the Version property.</param>
 /// <param name="checklistTaskID">Initial value of the ChecklistTaskID property.</param>
 /// <param name="dueTime">Initial value of the DueTime property.</param>
 /// <param name="alertTime">Initial value of the AlertTime property.</param>
 /// <param name="effectiveStartDate">Initial value of the EffectiveStartDate property.</param>
 /// <param name="lastUpdated">Initial value of the LastUpdated property.</param>
 /// <param name="lastUpdatedBy">Initial value of the LastUpdatedBy property.</param>
 /// <param name="createdDateLocal">Initial value of the CreatedDateLocal property.</param>
 public static OpsChecklist CreateOpsChecklist(global::System.Int32 id, global::System.Int32 version, global::System.Int32 checklistTaskID, global::System.TimeSpan dueTime, global::System.TimeSpan alertTime, global::System.DateTime effectiveStartDate, global::System.DateTime lastUpdated, global::System.String lastUpdatedBy, global::System.DateTime createdDateLocal)
 {
     OpsChecklist opsChecklist = new OpsChecklist();
     opsChecklist.ID = id;
     opsChecklist.Version = version;
     opsChecklist.ChecklistTaskID = checklistTaskID;
     opsChecklist.DueTime = dueTime;
     opsChecklist.AlertTime = alertTime;
     opsChecklist.EffectiveStartDate = effectiveStartDate;
     opsChecklist.LastUpdated = lastUpdated;
     opsChecklist.LastUpdatedBy = lastUpdatedBy;
     opsChecklist.CreatedDateLocal = createdDateLocal;
     return opsChecklist;
 }
Example #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the OpsChecklists EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOpsChecklists(OpsChecklist opsChecklist)
 {
     base.AddObject("OpsChecklists", opsChecklist);
 }
        public HttpResponseMessage EditTask(List<TaskItem> editedTasks)
        {
            List<OpsChecklist> opstaskscreated = new List<OpsChecklist>();
            foreach (TaskItem task in editedTasks)
            {
                if (task.IsTaskFromOpsChecklist == false)
                {
                    OpsChecklist opschecklisttask = new OpsChecklist()
                    {
                        AlertTime = TimeSpan.Parse(task.AlertTime),
                        DueTime = TimeSpan.Parse(task.DueTime),
                        EscalationLevel1Time = TimeSpan.Parse(task.EscalationLevel1Time),
                        ChecklistTaskID = task.ChecklistTaskID,
                        ChecklistTaskVersion = task.ChecklistTaskVersion,
                        EffectiveStartDate = DateTime.Now,
                        //DateTime.Parse(task.EffectiveStartDate),
                        EffectiveEndDate = null,
                        CreatedDateLocal = task.CreatedDateLocal,
                        LateIncompleteReasonID = task.LateIncompleteReasonID,
                        LinkToProcess = task.LinkToProcess,
                        ManagementSignOffStatusID = task.ManagementSignOffStatusID,
                        StatusID = task.StatusID,
                        TimeTakenToComplete = null,
                        Version = task.Version
                    };
                    if (opschecklisttask.StatusID == 6)
                    {
                        opschecklisttask.TimeTakenToComplete = (DateTime.Now - DateTime.Parse(task.EffectiveStartDate)).Ticks;
                    }
                    opschecklisttask.LastUpdatedBy = ContextUserLoginID;
                    opschecklisttask.LastUpdated = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second);
                    bCheckUOW.OpsChecklistRepository.Add(opschecklisttask);
                    opstaskscreated.Add(opschecklisttask);

                }
                else
                {
                    var existingtask = (from otask in bCheckUOW.OpsChecklistRepository.All()
                                        where otask.ID == task.OpsChecklistTaskID
                                        select otask).First();
                    existingtask.EffectiveEndDate = DateTime.Now;
                    OpsChecklist opschecklisttask = new OpsChecklist()
                    {
                        AlertTime = TimeSpan.Parse(task.AlertTime),
                        DueTime = TimeSpan.Parse(task.DueTime),
                        EscalationLevel1Time = TimeSpan.Parse(task.EscalationLevel1Time),
                        ChecklistTaskID = task.ChecklistTaskID,
                        ChecklistTaskVersion = task.ChecklistTaskVersion,
                        EffectiveStartDate = DateTime.Now,
                        EffectiveEndDate = null,
                        CreatedDateLocal = task.CreatedDateLocal,
                        LateIncompleteReasonID = task.LateIncompleteReasonID,
                        LinkToProcess = task.LinkToProcess,
                        ManagementSignOffStatusID = task.ManagementSignOffStatusID,
                        TimeTakenToComplete = null,
                        StatusID = task.StatusID,
                        Version = task.Version
                    };
                    if (opschecklisttask.StatusID == 6)
                    {
                        opschecklisttask.TimeTakenToComplete = (DateTime.Now - DateTime.Parse(task.EffectiveStartDate)).Ticks;
                    }
                    opschecklisttask.LastUpdatedBy = ContextUserLoginID;
                    opschecklisttask.LastUpdated = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second);
                    bCheckUOW.OpsChecklistRepository.Add(opschecklisttask);
                    opstaskscreated.Add(opschecklisttask);

                }
            }
            bCheckUOW.Save();
            for (int i = 0; i < opstaskscreated.Count; i++)
            {
                foreach (var assignee in editedTasks[i].Assignees)
                {
                    OpsChecklistTaskRole opstaskrole = new OpsChecklistTaskRole();
                    opstaskrole.OpsChecklistID = opstaskscreated[i].ID;
                    opstaskrole.ChecklistTaskID = opstaskscreated[i].ChecklistTaskID;
                    opstaskrole.SecurityUserLoginID = assignee.UserLoginID;
                    opstaskrole.TaskRoleId = 3;
                    opstaskrole.LastUpdatedBy = ContextUserLoginID;
                    opstaskrole.LastUpdated = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second);
                    bCheckUOW.OpsChecklistTaskRoleRepository.Add(opstaskrole);
                }

                foreach (var manager in editedTasks[i].Managers)
                {
                    OpsChecklistTaskRole opstaskrole = new OpsChecklistTaskRole();
                    opstaskrole.OpsChecklistID = opstaskscreated[i].ID;
                    opstaskrole.ChecklistTaskID = opstaskscreated[i].ChecklistTaskID;
                    opstaskrole.SecurityUserLoginID = manager.UserLoginID;
                    opstaskrole.TaskRoleId = 4;
                    opstaskrole.LastUpdatedBy = ContextUserLoginID;
                    opstaskrole.LastUpdated = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second);
                    bCheckUOW.OpsChecklistTaskRoleRepository.Add(opstaskrole);
                }
            }
            bCheckUOW.Save();
            var taskIds = (from t in editedTasks
                           select t.OpsChecklistTaskID).ToList();

            Dictionary<string, object> TasksModified = new Dictionary<string, object>();
            TasksModified["OriginalTaskIds"] = taskIds;

            List<TaskItem> titemsChanged = new List<TaskItem>();
            for (int i = 0; i < editedTasks.Count; i++)
            {
                editedTasks[i].OpsChecklistTaskID = opstaskscreated[i].ID;
                editedTasks[i].IsTaskFromOpsChecklist = true;
            }

            TasksModified["ModifiedTasks"] = editedTasks;
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, TasksModified);
            return response;
        }