public CompleteOutput Execute(CompleteInput input) { var output = new CompleteOutput(); // 読み込み対象ファイルの拡張子によって処理を変える var ext = Path.GetExtension(input.FilePath); var taskItems = null as OpenFileOutput.TaskItem[]; if (ext.Equals(".csv")) { // 全レコード変換 taskItems = this.csvReadService.Read(input.FilePath).ToArray(); } else if (ext.Equals(".xlsx")) { // 全レコード変換 taskItems = this.xlsxReadService.Read(input.FilePath).ToArray(); } output.TaskItems = taskItems; output.Tasks = ConvertTaskEntity(taskItems).ToArray(); output.Processes = ConvertProcessEntity(taskItems).ToArray(); output.Functions = ConvertFunctionEntity(taskItems).ToArray(); output.Members = ConvertMemberEntity(taskItems).ToArray(); return(output); }
public void Execute(object parameter) { var sender = parameter as ScheduleSim.ImportTool.Views.ImportPage; var viewModel = sender.DataContext as ImportPageViewModel; // 参照ファイルを取得 var filePath = viewModel.ImportFile; // インポートのモードを取得 var importType = viewModel.ImportType; // 取り込み先を選択 var isImportToPrjSettings = viewModel.IsImportToProjectSettings; var isImportToMembers = viewModel.IsImportToMembers; var isImportToWbs = viewModel.IsImportToWbs; var input = new CompleteInput(); input.FilePath = filePath; try { var output = this.businessLogic.Execute(input); // AppContextに読み込み内容を反映 UpdateContext(this.appContext, importType, isImportToPrjSettings, isImportToMembers, isImportToWbs, output); } catch (Exception ex) { // エラーメッセージを表示 MessageBox.Show(ex.Message, "読み込みエラー", MessageBoxButton.OK, MessageBoxImage.Error); return; } var window = Window.GetWindow(sender); MessageBox.Show("取り込み完了", string.Empty, MessageBoxButton.OK, MessageBoxImage.Information); window.Close(); }
private void FaultEntryProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output) { if (input.Faults != null) { foreach (var fault in input.Faults) { var fe = bill.FaultEntry.FirstOrDefault(x => x.FaultId == fault.FaultId); if (fe == null) { //新增分录 fe = new WorkOrderFaultEntry(); fe.ParentId = bill.Id; fe.FaultId = fault.FaultId; //fe.FaultReasonId = fault.FaultReasonId; //fe.FaultMeasureId = fault.FaultMeasureId; _workOrderFaultEntryRepository.Insert(fe); } } } for (int i = bill.FaultEntry.Count - 1; i >= 0; i--) { var entry = bill.FaultEntry.ElementAt(i); var entryInput = input.Faults.FirstOrDefault(x => x.FaultId == entry.FaultId); if (entryInput != null) { //修改 entry.FaultId = entryInput.FaultId; } else { if (input.Faults == null) { //删除分录 _workOrderFaultEntryRepository.Delete(entry.Id); bill.FaultEntry.Remove(entry); i--; } else { if (entryInput == null) { //删除分录 _workOrderFaultEntryRepository.Delete(entry.Id); bill.FaultEntry.Remove(entry); i--; } } } } }
private void PhotoProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output) { if (input.Photos != null) { foreach (var photo in input.Photos) { var newPhoto = bill.Photos.FirstOrDefault(x => x.FilePath == photo.FilePath); if (newPhoto == null) { //新增分录 newPhoto = new WorkOrderPhoto(); newPhoto.Bill = bill; newPhoto.FilePath = photo.FilePath; _workOrderPhotoRepository.Insert(newPhoto); } } } //删除照片 for (int i = bill.Photos.Count - 1; i >= 0; i--) { WorkOrderPhoto photo = bill.Photos.ElementAt(i); if (input.Photos == null) { //删除分录 _workOrderPhotoRepository.Delete(photo); i--; } else { var photoInput = input.Photos.FirstOrDefault(x => x.FilePath == photo.FilePath); if (photoInput == null) { //删除分录 _workOrderPhotoRepository.Delete(photo); i--; } } } }
private void AccessoryEntryProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output) { if (input.Accessories != null) { //新增 foreach (var accessory in input.Accessories) { var entry = bill.AccessoryEntry.FirstOrDefault(x => x.AccessoryId == accessory.AccessoryId); if (entry == null) { entry = new WorkOrderAccessoryEntry(); entry.AccessoryId = accessory.AccessoryId; entry.Count = accessory.Count; entry.NewSerials = entry.OldSerials; entry.BillId = bill.Id; Accessory accessoryEntity = _accessoryRepository.Get(accessory.AccessoryId); _workOrderAccessoryEntryRepository.Insert(entry); int currentCount = _inventoryDomainService.GetAccessoryCountByUser(bill.AssignedPerson, accessoryEntity); if (currentCount >= entry.Count) { //扣减库存 _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, entry.Accessory, entry.Count * (-1)); } else { //库存不足 output.Successed = false; string msg = string.Format("配件【{0}】持有量不足,缺少{1}{2}\r\n", entry.Accessory.Name, entry.Count - currentCount, entry.Accessory.Unit); output.Error = output.Error + msg; } } } } //删除分录 for (int i = bill.AccessoryEntry.Count - 1; i >= 0; i--) { WorkOrderAccessoryEntry accessoryEntry = bill.AccessoryEntry.ElementAt(i); if (input.Accessories == null) { //增加配件持有数量 _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count); //删除分录 _workOrderAccessoryEntryRepository.Delete(accessoryEntry); i--; } else { var entryInput = input.Accessories.FirstOrDefault(x => x.AccessoryId == accessoryEntry.AccessoryId); if (entryInput == null) { //增加配件持有数量 _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count); //删除分录 _workOrderAccessoryEntryRepository.Delete(accessoryEntry); i--; } else { //增加配件持有数量 _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count); //检查库存量 int currentCount = _inventoryDomainService.GetAccessoryCountByUser(bill.AssignedPerson, accessoryEntry.Accessory); if (currentCount >= entryInput.Count) { //更新分录 accessoryEntry.Count = entryInput.Count; accessoryEntry.NewSerials = entryInput.NewSerials; accessoryEntry.OldSerials = entryInput.OldSerials; //扣减 _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count * (-1)); } else { //库存不足 output.Successed = false; string msg = string.Format("配件【{0}】持有量不足,缺少{1} {2}\r\n", accessoryEntry.Accessory.Name, accessoryEntry.Count - currentCount, accessoryEntry.Accessory.Unit); output.Error = output.Error + msg; } //i--; } } } }
/// <summary> /// 完工回单 /// </summary> /// <param name="input"></param> /// <returns></returns> public void Complete(CompleteInput input) { CompleteOutput output = new CompleteOutput() { Successed = true }; var bill = _workOrderManager.Get(input.BillId); var archive = _equipmentArchiveAppService.GetArchiveBySerialNo(bill.SerialNo); if (bill.ServiceType.Equals(ServiceType.Install)) { if (archive != null) { throw new UserFriendlyException("序列号已存在"); } } else { if (archive == null) { throw new UserFriendlyException("序列号不存在"); } } //记录回单活动 if (bill.BillStatus == BillStatus.Dispatch) { var user = AsyncHelper.RunSync(() => UserManager.GetUserByIdAsync(UserManager.AbpSession.UserId.Value)); var reportActivity = new Activity() { Bill = bill, Operater = user, Name = "回单", Log = string.Format("服务人员【{0}】已将问题处理完毕。", user.Name) }; _workOrderManager.AddActivity(reportActivity); } //回单基本信息 bill.SerialNo = input.SerialNo; bill.Office = input.Office; bill.OfficeMobile = input.OfficeMobile; bill.OfficePerson = input.OfficePerson; bill.OfficePosition = input.OfficePosition; bill.OfficeTel = input.OfficeTel; bill.Warrenty = input.Warrenty; bill.ServiceTime = input.ServiceTime; bill.Dealfa = input.Dealfa; bill.Faultap = input.Faultap; //处理图片 PhotoProcess(input, bill, output); //完工 _workOrderManager.Complete(bill); if (!output.Successed) { throw new UserFriendlyException(output.Error); } if (!string.IsNullOrEmpty(bill.YUNMsg)) { //云办公已办 string bootURL = ConfigurationManager.AppSettings["bootURL"]; string pubKey = ConfigurationManager.AppSettings["pubKey"]; string no = ConfigurationManager.AppSettings["no"]; string pub = ConfigurationManager.AppSettings["pub"]; string time = DateTime.Now.CurrentTimeMillis().ToString(); string nonce = Guid.NewGuid().ToString(); string appID = ConfigurationManager.AppSettings["appID"]; //轻应用注册到云之家时生成 string appSecret = ConfigurationManager.AppSettings["appSecret"]; //轻应用注册到云之家时生成 string yunxt = ConfigurationManager.AppSettings["yunxt"]; YUNAPI.YUNXT = yunxt; string pubtoken = YUNAPI.CreatePubToken(no, pub, pubKey, nonce, time); var message = new { no = no, pub = pub, time = time, nonce = nonce, pubtoken = pubtoken, todoMsgIds = bill.YUNMsg, todoStatus = YUNAPI.TODOSTAUS_DONE, account = bill.AssignedPerson.UserName }; try { AsyncHelper.RunSync(() => YUNAPI.ChangeTodoMsgStatus(JsonConvert.SerializeObject(message))); } catch { } } }