public void HandleClickOnAttachments(TaskItem t, bool isArchive)
        {
            var dlg = new TaskAttachmentsDialog();
            if (isArchive)
                dlg.IsArchive = true;
            dlg.DataContext = t;
            dlg.Show();

        }
Exemple #2
0
        public static TaskItem ConvertTaskFromOMD(BCheck.Data.BCheckOMDVQuery.Row row)
        {
            TaskItem item = new TaskItem();
            item.AlertTime = row.Alert_Time;
            item.AssignedTo = row.Assign_To;
            item.AttachmentUrl = row.Attachments;
            item.Comments = row.Comments;
            item.Complete = row.Completed_Y_N_ == "Y";
            item.CreatedLocal = Convert.ToDateTime(row.Create_Date_Local);
            item.CreatedUtc = Convert.ToDateTime(row.Created_UTC);
            item.DueTime = row.Due_Time;
            item.EscalationTime = row.Escalation_Level_1_Time;
            item.ID = (int)row.Task_ID;
            item.Kri = row.KPI;
            item.LinkToProcess = row.Link_To_Process;
            item.ManagementSignOff = row.Management_Sign_Off;
            item.Manager = row.Manager;
            item.Modified = TaskItem.GetModifiedTimeAsPerCurrentRegion(Convert.ToDateTime((DateTime)row.Modified)).ToString();
            item.ModifiedBy = row.Modified_By;
            item.Status = row.Status;
            item.TaskDescription = ParseDescription(row.High_Level_Description);
            item.TaskName = row.Task_Name;
            item.Version = (int)row.Version;

            item.ID1 = row.Unique_ID;
            item.BusinessArea = row.Business_Area;
            item.Functional = row.Functional;
            item.Frequency = row.Frequency;
            item.SpecificFrequency = row.Specific_Frequency;
            item.RandomFrequency = row.Random_Frequency;
            item.KeyControl = row.Key_Control;
            item.MatrixDefinition = row.Matrix_Definition;
            item.Locations = row.Locations;
            item.HolidayCalendar = row.Holiday_Calendar;
            item.AssetCategory = row.Asset_Category;
            item.ManagingDirector = row.Managing_Director;
            item.Director = row.Director;
            if (row.Regional_Offset == null) //Mar 11 fix, 
                item.RegionalOffset = 0;
            else
                item.RegionalOffset = (double)row.Regional_Offset;
            item.CreatedDateLocal = Convert.ToDateTime(row.Create_Date_Local);
            item.DueTimeUtc = Convert.ToDateTime(row.Due_Time_UTC);
            item.Checklist = row.Checklist;
           

            string pattern = @"<(.|\n)*?>";

            string stripped = Regex.Replace(item.TaskDescription, pattern, string.Empty);
            stripped = HttpUtility.HtmlDecode(stripped);
            item.TaskDescription = stripped;

            return item;
        }
        /// <summary>
        /// Helper method to return a stub object for the purpose of debugging
        /// </summary>
        /// <returns></returns>
        public static AlertsDataTransfer CreateStub(int countAssignedTasks, int countManagedTasks)
        {
            var trfr = new AlertsDataTransfer
                           {
                               AssignedTasks = new ObservableCollection<TaskItem>(),
                               ManagedTasks = new ObservableCollection<TaskItem>()
                           };

            int sec = DateTime.Now.Second; //to inroduce a variability in the data 
            int count = countAssignedTasks;
            while (count > 0)
            {
                var  a = new TaskItem  
                                { 
                                    TaskName = "Some task" + count, 
                                    DueTime = (sec % 12 + 9) +":00",
                                    AssignedTo = "username:"******"abcdefghijklmnopqrstuvwxyz01234567890123456789";

                count--;
            }

            count = countManagedTasks;
            while (count > 0)
            {
                var a = new TaskItem  
                                    { 
                                    TaskName = "ManagedName:" + count,
                                    DueTime = (sec % 12 + 9) + ":00",
                                    AssignedTo = "user-"+sec,
                                    CreatedUtc =DateTime.Now.Date  
                                    };
                trfr.ManagedTasks.Add(a);
                count--;
            }

            trfr.TotalAlerts = DateTime.Now.Second;
            return trfr;
        }
 public bCheckV2.Helpers.Definitions.TaskItem FormatTaskItem(TaskItem task, View typeOfView)
 {
     bCheckV2.Helpers.Definitions.TaskItem t = new bCheckV2.Helpers.Definitions.TaskItem();
     t.ChecklistID = task.ChecklistID;
     t.ChecklistTaskID = task.ChecklistTaskID;
     t.OpsChecklistTaskID = task.OpsChecklistTaskID;
     t.AlertTime = task.AlertTime.ToString();
     t.Description = task.TaskDescription;
     t.StatusID = ViewModel.Current.StaticData["AssigneeStatus"].ToList().Where(status => status.Value == task.Status).First().Key;
     t.ManagementSignOffStatusID = ViewModel.Current.StaticData["ManagementStatus"].ToList().Where(status => status.Value == task.ManagementSignOff).First().Key;
     t.TaskName = task.TaskName == null ? "DummyTask" : task.TaskName;
     t.DueTime = task.DueTime.ToString();
     t.LocationID = ViewModel.Current.locations.Where(loc => task.Locations == loc.Location).First().Id;
     t.Comments = task.Comments;
     t.LinkToProcess = task.LinkToProcess;
     t.UniqueID = Guid.Parse(task.ID1);
     //t.AssignedTo = typeOfView == View.vwAssignedTasks ? GetFormattedUsers(task.Assignees) : GetFormattedUsers(task.Managers);
     t.CreatedDateLocal = new DateTime(task.CreatedLocal.Ticks,DateTimeKind.Utc);
     return t;
 }
        private Dictionary<string, string> GetRevisionChanges(TaskItem lastTaskItem, TaskItem currentItem)
        {
            var changes = new Dictionary<string,string>
                              {
                                  {"Version", currentItem.Version.ToString(CultureInfo.InvariantCulture)},
                                  {"Modified", currentItem.Modified},
                                  {"Modified By", currentItem.ModifiedBy}
                              };
            if (lastTaskItem == null || lastTaskItem.TaskName != currentItem.TaskName)
                changes.Add("Task Name", NullCheck(currentItem.TaskName));

            if (lastTaskItem == null || lastTaskItem.ID1 != currentItem.ID1)
                changes.Add("High Level Description", NullCheck(currentItem.ID1));

            if (lastTaskItem == null || lastTaskItem.ID1 != currentItem.ID1)
                changes.Add("ID1", NullCheck(currentItem.ID1));

            if (lastTaskItem == null || lastTaskItem.BusinessArea != currentItem.BusinessArea)
                changes.Add("Business Area", NullCheck(currentItem.BusinessArea));

            if (lastTaskItem == null || lastTaskItem.Functional != currentItem.Functional)
                changes.Add("Functional", NullCheck(currentItem.Functional));
            
            if (lastTaskItem == null || lastTaskItem.Frequency != currentItem.Frequency)
                changes.Add("Frequency", NullCheck(currentItem.Frequency));
            
            if (lastTaskItem == null || lastTaskItem.SpecificFrequency != currentItem.SpecificFrequency)
                changes.Add("Specific Frequency", NullCheck(currentItem.SpecificFrequency));
            
            if (lastTaskItem == null || lastTaskItem.RandomFrequency != currentItem.RandomFrequency)
                changes.Add("Random Frequency", NullCheck(currentItem.RandomFrequency));
            
            if (lastTaskItem == null || lastTaskItem.DueTime != currentItem.DueTime)
                changes.Add("Due Time", NullCheck(currentItem.DueTime));

            if (lastTaskItem == null || lastTaskItem.AlertTime != currentItem.AlertTime)
                changes.Add("Alert Time", NullCheck(currentItem.AlertTime));

            if (lastTaskItem == null || lastTaskItem.EscalationTime != currentItem.EscalationTime)
                changes.Add("Escalation Level 1 Time", NullCheck(currentItem.EscalationTime));
            
            if (lastTaskItem == null || lastTaskItem.ManagementSignOff != currentItem.ManagementSignOff)
                changes.Add("Management SignOff", NullCheck(currentItem.ManagementSignOff));

            if (lastTaskItem == null || lastTaskItem.KeyControl != currentItem.KeyControl)
                changes.Add("Key Control", NullCheck(currentItem.KeyControl));
            
            if (lastTaskItem == null || lastTaskItem.MatrixDefinition != currentItem.MatrixDefinition)
                changes.Add("Matrix Definition", NullCheck(currentItem.MatrixDefinition));
            
            if (lastTaskItem == null || lastTaskItem.Status != currentItem.Status)
                changes.Add("Status", NullCheck(currentItem.Status));

            if (lastTaskItem == null || lastTaskItem.Locations != currentItem.Locations)
                changes.Add("Locations", NullCheck(currentItem.Locations));
            
            if (lastTaskItem == null || lastTaskItem.HolidayCalendar != currentItem.HolidayCalendar)
                changes.Add("Holiday Calendar", NullCheck(currentItem.HolidayCalendar));
            
            if (lastTaskItem == null || lastTaskItem.AssignedTo != currentItem.AssignedTo)
                changes.Add("Assigned To", NullCheck(currentItem.AssignedTo));
            
            if (lastTaskItem == null || lastTaskItem.Manager != currentItem.Manager)
                changes.Add("Manager", NullCheck(currentItem.Manager));
            
            if (lastTaskItem == null || lastTaskItem.AssetCategory != currentItem.AssetCategory)
                changes.Add("Asset Category", NullCheck(currentItem.AssetCategory));
            
            if (lastTaskItem == null || lastTaskItem.ManagingDirector != currentItem.ManagingDirector)
                changes.Add("Managing Director", NullCheck(currentItem.ManagingDirector));
            
            if (lastTaskItem == null || lastTaskItem.Director != currentItem.Director)
                changes.Add("Director", NullCheck(currentItem.Director));
            
            if (lastTaskItem == null || lastTaskItem.RegionalOffset != currentItem.RegionalOffset)
                changes.Add("RegionalOffset", currentItem.RegionalOffset.ToString(CultureInfo.InvariantCulture));
            
            if (lastTaskItem == null || lastTaskItem.CreatedDateLocal != currentItem.CreatedDateLocal)
                changes.Add("CreatedDateLocal", currentItem.CreatedDateLocal.ToString(CultureInfo.InvariantCulture));
            
            if (lastTaskItem == null || lastTaskItem.DueTimeUtc != currentItem.DueTimeUtc)
                changes.Add("DueTimeUtc", currentItem.DueTimeUtc.ToString(CultureInfo.InvariantCulture));
            
            if (lastTaskItem == null || lastTaskItem.Checklist != currentItem.Checklist)
                changes.Add("Checklist", NullCheck(currentItem.Checklist));
            
            if (lastTaskItem == null || lastTaskItem.Comments != currentItem.Comments)
                changes.Add("Comments", NullCheck(currentItem.Comments));

            if (lastTaskItem == null || lastTaskItem.Complete != currentItem.Complete)
                changes.Add("Complete", currentItem.Complete.ToString(CultureInfo.InvariantCulture));

            return changes;
        }
Exemple #6
0
        /// <summary>
        /// Returns the update statement to update the specified TaskItem based on the selected view
        /// </summary>
        /// <param name="t"></param>
        /// <param name="vw"></param>
        public static string QueryUpdateTaskEdit(TaskItem t, View vw,
                                            bool bIsAssignedUser, bool bIsManagerUser)
        {

            const string updatefragmentAssigned = "<Method ID='taskid{0}' Cmd='Update'>" +
                                                  "<Field Name='ID'>{0}</Field>" +
                                                  "<Field Name='owshiddenversion'>{1}</Field>" +
                                                  "<Field Name='" + STATUS_COLUMN + "'>{2}</Field>" +
                                                  "<Field Name='" + COMMENTS_COLUMN + "'>{3}</Field>" +
                                                  "<Field Name='" + KPI_COLUMN + "'>{4}</Field>" +
                                                  "<Field Name='" + ALERTTIME_COLUMN + "'>{5}</Field>" +
                                                  "<Field Name='" + ASSIGNTO_COLUMN + "'>{6}</Field>" +
                                                  "<Field Name='" + TIMETOCOMPLETE_COLUMN + "'>{7}</Field>" +
                                                  "<Field Name='" + LATEINCOMPLETE_REASON_COLUMN + "'>{8}</Field>" +
                                                  "<Field Name='" + SYSTEM_OUTRAGE_COLUMN + "'>{9}</Field>" +
                                                  "<Field Name='" + COMPLETEDBY_COLUMN + "'>{10}</Field>" +
                                                  "</Method>";

            const string updatefragmentManaged = "<Method ID='taskid{0}' Cmd='Update'>" +
                                                 "<Field Name='ID'>{0}</Field>" +
                                                 "<Field Name='owshiddenversion'>{1}</Field>" +
                                                 "<Field Name='" + STATUS_COLUMN + "'>{2}</Field>" +
                                                 "<Field Name='" + MANAGEMENT_SIGNOFF_COLUMN + "'>{3}</Field>" +
                //"<Field Name='" + NAME_COLUMN + "'>{4}</Field>" +
                //"<Field Name='" + DESCRIPTION_COLUMN  + "'>{5}</Field>" +
                                                 "<Field Name='" + COMMENTS_COLUMN + "'>{6}</Field>" +
                                                 "<Field Name='" + KPI_COLUMN + "'>{7}</Field>" +
                                                 "<Field Name='" + MATRIX_COLUMN + "'>{8}</Field>" +
                                                 "<Field Name='" + DUEDATE_COLUMN + "'>{9}</Field>" +
                                                 "<Field Name='" + ESCALATIONTIME_COLUMN + "'>{10}</Field>" +
                                                 "<Field Name='" + LINKTOPROCESS_COLUMN + "'>{11}</Field>" +
                                                 "<Field Name='" + ASSIGNTO_COLUMN + "'>{12}</Field>" +
                                                 "<Field Name='" + ALERTTIME_COLUMN + "'>{13}</Field>" + //sep 20
                                                 "<Field Name='" + MANAGER_COLUMN + "'>{14}</Field>" +
                                                 "<Field Name='" + TIMETOCOMPLETE_COLUMN + "'>{15}</Field>" +
                                                 "<Field Name='" + LATEINCOMPLETE_REASON_COLUMN + "'>{16}</Field>" +
                                                 "<Field Name='" + SYSTEM_OUTRAGE_COLUMN + "'>{17}</Field>" +
                                                 "<Field Name='" + COMPLETEDBY_COLUMN + "'>{18}</Field>" +
                                                 "</Method>";

            bool bIsDirectApprove = false;//this variable will be evalated in the next steps
            bool flag = true;
            bool bIsUserCompleting = false;
            string updatestmnt = "";
            if ((t.Status == COMPLETED_STATUS) && (!t.GetOriginalValue("Status").Equals(COMPLETED_STATUS)))
            {
                bIsUserCompleting = true;
            }
            while (flag && bIsUserCompleting)
            {
                flag = false;
                if (t.IsBypassApprovalAllowed)
                {
                    bIsDirectApprove = true;
                    break;
                }
                if ((bIsAssignedUser) && (bIsManagerUser) && (t.IsManagerSelfApprovalAllowed))
                {
                    bIsDirectApprove = true;
                    break;
                }
            }

            if (bIsDirectApprove)
            {
                t.ManagementSignOff = APPROVED_SIGNOFF;
                updatestmnt = string.Format(updatefragmentManaged,
                        t.ID, t.Version, t.Status,
                        t.ManagementSignOff,
                        "", //task name - encoding!
                        "",//description - encoding!
                        "",//comments - encoding!
                        t.Kri,
                        "", //matrix definiton - encoding!
                        t.DueTime, t.EscalationTime,
                        "",//link to process - encoding!
                        "",////Aug 2,use XML encoding for assigned to ,
                        t.AlertTime,
                        "",
                        t.TimeForCompletion,
                        t.LateIncompleteReason,
                        t.SystemOutrage,
                        t.CompletedBy // Jun 2014 for Assignee manager approval verification
                        );
                updatestmnt = InsertEncodedTextInXml(updatestmnt, t);

            }

            if (((vw & View.vwAssignedTasks) > 0) && (bIsDirectApprove == false))
            {
                updatestmnt = string.Format(updatefragmentAssigned,
                        t.ID, t.Version, t.Status, "", t.Kri,
                        t.AlertTime, "", t.TimeForCompletion, t.LateIncompleteReason, t.SystemOutrage, t.CompletedBy
                        );//Aug 2,use XML encoding for assigned to

                updatestmnt = InsertEncodedTextInXml(updatestmnt, t);
            }

            if (((vw & View.vwManagedTasks) > 0) && (bIsDirectApprove == false))
            {
                string status = t.Status;

                /*
                 * if updating as manager
                 * then
                 * update MANAGEMENTSIGNOFF only when user is attempting to udpate this field
                 * if user is attempting to update MANAGEMENTSIGNOFF then update status accordingly
                */
                if (!t.ManagementSignOff.Equals(t.GetOriginalValue("ManagementSignOff")))
                {
                    if (t.ManagementSignOff.Equals(REJECTED_SIGNOFF))
                    {
                        status = IN_PROGRESS_STATUS;
                    }
                    if (t.ManagementSignOff.Equals(APPROVED_SIGNOFF))
                    {
                        status = COMPLETED_STATUS;
                    }
                }

                updatestmnt = string.Format(updatefragmentManaged,
                        t.ID, t.Version, status,
                        t.ManagementSignOff,
                        "", //task name - encoding!
                        "",//description - encoding!
                        "",//comments - encoding!
                        t.Kri,
                        "", //matrix definiton - encoding!
                        t.DueTime, t.EscalationTime,
                        "",//link to process - encoding!
                        "",////Aug 2,use XML encoding for assigned to ,
                        t.AlertTime,
                        "",
                        t.TimeForCompletion,
                        t.LateIncompleteReason,
                        t.SystemOutrage,
                        t.CompletedBy // Jun 2014 for Assignee manager approval verification
                        );
                updatestmnt = InsertEncodedTextInXml(updatestmnt, t);
            }

            var sb = new StringBuilder();
            sb.Append("<Batch OnError='Continue'  ViewName=''>");
            //Add the TaskOwner xml fragment if user is Completing the Task
            if (bIsUserCompleting)
            {
                const string taskownerFragment = "<Field Name='" + TASKOWNER_COLUMN + "'>{0}</Field>";
                string taskownerStmnt = string.Format(taskownerFragment, ViewModel.Current.WssUserId);
                XElement owner = XElement.Parse(taskownerStmnt);
                XElement wss = XElement.Parse(updatestmnt);
                wss.Add(owner);
                updatestmnt = wss.ToString();
            }
            sb.Append(updatestmnt);
            sb.Append("</Batch>");

            return sb.ToString();
        }
        public void GetAlertsWithDetails(string CAMLTaskQuery, Action<List<TaskItem>> reply)
        {
            var opschecklist = _alertsclient.Web.Lists.GetByTitle(InitParams.Current.ListName);
            CamlQuery cquery = new CamlQuery();
            cquery.ViewXml = CAMLTaskQuery;
            ListItemCollection tasks;
            tasks = opschecklist.GetItems(cquery);

            _alertsclient.Load(tasks, items => items.Include(item => item["CreatedDateLocal"],
                item => item["Title"],
                item => item["ID"],
                item => item["Comments"],
                item => item["Alert_x0020_Time"],
                item => item["Due_x0020_Time"],
                item => item["Escalation_x0020_Level_x0020_1_x"],
                item => item["High_x0020_Level_x0020_Descripti"],
                item => item["Status"],
                item => item["KPI"],
                item => item["Assign_x0020_to"],
                item => item["Management_x0020_Signoff"],
                item => item["Attachments"],
                item => item["Matrix_x0020_Definition"],
                item => item["Link_x0020_to_x0020_Process"],
                item => item["Assign_x0020_to"],
                item => item["Manager"],
                item => item["Functional"],
                item => item["BypassManagerApproval"],
                item => item["ManagerSelfApproval"],
                item => item["TaskOwner"],
                item => item["Time_x0020_Taken"],
                item => item["Created"],
                item => item["Completed_x0020_By"],
                item => item["LateIncompleteReason"],
                item => item["SystemOutrage"]
                ));

            ClientRequestSucceededEventHandler SuccessHandler = null;
            ClientRequestFailedEventHandler FailureHandler = null;

            SuccessHandler = (s, e1) =>
            {
                List<TaskItem> taskitems = new List<TaskItem>();
                TaskItem task;
                foreach (ListItem l in tasks)
                {
                    task = new TaskItem();
                    task.TaskName = (l["Title"] != null) ? l["Title"].ToString() : "";
                    task.ID = (l["ID"] != null) ? int.Parse(l["ID"].ToString()) : 0;
                    task.Version = (l.ObjectVersion != null) ? int.Parse(l.ObjectVersion) : 1;
                    task.TaskDescription = (l["High_x0020_Level_x0020_Descripti"] != null) ? l["High_x0020_Level_x0020_Descripti"].ToString() : "";
                    if (l["Assign_x0020_to"] != null)
                    {
                        var users = ((FieldUserValue[])l["Assign_x0020_to"]);
                        task.AssignedTo = "";
                        task.AssignedTo += users[0].LookupId.ToString() + ";#" + users[0].LookupValue;
                        for (int i = 1; i < users.Length; i++)
                        {
                            task.AssignedTo += ";#" + users[i].LookupId.ToString() + ";#" + users[i].LookupValue;
                        }
                    }
                    else
                    {
                        task.AssignedTo = null;
                    }

                    if (l["Manager"] != null)
                    {
                        var users = ((FieldUserValue[])l["Manager"]);
                        task.Manager = "";
                        task.Manager += users[0].LookupId.ToString() + ";#" + users[0].LookupValue;
                        for (int i = 1; i < users.Length; i++)
                        {
                            task.Manager += ";#" + users[i].LookupId.ToString() + ";#" + users[i].LookupValue;
                        }
                    }
                    else
                    {
                        task.Manager = null;
                    }

                    task.DueTime = (l["Due_x0020_Time"] != null) ? l["Due_x0020_Time"].ToString() : null;
                    task.ManagementSignOff = (l["Management_x0020_Signoff"] != null) ? l["Management_x0020_Signoff"].ToString() : null;
                    task.Kri = (l["KPI"] != null) ? l["KPI"].ToString() : null;
                    task.Comments = (l["Comments"] != null) ? l["Comments"].ToString() : null;
                    task.Status = (l["Status"] != null) ? l["Status"].ToString() : null;
                    task.CreatedUtc = (DateTime)l["Created"];
                    task.AlertTime = (l["Alert_x0020_Time"] != null) ? l["Alert_x0020_Time"].ToString() : null;
                    task.EscalationTime = (l["Escalation_x0020_Level_x0020_1_x"] != null) ? l["Escalation_x0020_Level_x0020_1_x"].ToString() : null;
                    task.CreatedLocal = TaskItem.GetCreatedTimeAsPerCurrentRegion((DateTime)l["Created"]);
                    task.Functional = (l["Functional"] != null) ? l["Functional"].ToString() : null;
                    task.AttachmentUrl = (l["Attachments"] != null) ? l["Attachments"].ToString() : null;
                    task.KriDefinition = (l["Matrix_x0020_Definition"] != null) ? l["Matrix_x0020_Definition"].ToString() : null;
                    //task.LinkToProcess = (l["Link_x0020_to_x0020_Process"] != null) ? ((FieldUrlValue)l["Link_x0020_to_x0020_Process"]).Url : null;
                    task.LinkToProcess = (l["Link_x0020_to_x0020_Process"] != null) ? l["Link_x0020_to_x0020_Process"].ToString() : null;
                    task.BypassApproval = (l["BypassManagerApproval"] != null) ? l["BypassManagerApproval"].ToString() : null;
                    task.ManagerSelfApproval = (l["ManagerSelfApproval"] != null) ? l["ManagerSelfApproval"].ToString() : null;
                    task.TaskOwner = (l["TaskOwner"] != null) ? l["TaskOwner"].ToString() : null;
                    task.TimeForCompletion = (l["Time_x0020_Taken"] != null) ? l["Time_x0020_Taken"].ToString() : null;
                    task.LateIncompleteReason = (l["LateIncompleteReason"] != null) ? l["LateIncompleteReason"].ToString() : null;
                    task.SystemOutrage = (l["SystemOutrage"] != null) ? l["SystemOutrage"].ToString() : null;
                    task.CompletedBy = (l["Completed_x0020_By"] != null) ? l["Completed_x0020_By"].ToString() : null;
                    taskitems.Add(task);
                }
                reply(taskitems);
            };

            FailureHandler = (s, e1) =>
            {
                List<TaskItem> taskitems = new List<TaskItem>();
                reply(taskitems);
            };

            _alertsclient.ExecuteQueryAsync(SuccessHandler, FailureHandler);
        }
Exemple #8
0
        /// <summary>
        /// Consumes a DueTime and converts to a typed DateTime object that accurately represents 
        /// when the Task is/was due.
        /// The conversion here is regardless of the Task being due today or in the past.
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static DateTime ConvertDueDateToFullDate(TaskItem t)
        {
            TimeSpan dueSpan;
            DateTime computedDate;
            if (!TimeSpan.TryParse(t.DueTime, out dueSpan)) dueSpan = TimeSpan.FromSeconds(0);   //if cannot be parsed, then assume midnight

            computedDate = t.CreatedLocal.Date.Add(dueSpan);
            return computedDate;
        }
Exemple #9
0
 void ISharePointDataProvider.FetchRevisionHistory(TaskItem task)
 {
     throw new NotImplementedException();
 }
Exemple #10
0
 public void UpdateTaskItem(TaskItem t)
 {
     Thread th = new Thread(this.LongOperationToUpdateTask);
     th.Start(t);
 }
Exemple #11
0
 public void AddAttachment(TaskItem t, string attachmentName, System.IO.Stream contents)
 {
     Thread th = new Thread(this.LongOperationToAddAttachment);
     object[] userparams = { t, attachmentName ,contents  };
     th.Start(userparams);                        
 }
Exemple #12
0
 public void DeleteAttachment(TaskItem t, object attachmentidentifier)
 {
     Thread th = new Thread(this.LongOperationToDeleteAttachment);
     object[] userparams = { t,attachmentidentifier };
     th.Start(userparams );            
 }
Exemple #13
0
        public static Alerts  CreateStubbedAlerts()
        {
            Alerts a = new Alerts();

            int count = 8;
            int now = DateTime.Now.Second % 10;//to introduce variability in stubbed data

            count = now;
            while (count > 0)
            {
                TaskItem item = new TaskItem()
                                {
                                    TaskName ="Task name----:abcdefghijklmnopqrstuvwxyz0123456789"+count,
                                    DueTime ="15:00"
                                };
                a.AssignedTasksAlerts.Add(item);
                count--;
            }

            count = now;
            while (count > 0)
            {
                TaskItem item = new TaskItem()
                {
                    TaskName = "Task name----:(managed)abcdefghijklmnopqrstuvwxyz0123456789" + count,
                    DueTime = "15:00"
                };
                a.ManagedTasksAlerts.Add(item);
                count--;
            }
            return a;
        }
Exemple #14
0
        private static List<TaskItem> StubbedTasks;//useful to keep in memory to mimic update operations 
        public static List<TaskItem> CreateStubbedTasks(View vw)
        {

            List<TaskItem> tasks=new List<TaskItem>();
            int count = 24;
            //switch (vw)
            //{
            //    case View.vwCompletedApproved:
            //        count = 5;
            //        break;

            //    case View.vwDueToday:
            //        count = 23;
            //        break;
            //}

            Random r = new Random(DateTime.Now.Second);
            while (count > 0)
            {
                if (vw == View.vwManagedTasks)
                {
                    int x, y = 0;
                    x = 1 / y;
                }
                TaskItem task = new TaskItem();
                task.ID = DateTime.Now.Second + count;
                task.CreatedUtc = DateTime.Now.Date.AddDays(-count%5);
                task.CreatedUtc = task.CreatedUtc.AddMonths (-count % 3);
 
                task.TaskName = string.Format("Task Item:{0}, View:{1}, random:{2}", count, vw , r.Next());
                task.TaskDescription = string.Format ("<div>some task description id={0}</div>",task.ID );
                switch (count % 4)
                {
                    case 0:
                        task.AssignedTo = "322;#Dasgupta, Saurabh: IT (LDN);#326;#Ewing, Derek: IT (LDN)";
                        task.AttachmentUrl = ATTACHMENT1;

                        break;

                    case 1:
                        task.AssignedTo = "322;#Dasgupta, Saurabh: IT (LDN)";
                        task.AttachmentUrl = ATTACHMENT2;
                        break;

                    case 2:
                        task.AssignedTo = "322;#Dasgupta, Saurabh: IT (LDN);#326;#Ewing, Derek: IT (LDN)";
                        task.AttachmentUrl = ATTACHMENT3; 
                        break;
                        

                    default:
                        task.AssignedTo = "322;#Dasgupta, Saurabh: IT (LDN);#326;#Ewing, Derek: IT (LDN)";
                        task.AttachmentUrl = "0"; 
                        break;
                }

                task.DueTime =string.Format("{0}:00", count % 6 + 17);
                task.Status = "Outstanding";
                task.ManagementSignOff = "Pending";
                task.Comments = "task commments";
                if (count % 2 == 1)
                    task.LinkToProcess = string.Format("http://www.google.com?param={0}", count);
                else
                    task.LinkToProcess = "";
                task.Kri = "(none)";
                

                if ((count % 2) == 1) task.Complete = true;
                tasks.Add(task);
                count--;
            }


            return tasks;
        }
Exemple #15
0
        /// <summary>
        /// Encapsulates the logic for testing whether this Task qualifies as an alert for assigned Task
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static bool DoesTaskQualifyForAssignedTaskAlert(TaskItem t)
        {
            try
            {
                if (TaskItem.IsUserInAssignedTo(ViewModel.Current.WssUserId, t) == false) return false; 
                if (RegionalSetting.CurrentLocalTime.Date != t.CreatedLocal.Date ) return false; 
                if (t.Status.Equals(CamlHelper.COMPLETED_STATUS, StringComparison.CurrentCultureIgnoreCase)) return false;
                if (t.Status.Equals(CamlHelper.NOTAPPLICABLE_STATUS, StringComparison.CurrentCultureIgnoreCase)) return false;// May 18, do not show NA tasks in alerts
  
                UserOptions opts = UserOptions.Current;
                string dueTimespanString = t.DueTime;
                if (string.IsNullOrEmpty(dueTimespanString))
                {
                    dueTimespanString = "00:00";
                }
                TimeSpan dueTimeSpan = TimeSpan.Parse(dueTimespanString);
                DateTime duetime = RegionalSetting.CurrentLocalTime.Date.Add(dueTimeSpan);

                if (string.IsNullOrEmpty(t.AlertTime))
                {
                    DateTime timeWarn = duetime.Subtract(TimeSpan.FromMinutes(opts.AssignedTasksReminderTime));
                    if (RegionalSetting.CurrentLocalTime > timeWarn) return true;
                }
                else
                {
                    TimeSpan alertSpan;
                    if (TimeSpan.TryParse(t.AlertTime, out alertSpan))
                    {
                        //DateTime alertTime = DateTime.Now.Date.Add(alertSpan); //July 6
                        DateTime alertTime = RegionalSetting.CurrentLocalTime.Date.Add(alertSpan);
                        //Checking for alerts due in advance by a time of RefreshPollingPeriod (15 minutes at present) 
                        if (RegionalSetting.CurrentLocalTime > alertTime.Subtract(TimeSpan.FromSeconds(InitParams.Current.RefreshPollingPeriod)))
                        {
                            return true;
                        }
                    }
                    else
                    {
                        //Invalid Alert time
                        DateTime timeWarn = duetime.Subtract(TimeSpan.FromMinutes(opts.AssignedTasksReminderTime));
                        ViewModel.Current.Status.StatusItems.Enqueue(
                                        new StatusItem
                                        {
                                            IsError = true,
                                            Message =
           string.Format("Task with Name:{0} does not have a valid Alert time{1}. Using the value defined through Options dialog", t.TaskName, t.AlertTime),
                                        }
                                                   );
                        if (RegionalSetting.CurrentLocalTime > timeWarn) return true;
                    }
                }
            }
            catch (Exception ex)
            {
                ViewModel.Current.Status.AddToLog (
                    string.Format("Exception encountered while processing assigned Task with Name:'{0}'. Detailed error: {1}", t.TaskName, ex),
                    true 
                                           );
            }

            return false ;
        }
Exemple #16
0
 /// <summary>
 /// Returns True if the specified user is a Task owner for the specified Task
 /// If the user is not an owner then return is False
 /// If the Task has no owner then return is False
 /// Rationale: Reusable logic required for Task ownership functionality. April 20
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static bool IsUserTaskOwner(int userid, TaskItem t)
 {
     List<UserInfo> mgrs = TaskItem.ParseNames(t.TaskOwner);
     bool isowner = false;
     foreach (UserInfo u in mgrs)
     {
         if (u.UserID == userid)
         {
             isowner = true;
             break;
         }
     }
     return isowner;
 }
Exemple #17
0
 /// <summary>
 /// Returns True if the specified user belongs to the AssignedTo field for this Task, otherwise False
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static bool IsUserInAssignedTo(int userid, TaskItem t)
 {
     List<UserInfo> assignedtousers = TaskItem.ParseNames(t.AssignedTo);
     bool isassignedtouser = false;
     foreach (UserInfo u in assignedtousers)
     {
         if (u.UserID == userid)
         {
             isassignedtouser = true;
             break;
         }
     }
     return isassignedtouser;
 }
Exemple #18
0
 void ISharePointDataProvider.DeleteAttachment(TaskItem t, object attachmentidentifier)
 {
     throw new NotImplementedException();
 }
Exemple #19
0
        /// <summary>
        /// Method to compute whether the task is shortly due, over due, complete.
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static TaskCompletionStatus GetCompletionStatus(TaskItem t)
        {
            TaskCompletionStatus returnInfo = TaskCompletionStatus.Overdue;
            BCheck.Data.TaskItem task = t;
            if (task.ManagementSignOff.Equals("Approved"))
            {
                return TaskCompletionStatus.Complete;
            }

            TimeSpan spanduetime;
            if (TimeSpan.TryParse(task.DueTime, out spanduetime))
            {
                DateTime dateCreaeted = task.CreatedLocal;
                DateTime dueTime = dateCreaeted.Date.Add(spanduetime);
                DateTime now = RegionalSetting.CurrentLocalTime; //DateTime.Now; //July 06
                if (now > dueTime)
                {
                    returnInfo = TaskCompletionStatus.Overdue;
                }

                TimeSpan onehr = TimeSpan.FromHours(1);
                if ((now < dueTime) && (now > dueTime.Subtract(onehr)))
                {
                    returnInfo = TaskCompletionStatus.ShortlyDue;
                }

                if (now < dueTime.Subtract(onehr))
                {
                    returnInfo = TaskCompletionStatus.NotDueImmediately;
                }

            }
            else
            {
                ViewModel vm = ViewModel.Current;
                vm.Status.StatusItems.Enqueue(
                                new StatusItem
                                {
                                    IsError = true,
                                    Message = string.Format("Exception encountered while processing the due time of the Task with Name:'{0}'. Due time: {1}", t.TaskName, t.DueTime)
                                });

                //commenting out the exception because this has undesirable effects on the C1DataGrid when called from IValueConverter
                throw new InvalidOperationException("Could not compute the completion status of the Task");
            }

            return returnInfo;
        }
Exemple #20
0
 void ISharePointDataProvider.AddAttachment(TaskItem t, string attachmentName, System.IO.Stream contents)
 {
     throw new NotImplementedException();
 }
Exemple #21
0
        /// Helper function to 'safely' insert text in a CAML statement in cases where the text
        /// may contain special characters like <,>,&,= 
        /// E.g. The Comments, URL 
        /// </summary>
        /// <param name="xmlin"></param>
        /// <returns></returns>
        private static string InsertEncodedTextInXml(string xmlin, TaskItem t)
        {
            XElement wss = XElement.Parse(xmlin);

            var qFieldTaskname = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(NAME_COLUMN) select x;
            if (qFieldTaskname.Any())
            {
                XElement taskname = qFieldTaskname.First();
                taskname.SetValue(ConvertFromNullToString((t.TaskName)));
            }


            var qFieldDescription = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(DESCRIPTION_COLUMN) select x;
            if (qFieldDescription.Any())
            {
                XElement description = qFieldDescription.First();
                description.SetValue(ConvertFromNullToString((t.TaskDescription)));
            }


            var qFieldComments = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(COMMENTS_COLUMN) select x;
            if (qFieldComments.Any())
            {
                XElement comments = qFieldComments.First();
                comments.SetValue(ConvertFromNullToString((t.Comments)));
            }


            var qFieldLinktoProcess = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(LINKTOPROCESS_COLUMN) select x;
            if (qFieldLinktoProcess.Any())
            {
                XElement LinktoProcess = qFieldLinktoProcess.First();
                string encodedurl = ConvertFromNullToString((t.LinkToProcess));
                LinktoProcess.SetValue(encodedurl);
            }


            var qFieldKriDefinition = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(MATRIX_COLUMN) select x;
            if (qFieldKriDefinition.Any())
            {
                XElement KriDefinition = qFieldKriDefinition.First();
                KriDefinition.SetValue(ConvertFromNullToString((t.KriDefinition)));
            }

            var qAssignedTo = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(ASSIGNTO_COLUMN) select x;
            if (qAssignedTo.Any())
            {
                XElement AssignedTo = qAssignedTo.First();
                AssignedTo.SetValue(ConvertFromNullToString((t.AssignedTo)));
            }

            //Oct 14, for updating manager
            var qManager = from x in wss.Descendants("Field") where x.Attribute("Name").Value.Equals(MANAGER_COLUMN) select x;
            if (qManager.Any())
            {
                XElement manager = qManager.First();
                manager.SetValue(ConvertFromNullToString((t.Manager)));
            }

            return wss.ToString();

        }
Exemple #22
0
 void ISharePointDataProvider.UpdateTaskItem(TaskItem t)
 {
     throw new NotImplementedException();
 }
Exemple #23
0
        public static TaskItem ConvertTaskFromOMD(BCheck.Data.BCheckOMDQuery.Row row)
        {
            TaskItem item = new TaskItem();
            item.AlertTime = row.Alert_Time;
            item.AssignedTo = row.Assign_To;
            item.AttachmentUrl = attachmentConverter(row.Attachments);
            item.Comments = row.Comments;
            item.Complete = row.Completed_Y_N_ == "Y";
            item.CreatedLocal = Convert.ToDateTime(row.Create_Date_Local);
            item.CreatedUtc = Convert.ToDateTime(row.Created_UTC);
            item.DueTime = row.Due_Time;
            item.EscalationTime = row.Escalation_Level_1_Time;
            item.ID = (int)row.Task_ID;
            item.Kri = row.KPI;
            item.LinkToProcess = row.Link_To_Process;
            item.ManagementSignOff = row.Management_Sign_Off;
            item.Manager = row.Manager;
            item.Modified = row.Modified.ToString();
            item.ModifiedBy = row.Modified_By;
            item.Status = row.Status;
            item.TaskDescription = ParseDescription(row.High_Level_Description);
            item.TaskName = row.Task_Name;
            item.Version = (int)row.Version;       

            return item;
        }
Exemple #24
0
 public void GetAttachments(TaskItem t)
 {
     throw new NotImplementedException();
 }
        internal void Initialize(TaskItem selectedTaskItem)
        {
            _model.Provider.FetchRevisionHistory(selectedTaskItem);

        }
Exemple #26
0
 public void FetchRevisionHistory(TaskItem task)
 {
     item = task;
     Thread t = new Thread(this.LongOperationToFetchRevisionHistory);
     t.Start();
 }
        /// <summary>
        /// function to check if the fileName exists in the collection of attachments.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="task"></param>
        /// <returns></returns>
        private bool ValidateIfDuplicateFileName(string fileName, TaskItem task)
        {
            if (task == null) throw new ArgumentNullException("task");
            List<string> attachmentUrls=TaskItem.ParseAttachmentUrl(task);
            IValueConverter converter = new Converters.AttachmentTitleConverter ();
            foreach (string url in attachmentUrls)
            {
                var title=(string)converter.Convert (url , null ,null ,null );
                if (title.Equals (fileName, StringComparison .InvariantCultureIgnoreCase)) return true; 
            }

            return false ;
        }
Exemple #28
0
        /// <summary>
        /// Implementing a static function to let Task Edit dialog update the selected Row 
        /// after successfuly completing an Edit operation.
        /// Ideally, this should have been done through data-binding to an exposed property in the View Model.
        /// However, this does not seem to work.
        /// </summary>
        /// <param name="t"></param>
        public static void SetSelectedTask(TaskItem t)
        {
            if (t == null) return;
            //adding a try-catch handler to gracfully handle exceptions
            //in those cases when the specified TaskItem no more belongs to the underlying collection
            //this is in those scenarios wherein the data has refreshed when a dialog was open
            //July 16
            try
            {                
                //TasksViewC1._thisGrid.TaskGrid.SelectedItem = t;
                foreach (TaskItem taskInUi in TasksViewC1._thisGrid.TaskGrid.ItemsSource)
                {
                    if (t.ID == taskInUi.ID)
                    {
                        TasksViewC1._thisGrid.TaskGrid.SelectedItem = taskInUi;
                        break;
                    }
                }
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(true, ex.ToString());
            }
        }
        public TaskItemInMemoryChangeEventArgs (TaskItem taskModified,string propName)
	    {
            this.Task = taskModified;
            this.PropName = propName;
	    }
Exemple #30
0
        /// <summary>
        /// Helper function to strip a valid WSS attachment URL (returned from a WSS service) of its leading & trailing delimiters
        /// e.g. of an URL that comes from a WSS web service
        ///;#http://bcheck.intranet.barcapint.com/sites/bcheck/tasks/Lists/operations checklist/Attachments/38449/debug.xap;#        
        ///;#http://bcheck.intranet.barcapint.com/sites/bcheck/tasks/Lists/operations checklist/Attachments/38449/debug.xap;#http://bcheck.intranet.barcapint.com/sites/bcheck/tasks/Lists/operations checklist/Attachments/38449/junk1.xap;#
        /// </summary>
        /// <param name="t"></param>
        public static List<string> ParseAttachmentUrl(TaskItem t)
        {
            List<string> urls = new List<string>();
            bool matchfound = false;
            string url = t.attachmentUrl;
            const string delim = ";#";
            while (!matchfound)
            {
                if (string.IsNullOrEmpty(url)) break;
                int delimpos = url.IndexOf(delim);
                if (delimpos >= 0)
                {
                    url = url.Remove(delimpos, delim.Length);
                }
                else
                {
                    break;
                }
                delimpos = url.IndexOf(delim);
                if (delimpos >= 0)
                {
                    string url1;
                    url1 = url.Substring(0, delimpos);
                    urls.Add(url1);
                    url = url.Remove(0, delimpos);
                }
                else
                {
                    matchfound = true;
                }
            }

            return urls;
        }