public bool GetTechnologyProblemClass(ref TechnologyProblemClass tpr, bool refreshClass = false) { bool isFill = false; if (_tpr == null || refreshClass) { _tpr = new TechnologyProblemClass(App.ConnectionInfo.ConnectionString); isFill = true; } tpr = _tpr; return(isFill); }
private void Change() { var taskName = TaskName.Text; var taskDescription = TaskDescription.Text; if (IsDeadLineEnable.IsChecked.HasValue && IsDeadLineEnable.IsChecked.Value) { if (DeadLineDate.SelectedDate.HasValue) { var deadLineDate = DeadLineDate.SelectedDate.Value; _taskClass.Tasks.Change(_taskId, taskName, taskDescription, true, deadLineDate); } } else { _taskClass.Tasks.Change(_taskId, taskName, taskDescription); } // Add new performers foreach (var workerId in _newPerformers.Select(newPerformer => newPerformer.WorkerID)) { _taskClass.AddNewPerformer(_taskId, (int)workerId); NotificationManager.AddNotification((int)workerId, AdministrationClass.Modules.TasksPage, _taskId); } // Add new observers foreach (var workerId in _newObservers.Select(newObserver => newObserver.WorkerID)) { _taskClass.AddNewObserver(_taskId, (int)workerId); } // Delete performers foreach (var performerId in from deletedPerformer in _deletedPerformers select deletedPerformer.WorkerID into workerId select _taskClass.Performers.Table.Select("TaskID = " + _taskId + " AND WorkerID = " + workerId) into performers where performers.Any() select performers.First() into performer select Convert.ToInt32(performer["PerformerID"])) { _taskClass.DeletePerformer(performerId); } // Delete observers foreach (var observerId in from deletedObserver in _deletedObservers select deletedObserver.WorkerID into workerId select _taskClass.Observers.Table.Select("TaskID = " + _taskId + " AND WorkerID = " + workerId) into obserbers where obserbers.Any() select obserbers.First() into observer select Convert.ToInt32(observer["ObserverID"])) { _taskClass.DeleteObserver(observerId); } // Set task as completed if all workers allready has finished task if (_taskClass.Performers.Table.AsEnumerable().Where(p => p.Field <Int64>("TaskID") == _taskId) .All(p => p.Field <bool>("IsComplete"))) { var currentDate = App.BaseClass.GetDateFromSqlServer(); _taskClass.Tasks.EndTask(_taskId, currentDate); var tasks = _taskClass.Tasks.Table.AsEnumerable().Where(r => r.Field <Int64>("TaskID") == _taskId); if (tasks.Any()) { var task = tasks.First(); var senderAppId = Convert.ToInt32(task["SenderAppID"]); var mainWorkerId = Convert.ToInt32(task["MainWorkerID"]); var globalId = task["GlobalID"].ToString(); switch ((TaskClass.SenderApplications)senderAppId) { case TaskClass.SenderApplications.ServiceDamage: { ServiceEquipmentClass servEquipClass = null; App.BaseClass.GetServiceEquipmentClass(ref servEquipClass); if (servEquipClass != null) { servEquipClass.FillCompletionInfo(globalId, currentDate, mainWorkerId, null); AdministrationClass.AddNewAction(10); } break; } case TaskClass.SenderApplications.TechnologyProblem: { TechnologyProblemClass techProblemClass = null; App.BaseClass.GetTechnologyProblemClass(ref techProblemClass); if (techProblemClass != null) { techProblemClass.FillCompletionInfo(globalId, currentDate, mainWorkerId); } break; } case TaskClass.SenderApplications.PlannedWorks: { PlannedWorksClass plannedWorksClass = null; App.BaseClass.GetPlannedWorksClass(ref plannedWorksClass); if (plannedWorksClass != null) { plannedWorksClass.FinishPlannedWorks(_taskId); } break; } } } } var mainWindow = Window.GetWindow(this) as MainWindow; if (mainWindow != null) { var taskPage = mainWindow.MainFrame.Content as XamlFiles.TaskPage; if (taskPage != null) { var taskViewModel = taskPage.DataContext as TasksViewModel; if (taskViewModel != null) { taskViewModel.UpdateTaskView(); taskViewModel.SelectTask(_taskId); } } var servEquipPage = mainWindow.MainFrame.Content as XamlFiles.ServiceEquipmentPage; if (servEquipPage != null) { servEquipPage.RefillInfo(); } var techProblemPage = mainWindow.MainFrame.Content as XamlFiles.TechnologyProblemPage; if (techProblemPage != null) { techProblemPage.ChangeReceivedNotes(taskDescription); techProblemPage.RefillInfo(); } } }