void Current_DeleteAttachmentCompleteEvent(object sender, TaskItemUpdateCompleteEventArgs args)
        {
            ViewModel.Current.TaskUpdateCompleteEvent -= Current_DeleteAttachmentCompleteEvent;
            if (args.Error != null)
            {
                DialogResult = false; //Oct 13, let the dialog be closed if errored, message box will appear on top
                string customerrormessage = ViewModel.Current.GetFriendlyMessage(args.Error);
                C1.Silverlight.C1MessageBox.Show(
                    "Error while updating/deleting attachments:" + customerrormessage,
                    MainPage.GetMessage("title"), 
                    C1.Silverlight.C1MessageBoxButton.OK, 
                    C1.Silverlight.C1MessageBoxIcon.Error);
                return;
            }

            if (args.UpdatedTasks.Count == 0)
            {
                DialogResult = false; //Oct 13, let the dialog be closed if errored, message box will appear on top
                C1.Silverlight.C1MessageBox.Show(
                    "No tasks were updated in this operation!",
                    MainPage.GetMessage("title"),
                    C1.Silverlight.C1MessageBoxButton.OK,
                    C1.Silverlight.C1MessageBoxIcon.Error);
                return;
            }

            DataContext = args.UpdatedTasks[0];
            //the following statement will ensure that the newly edited Task continues to be shown as
            //the highlighted task item
            TasksViewC1.SetSelectedTask(args.UpdatedTasks[0]);  

        }
 void ViewModel_BulkUpdateHandler(object sender, TaskItemUpdateCompleteEventArgs args)
 {
     ViewModel.Current.BulkUpdateHandler -= new TaskUpdateComplete(ViewModel_BulkUpdateHandler);
     SelectAllClickHandler.vm_BulkUpdateSelectedTasksCompleteHandler(sender, args);
     if (args.Error == null)
     {
         this.DialogResult = MessageBoxResult.OK;
         this.Close();
     }
 }
Example #3
0
        void Provider_TaskBulkUpdateCompleteEvent(object sender, TaskItemUpdateCompleteEventArgs args)
        {
            this.IsUpdating = false;
            this.Provider.TaskUpdateCompleteEvent -= new TaskUpdateComplete(Provider_TaskBulkUpdateCompleteEvent);
            if (args != null)
            {
                TaskItemUpdateCompleteEventArgs newargs = args.Clone();

                if ((args.Error != null) || (args.Cancelled == true))
                {
                    if (args.Error != null)
                        this.Status.Exception = args.Error;
                    else
                        this.Status.Message = "The web service operation was cancelled by the user";
                }
                else
                {
                    AddRemoveTaskItemNoSelectionMemory(newargs.UpdatedTasks);

                    TaskAlerts.AssignedTasksAlerts.BeginUpdate();
                    TaskAlerts.AssignedTasksAlertsNearFuture.BeginUpdate();
                    TaskAlerts.ManagedTasksAlerts.BeginUpdate();
                    TaskAlerts.ManagedTasksAlertsNearFuture.BeginUpdate();
                    this.TaskAlerts.EvaluateAndAddTasksForAlerts(newargs.UpdatedTasks);
                    TaskAlerts.AssignedTasksAlerts.EndUpdate();
                    TaskAlerts.AssignedTasksAlertsNearFuture.EndUpdate();
                    TaskAlerts.ManagedTasksAlerts.EndUpdate();
                    TaskAlerts.ManagedTasksAlertsNearFuture.EndUpdate();

                }

                if (this.BulkUpdateHandler != null)
                {
                    this.BulkUpdateHandler(this, newargs);
                }
            }
            this.RefreshData(false); //avoid updating the UI, no other change in state so not important
        }
Example #4
0
        /// <summary>
        /// Common internal function for doing bulk assignment. All regular validations are burnt in here.
        /// This function will do the required validations and return the filtered collection of updatable tasks
        /// The caller should invoke the web services for doing the update.
        /// </summary>
        /// <param name="tasksSelected"></param>
        private IEnumerable<TaskItem> GetTasksForBulkUpdate(IEnumerable<TaskItem> tasksSelected, UpdateTaskHandler handler)
        {

            List<TaskItem> tasksToWorkOn = new List<TaskItem>();
            TaskItemUpdateCompleteEventArgs argsIncaseNoRights = new TaskItemUpdateCompleteEventArgs(null, false, null);
            foreach (TaskItem t in tasksSelected)
            {
                handler(t);
                this.Status.AddToLog(
                    string.Format("adding task for bulk assign:{0}", t.TaskName), false);
                tasksToWorkOn.Add(t);
            }

            if (tasksToWorkOn.Count == 0)
            {
                if (this.BulkUpdateHandler != null)
                {
                    this.BulkUpdateHandler(this, argsIncaseNoRights);
                }
                return null;
            }

            return tasksToWorkOn;
        }
Example #5
0
        public void BulkCompleteWithLateIncompleteReason(IEnumerable<TaskItem> tasksSelected, bool completeflag, string taskComments, string lateIncompleteReason, string systemOutrage)
        {
            if (tasksSelected == null) throw new ArgumentNullException("The collection of Tasks for updation cannot be null");
            if (_tasks.Count() == 0) throw new ArgumentException("1 or more tasks required for user re-assignment");
            ValidateMaxUpdateInBatchLimit(tasksSelected, View.vwAssignedTasks);
            ValidateIsUserAllowedToUpdate(tasksSelected, 1);

            this.Status.AddToLog("Begin bulk complete:{0}" + completeflag, false);
            List<TaskItem> tasksToWorkOn = new List<TaskItem>();
            TaskItemUpdateCompleteEventArgs argsIncaseNoRights = new TaskItemUpdateCompleteEventArgs(
                    null,
                    false, null);

            var qryAccessDenied = from deniedTask in tasksSelected where (TaskItem.IsUserInAssignedTo(this.wssUserId, deniedTask) == false) select deniedTask;
            foreach (TaskItem t in qryAccessDenied)
            {
                argsIncaseNoRights.Errors.Add(string.Format("Task '{0}' will not be updated because the current user does not have sufficient rights", t.TaskName));
                this.Status.AddToLog(
                    string.Format("!!!not adding task for bulk approve-reject:{0}", t.TaskName), false);
            }
            //check if there were any exclusions and do not proceed even if there is one that is not allowable
            if (qryAccessDenied.Count() > 0)
            {
                if (BulkUpdateHandler != null)
                {
                    BulkUpdateHandler(this, argsIncaseNoRights);
                }
                return;
            }

            foreach (TaskItem t in tasksSelected)
            {
                //check for security
                if (TaskItem.IsUserInAssignedTo(this.wssUserId, t))
                {
                    this.Status.AddToLog(
                        string.Format("Adding Task for completion. TaskName={0}", t.TaskName),
                        false);
                    t.Status = (completeflag) ? CamlHelper.COMPLETED_STATUS : CamlHelper.IN_PROGRESS_STATUS;
                    t.CompletedBy = (completeflag) ? ViewModel.Current.WssUserId.ToString() : "";
                    this.Status.AddToLog(
                        string.Format("adding task for bulk approve-reject:{0}", t.TaskName), false);
                    tasksToWorkOn.Add(t);
                }
                else
                {
                }
            }

            IEnumerable<TaskItem> tasksPrepared = BulkPrepareLateIncompleteReason(tasksSelected, taskComments, lateIncompleteReason, systemOutrage);

            this.IsUpdating = true;
            this.Status.AddToLog("Initiating we request for bulk complete", false);

            this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskBulkUpdateCompleteEvent);
            this.Provider.UpdateLateCompleteReasonWithCompleteFlag(tasksPrepared);
        }
Example #6
0
        /// <summary>
        /// This method will approve/reject the tasks in the collection
        /// </summary>
        /// <param name="tasks">if True then approve else reject</param>
        /// <param name="taskcomments">Specifies the comments to be applied to the Task(s) during rejection</param>
        /// <param name="bQuiet">If bQuiet=true, then this method skips those Tasks which are not allowed access and proceeds with those
        /// teh rest. If bQuiet=false, then this method throws an Exception if there is atleast 1 task which cannot be updated.</param>
        public bool BulkApproveAllTasks(
                    IEnumerable<TaskItem> tasksSelected,
                    bool isapprove,
                    string taskcomments,
                    bool bQuiet,
                    TaskUpdateComplete cb, out string message)
        {
            message = "";
            if (tasksSelected == null) throw new ArgumentNullException("The collection of Tasks for updation cannot be null");
            if (!tasksSelected.Any()) throw new ArgumentException("1 or more tasks required for user re-assignment");
            ValidateMaxUpdateInBatchLimit(tasksSelected, View.vwManagedTasks);
            //ValidateIsUserAllowedToUpdate(tasksSelected,2 );
            this.Status.AddToLog("Begin bulk approve-reject:{0}" + isapprove, false);
            List<TaskItem> tasksToWorkOn = new List<TaskItem>();
            TaskItemUpdateCompleteEventArgs argsIncaseNoRights = new TaskItemUpdateCompleteEventArgs(
                    null,
                    false, null);

            System.Text.StringBuilder sbMsg = new System.Text.StringBuilder();


            var validTasks = new List<TaskItem>();
            tasksSelected.ToList().ForEach(task =>
            {
                if (task.IsManagerSelfApprovalAllowed == false && task.IsBypassApprovalAllowed == false)
                {
                    if (task.CompletedBy != ViewModel.Current.WssUserId.ToString() || task.CompletedBy == null)
                    {
                        validTasks.Add(task);
                    }
                }
                else
                {
                    validTasks.Add(task);
                }
            });

            if (tasksSelected.Count() > validTasks.Count)
            {
                string errmessage = String.Format("{0} task(s) not updated and will still be marked as selected. Reason : Manager self approval for the tasks is not allowed. \r\n", (tasksSelected.Count() - validTasks.Count).ToString());
                sbMsg.Append(errmessage);
            }

            tasksSelected = validTasks;

            var qryAccessDenied = from deniedTask in tasksSelected where (TaskItem.IsUserManager(this.wssUserId, deniedTask) == false) select deniedTask;
            foreach (TaskItem t in qryAccessDenied)
            {
                argsIncaseNoRights.Errors.Add(string.Format("Task '{0}' will not be updated because the current user does not have sufficient rights", t.TaskName));
                this.Status.AddToLog(
                    string.Format("!!!not adding task for bulk approve-reject:{0}", t.TaskName), false);
            }
            var qryTasksNotCompleted = from incompleteTask in tasksSelected where !incompleteTask.Status.Equals(CamlHelper.COMPLETED_STATUS) select incompleteTask;
            if ((qryTasksNotCompleted.Count() > 0) && (isapprove == true) && (bQuiet == false))
            {
                string msg = string.Format("There are {0} tasks which cannot be updated. The selected Task(s) require completion before approval.", qryTasksNotCompleted.Count());
                //throw new Exception(msg);
            }

            bool conditionAccessDenied = (qryAccessDenied.Count() > 0);
            bool conditionTaskIncomplete = ((qryTasksNotCompleted.Count() > 0) && (isapprove == true));
            if (conditionAccessDenied)
            {
                string msg =
                    string.Format("There are {0} tasks which cannot be updated. This could be because the user is not a manager of these tasks.",
                    qryAccessDenied.Count());
                sbMsg.Append(msg);
            }
            if (conditionTaskIncomplete)
            {
                string msg =
                    string.Format("There are {0} tasks which cannot be approved. These Task(s) require completion before approval.", qryTasksNotCompleted.Count());
                //throw new Exception(msg);
                sbMsg.Append(msg);
            }

            if (conditionTaskIncomplete || conditionAccessDenied)
            {
                if (!bQuiet)
                {
                    message = sbMsg.ToString();
                    return false;
                }
            }
            //filter out those tasks which are iaccessible due to non-completion OR lack of access
            var qryPermittedTasks = from t in tasksSelected
                                    where !(
                                            qryTasksNotCompleted.Any(nc => (nc.ID == t.ID))
                                            ||
                                            qryAccessDenied.Any(ad => (ad.ID == t.ID))
                                            )
                                    select t;
            if (qryPermittedTasks.Count() == 0) throw new ArgumentException(
                "No tasks to update. This could be due to any of the following reasons:\r\nThe Task(s) need to be Completed to use this feature\r\nThe current user is not a manager for the selected Task(s)\r\nManager self approval for the Task(s) is not allowed.");
            //foreach (TaskItem t in tasksSelected)
            foreach (TaskItem t in qryPermittedTasks)
            {
                //check for security
                if (TaskItem.IsUserManager(this.wssUserId, t))
                {
                    t.ManagementSignOff = (isapprove) ? "Approved" : "Rejected";
                    this.Status.AddToLog(
                        string.Format("adding task for bulk approve-reject:{0}", t.TaskName), false);
                    tasksToWorkOn.Add(t);

                    //Mar 2011 release. Comments is required while rejecting a Task
                    if (!isapprove)
                    {

                        if (string.IsNullOrEmpty(t.Comments))
                        {
                            t.Comments = string.Format("{0}", taskcomments);
                        }
                        else
                        {
                            string comments = "";
                            comments = t.Comments.Trim();
                            t.Comments = string.Format("{0};{1}", comments, taskcomments);
                        }
                    }
                }
                else
                {
                }
            }


            this.IsUpdating = true;
            this.Status.AddToLog("Initiating we request for bulk approve-reject", false);

            this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskBulkUpdateCompleteEvent);
            if (cb != null) this.BulkUpdateHandler = cb;
            this.Provider.UpdateManagedTasksSignOff(tasksToWorkOn);
            return true;
        }
Example #7
0
        void Provider_TaskCheckBoxUpdationComplete(object sender, TaskItemUpdateCompleteEventArgs args)
        {
            bool haserrors = false;
            this.IsUpdating = false;
            TaskItemUpdateCompleteEventArgs newargs = args.Clone();
            this.Provider.TaskUpdateCompleteEvent -= new TaskUpdateComplete(Provider_TaskCheckBoxUpdationComplete);
            if ((args.Error != null) || (args.Cancelled == true))
            {
                if (args.Error != null)
                    this.Status.Exception = args.Error;
                else
                    this.Status.Message = "The web service operation was cancelled by the user";
                haserrors = true;
            }
            else
            {
                //AddRemoveTaskItem(newargs.UpdatedTasks); July 7
                AddRemoveTaskItemNoSelectionMemory(newargs.UpdatedTasks);
                haserrors = false;
            }

            if (this.TaskUpdateCompleteEvent != null)
            {
                this.TaskUpdateCompleteEvent(this, newargs);
            }

            if (haserrors == false) this.RefreshData(false); //Oct 13, if error in udpating, then do not refresh
        }
Example #8
0
        private void LongOperationToDeleteAttachment(object param)
        {
            if (this.TaskUpdateCompleteEvent == null) return;
            Thread.Sleep(2000);

            Object[] paramarray = (Object[]) param;
            TaskItem t = (TaskItem)paramarray[0];
            string attachmentid = (string)paramarray[1];
            TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(null, false, null);
            args.UpdatedTasks.Add ( t.Clone());

            while (true)
            {
                if (t.AttachmentUrl.Contains("item3")) { args.UpdatedTasks[0].AttachmentUrl = ATTACHMENT2; break; }
                if (t.AttachmentUrl.Contains("item2")) {args.UpdatedTasks[0].AttachmentUrl = ATTACHMENT1; break;}
                if (t.AttachmentUrl.Contains("item1")) { args.UpdatedTasks[0].AttachmentUrl = "0"; break; }//all attachments deleted
                break;
            }
            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                TaskUpdateCompleteEvent (this, args);
            });

        }
Example #9
0
        private void LongOperationToAddAttachment(object param)
        {
            if (this.TaskUpdateCompleteEvent == null) return;
            Thread.Sleep(2000);

            Object[] paramarray = (Object[])param;
            TaskItem t = (TaskItem)paramarray[0];
            string attachmentName = (string)paramarray[1];
            System.IO.Stream contents = (System.IO.Stream)paramarray[2];
            TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(null, false, null);
            args.UpdatedTasks.Add  ( t.Clone());
            string existingattachments = args.UpdatedTasks[0].AttachmentUrl ;
            if (args.UpdatedTasks[0].AttachmentUrl.Equals("0"))
            {
                existingattachments = ";#";
            }

            args.UpdatedTasks[0].AttachmentUrl = string.Format(
                            "{0}http://bcheck/{1};#",
                            existingattachments  ,attachmentName); 

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                TaskUpdateCompleteEvent(this, args);
            });
        }
Example #10
0
        /// <summary>
        /// Callback handler when a Task has been updated.
        /// Rationale: needed a place holder from where another query could be issued to fetch the updated Task item.
        /// Important to re-issue web service to fetch the Task, rather than rely on the XML fragment returned after UpdateListItem
        /// because of UTC options
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void UpdateSingleTaskItemCompletedHandler(
                object sender,
                BCheck.Data.BCheckLists.UpdateListItemsCompletedEventArgs e)
        {
            if ((e.Cancelled) || (e.Error != null))
            {
                TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(e.Error, e.Cancelled, null);
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    TaskUpdateCompleteEvent(this, args);
                });

                return;
            }
            /*
             * loop throuhg the returned XML
             * find out if there were any errors
             * Issue another web service query to fetch complete data for the TaskItem that has got updated
             */
            XElement xresults = e.Result;
            XNamespace nsRow = "#RowsetSchema";
            XNamespace nsResults = "http://schemas.microsoft.com/sharepoint/soap/";
            var query = from x in xresults.Descendants()
                        where x.Name == nsResults + "Result"
                        select x;
            List<int> updatedtaskIDs = new List<int>();
            List<string> errorcodes = new List<string>();
            List<int> erroredtaskIDs = new List<int>();
            foreach (XElement result in query)
            {
                XElement error = result.Element(nsResults + "ErrorCode");
                string errorCode = error.Value;
                if (errorCode.Equals("0x00000000"))
                {
                    XElement row = result.Element(nsRow + "row");
                    int taskid = (int?)row.Attribute("ows_ID") ?? 0;
                    updatedtaskIDs.Add(taskid);
                }
                else
                {
                    //get the ErrorText element
                    XElement errorTxt = result.Element(nsResults + "ErrorText");
                    if (errorTxt != null) errorcodes.Add(errorTxt.Value);
                }
            }
            IEnumerable<TaskItem> updatedTasks = XmlToTaskObjects(xresults);
            foreach (TaskItem t in updatedTasks)
            {
                t.SetInitializationComplete();
            }
            Exception errors;
            if (errorcodes.Count != 0)
            {
                errors = new Exception(string.Format("Errors while updating {0} Task items, erorcode:{1}", errorcodes.Count, errorcodes[0]));
                TaskItemUpdateCompleteEventArgs evargs = new TaskItemUpdateCompleteEventArgs(errors, false, null);
                evargs.Errors = errorcodes;
                foreach (TaskItem t in updatedTasks) { evargs.UpdatedTasks.Add(t); }
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    TaskUpdateCompleteEvent(this, evargs);
                });
                return;
            }
            if (updatedTasks.Count() == 0)
            {
                TaskItemUpdateCompleteEventArgs evargs = new TaskItemUpdateCompleteEventArgs(null, false, null);
                evargs.Errors = new List<string>();
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    TaskUpdateCompleteEvent(this, evargs);
                });
                return;
            }
            //re-fetch the TaskItem data once more
            string url = this.ConstructUrlParams(IIsAction.QUERYSINGLE, null, 0);
            TaskItem firstTask = updatedTasks.First();
            EndpointAddress addr = new EndpointAddress(url);//URL params injected, Mar 29
            BasicHttpBinding bnd = new BasicHttpBinding();
            bnd.MaxBufferSize = InitParams.Current.MaxBufferSize;
            bnd.MaxReceivedMessageSize = bnd.MaxBufferSize;


            BCheckLists.ListsSoapClient listClient = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr);
            string queryOptionsXml = "<QueryOptions><DateInUtc>TRUE</DateInUtc><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>";
            XElement queryOptions = XElement.Parse(queryOptionsXml);
            string maxrows = BCheck.Data.InitParams.Current.MaxCamlRows.ToString();
            string queryXml = "";
            queryXml = CamlHelper.QueryFetchTaskWithID(firstTask.ID);
            XElement queryXe = XElement.Parse(queryXml);
            string viewFieldsXml = "";
            viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            XElement viewFields = XElement.Parse(viewFieldsXml);

            //listClient.GetListItemsCompleted +=
            //    delegate(object sender, BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs e)
            //    {
            //    };
            listClient.GetListItemsCompleted += new EventHandler<BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs>(listClient_GetListItemsCompleted);
            //this.FetchTasksCompleteEvent +=
            //        delegate(object sender1, TaskFetchCompletedEventArgs args1)
            //        {
            //            TaskItemUpdateCompleteEventArgs evargs = new TaskItemUpdateCompleteEventArgs(null, false, null);
            //            evargs.UpdatedTasks = args1.Tasks;  
            //            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            //            {
            //                TaskUpdateCompleteEvent(this, evargs);
            //            });
            //        };

            //objectstate=QUERYSINGLE, so that the event handler knows to invoke the right call back
            TaskUpdateCompleteEvent(this, null);
            //listClient.GetListItemsAsync(
            //        InitParams.Current.ListName, "", queryXe, viewFields,
            //        maxrows, queryOptions, null, IIsAction.QUERYSINGLE);

        }
Example #11
0
        void listClient_GetListItemsCompleted(object sender, BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs e)
        {
            if (FetchTasksCompleteEvent == null) return;


            TaskFetchCompletedEventArgs args;
            try
            {
                if (e.Error != null)
                {
                    args = new TaskFetchCompletedEventArgs(e.Error, e.Cancelled, null);
                }
                else
                {
                    args = new TaskFetchCompletedEventArgs();
                    args.Tasks = new List<TaskItem>();
                    XElement xresults = e.Result;
                    XNamespace ns = "#RowsetSchema";
                    var query = from x in xresults.Descendants()
                                where x.Name == ns + "row"
                                select new TaskItem
                                    {
                                        TaskName = (string)x.Attribute("ows_Title"),
                                        ID = (int?)x.Attribute("ows_ID") ?? 0,
                                        Version = (int?)x.Attribute("ows_owshiddenversion") ?? 1,
                                        TaskDescription = (string)x.Attribute("ows_High_x0020_Level_x0020_Descripti"),
                                        AssignedTo = (string)x.Attribute("ows_Assign_x0020_to"),
                                        Status = (string)x.Attribute("ows_Status"),
                                        DueTime = (string)x.Attribute("ows_Due_x0020_Time"),
                                        ManagementSignOff = (string)x.Attribute("ows_Management_x0020_Signoff"),
                                        Kri = (string)x.Attribute("ows_KPI"),
                                        Comments = (string)x.Attribute("ows_Comments"),
                                        CreatedUtc = (DateTime)x.Attribute("ows_Created"),
                                        AttachmentUrl = (string)x.Attribute("ows_Attachments"),
                                        KriDefinition = (string)x.Attribute("ows_Matrix_x0020_Definition"),
                                        AlertTime = (string)x.Attribute("ows_Alert_x0020_Time"),
                                        EscalationTime = (string)x.Attribute("ows_Escalation_x0020_Level_x0020_1_x"),
                                        LinkToProcess = (string)x.Attribute("ows_Link_x0020_to_x0020_Process"),
                                        Manager = (string)x.Attribute("ows_Manager"),
                                        CreatedLocal = TaskItem.GetCreatedTimeAsPerCurrentRegion((DateTime)x.Attribute("ows_Created")),
                                        Functional = (string)x.Attribute("ows_Functional"),
                                        BypassApproval = (string)x.Attribute("ows_BypassManagerApproval"),
                                        ManagerSelfApproval = (string)x.Attribute("ows_ManagerSelfApproval"),
                                        TaskOwner = (string)x.Attribute("ows_TaskOwner"),
                                        TimeForCompletion = (string)x.Attribute("ows_Time_x0020_Taken"),
                                        LateIncompleteReason = (string)x.Attribute("ows_LateIncompleteReason"),
                                        SystemOutrage = (string)x.Attribute("ows_SystemOutrage"),
                                        CompletedBy = (string)x.Attribute("ows_Completed_x0020_By")
                                    };
                    //Status = x.Attribute("ows_Status").Value,
                    //ManagementSignOff = x.Attribute("Management_x0020_Signoff").Value

                    //select (string)c.Element("Name");
                    /*
                     loop through all the XML entries and construct a TaskItem object here
                     */
                    foreach (TaskItem t in query)
                    {
                        t.CompletedBy = RegexMatchOrNull(t.CompletedBy);
                        t.SetInitializationComplete();
                        args.Tasks.Add(t);
                    }
                }

            }

            catch (Exception ex)
            {
                args = new TaskFetchCompletedEventArgs(ex, true, null);
                args.Tasks = new List<TaskItem>();//return an empty collection nevertheless 

            }
            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                if (e.UserState == null)
                {
                    FetchTasksCompleteEvent(this, args);
                    return;
                }
                if (e.UserState.Equals(IIsAction.QUERYSINGLE))//May10,when a single Task is udpated , fire back a different event. You do not want the complete UI to refresh
                {
                    TaskItemUpdateCompleteEventArgs evargs = new TaskItemUpdateCompleteEventArgs(null, false, null);
                    evargs.UpdatedTasks = args.Tasks;
                    TaskUpdateCompleteEvent(this, evargs);
                    return;
                }
            });
        }
Example #12
0
        void assignedTasksUpdateClient_UpdateListItemsCompleted(
                            object sender,
                            BCheck.Data.BCheckLists.UpdateListItemsCompletedEventArgs e)
        {
            if ((e.Cancelled) || (e.Error != null))
            {
                TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(e.Error, e.Cancelled, null);
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    TaskUpdateCompleteEvent(this, args);
                });

                return;
            }

            /*
             * run through the e.Result
             * find out the rows that were updated and those were not
             * look into the <ErrorCode> flag for each of the <Result> elements
             * look into the ID attribute in the <Result> elements
             * prepare a CAML query to re-fetch all successfully updated elements
             */

            XElement xresults = e.Result;
            XNamespace nsRow = "#RowsetSchema";
            XNamespace nsResults = "http://schemas.microsoft.com/sharepoint/soap/";
            var query = from x in xresults.Descendants()
                        where x.Name == nsResults + "Result"
                        select x;
            List<int> updatedtaskIDs = new List<int>();
            List<string> errorcodes = new List<string>();
            List<int> erroredtaskIDs = new List<int>();
            foreach (XElement result in query)
            {
                XElement error = result.Element(nsResults + "ErrorCode");
                string errorCode = error.Value;
                if (errorCode.Equals("0x00000000"))
                {
                    XElement row = result.Element(nsRow + "row");
                    int taskid = (int?)row.Attribute("ows_ID") ?? 0;
                    updatedtaskIDs.Add(taskid);
                }
                else
                {
                    //get the ErrorText element
                    XElement errorTxt = result.Element(nsResults + "ErrorText");
                    if (errorTxt != null) errorcodes.Add(errorTxt.Value);
                }
            }

            //IEnumerable<TaskItem> result = XmlToTaskObjects(null);
            Exception errors;
            if (errorcodes.Count == 0)
            {
                errors = null;
            }
            else
            {
                errors = new Exception(string.Format("Errors while updating {0} Task items, erorcode:{1}", errorcodes.Count, errorcodes[0]));
            }

            TaskItemUpdateCompleteEventArgs evargs = new TaskItemUpdateCompleteEventArgs(errors, false, null);
            evargs.Errors = errorcodes;
            IEnumerable<TaskItem> updatedTasks = XmlToTaskObjects(xresults);
            foreach (TaskItem t in updatedTasks)
            {
                t.SetInitializationComplete();
                evargs.UpdatedTasks.Add(t);
            }

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                TaskUpdateCompleteEvent(this, evargs);
            });
        }
Example #13
0
        void attachmentsUpdatedClient_GetListItemsCompleted(object sender, BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs e)
        {
            if ((e.Cancelled) && (e.Error != null))
            {
                TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(e.Error, e.Cancelled, null);
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    TaskUpdateCompleteEvent(this, args);
                });

                return;
            }

            IEnumerable<TaskItem> result = XmlToTaskObjects(e.Result);
            TaskItemUpdateCompleteEventArgs evargs = new TaskItemUpdateCompleteEventArgs(null, false, null);
            foreach (TaskItem t in result)
            {
                evargs.UpdatedTasks.Add(t);
            }

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                TaskUpdateCompleteEvent(this, evargs);
            });
        }
Example #14
0
        void attachmentsClient_AddAttachmentCompleted(object sender,
                BCheck.Data.BCheckLists.AddAttachmentCompletedEventArgs e)
        {
            if ((e.Cancelled) || (e.Error != null))
            {
                TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(e.Error, e.Cancelled, null);
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    TaskUpdateCompleteEvent(this, args);
                });

                return;
            }

            //on success, fetch the updated task
            this.GetAttachments(BCheck.Data.ViewModel.Current.SelectedTask);

            //string url = this.ConstructUrlParams(IIsAction.QUERYSINGLE, null, 0);
            //EndpointAddress addr = new EndpointAddress(url);//URL params injected, Mar 29
            //BasicHttpBinding bnd = new BasicHttpBinding();
            //bnd.MaxBufferSize = InitParams.Current.MaxBufferSize;
            //bnd.MaxReceivedMessageSize = bnd.MaxBufferSize;


            //Object[] paramarray = (Object[])e.UserState;
            //TaskItem tUpdated = (TaskItem)paramarray[0];

            //BCheckLists.ListsSoapClient attachmentsUpdatedClient = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr);
            //attachmentsUpdatedClient.GetListItemsCompleted += new EventHandler<BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs>(attachmentsUpdatedClient_GetListItemsCompleted);

            //string queryXml = "";
            //string viewFieldsXml = "";

            //queryXml = CamlHelper.QueryFetchTaskWithID(tUpdated.ID);
            //viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //XElement query = XElement.Parse(queryXml);
            //XElement viewFields = XElement.Parse(viewFieldsXml);

            //string queryOptionsXml = "<QueryOptions><DateInUtc>TRUE</DateInUtc><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls></QueryOptions>";
            //XElement queryOptions = XElement.Parse(queryOptionsXml);
            //string maxrows = "1";
            //attachmentsUpdatedClient.GetListItemsAsync(
            //            InitParams.Current.ListName, "", query, viewFields, maxrows, queryOptions, null, paramarray);

        }
Example #15
0
 void Provider_AttachmentAddCompleteEvent(object sender, TaskItemUpdateCompleteEventArgs args)
 {
     this.IsUpdating = false;
     this.Provider.TaskUpdateCompleteEvent -= new TaskUpdateComplete(Provider_AttachmentAddCompleteEvent);
     TaskItemUpdateCompleteEventArgs newargs = args.Clone();
     if ((args.Error != null) || (args.Cancelled == true))
     {
         if (args.Error != null)
             this.Status.Exception = args.Error;
         else
             this.Status.Message = "The web service operation was cancelled by the user";
     }
     else
     {
         AddRemoveTaskItem(newargs.UpdatedTasks);
     }
     if (this.TaskUpdateCompleteEvent != null)
     {
         this.TaskUpdateCompleteEvent(this, newargs);
     }
 }
Example #16
0
        private void LongOperationToUpdateCheckBoxes(object param)
        {
            if (this.TaskUpdateCompleteEvent == null) return;
            Thread.Sleep(2000);

            Object[] paramarray = (Object[])param;
            IEnumerable<TaskItem> tasks = (IEnumerable<TaskItem>)paramarray[0];
            TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(null, false, null);


            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                foreach (TaskItem updated in tasks)
                {
                    TaskItem updatedNew = updated.Clone();
                    updatedNew.TaskName += "updated!";
                    args.UpdatedTasks.Add(updatedNew);
                }
            TaskUpdateCompleteEvent(this, args);
            });
        }
Example #17
0
        /// <summary>
        /// Instructs the provider to update all the tracked Tasks
        /// </summary>
        public void UpdateDirtyTasks()
        {
            if (this.Tasks.DirtyObjects.Count > InitParams.Current.MaxRecordsUpdateableInBatch)
            {
                InvalidOperationException ex = new
                    InvalidOperationException(
                    string.Format(
                        "Cannot perform a bulk update of Tasks when there are more than {0} modified Task items. Please refresh the contents by pressing the Refresh button and select a smaller number of items.",
                        InitParams.Current.MaxRecordsUpdateableInBatch));
                TaskItemUpdateCompleteEventArgs newargs = new TaskItemUpdateCompleteEventArgs(ex, false, null);
                if (this.TaskUpdateCompleteEvent != null)
                {
                    this.TaskUpdateCompleteEvent(this, newargs);
                }
                return;
            }
            if ((this.SelectedView & View.vwAssignedTasks) > 0)
            {
                this.IsUpdating = true;
                this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskCheckBoxUpdationComplete);
                this.Provider.UpdateAssignedTasksCompletionStatus(this.Tasks.DirtyObjects);
                return;
            }

            if ((this.SelectedView & View.vwManagedTasks) > 0)
            {
                this.IsUpdating = true;
                this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskCheckBoxUpdationComplete);
                this.Provider.UpdateManagedTasksSignOff(this.Tasks.DirtyObjects);
                return;
            }


            /*
             * May 24,2010
             * commenting out access control for now
             * because Business would prefer having the flexibility for an user to take ownership of someone else's task
             * 
                        if ((this.SelectedView & View.vwCustomSearch) > 0)
                        {            
                            //verify if the user has rights as an assigned to OR managed user on each of the Tasks being udpated
                            //even if a single Task is not permissible, update nothing.

                            foreach (TaskItem t in this.Tasks.DirtyObjects)
                            {
                                int currentUser = this.wssUserId;
                                if (TaskItem.IsUserManager(currentUser, t) || TaskItem.IsUserInAssignedTo(currentUser, t))
                                {
                                    continue;
                                }
                                else
                                {
                                    string unpermittedtaskmsg = string.Format(
            "The task {0} with with description {1} cannot be updated due to access restrictions. Only an user who is in the Assigned To list or a Manager can udpate a Task. No tasks will be updated",
                                                t.TaskName, t.TaskDescription);
                                    if (this.TaskUpdateCompleteEvent != null)
                                    {
                                        TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs();
                                        args.Errors.Add(unpermittedtaskmsg);
                                        this.TaskUpdateCompleteEvent(this, args);
                                        return;
                                    }
                                    else
                                    {
                                        throw new AccessViolationException(unpermittedtaskmsg);
                                    }
                                }
                            }
                            this.IsUpdating = true;
                            this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskCheckBoxUpdationComplete);
                            this.Provider.UpdateAssignedTasksCompletionStatus(this.Tasks.DirtyObjects);
                        }
            */
            /*reverting to the following, as per discussions on May 24*/
            if ((this.SelectedView & View.vwCustomSearch) > 0)
            {
                int currentUser = this.wssUserId;
                if (this.SearchParams.Manager.IsResolved) //this if condition is deprecated, can be flattened, Sep 13
                {
                    foreach (TaskItem t in this.Tasks.DirtyObjects)
                    {
                        try
                        {
                            ValidationContext ctx = new ValidationContext(t, null, null);
                            Validator.ValidateObject(t, ctx, true);
                        }

                        catch (Exception ex)
                        {
                            TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs();
                            args.Errors.Add(ex.Message);
                            this.TaskUpdateCompleteEvent(this, args);
                            return;

                        }


                    }

                    this.IsUpdating = true;
                    this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskCheckBoxUpdationComplete);
                    this.Provider.UpdateManagedTasksSignOff(this.Tasks.DirtyObjects);
                }
                else
                {
                    //if user is manager , but not in assigned to, then cannot change status of task
                    foreach (TaskItem t in this.Tasks.DirtyObjects)
                    {
                        try
                        {
                            ValidationContext ctx = new ValidationContext(t, null, null);
                            Validator.ValidateObject(t, ctx, true);
                        }

                        catch (Exception ex)
                        {
                            TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs();
                            args.Errors.Add(ex.Message);
                            this.TaskUpdateCompleteEvent(this, args);
                            return;
                        }
                    }

                    this.IsUpdating = true;
                    this.Provider.TaskUpdateCompleteEvent += new TaskUpdateComplete(Provider_TaskCheckBoxUpdationComplete);
                    this.Provider.UpdateAssignedTasksCompletionStatus(this.Tasks.DirtyObjects);
                }
                return;
            }

        }
Example #18
0
 public void LongOperationToUpdateTask(object param)
 {
     TaskItem tSrc = (TaskItem)param;
     Thread.Sleep(2000);
     TaskItemUpdateCompleteEventArgs args = new TaskItemUpdateCompleteEventArgs(null, false, null);
     Deployment.Current.Dispatcher.BeginInvoke(delegate()
     {
         TaskUpdateCompleteEvent(this, args);
     });
 }
        void Current_AttachmentAddedCompleteEvent(object sender, TaskItemUpdateCompleteEventArgs args)
        {

            ViewModel.Current.TaskUpdateCompleteEvent -= Current_AttachmentAddedCompleteEvent;
            if (args.Error != null)
            {
                DialogResult = false; //Oct 13, let the dialog be closed if errored, message box will appear on top
                string customerrormessage = args.Error.GetType() == typeof(System.ServiceModel.CommunicationException) 
                                                ? "Error while adding attachments.This could be because the server timed out or it could be because some file types such as .exe, .dll,etc. are blocked by the web server. Please try again. If the issue persists then please contact support." 
                                                : ViewModel.Current.GetFriendlyMessage (args.Error);

                C1.Silverlight.C1MessageBox.Show(
                    customerrormessage ,
                    Messages.title  ,
                    C1.Silverlight.C1MessageBoxButton.OK,
                    C1.Silverlight.C1MessageBoxIcon.Error);

                return;
            }

            if (args.UpdatedTasks.Count == 0)
            {
                DialogResult = false; //Oct 13, let the dialog be closed if errored, message box will appear on top
                C1.Silverlight.C1MessageBox.Show(
                    "No tasks were updated in this operation!",
                    MainPage.GetMessage("title"),
                    C1.Silverlight.C1MessageBoxButton.OK,
                    C1.Silverlight.C1MessageBoxIcon.Error);

                return;
            }
            DataContext = args.UpdatedTasks[0];
            //the following statement will ensure that the newly edited Task continues to be shown as
            //the highlighted task item
            TasksViewC1.SetSelectedTask(args.UpdatedTasks[0]);  

        }
Example #20
0
        void TaskEditUpdateCompleteEvent(object sender, TaskItemUpdateCompleteEventArgs args)
        {
            this.Provider.TaskUpdateCompleteEvent -= new TaskUpdateComplete(TaskEditUpdateCompleteEvent);
            TaskItemUpdateCompleteEventArgs newargs = new TaskItemUpdateCompleteEventArgs();

            //TaskItemUpdateCompleteEventArgs newargs = args.Clone();
            //if ((args.Error != null) || (args.Cancelled == true))
            //{
            //    if (args.Error != null)
            //        this.Status.Exception = args.Error;
            //    else
            //        this.Status.Message = "The web service operation was cancelled by the user";
            //}
            //else
            //{
            //    Status.Message = string.Format(
            //        "Updated Task '{0}'", args.UpdatedTasks[0].TaskName.Truncate(15)); ;
            //    AddRemoveTaskItem(newargs.UpdatedTasks);

            //    TaskAlerts.AssignedTasksAlerts.BeginUpdate();
            //    TaskAlerts.AssignedTasksAlertsNearFuture.BeginUpdate();
            //    TaskAlerts.ManagedTasksAlerts.BeginUpdate();
            //    TaskAlerts.ManagedTasksAlertsNearFuture.BeginUpdate();
            //    this.TaskAlerts.EvaluateAndAddTasksForAlerts(newargs.UpdatedTasks);
            //    TaskAlerts.AssignedTasksAlerts.EndUpdate();
            //    TaskAlerts.AssignedTasksAlertsNearFuture.EndUpdate();
            //    TaskAlerts.ManagedTasksAlerts.EndUpdate();
            //    TaskAlerts.ManagedTasksAlertsNearFuture.EndUpdate();
            //}

            //if (this.TaskUpdateCompleteEvent != null)
            //{
            this.TaskUpdateCompleteEvent(this, newargs);
            //}
            //this.Refresh(false);
            this.RefreshData(false, true);
            this.IsUpdating = false;
        }
Example #21
0
        void Current_TaskUpdateCompleteEvent(object sender, TaskItemUpdateCompleteEventArgs args)
        {
            BCheck.Data.ViewModel.Current.TaskUpdateCompleteEvent -= new TaskUpdateComplete(Current_TaskUpdateCompleteEvent);
            string message = "";
            if (args.Cancelled == true)
            {
                C1.Silverlight.C1MessageBox.Show("Operation was cancelled. Please try again.", Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error);
                return;
            }
            if (args.Error != null)
            {
                ViewModel.Current.Status.AddToLog(args.Error.ToString(), true);
                //C1.Silverlight.C1MessageBox.Show("Error while updating:\r\n" + args.Error.Message, Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error); //oct 13, simplifying error message
                message = string.Format("Error while updating task(s). {0}", ViewModel.Current.GetFriendlyMessage(args.Error)); //simplify, Oct 13
                C1.Silverlight.C1MessageBox.Show(message, Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error);

                return;
            }

            if (args.Errors.Count != 0)
            {
                message = string.Format("{0} task(s) were not updated.", args.Errors.Count);
                message += "\r\n";
                message += args.Errors[0];
                //ViewModel.Current.Status.StatusItems.Enqueue(new StatusItem { IsError = true, Message = message });
                ViewModel.Current.Status.AddToLog(message, true);
                C1.Silverlight.C1MessageBox.Show(message, Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error);

                return;
            }
            message = string.Format("{0} task(s) were updated successfully", args.UpdatedTasks.Count);
            ViewModel.Current.Status.StatusItems.Enqueue(new StatusItem { IsError = false, Message = message });
            C1.Silverlight.C1MessageBox.Show(message, Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Information);
        }
Example #22
0
        public static void vm_BulkUpdateSelectedTasksCompleteHandler(object sender, TaskItemUpdateCompleteEventArgs args)
        {
            ViewModel vm = ViewModel.Current;
            vm.BulkUpdateHandler -= vm_BulkUpdateSelectedTasksCompleteHandler;
            string message;

            if (args.Cancelled)
            {
                C1MessageBox.Show("Operation was cancelled. Please try again.", Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error);
                return;
            }
            if (args.Error != null)
            {
                vm.Status.AddToLog   (args.Error.ToString() ,true );
                message = vm.GetFriendlyMessage(args.Error); 
                C1MessageBox.Show("Error while updating.\r\n" + message , Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error);
                return;
            }
            if (args.Errors.Count != 0)
            {
                var msg = new StringBuilder();
                msg.Append(args.Error);
                msg.Append("\r\n");
                msg.Append(string.Format("{0} task(s) cannot be updated. Please de-select these Tasks and try again", args.Errors.Count));
                msg.Append ("\r\n");
                foreach (string err in args.Errors)
                {
                    msg.Append("\r\n");
                    msg.Append(err);
                }

                message = msg.ToString ();
                vm.Status.AddToLog(message ,false );
                C1MessageBox.Show(message, "b:)check", C1MessageBoxButton.OK, C1MessageBoxIcon.Error);
                return;
            }
            if (ViewModel.Current.AreTasksReassignedToAssignees == true)
            {
                message = string.Format("{0} task(s) were updated successfully .", args.UpdatedTasks.Count);
                if (args.UpdatedTasks.Count < ViewModel.Current.SelectedTasks.Count())
                {
                    message += "The tasks not updated are still marked as selected. Reason : A task having a single Manager may not have the same user as an Assignee too.";
                }
                ViewModel.Current.AreTasksReassignedToAssignees = false;
                ViewModel.Current.AreTasksReassignedToManagers = false;
                ViewModel.Current.SelectedTasks.ToList().ForEach(seltask => {

                    args.UpdatedTasks.ForEach(task => {

                        if (task.ID == seltask.ID)
                        {
                            task.IsSelected = false;
                        }
                    });

                });

            }
            else if (ViewModel.Current.AreTasksReassignedToManagers == true)
            {
                message = string.Format("{0} task(s) were updated successfully .", args.UpdatedTasks.Count);
                if (args.UpdatedTasks.Count < ViewModel.Current.SelectedTasks.Count())
                {
                    message += "The tasks not updated are still marked as selected. Reason : A task having a single Manager may not have the same user as an Assignee too.";
                }
                ViewModel.Current.AreTasksReassignedToAssignees = false;
                ViewModel.Current.AreTasksReassignedToManagers = false;
                ViewModel.Current.SelectedTasks.ToList().ForEach(seltask =>
                {

                    args.UpdatedTasks.ForEach(task =>
                    {

                        if (task.ID == seltask.ID)
                        {
                            task.IsSelected = false;
                        }
                    });

                });
            }
            else
            {
                message = string.Format("{0} task(s) were updated successfully .", args.UpdatedTasks.Count);
            }
            C1MessageBox.Show(message, Messages.title, C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Information);
        }