Ejemplo n.º 1
0
        void ISharePointDataProvider.FetchBusinessAreas()
        {
            string url = ViewModel.OrgStructureUrl;
            EndpointAddress addr = new EndpointAddress(url);
            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;

            string queryXml = CamlHelper.QueryBusinessAreasFromList();
            string viewFieldsXml = CamlHelper.VIEWFIELDS_BUSINESSAREAS;

            BCheckLists.ListsSoapClient listClient = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr);
            listClient.GetListItemsCompleted += new EventHandler<BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs>(listClient_GetListItemsOrgCompleted);
            XElement query = XElement.Parse(queryXml);
            XElement viewFields = XElement.Parse(viewFieldsXml);

            string queryOptionsXml = "<QueryOptions><DateInUtc>FALSE</DateInUtc><IncludeAttachmentUrls>FALSE</IncludeAttachmentUrls><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>";

            XElement queryOptions = XElement.Parse(queryOptionsXml);
            string maxrows = "1000";
            listClient.GetListItemsAsync(InitParams.Current.OrgListName, "", query, viewFields, maxrows, queryOptions, null);
        }
Ejemplo n.º 2
0
        public void FetchAlertsForOverLoadCondition()
        {
            string url = this.ConstructUrlParams(IIsAction.ALERTS, 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;

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

            string queryXml = CamlHelper.QueryMyTasksDueToday(); ;
            XElement query = XElement.Parse(queryXml);

            string viewFieldsXml = CamlHelper.VIEWFIELDS_ASSIGNEDTASKSALERTS;
            XElement viewFields = XElement.Parse(viewFieldsXml);
            string queryOptionsXml = "<QueryOptions><DateInUtc>TRUE</DateInUtc></QueryOptions>";
            XElement queryOptions = XElement.Parse(queryOptionsXml);

            taskAlertsClientAssignedTasks.GetListItemsAsync(InitParams.Current.ListName, "", query, viewFields, "150", queryOptions, null);

            //fetch maanged tasks alerts
            BCheckLists.ListsSoapClient taskAlertsClientManagedTasks = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr);
            taskAlertsClientManagedTasks.GetListItemsCompleted += new EventHandler<BCheck.Data.BCheckLists.GetListItemsCompletedEventArgs>(taskAlertsClientManagedTasks_GetListItemsCompleted);
            viewFieldsXml = CamlHelper.VIEWFIELDS_MANAGEDTASKSALERTS;
            queryXml = CamlHelper.QueryManagedTaskAlertsDueToday();
            query = XElement.Parse(queryXml);
            taskAlertsClientManagedTasks.GetListItemsAsync(InitParams.Current.ListName, "", query, viewFields, "150", queryOptions, null);
        }
Ejemplo n.º 3
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();
                                }*/
            }
        }