protected override bool OnSaving() { var sourceTask = (ProjectTask)ObjectEntity; if (newTaskOne.ActualWorkHours < sourceTask.Effort || newTaskOne.QuoteWorkHours < sourceTask.ActualInput) { XtraMessageBox.Show(ResourceService.GetString("SplitTaskTip"), ResourceService.GetString("Katrin"), MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return(false); } var entityOne = (ProjectTask)_objectSpace.GetOrNew("ProjectTask", newTaskOne.TaskId, null); entityOne.TaskNumber = newTaskOne.TaskNumber; entityOne.ProjectIterationId = newTaskOne.ProjectIterationId; entityOne.QuoteWorkHours = newTaskOne.QuoteWorkHours; entityOne.ActualWorkHours = newTaskOne.ActualWorkHours; entityOne.Name = newTaskOne.Name; TaskOperator.UpdateTaskStatus(entityOne); bool needCopy = newTaskTwo.TaskId == Guid.Empty?true:false; var entityTwo = (ProjectTask)_objectSpace.GetOrNew("ProjectTask", newTaskTwo.TaskId, null); entityTwo.TaskNumber = newTaskTwo.TaskNumber; entityTwo.ProjectIterationId = newTaskTwo.ProjectIterationId; entityTwo.QuoteWorkHours = newTaskTwo.QuoteWorkHours; entityTwo.ActualWorkHours = newTaskTwo.ActualWorkHours; entityTwo.Name = newTaskTwo.Name; if (needCopy) { entityTwo.Description = entityOne.Description; entityTwo.EndDate = entityOne.EndDate; entityTwo.OwnerId = entityOne.OwnerId; entityTwo.PriorityCode = entityOne.PriorityCode; entityTwo.ProjectId = entityOne.ProjectId; entityTwo.ProjectModuleId = entityOne.ProjectModuleId; entityTwo.StartDate = entityOne.StartDate; entityTwo.TaskCategoryCode = entityOne.TaskCategoryCode; entityTwo.StatusCode = 1; } return(base.OnSaving()); }
public static void Continue() { Task.Run(() => { for (int i = 0; i < MonitorDataBaseModel.IOCommunications.Count; i++) { //此处不用线程,在具体实现中用户采用线程 if (MonitorDataBaseModel.IOCommunications[i].CommunicateDriver != null) { ScadaCommunicateKernel driverDll = (ScadaCommunicateKernel)MonitorDataBaseModel.IOCommunications[i].CommunicateDriver; driverDll.ContinueServer(); } } TaskOperator = TaskOperator.运行; if (OnMonitorOperator != null) { OnMonitorOperator(TaskOperator); } AddLogToMainLog("继续采集服务"); }); }
private bool UpdateTask(TaskTimeHistory task) { var projectTask = new Katrin.Domain.Impl.ProjectTask(); if (taskList.Select(c => c.TaskId).Contains(task.TaskId)) { projectTask = taskList.Where(c => c.TaskId == task.TaskId).First(); } else { projectTask = (Katrin.Domain.Impl.ProjectTask)_objectSpace.GetOrNew("ProjectTask", task.TaskId, null); taskList.Add(projectTask); } projectTask.ActualInput = Convert.ToDouble(projectTask.ActualInput ?? 0) + task.ActualInput; projectTask.Effort = Convert.ToDouble(projectTask.Effort ?? 0) + task.Effort; if (task.TaskTimeHistoryId != Guid.Empty) { projectTask.Effort -= task.SourceEffort; } task.SourceEffort = task.Effort; projectTask.Overtime = Convert.ToDouble(projectTask.Overtime ?? 0) + task.Overtime; if (task.TaskTimeHistoryId == Guid.Empty) { projectTask.Description = projectTask.Description ?? " " + task.Description; } TaskOperator.UpdateTaskStatus(projectTask); if (projectTask.Effort > projectTask.ActualWorkHours) { _newEffortView.ValidateResult = false; XtraMessageBox.Show(StringParser.Parse("OverEffortMessage"), StringParser.Parse("Katrin"), MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return(false); } return(true); }
//metoda odpowiedzialna za zapisywanie zmian w obiekcie (zadaniu) private void SaveChanges(object sender, RoutedEventArgs e) { if (Name.Text.Length >= 3 && Description.Text.Length >= 3) { TaskCreator toChange = TaskOperator.FindTask((int)((Button)sender).Tag); toChange.Name = Name.Text; toChange.Description = Description.Text; toChange.Priority = Priority.Text; toChange.Status = Status.Text; toChange.Date = Date.SelectedDate; DatabaseOperator databaseOperator = new DatabaseOperator(); databaseOperator.UpdateTask(toChange); //TODO sprawdzenie czy dane zostały poprawnie zapisane w bazie Button button = sender as Button; Popup pop = new Popup(); TextBlock popupText = new TextBlock(); popupText.Text = "Zapisano pomyślnie. Możesz zamknąć okno."; popupText.Background = Brushes.Green; popupText.Foreground = Brushes.White; pop.Child = popupText; pop.PlacementTarget = button; pop.IsOpen = true; mainWindow.FillTasksList(TaskOperator.ListOfTasks); } else { if (Name.Text.Length < 3) { Name.Background = Brushes.LightPink; } if (Description.Text.Length < 3) { Description.Background = Brushes.LightPink; } LengthWarning.Visibility = Visibility.Visible; } }
public static void Stop() { Task.Run(() => { try { if (MonitorDataBaseModel.IOCommunications != null) { for (int i = 0; i < MonitorDataBaseModel.IOCommunications.Count; i++) { //此处不用线程,在具体实现中用户采用线程 if (MonitorDataBaseModel.IOCommunications[i].CommunicateDriver != null) { ScadaCommunicateKernel driverDll = (ScadaCommunicateKernel)MonitorDataBaseModel.IOCommunications[i].CommunicateDriver; driverDll.StopServer(); } } } if (MonitorDataBaseModel.IODevices != null) { for (int i = 0; i < MonitorDataBaseModel.IODevices.Count; i++) { MonitorDataBaseModel.IODevices[i].ClearCollectDatas(); } } TaskOperator = TaskOperator.停止; if (OnMonitorOperator != null) { OnMonitorOperator(TaskOperator); } AddLogToMainLog("停止采集服务"); } catch (Exception emx) { ThrowExceptionToMain(emx); } }); }
private bool UpdateTask(Katrin.Domain.Impl.ProjectTask taskEntity, TaskTimeHistory task) { if (taskEntity == null) { return(true); } taskEntity.ActualInput = Convert.ToDouble(taskEntity.ActualInput ?? 0) + task.ActualInput; taskEntity.Effort = Convert.ToDouble(taskEntity.Effort ?? 0) + task.Effort; taskEntity.Overtime = Convert.ToDouble(taskEntity.Overtime ?? 0) + task.Overtime; TaskOperator.UpdateTaskStatus(taskEntity); if (taskEntity.Effort > taskEntity.ActualWorkHours) { _taskEffortView.ValidateResult = false; XtraMessageBox.Show(StringParser.Parse("OverEffortMessage"), StringParser.Parse("Katrin"), MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return(false); } return(true); }
public static void InitMonitor() { commDriverBll = new Scada.Business.SCADA_DRIVER(); //开启日志保存服务 MonitorLogRun(); #region 创建通讯和设备驱动 int num = MonitorDataBaseModel.ProgressMaxNum + 4; //执行方法 #region 读取当前采集站工程数据 try { TaskOperator = TaskOperator.关闭; IOServer = MonitorDataBaseModel.IOServer; //创建驱动模块 for (int i = 0; i < MonitorDataBaseModel.IOCommunications.Count; i++) { if (MonitorDataBaseModel.IOCommunications[i].DriverInfo == null) { AddLogToMainLog("创建通道" + MonitorDataBaseModel.IOCommunications[i].IO_COMM_NAME.ToString() + @"[" + MonitorDataBaseModel.IOCommunications[i].IO_COMM_LABEL + @"]驱动失败,请在采集站中设置该通讯通道驱动!"); continue; } try { if (MonitorDataBaseModel.IOCommunications[i].CommunicateDriver == null) { continue; } else { ((ScadaCommunicateKernel)MonitorDataBaseModel.IOCommunications[i].CommunicateDriver).IsCreateControl = false; } AddLogToMainLog("创建通道" + MonitorDataBaseModel.IOCommunications[i].IO_COMM_NAME.ToString() + @"[" + MonitorDataBaseModel.IOCommunications[i].IO_COMM_LABEL + @"]驱动成功!"); ScadaCommunicateKernel driverDll = (ScadaCommunicateKernel)MonitorDataBaseModel.IOCommunications[i].CommunicateDriver; driverDll.SetUIParameter(MonitorDataBaseModel.IOCommunications[i].IO_COMM_PARASTRING); driverDll.IsCreateControl = false; driverDll.InitKernel(MonitorDataBaseModel.IOServer, MonitorDataBaseModel.IOCommunications[i], MonitorDataBaseModel.IOCommunications[i].Devices, MonitorDataBaseModel.IOCommunications[i].DriverInfo); driverDll.CommunctionClose += CDriverDll_CommunctionClose; driverDll.CommunctionContinue += CDriverDll_CommunctionContinue; driverDll.CommunctionPause += CDriverDll_CommunctionPause; driverDll.CommunctionStart += CDriverDll_CommunctionStart; driverDll.CommunctionStop += CDriverDll_CommunctionStop; driverDll.DeviceSended += CDriverDll_DeviceSended; driverDll.DeviceStatusChanged += CDriverDll_DeviceStatusChanged; driverDll.Exception += CDriverDll_Exception; driverDll.OnDataReceived += CDriverDll_OnDataReceived; driverDll.OnShowFormLog += CDriverDll_OnShowFormLog; AddLogToMainLog("准备创建该通道下的设备驱动....."); for (int d = 0; d < MonitorDataBaseModel.IOCommunications[i].Devices.Count; d++) { Scada.Model.IO_DEVICE device = MonitorDataBaseModel.IOCommunications[i].Devices[d]; try { if (MonitorDataBaseModel.IOCommunications[i].Devices[d].DriverInfo == null) { AddLogToMainLog("创建设备" + device.IO_DEVICE_LABLE.ToString() + @"[" + device.IO_DEVICE_NAME + @"]驱动失败,请在采集站中设置该设备驱动!"); continue; } ((ScadaDeviceKernel)device.DeviceDrive).IsCreateControl = false; ((ScadaDeviceKernel)device.DeviceDrive).ExceptionEvent += CDriverDll_ExceptionEvent; ((ScadaDeviceKernel)device.DeviceDrive).InitKernel(MonitorDataBaseModel.IOServer, MonitorDataBaseModel.IOCommunications[i], device, null, device.DriverInfo); } catch (Exception ex) { ThrowExceptionToMain(new Exception("创建设备" + MonitorDataBaseModel.IOCommunications[i].Devices[d].IO_DEVICE_LABLE.ToString() + @"[" + MonitorDataBaseModel.IOCommunications[i].Devices[d].IO_DEVICE_NAME + @"]驱动失败,!错误原因:" + ex.Message)); } } } catch (Exception ex) { ThrowExceptionToMain(new Exception("ERROR600001" + ex.Message)); } } #endregion //创建垃圾定时回收 ClearMemoryTimer = new System.Threading.Timer(delegate { ClearMemory(); }, null, 1000, 30000); } catch (Exception ex) { ThrowExceptionToMain(new Exception("ERROR600002" + ex.Message)); } #endregion receiveRealCache = new ReceiveRealCache(100, 3000); //批量上传实时数据 receiveRealCache.WillUpload = (List <ReceiveCacheObject> result) => { try { //定时从缓存区上传数据 var analysisTask = Task.Run(() => { RealDataDBUtility.UploadReal(result); }); return(analysisTask); } catch { return(null); } }; ///批量上传报警数据 receiveRealCache.WillUploadAlarm = (List <AlarmCacheObject> result) => { try { //定时从缓存区上传数据 var analysisTask = Task.Run(() => { RealDataDBUtility.UploadAlarm(result); }); return(analysisTask); } catch { return(null); } }; receiveRealCache.Read(); Start(); }
private void SortTasksBy(object sender, RoutedEventArgs e) { string sortBy = ((TextBlock)sender).Tag.ToString(); FillTasksList(TaskOperator.SortTasks(sortBy).ToList()); }
public void ShowTaskDescription(object sender, MouseButtonEventArgs e) { int id = (int)((StackPanel)sender).Tag; TaskDetails.Text = (TaskOperator.FindTask(id).Description); }