Ejemplo n.º 1
0
        public static string QueryCustomSearch(SearchParams searchParam)
        {
            var query = new StringBuilder();
            var criteria = new List<string>();
            if (searchParam.AssignedTo.ResolvedUser != null)
            {
                criteria.Add("<Eq><FieldRef Name='" + ASSIGNTO_COLUMN + "' LookupId='TRUE'/>" +
                    "<Value Type='Integer'>" + searchParam.AssignedTo.ResolvedUser.UserID.ToString() + "</Value></Eq>");
            }
            if (searchParam.Manager.ResolvedUser != null)
            {
                criteria.Add("<Eq><FieldRef Name='" + MANAGER_COLUMN + "' LookupId='TRUE'/>" +
                    "<Value Type='Integer'>" + searchParam.Manager.ResolvedUser.UserID + "</Value></Eq>");
            }
            if (!string.IsNullOrEmpty(searchParam.TaskName))
            {
                criteria.Add("<Contains><FieldRef Name='" + NAME_COLUMN + "'/>" +
                    "<Value Type='Text'>" + searchParam.TaskName + "</Value></Contains>");
            }
            if (searchParam.StartDate != null)
            {
                var d = (DateTime)searchParam.StartDate;
                DateTime dUtc = RegionalSetting.RegionalToUtc(d); //July 8
                criteria.Add("<Geq><FieldRef Name='" + CREATED_COLUMN + "'/><Value Type='DateTime' StorageTZ='TRUE' IncludeTimeValue='TRUE'>" +
                    dUtc.ToString("s") + "</Value></Geq>");
            }
            if (searchParam.EndDate != null)
            {
                var d = (DateTime)searchParam.EndDate;
                //d = d.Add(TimeSpan.FromDays(1));//Aug 2, the end date should not be 1-dec 0000 hrs, rather 1 dec 2359 hrs
                d = d.Add(TimeSpan.FromMinutes(24 * 60 - 1));
                DateTime dUtc = RegionalSetting.RegionalToUtc(d); //July 8
                criteria.Add("<Leq><FieldRef Name='" + CREATED_COLUMN + "'/><Value Type='DateTime' StorageTZ='TRUE' IncludeTimeValue='TRUE'>" +
                    dUtc.ToString("s") + "</Value></Leq>");
            }
            //JIRA - Saved searches
            if (!string.IsNullOrEmpty(searchParam.Functional))
            {
                criteria.Add("<Contains><FieldRef Name='" + FUNCTIONAL_COLUMN + "'/>" +
                    "<Value Type='Text'>" + searchParam.Functional + "</Value></Contains>");
            }
            //JIRA - Saved searches
            if (!string.IsNullOrEmpty(searchParam.BusinessArea) && !searchParam.BusinessArea.Contains("None"))
            {
                criteria.Add("<Contains><FieldRef Name='" + BUSINESS_AREA_COLUMN + "'/>" +
                    "<Value Type='Text'>" + searchParam.BusinessArea + "</Value></Contains>");
            }
            //JIRA - Saved searches
            if ((!string.IsNullOrEmpty(searchParam.Status)) && (!searchParam.Status.Contains("None")))
            {
                criteria.Add("<Eq>" + "<FieldRef Name='" + STATUS_COLUMN + "'/><Value Type='String'>" +
                searchParam.Status + "</Value>" + "</Eq>");
            }

            query.Append("<Query><Where>");
            if (criteria.Count == 1)
            {
                query.Append(criteria[0]);
            }
            else if (criteria.Count == 2)
            {
                query.Append("<And>" + criteria[0] + criteria[1] + "</And>");
            }
            else if (criteria.Count == 3)
            {
                query.Append("<And><And>" + criteria[0] + criteria[1] + "</And>" +
                    criteria[2] + "</And>");
            }
            else if (criteria.Count == 4)
            {
                query.Append("<And><And>" + criteria[0] + criteria[1] + "</And>" +
                    "<And>" + criteria[2] + criteria[3] + "</And></And>");
            }
            else if (criteria.Count == 5)
            {
                query.Append("<And><And><And>" + criteria[0] + criteria[1] + "</And>" +
                    "<And>" + criteria[2] + criteria[3] + "</And></And>" +
                    criteria[4] + "</And>");
            }
            else if (criteria.Count == 6)
            {
                query.Append(
                        @"
                        <And>
                            <And>
                                <And>"
                                    + criteria[0] + criteria[1]
                             + "</And>" +
                                "<And>"
                                + criteria[2] + criteria[3]
                            + "</And>" +
                            "</And>" +
                            "<And>"
                                + criteria[4] + criteria[5] +
                            "</And>" +
                        "</And>"
                        );
            }
            else if (criteria.Count == 7)
            {
                query.Append(
                            @"
                                <And><And>
                                    <And>"
                                        + criteria[0] + criteria[1] +
                                    "</And>" +
                                    "<And>"
                                        + criteria[2] + criteria[3] +
                                    "</And>" +
                                "</And>" +
                                "<And>" +
                                    "<And>"
                                        + criteria[4] + criteria[5] +
                                    "</And>"
                                        + criteria[6] +
                                "</And></And>"
                            );
            }
            else if (criteria.Count == 8)
            {
                query.Append(
                            @"
                                <And><And>
                                    <And>"
                                        + criteria[0] + criteria[1] +
                                    "</And>" +
                                    "<And>"
                                        + criteria[2] + criteria[3] +
                                    "</And>" +
                                "</And>" +
                                "<And>" +
                                    "<And>"
                                        + criteria[4] + criteria[5] +
                                    "</And>" +
                                    "<And>"
                                        + criteria[6] + criteria[7] +
                                    "</And>" +
                                "</And></And>"
                            );
            }
            query.Append("</Where></Query>");
            ViewModel.Current.Status.AddToLog(string.Format("Custom search criteria:{0}", query.ToString()), false);

            return query.ToString();
        }
Ejemplo n.º 2
0
 void ISharePointDataProvider.FetchTasks(View vw, SearchParams param)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
        public string CreateCAMLQuery(View vw, SearchParams paramSearch, UserTasks taskids)
        {
            string queryXml = "";
            string viewFieldsXml = "";

            switch (vw)
            {
                case View.vwOpsChecklistLoad:
                    if (taskids.AssignedTasksDueToday.Count + taskids.AssignedTasksOverdue.Count + taskids.AssignedTasksCompletedApproved.Count + taskids.AssignedTasksNotApplicable.Count + taskids.ManagedTasksDueToday.Count + taskids.ManagedTasksIncomplete.Count + taskids.ManagedTasksCompleted.Count + taskids.ManagedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryMyTasksOnLoad(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwDueToday | View.vwAssignedTasks:
                    if (taskids.AssignedTasksDueToday.Count + taskids.AssignedTasksOverdue.Count + taskids.AssignedTasksCompletedApproved.Count + taskids.AssignedTasksNotApplicable.Count + taskids.ManagedTasksDueToday.Count + taskids.ManagedTasksIncomplete.Count + taskids.ManagedTasksCompleted.Count + taskids.ManagedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryMyTasksOnLoad(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwOverDue | View.vwAssignedTasks:
                    if (taskids.AssignedTasksDueToday.Count + taskids.AssignedTasksOverdue.Count + taskids.AssignedTasksCompletedApproved.Count + taskids.AssignedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryMyTasksOverdue(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwCompletedApproved | View.vwAssignedTasks:
                    if (taskids.AssignedTasksCompletedApproved.Count + taskids.AssignedTasksDueToday.Count + taskids.AssignedTasksOverdue.Count + taskids.AssignedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryMyTasksApprovedComplete(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;


                case View.vwDueToday | View.vwManagedTasks:
                    if (taskids.AssignedTasksDueToday.Count + taskids.AssignedTasksOverdue.Count + taskids.ManagedTasksDueToday.Count + taskids.ManagedTasksIncomplete.Count + taskids.ManagedTasksCompleted.Count + taskids.ManagedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryManagedTasksDueToday(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwOverDue | View.vwManagedTasks:
                    if (taskids.ManagedTasksDueToday.Count + taskids.ManagedTasksIncomplete.Count + taskids.ManagedTasksCompleted.Count + taskids.ManagedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryManagedTasksIncomplete(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwCompletedApproved | View.vwManagedTasks:
                    if (taskids.ManagedTasksCompleted.Count + taskids.ManagedTasksDueToday.Count + taskids.ManagedTasksIncomplete.Count + taskids.ManagedTasksNotApplicable.Count < 400)
                    {
                        queryXml = CamlHelper.QueryManagedTasksCompleted(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwCustomSearch:
                    queryXml = CamlHelper.QueryCustomSearch(paramSearch);
                    viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    break;

                case View.vwArchiveView:
                    // If its the custom search do nothing, we just use the different service to query
                    break;

                case View.vwAssignedTasks | View.vwNotApplicable:
                    if (taskids.AssignedTasksNotApplicable.Count + taskids.AssignedTasksDueToday.Count + taskids.AssignedTasksOverdue.Count + taskids.AssignedTasksCompletedApproved.Count < 400)
                    {
                        queryXml = CamlHelper.QueryAssignedTasksNotApplicable(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                case View.vwManagedTasks | View.vwNotApplicable:
                    if (taskids.ManagedTasksNotApplicable.Count + taskids.ManagedTasksDueToday.Count + taskids.ManagedTasksIncomplete.Count + taskids.ManagedTasksCompleted.Count < 400)
                    {
                        queryXml = CamlHelper.QueryManagedTasksNotApplicable(taskids);
                        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
                    }
                    else
                    {
                        queryXml = "Overload"; //Too many tasks, revert to old solution
                    }
                    break;

                default:
                    queryXml = "";
                    throw new NotImplementedException("this view has not been implemented:" + vw.ToString());
                //break;
            }
            queryXml = queryXml.Replace("&", "&amp;");
            return queryXml;
        }
Ejemplo n.º 4
0
 public void FetchTasks(View vw, SearchParams param)
 {
     view = vw;
     Thread t = new Thread(this.LongOperationToFetchTasks);
     t.Start(vw);
 }
Ejemplo n.º 5
0
        public virtual void FetchTasks(View vw, SearchParams paramSearch)
        {

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

            #region Old CamlCreator

            //switch (vw)
            //{
            //    case View.vwOpsChecklistLoad:
            //        //queryXml = CamlHelper.QueryMyTasksOnLoad();
            //        //viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        queryXml = CamlHelper.QueryMyTasksDueToday();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwDueToday | View.vwAssignedTasks:
            //        queryXml = CamlHelper.QueryMyTasksDueToday();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwOverDue | View.vwAssignedTasks:
            //        queryXml = CamlHelper.QueryMyTasksOverdue();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwCompletedApproved | View.vwAssignedTasks:
            //        queryXml = CamlHelper.QueryMyTasksApprovedComplete();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;


            //    case View.vwDueToday | View.vwManagedTasks:
            //        queryXml = CamlHelper.QueryManagedTasksDueToday();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwOverDue | View.vwManagedTasks:
            //        queryXml = CamlHelper.QueryManagedTasksIncomplete();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwCompletedApproved | View.vwManagedTasks:
            //        queryXml = CamlHelper.QueryManagedTasksCompleted();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwCustomSearch:
            //        queryXml = CamlHelper.QueryCustomSearch(paramSearch);
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwArchiveView:
            //        // If its the custom search do nothing, we just use the different service to query
            //        break;

            //    case View.vwAssignedTasks | View.vwNotApplicable:
            //        queryXml = CamlHelper.QueryAssignedTasksNotApplicable();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    case View.vwManagedTasks | View.vwNotApplicable:
            //        queryXml = CamlHelper.QueryManagedTasksNotApplicable();
            //        viewFieldsXml = CamlHelper.VIEWFIELDS_MYTASKSVERBOSE;
            //        break;

            //    default:
            //        queryXml = "";
            //        throw new NotImplementedException("this view has not been implemented:" + vw.ToString());
            //    //break;
            //}
            //queryXml = queryXml.Replace("&", "&amp;");
            #endregion

            UserTasks taskids = MasterLookupService.Current.GetUserTaskIDs();
            if (vw == View.vwArchiveView || vw == View.vwCustomSearch)
            {
                //int hoursOffset = -12;
                //EndpointAddress addr = new EndpointAddress(ViewModel.OMDQueryAsmxUrl);
                //BasicHttpBinding bnd = new BasicHttpBinding();
                //bnd.ReceiveTimeout = TimeSpan.FromMinutes(6);
                //bnd.SendTimeout = TimeSpan.FromMinutes(6);
                //bnd.OpenTimeout = TimeSpan.FromMinutes(6);
                //bnd.CloseTimeout = TimeSpan.FromMinutes(6);
                //bnd.MaxBufferSize = InitParams.Current.MaxBufferSize;
                //bnd.MaxReceivedMessageSize = bnd.MaxBufferSize;
                //OMDQuerySoapClient omdQuery = new OMDQuerySoapClient(bnd, addr);

                //DateTime? startDate = paramSearch.StartDate;
                //DateTime? endDate = paramSearch.EndDate;

                //if (paramSearch.StartDate != null)
                //    startDate = ((DateTime)paramSearch.StartDate).AddHours(hoursOffset);
                //if (paramSearch.EndDate != null)
                //    endDate = ((DateTime)paramSearch.EndDate).AddDays(1).AddHours(hoursOffset).AddMinutes(-1);

                //omdQuery.QueryTasksCompleted += new EventHandler<BCheck.Data.BCheckOMDQuery.QueryTasksCompletedEventArgs>(omdBridge_QueryTasksCompleted);
                //omdQuery.QueryTasksAsync(ArchiveHelper.GetUserSearchText(paramSearch.AssignedTo), paramSearch.TaskName, ArchiveHelper.GetUserSearchText(paramSearch.Manager),
                //    paramSearch.StartDate, endDate, null);
                TaskFetchCompletedEventArgs args = new TaskFetchCompletedEventArgs();
                args.Tasks = new List<TaskItem>();
                FetchedTasks = new List<bCheckV2.Helpers.Definitions.TaskItem>();
                OpsChecklistDataAgentService opschecklistdataservice = new OpsChecklistDataAgentService();
                opschecklistdataservice.GetArchivedTasks(results =>
                {
                    FetchedTasks.AddRange(results);
                    foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                    {
                        args.Tasks.Add(FormatTaskItem(task, View.vwAssignedTasks));
                    }
                    Deployment.Current.Dispatcher.BeginInvoke(delegate()
                    {
                        FetchTasksCompleteEvent(this, args);
                        return;
                    });

                }, ArchiveHelper.GetUserSearchText(paramSearch.AssignedTo), paramSearch.TaskName, ArchiveHelper.GetUserSearchText(paramSearch.Manager), paramSearch.StartDate.Value.ToString(), paramSearch.EndDate.Value.ToString(), paramSearch.Functional, paramSearch.BusinessArea, paramSearch.Status);
            }
            else if (vw == View.vwCustomSearch)
            {
                string url = this.ConstructUrlParams(IIsAction.QUERY, vw, 0);
                EndpointAddress addr = new EndpointAddress(url);//URL params injected, Mar 29
                BasicHttpBinding bnd = new BasicHttpBinding();
                bnd.ReceiveTimeout = TimeSpan.FromMinutes(6);
                bnd.SendTimeout = TimeSpan.FromMinutes(6);
                bnd.OpenTimeout = TimeSpan.FromMinutes(6);
                bnd.CloseTimeout = TimeSpan.FromMinutes(6);
                bnd.MaxBufferSize = InitParams.Current.MaxBufferSize;
                bnd.MaxReceivedMessageSize = bnd.MaxBufferSize;


                BCheckLists.ListsSoapClient listClient = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr);
                listClient.GetListItemsCompleted += new EventHandler<BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs>(listClient_GetListItemsCompleted);

                XElement query = XElement.Parse(queryXml);

                XElement viewFields = XElement.Parse(viewFieldsXml);

                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();
                listClient.GetListItemsAsync(InitParams.Current.ListName, "", query, viewFields, maxrows, queryOptions, null);
            }
            else
            {
                TaskFetchCompletedEventArgs args = new TaskFetchCompletedEventArgs();
                args.Tasks = new List<TaskItem>();
                FetchedTasks = new List<bCheckV2.Helpers.Definitions.TaskItem>();
                OpsChecklistDataAgentService opschecklistdataservice = new OpsChecklistDataAgentService();
                if (vw == (View.vwAssignedTasks | View.vwDueToday) || vw == View.vwOpsChecklistLoad)
                {
                    opschecklistdataservice.GetAssignedTasksDueToday(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwAssignedTasks));
                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwAssignedTasks | View.vwNotApplicable))
                {
                    opschecklistdataservice.GetAssignedTasksNotApplicable(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwAssignedTasks));
                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwManagedTasks | View.vwNotApplicable))
                {
                    opschecklistdataservice.GetAssignedTasksNotApplicable(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwManagedTasks));
                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwAssignedTasks | View.vwOverDue))
                {
                    opschecklistdataservice.GetAssignedTasksOverdue(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwAssignedTasks));

                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwAssignedTasks | View.vwCompletedApproved))
                {
                    opschecklistdataservice.GetAssignedTasksCompleted(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwAssignedTasks));

                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwManagedTasks | View.vwDueToday))
                {
                    opschecklistdataservice.GetManagedTasksDueToday(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwManagedTasks));

                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwManagedTasks | View.vwOverDue))
                {
                    opschecklistdataservice.GetManagedTasksOverdue(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwManagedTasks));

                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }
                if (vw == (View.vwManagedTasks | View.vwCompletedApproved))
                {
                    opschecklistdataservice.GetManagedTasksApproved(results =>
                    {
                        FetchedTasks.AddRange(results);
                        foreach (bCheckV2.Helpers.Definitions.TaskItem task in results)
                        {
                            args.Tasks.Add(FormatTaskItem(task, View.vwManagedTasks));
                        }
                        Deployment.Current.Dispatcher.BeginInvoke(delegate()
                        {
                            FetchTasksCompleteEvent(this, args);
                            return;
                        });

                    });
                }



                /*
                                string TasksCAMLQuery = CreateCAMLQuery(vw, paramSearch, taskids);
                                if (TasksCAMLQuery != "Overload")
                                {
                                    if (vw == View.vwOpsChecklistLoad || vw == (View.vwDueToday | View.vwAssignedTasks) || vw == (View.vwDueToday | View.vwManagedTasks))
                                    {
                                        TaskFetchCompletedEventArgs args;
                                        TaskAlertsFetchCompletedEventArgs alertargs;
                                        alertargs = new TaskAlertsFetchCompletedEventArgs();
                                        args = new TaskFetchCompletedEventArgs();
                                        args.Tasks = new List<TaskItem>();
                                        alertargs.AssignedTasks = new List<TaskItem>();
                                        alertargs.ManagedTasks = new List<TaskItem>();

                                        MasterLookupService.Current.GetTasksWithDetails(TasksCAMLQuery, tasks =>
                                        {
                                            alertargs.HasAssignedTasks = false;
                                            List<String> assignedtaskidstocheck = new List<String>();
                                            taskids.AssignedTasksDueToday.ForEach(tid => assignedtaskidstocheck.Add(tid));
                                            taskids.AssignedTasksOverdue.ForEach(tid => assignedtaskidstocheck.Add(tid));
                                            taskids.AssignedTasksCompletedApproved.ForEach(tid => assignedtaskidstocheck.Add(tid));
                                            taskids.AssignedTasksNotApplicable.ForEach(tid => assignedtaskidstocheck.Add(tid));
                                            foreach (var taskid in assignedtaskidstocheck)
                                            {
                                                var tasksassigned = tasks.Where(t => t.ID == int.Parse(taskid));
                                                if (tasksassigned.Count() > 0)
                                                {
                                                    TaskItem t = tasksassigned.First();
                                                    t.SetInitializationComplete();
                                                    if ((vw & View.vwAssignedTasks) == View.vwAssignedTasks || vw == View.vwOpsChecklistLoad)
                                                    {
                                                        args.Tasks.Add(t);
                                                    }
                                                    alertargs.AssignedTasks.Add(t);
                                                    alertargs.HasAssignedTasks = true;
                                                }
                                            }

                                            alertargs.HasManagedTasks = false;
                                            List<String> managedtaskstocheck = new List<string>();
                                            taskids.ManagedTasksDueToday.ForEach(tid => managedtaskstocheck.Add(tid));
                                            taskids.ManagedTasksIncomplete.ForEach(tid => managedtaskstocheck.Add(tid));
                                            taskids.ManagedTasksCompleted.ForEach(tid => managedtaskstocheck.Add(tid));
                                            taskids.ManagedTasksNotApplicable.ForEach(tid => managedtaskstocheck.Add(tid));
                                            foreach (var taskid in managedtaskstocheck)
                                            {
                                                var tasksmanaged = tasks.Where(t => t.ID == int.Parse(taskid));
                                                if (tasksmanaged.Count() > 0)
                                                {
                                                    TaskItem t = tasksmanaged.First();
                                                    t.SetInitializationComplete();
                                                    if ((vw & View.vwManagedTasks) == View.vwManagedTasks)
                                                    {
                                                        args.Tasks.Add(t);
                                                    }
                                                    alertargs.ManagedTasks.Add(t);
                                                    alertargs.HasManagedTasks = true;
                                                }
                                            }

                                            Deployment.Current.Dispatcher.BeginInvoke(delegate()
                                            {
                                                FetchTasksCompleteEvent(this, args);
                                                FetchTaskAlertsCompleteEvent(this, alertargs);
                                                return;

                                            });
                                        });
                                    }
                                    else
                                    {

                                        TaskFetchCompletedEventArgs args;
                                        args = new TaskFetchCompletedEventArgs();

                                        //string TasksCAMLQuery = CreateCAMLQuery(vw, paramSearch, taskids);
                                        args.Tasks = new List<TaskItem>();

                                        //Adding tasks which have been returned in the query, the task filtering happens in the CAML helper
                                        MasterLookupService.Current.GetTasksWithDetails(TasksCAMLQuery, tasks =>
                                        {
                                          //  if ((vw == (View.vwOverDue | View.vwAssignedTasks)) || (vw == (View.vwOverDue | View.vwManagedTasks)))
                                            if ((vw & View.vwOverDue) == View.vwOverDue )
                                            {
                                                foreach (var task in tasks)
                                                {
                                                    if (task.CreatedUtc < RegionalSetting.GetRegionalMidnightToUtc())
                                                    {
                                                        task.SetInitializationComplete();
                                                        args.Tasks.Add(task);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                foreach (var task in tasks)
                                                {
                                                    task.SetInitializationComplete();
                                                    args.Tasks.Add(task);
                                                }
                                            }
                                            Deployment.Current.Dispatcher.BeginInvoke(delegate()
                                            {
                                                FetchTasksCompleteEvent(this, args);
                                                return;
                                            });
                                        });
                                    }
                                }
                                else
                                {
                                    string url = this.ConstructUrlParams(IIsAction.QUERY, vw, 0);
                                    EndpointAddress addr = new EndpointAddress(url);//URL params injected, Mar 29
                                    BasicHttpBinding bnd = new BasicHttpBinding();
                                    bnd.ReceiveTimeout = TimeSpan.FromMinutes(6);
                                    bnd.SendTimeout = TimeSpan.FromMinutes(6);
                                    bnd.OpenTimeout = TimeSpan.FromMinutes(6);
                                    bnd.CloseTimeout = TimeSpan.FromMinutes(6);
                                    bnd.MaxBufferSize = InitParams.Current.MaxBufferSize;
                                    bnd.MaxReceivedMessageSize = bnd.MaxBufferSize;


                                    BCheckLists.ListsSoapClient listClient = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr);
                                    listClient.GetListItemsCompleted += new EventHandler<BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs>(listClient_GetListItemsCompleted);

                                    XElement query = XElement.Parse(queryXml);

                                    XElement viewFields = XElement.Parse(viewFieldsXml);

                                    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();
                                    listClient.GetListItemsAsync(InitParams.Current.ListName, "", query, viewFields, maxrows, queryOptions, null);
                                    FetchAlertsForOverLoadCondition();
                                }*/
            }
        }