public TaskHistoryDialogViewModel() { TaskVersions = new ObservableCollection<bCheckV2.Helpers.Definitions.TaskItem>(); CloseCommand = new RelayCommand(CloseAction); CloseCommand.IsEnabled = true; dataservice = new OpsChecklistDataAgentService(); dataservice.GetTaskHistory(FormatTaskItem(ViewModel.Current.SelectedTask, View.vwAssignedTasks), result => { Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { result.ToList().ForEach(task => TaskVersions.Add(task)); } )); }); }
public Search() { InitializeComponent(); Loaded += Search_Loaded; dataservice = new OpsChecklistDataAgentService(); }
public void UpdateManagedTasksSignOff(IEnumerable<TaskItem> tasks) { OpsChecklistDataAgentService dataservice = new OpsChecklistDataAgentService(); List<bCheckV2.Helpers.Definitions.TaskItem> taskitems = new List<bCheckV2.Helpers.Definitions.TaskItem>(); tasks.ToList().ForEach(t => taskitems.Add(FetchedTasks.Where(ft => ft.UniqueID.ToString() == t.ID1).First())); //FetchedTasks[0].StatusID = 6; //taskitems.Add(FetchedTasks[0]); //tasks.ToList().ForEach(task => { // FetchedTasks.Where(ft => ft.TaskName == task.TaskName).ToList().ForEach(t =>{ // })}); //}); taskitems.ForEach(titem => titem.StatusID = ViewModel.Current.StaticData["ManagementStatus"].Where(mgmtstatus => mgmtstatus.Value == ManagementStatus.APPROVED).First().Key); dataservice.UpdateTasks(taskitems, reply => { if (reply != null) { Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { ViewModel.Current.IsUpdating = false; ViewModel.Current.Refresh(false); })); } else { Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { ViewModel.Current.IsUpdating = false; ViewModel.Current.Refresh(false); })); } }); //string url = this.ConstructUrlParams(IIsAction.UPDATEBULK, null, tasks.Count()); //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 assignedTasksUpdateClient = new BCheck.Data.BCheckLists.ListsSoapClient(bnd, addr); //assignedTasksUpdateClient.UpdateListItemsCompleted += // new EventHandler<BCheck.Data.BCheckLists.UpdateListItemsCompletedEventArgs>(assignedTasksUpdateClient_UpdateListItemsCompleted); //string xmlUdpates = CamlHelper.QueryUpdateManagedTasks(tasks); //XElement updateQuery = XElement.Parse(xmlUdpates); //assignedTasksUpdateClient.UpdateListItemsAsync(InitParams.Current.ListName, updateQuery); }
public void UpdateTasksNotApplicable(IEnumerable<TaskItem> tasks) { OpsChecklistDataAgentService dataservice = new OpsChecklistDataAgentService(); List<bCheckV2.Helpers.Definitions.TaskItem> taskitems = new List<bCheckV2.Helpers.Definitions.TaskItem>(); tasks.ToList().ForEach(t => taskitems.Add(FetchedTasks.Where(ft => ft.UniqueID.ToString() == t.ID1).First())); taskitems.ForEach(titem => titem.StatusID = ViewModel.Current.StaticData["AssigneeStatus"].Where(status => status.Value == AssigneeStatus.NA).First().Key); dataservice.UpdateTasks(taskitems, reply => { if (reply != null) { Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { ViewModel.Current.IsUpdating = false; ViewModel.Current.Refresh(false); })); } else { Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { ViewModel.Current.IsUpdating = false; ViewModel.Current.Refresh(false); })); } }); //string url = ConstructUrlParams(IIsAction.UPDATEBULK, null, tasks.Count()); //var addr = new EndpointAddress(url);//URL params injected, Mar 29 //var bnd = new BasicHttpBinding { MaxBufferSize = InitParams.Current.MaxBufferSize }; //bnd.MaxReceivedMessageSize = bnd.MaxBufferSize; //var changeTaskUsersClient = new BCheckLists.ListsSoapClient(bnd, addr); //changeTaskUsersClient.UpdateListItemsCompleted += // assignedTasksUpdateClient_UpdateListItemsCompleted; //string xmlUdpates = CamlHelper.QueryUpdateTaskNotApplicable(tasks); //XElement updateQuery = XElement.Parse(xmlUdpates); //changeTaskUsersClient.UpdateListItemsAsync(InitParams.Current.ListName, updateQuery); }
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("&", "&"); #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(); }*/ } }