public ActionResult SetCustomerVisibility(Guid inspectionItemId, Guid imageId, [FromBody] bool isVisibleToCustomer) { var inspectionItemInDb = _context.InspectionItems .Include(item => item.InspectionImages) .SingleOrDefault(item => item.Id == inspectionItemId); if (inspectionItemInDb == null) { return(NotFound()); } var inspectionImage = inspectionItemInDb.InspectionImages.SingleOrDefault(ii => ii.Id == imageId); if (inspectionImage == null) { return(NotFound()); } return(InspectionService.UpdateInspectionImageVisibility( _context, inspectionImage, isVisibleToCustomer) ? NoContent() : StatusCode(500)); }
public ActionResult GetInspectionByAddressParts(string searchText, string unitNumber, string streetNumber, string streetAddress, string subLocality, string suburb, string city, string state, string country, string postalCode) { HttpClient httpClient = null; try { httpClient = GetHttpClient(); var inspections = InspectionService.QueryInspectionByAddressParts(GetHttpClient(), searchText, unitNumber, streetNumber, streetAddress, subLocality, suburb, city, state, country, postalCode); return(Json(inspections, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogService.LogMessage(httpClient, new Log() { Level = (int)LogType.Error, Name = ex.Message, FunctionName = this.GetType().Name + " | " + MethodBase.GetCurrentMethod().Name, Message = ex.InnerException != null ? ex.InnerException.Message : ex.Message }); return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } }
public InspectionDetailService(SQLiteConnection conn) { inspectionService = new InspectionService(conn); inspectionTransactionService = new InspectionTransactionService(conn); optionimgService = new OptionImageService(conn); this.conn = conn; }
public InspectionTransactionService(SQLiteConnection conn) { this.conn = conn; inspectionTransactionRepository = RepositoryFactory <InspectionTransactionDO> .GetRepository(conn); inspectionService = new InspectionService(conn); }
private void ComboBox_DropDownClosed(object sender, EventArgs e) { string s = comboBox1.Text; ComboBox cmb = sender as ComboBox; if (s != "Make Selection...") { InspectionService inspectionService = new InspectionService(); var Manholes = inspectionService.GetManholeByDrainageArea(s); List <Author> authors = new List <Author>(); foreach (var manhole in Manholes) { authors.Add(new Author() { Manhole = manhole }); } dataGrid1.ItemsSource = authors; } else { dataGrid1.ItemsSource = null; } }
/// <summary> /// Get confirm informartion /// </summary> /// <returns></returns> public BookRepair_ConfirmInfoModel GetConfirmBookInfo() { // get product info var prodS = new ProductService(_dataContext); var product = prodS.GetGeneralInfo(prodS.GetModelId()); //product.add //get repair info var custS = new CustomerService(_dataContext); var inspS = new InspectionService(_dataContext); var inspection = inspS.GetGeneralinspectionInfoFromSession(); product.Additionalfields = inspection; var customer = custS.GetGeneralCustomerInfoFromSession(); var result = new BookRepair_ConfirmInfoModel(); // get agent info var agent = GetAgentRepairInfo(); // set values result.AgentInfo.Address = agent.Address; result.AgentInfo.CollectionInfo = agent.CollectionInfo; result.AgentInfo.EngineerId = agent.EngineerId; result.AgentInfo.ExtraInfo = agent.ExtraInfo; result.AgentInfo.Name = agent.Name; result.AgentInfo.NextStep = agent.NextStep; result.AgentInfo.OpeningHours = agent.OpeningHours; result.AgentInfo.Postcode = agent.Postcode; result.AgentInfo.TelephoneNumber = agent.TelephoneNumber; result.AgentInfo.BookingUrl = agent.BookingUrl; result.AgentInfo.InHomeAvailable = agent.InHomeAvailable; // set customer info result.CustomerInfo.CustomerId = customer.CustomerId; result.CustomerInfo.Address1 = customer.Address1; result.CustomerInfo.Address2 = customer.Address2; result.CustomerInfo.Address3 = customer.Address3; result.CustomerInfo.CustomerName = customer.CustomerName; result.CustomerInfo.PostCode = customer.PostCode; // set product info result.ProductInfo.ItemNumber = product.ItemNumber; result.ProductInfo.Description = product.Description; result.ProductInfo.OriginalCondition = product.OriginalCondition; result.ProductInfo.SerialNumber = product.SerialNumber; result.ProductInfo.TransactionInfo = product.TransactionInfo; result.ProductInfo.DateOfPurchase = product.DateOfPurchase; result.ProductInfo.ItemCode = product.ItemCode; result.ProductInfo.Additionalfields = inspection; // update info in sssion var repairState = _bookStateHolder.Load(); repairState.EngineerId = result.AgentInfo.EngineerId; // repairState.Appointmentdate = _bookStateHolder.; repairState.NextStep = result.AgentInfo.NextStep; _bookStateHolder.UpdateFrom(repairState); result.SelectedAppointment = repairState.AppointmentDate; return(result); }
public JsonResult CreateInspectionDetails(List <Inspection> inspectionDetails) { HttpClient httpClient = null; try { httpClient = GetHttpClient(); var newInspectionDetailIds = new List <Guid>(); foreach (var inspectionDetail in inspectionDetails) { var newInspectionDetailId = InspectionService.CreateInspection(httpClient, inspectionDetail); newInspectionDetailIds.Add(newInspectionDetailId); } return(Json(newInspectionDetailIds, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogService.LogMessage(httpClient, new Log() { Level = (int)LogType.Error, Name = ex.Message, FunctionName = this.GetType().Name + " | " + MethodBase.GetCurrentMethod().Name, Message = ex.InnerException != null ? ex.InnerException.Message : ex.Message }); return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } }
public TransportServiceImpl(TransportDAO transportDAO, InspectionService inspectionService, BatchService batchService, VehicleService vehicleService) { this.transportDAO = transportDAO; this.inspectionService = inspectionService; this.batchService = batchService; this.vehicleService = vehicleService; }
public void Setup() { defibrillatorRepository = new Mock <IDefibrillatorRepository>(); defibrillator = new Mock <Defibrillator>(); defibrillatorRepository.Setup(repo => repo.FindBySerialNumber(SERIAL_NUMBER)).Returns(defibrillator.Object); inspectionService = new InspectionService(defibrillatorRepository.Object); }
public void Setup() { var options = new DbContextOptionsBuilder <ApplicationContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; _tenantService = new Mock <ITenantService>().Object; _applicationContext = new ApplicationContext(options, _tenantService); _sut = new InspectionService(_applicationContext); }
public JsonResult Report(Guid id, bool grouped = false, bool includeUnknown = false) { var imageBaseUrl = $"{this.Request.Scheme}://{this.Request.Host}"; // TODO: DJC this looks supiciously wrong... Investigate var inspectionItems = InspectionService.GetInspectionItems(_context) .Single(i => i.Id == id) .InspectionItems; return(InspectionService.BuildInspectionReport(_context, imageBaseUrl, inspectionItems, grouped, includeUnknown)); }
public Inspection1PageViewModel( INavigator navigator, InspectionService inspectionService) { this.navigator = navigator; this.inspectionService = inspectionService; BackCommand = MakeAsyncCommand(Back); NextCommand = MakeAsyncCommand(Next, () => selected.Value != null).Observe(selected); SelectCommand = new DelegateCommand <SelectableItem <InspectionStatusEntity> >(Select); }
/// <summary> /// Get job info /// </summary> /// <returns>Return model</returns> public BookRepair_JobModel GetJobInfo() { var book = _bookStateHolder.Load(); var Inspection = new InspectionService(_dataContext); var result = new BookRepair_JobModel(); var store = new StoreService(_dataContext); // if mandatory fields are null and service id is exist, then load from DB if ((book.FaultDescr == null) && (book.DateOfPurchase == null) && (book.ServiceId.HasValue)) { result = _reporsitory.GetAcceptingJobInfo(book.ServiceId ?? 0); //book.AcceptJobFlag = false; _bookStateHolder.UpdateFrom(book); } // if normal booking process, then get info from session //if (!book.AcceptJobFlag) else { var product = new ProductService(_dataContext); var prodInfo = product.GetGeneralInfoFromSession(); result.SerialNumber = prodInfo.SerialNumber; result.ItemCondition = prodInfo.OriginalCondition; result.DateOfPurchase = prodInfo.DateOfPurchase; result.StoreNumber = book.StoreNumber;// == null ?store.GetStoreId().ToString(): book.StoreNumber; result.TillNumber = book.TillNumber; result.TransNumber = prodInfo.TransactionInfo; result.SelectedType = book.Type; result.FaultDescr = book.FaultDescr; result.EngineerId = book.EngineerId; result.DateOfPurchaseString = book.DateOfPurchaseString; result.AdditionalFields = book.FieldsForInspection == null?Inspection.GetSpecificInspection() : book.FieldsForInspection; //prodInfo.Additionalfields } // result.AdditionalFields = book.FieldsForInspection == null ? Inspection.GetSpecificInspection() : book.FieldsForInspection; result.Type = GetJobTypesList(); // result.AdditionalFields = Inspection.GetSpecificInspection(); result.AppointmentDate = book.AppointmentDate; //result.StoreCollection = book.StoreCollection; result.OnlineBookingFailed = book.OnlineBookingFailed; var repairAgent = GetAgentRepairInfo(); result.BookingUrl = repairAgent.BookingUrl; result.InHomeAvailable = repairAgent.InHomeAvailable; if (!string.IsNullOrEmpty(repairAgent.BookingUrl)) { result.StoreCollection = book.StoreCollection;// !repairAgent.InHomeAvailable ? true : } return(result); }
public ActionResult SetCustomerConcern(Guid id, [FromBody] bool isCustomerConcern) { var inspectionItemInDb = _context.InspectionItems.SingleOrDefault(item => item.Id == id); if (inspectionItemInDb == null) { return(NotFound()); } return(InspectionService.UpdateIsCustomerConcern(_context, inspectionItemInDb, isCustomerConcern) ? NoContent() : StatusCode(500)); }
public ActionResult SetItemNotes(Guid id, [FromBody] string notes) { var inspectionItemInDb = _context.InspectionItems.SingleOrDefault(item => item.Id == id); if (inspectionItemInDb == null) { return(NotFound()); } return(InspectionService.UpdateInspectionItemNote(_context, inspectionItemInDb, notes) ? NoContent() : StatusCode(500)); }
public ActionResult SetCondition(Guid id, Condition condition) { var inspectionItemInDb = _context.InspectionItems.SingleOrDefault(item => item.Id == id); if (inspectionItemInDb == null) { return(NotFound()); } return(InspectionService.UpdateInspectionItemCondition(_context, inspectionItemInDb, TypeSafeEnum.FromValue <Models.Inspections.InspectionItemCondition>((int)condition)) ? NoContent() : StatusCode(500)); }
public Page1() { InitializeComponent(); InspectionService inspectionService = new InspectionService(); List <string> DrainageAreas = new List <string>(); DrainageAreas.Add("Make Selection..."); comboBox1.SelectedIndex = 0; DrainageAreas.AddRange(inspectionService.GetDrainageAreas()); comboBox1.ItemsSource = DrainageAreas; }
public ActionResult Delete(string id) { var inspection = _context.Inspections.SingleOrDefault(i => i.WorkOrderId == id); if (inspection == null) { return(NoContent()); } var webRootPath = _env.WebRootPath; var wasSuccessful = InspectionService.DeleteInspection(_context, inspection, webRootPath); return(wasSuccessful ? NoContent() : StatusCode(500)); }
/// <summary> /// 查看巡查信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <param name="employeeName">人员名字</param> /// <param name="time">巡查时间</param> /// <returns></returns> public InspectInfo CheckInspectInfo(string taskNumber, string employeeName, DateTime time) { var inspectionService = new InspectionService(); var inspectionExceptionService = new InspectionExceptionService(); var exceptionService = new ExceptionTypeService(); task task = new TaskService().FindByTaskNumber(taskNumber); var checkInspectInfo = new InspectInfo(); checkInspectInfo.InspectDetail = new List<InspectDetail>(); checkInspectInfo.TaskNumber = taskNumber; checkInspectInfo.EmployeeName = employeeName; if (task != null) { foreach ( inspection inspectionItem in inspectionService.FindByTaskId(task.Id).OrderByDescending(m => m.Time).Where( m => m.employee.Name.Equals(employeeName))) { if (!time.Date.Equals(inspectionItem.Time.Date)) continue; List<inspection_exception> exceptionList = inspectionExceptionService.FindByInspectionId(inspectionItem.Id); if (exceptionList.Count > 0) foreach (var exceptionItem in inspectionExceptionService.GetPigstyInfoNums(inspectionItem)) { checkInspectInfo.InspectDetail.Add(new InspectDetail { PigHouse = inspectionItem.pig_house.pig_house_type.Name + inspectionItem.pig_house.Number, Pigsty = exceptionItem.Value, DetailTime = inspectionItem.Time, InspectionException = exceptionService.Find(exceptionItem.Key).Name }); } else checkInspectInfo.InspectDetail.Add(new InspectDetail { PigHouse = inspectionItem.pig_house.pig_house_type.Name + inspectionItem.pig_house.Number, Pigsty = "", DetailTime = inspectionItem.Time, InspectionException = "正常" }); } return checkInspectInfo; } return null; }
public ActionResult ReportForOrder(string id, bool grouped = false, bool includeUnknown = false) { var imageBaseUrl = $"{this.Request.Scheme}://{this.Request.Host}"; var inspectionItems = InspectionService.GetInspectionItems(_context) .SingleOrDefault(i => i.WorkOrderId == id) ?.InspectionItems; if (inspectionItems == null) { return(NotFound()); } return(InspectionService.BuildInspectionReport(_context, imageBaseUrl, inspectionItems, grouped, includeUnknown)); }
public ActionResult SetMeasurements(Guid id, [FromBody] IEnumerable <UpdateInspectionMeasurementRequest> measurementUpdates) { var inspectionItemInDb = _context.InspectionItems.SingleOrDefault(item => item.Id == id); if (inspectionItemInDb == null) { return(NotFound()); } return(InspectionService.UpdateInspectionItemMeasurements( _context, measurementUpdates) ? NoContent() : StatusCode(500)); }
public ActionResult SetCannedResponses(Guid id, [FromBody] IEnumerable <Guid> selectedCannedResponseIds) { var inspectionItemInDb = _context.InspectionItems .Include(ii => ii.InspectionItemCannedResponses) .ThenInclude(iicr => iicr.CannedResponse) .SingleOrDefault(item => item.Id == id); if (inspectionItemInDb == null) { return(NotFound()); } return(InspectionService.UpdateInspectionItemCannedResponses(_context, inspectionItemInDb, selectedCannedResponseIds.ToList()) ? NoContent() : StatusCode(500)); }
public Inspection2PageViewModel( INavigator navigator, IDialogService dialogService, ISettingService settingService, InspectionService inspectionService, Session session) { this.navigator = navigator; this.dialogService = dialogService; this.inspectionService = inspectionService; UserId.Value = session.UserId; TerminalNo.Value = settingService.GetTerminalNo(); BackCommand = MakeAsyncCommand(Back); NextCommand = MakeAsyncCommand(Next); EditCommand = MakeAsyncCommand <InspectionEntity>(Edit); }
public InspectionRecievePageViewModel( INavigator navigator, IDialogService dialogService, ILoadingService loadingService, ISettingService settingService, INetworkClient networkClient, InspectionService inspectionService) { this.navigator = navigator; this.dialogService = dialogService; this.loadingService = loadingService; this.settingService = settingService; this.networkClient = networkClient; this.inspectionService = inspectionService; BackCommand = MakeAsyncCommand(Back); RecieveCommand = MakeAsyncCommand(Recieve, () => selectedCount.Value > 0).Observe(selectedCount); SelectCommand = new DelegateCommand <SelectableItem <StorageResponseEntry> >(Select); }
public InspectionSendPageViewModel( INavigator navigator, IDialogService dialogService, ILoadingService loadingService, ISettingService settingService, INetworkClient networkClient, InspectionService inspectionService, Session session) { this.navigator = navigator; this.dialogService = dialogService; this.loadingService = loadingService; this.settingService = settingService; this.networkClient = networkClient; this.inspectionService = inspectionService; this.session = session; BackCommand = MakeAsyncCommand(Back); SendCommand = MakeAsyncCommand(Send, () => Entities.Count > 0).Observe(Entities); }
public ActionResult Upload(Guid inspectionItemId, IFormFile image) { var inspectionItemInDb = _context.InspectionItems .Include(ii => ii.Inspection) .SingleOrDefault(item => item.Id == inspectionItemId); if (inspectionItemInDb == null) { return(NotFound()); } var workOrderId = inspectionItemInDb.Inspection.WorkOrderId; // New guid is used as a random prefix to the filename to ensure uniqueness Image imageDto = ImageService.SaveImage(image, new[] { ImageDirectory, workOrderId, inspectionItemId.ToString() }, Guid.NewGuid().ToString(), false); return(InspectionService.AddInspectionItemImage(_context, inspectionItemInDb, imageDto) ? NoContent() : StatusCode(500)); }
public InspectionServiceTests() { // Setup database mock _dbMock = new Mock <FestispecContext>(); _modelMocks = new ModelMocks(); // Setup add mock _dbMock.Setup(x => x.PlannedInspections.Add(It.IsAny <PlannedInspection>())) .Returns((PlannedInspection u) => u); // Mock accounts _dbMock.Setup(x => x.PlannedInspections) .Returns(MockHelpers.CreateDbSetMock(new ModelMocks().PlannedInspections).Object); _dbMock.Setup(x => x.Festivals).Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Festivals).Object); _dbMock.Setup(x => x.Questionnaires) .Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Questionnaires).Object); _dbMock.Setup(x => x.Employees).Returns(MockHelpers.CreateDbSetMock(new ModelMocks().Employees).Object); // Create InspectionService _inspectionService = new InspectionService(_dbMock.Object, new JsonSyncService <PlannedInspection>(_dbMock.Object)); }
/// <summary> /// Setup the test /// </summary> public InspectionApiUnitTest() { DbContextOptions <DbAppContext> options = new DbContextOptions <DbAppContext>(); Mock <DbAppContext> dbAppContext = new Mock <DbAppContext>(null, options); /* * * Here you will need to mock up the context. * * ItemType fakeItem = new ItemType(...); * * Mock<DbSet<ItemType>> mockList = MockDbSet.Create(fakeItem); * * dbAppContext.Setup(x => x.ModelEndpoint).Returns(mockItem.Object); * */ InspectionService _service = new InspectionService(null, dbAppContext.Object); _InspectionApi = new InspectionController(_service); }
public ActionResult Delete(Guid inspectionItemId, Guid imageId) { var image = _context.InspectionImages.SingleOrDefault(inspectionImage => inspectionImage.Id == imageId); if (image == null) { return(NotFound()); } var inspectionItemInDb = _context.InspectionItems.SingleOrDefault(inspectionItem => inspectionItem.Id == inspectionItemId); if (inspectionItemInDb == null) { return(NotFound()); } ImageService.DeleteImage(image); return(InspectionService.DeleteInspectionItemImage(_context, image) ? NoContent() : StatusCode(500)); }
/// <summary> /// Initializes a new instance of the <see cref="SelectorWindowViewModel"/> class. /// </summary> public SelectorWindowViewModel() { _inspectionService = ServiceLocator.Resolve <InspectionService>(); _updateCheckService = ServiceLocator.Resolve <UpdateCheckService>(); UpdateInformation = _updateCheckService.UpdateInformation; _managedApplicationsService = new ManagedApplicationsService(); ManagedApplicationsInfo = _managedApplicationsService.ManagerApplicationsInfo; ManagedApplicationsInfo.ManagedApplicationInfos.CurrentChanged += (s, e) => InspectCommand.RaiseCanExecuteChanged(); ManagedApplicationsInfo.ManagedApplicationInfos.CollectionChanged += (s, e) => { if (ManagedApplicationsInfo.ManagedApplicationInfos.CurrentItem == null) { ManagedApplicationsInfo.ManagedApplicationInfos.MoveCurrentToFirst(); } }; RefreshCommand = new Command <object>(RefreshApplicationList); InspectCommand = new Command <object>(_ => Inspect(), _ => ManagedApplicationsInfo.ManagedApplicationInfos.CurrentItem != null); ExitCommand = new Command <object>(o => Application.Current.Shutdown()); AboutCommand = new Command <object>(o => new AboutWindow().ShowDialog()); VisitWebpageCommand = new Command <object>(VisitWebPage); }
public ActionResult UpdateAdditionalInfo(Job_DetailsModel Model) { InspectionService insp = new InspectionService(Data); //if (!ModelState.IsValid) //{ // var errorResult = ModelState // .Where(x => x.Value.Errors.Count > 0) // .Select(x => new { MemberNames = x.Key, ErrorMessage = x.Value.Errors.ElementAt(0).ErrorMessage }) // .ToList(); // return Json(errorResult); //} //else //{ insp.UpdateAdditionalInfo(Model.ProductInformation.Additionalfields); // Add log record in ServiceUsage // Log.Database.Job.Add.Updated(_bookRepair.GetServiceIdFromSession()); _jobService.AddNote("Change additional info"); return(new EmptyResult()); }
/// <summary> /// 删除巡查信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <param name="employeeName">人员名字</param> /// <param name="time">巡查时间</param> /// <returns></returns> public bool DelInspectInfo(string taskNumber, string employeeName, DateTime time) { var inspectionService = new InspectionService(); var inspectionExceptionService = new InspectionExceptionService(); task task = new TaskService().FindByTaskNumber(taskNumber); if (task != null) { foreach ( inspection inspectionItem in inspectionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employeeName))) { if (!time.Date.Equals(inspectionItem.Time.Date)) continue; List<inspection_exception> exceptionList = inspectionExceptionService.FindByInspectionId(inspectionItem.Id); if (exceptionList.Count > 0) foreach (inspection_exception exceptionItem in exceptionList) { inspectionExceptionService = new InspectionExceptionService(); inspectionExceptionService.Delete(inspectionExceptionService.Find(exceptionItem.Id)); } inspectionService = new InspectionService(); inspectionService.Delete(inspectionService.Find(inspectionItem.Id)); } return true; } return false; }
/// <summary> /// 更新修改巡查信息 /// </summary> /// <param name="updateInfo">巡查页面类</param> /// <returns></returns> public bool UpdateInspectInfo(InspectInfo updateInfo, DateTime time, string employeeName) { var inspectionService = new InspectionService(); var inspectionExceptionService = new InspectionExceptionService(); var taskService = new TaskService(); int count = 0; task task = taskService.FindByTaskNumber(updateInfo.TaskNumber); if (task == null) return false; var pigHouse = new HashSet<long>(); foreach (InspectDetail detail in updateInfo.InspectDetail) pigHouse.Add(long.Parse(detail.PigHouse)); foreach ( inspection inspection in inspectionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employeeName))) { if (!time.Date.Equals(inspection.Time.Date)) continue; if (count < pigHouse.Count) { inspection.PigHouseId = pigHouse.ElementAtOrDefault(count); inspection.Time = updateInfo.InspectDetail[count].DetailTime; inspection.Memo = updateInfo.Meno; inspectionService.Update(inspection); } else { inspectionExceptionService.ClearInspectionException(inspection); inspectionService = new InspectionService(); inspectionService.Delete(inspectionService.Find(inspection)); } count++; } for (; count < pigHouse.Count; count++) { inspectionService.Insert(new inspection { TaskId = task.Id, EmployeeId = long.Parse(updateInfo.EmployeeName), PigHouseId = long.Parse(updateInfo.InspectDetail[count].PigHouse), Time = updateInfo.InspectDetail[count].DetailTime, Memo = updateInfo.Meno }); } Dictionary<long, Dictionary<long, long>> pigstyAndexception = SortPigstyAndexception(updateInfo); foreach (var exception in pigstyAndexception) { count = 0; inspection inspection = inspectionService.FindByTaskId(task.Id).FirstOrDefault(m => m.employee.Name.Equals(employeeName) && m.Time.Date.Equals(time.Date) && m.PigHouseId == exception.Key); if (inspection == null) continue; foreach (var l in exception.Value) { if (count < inspection.inspection_exception.Count) { inspection_exception inspectionException = inspectionExceptionService.FindByInspectionId(inspection.Id).ElementAtOrDefault(count); if (inspectionException == null) continue; inspectionException.PigstyId = l.Key; inspectionException.ExceptionTypeId = l.Value; inspectionExceptionService.Update(inspectionException); count++; } else { var inspectionException = new inspection_exception { InspectionId = inspection.Id, PigstyId = l.Key, ExceptionTypeId = l.Value }; inspectionExceptionService.Insert(inspectionException); } } for (; count < inspection.inspection_exception.Count; count++) { inspection_exception inspectionException = inspectionExceptionService.FindByInspectionId(inspection.Id).FirstOrDefault(); if (inspectionException == null) continue; inspectionExceptionService = new InspectionExceptionService(); inspectionExceptionService.Delete(inspectionExceptionService.Find(inspectionException.Id)); } } return true; }
/// <summary> /// 新建巡查信息 /// </summary> /// <param name="newInfo">巡查页面类</param> /// <returns></returns> public bool CreateInspectInfo(InspectInfo newInfo) { if (newInfo == null) return false; var inspectionService = new InspectionService(); var taskStatusTypeService = new TaskStatusTypeService(); var taskService = new TaskService(); Dictionary<long, Dictionary<long, long>> pigstyAndexception = SortPigstyAndexception(newInfo); foreach (var inspectDetail in pigstyAndexception) { InspectDetail newInfoDetail = newInfo.InspectDetail.FirstOrDefault(m => m.PigHouse.Equals(inspectDetail.Key + "")); if (newInfoDetail == null) continue; var inspection = new inspection { TaskId = long.Parse(newInfo.TaskNumber), EmployeeId = long.Parse(newInfo.EmployeeName), PigHouseId = inspectDetail.Key, Time = newInfoDetail.DetailTime, Memo = newInfo.Meno }; foreach (var pigsty in inspectDetail.Value) { inspection.inspection_exception.Add(new inspection_exception { PigstyId = pigsty.Key, ExceptionTypeId = pigsty.Value }); } inspectionService.Insert(inspection); } task_status_type taskStatusType = taskStatusTypeService.FindByName("正在进行"); task task = taskService.Find(long.Parse(newInfo.TaskNumber)); if (taskStatusType != null && task != null) { task.TaskStatusId = taskStatusType.Id; taskService.Update(task); } return true; }
/// <summary> /// 巡查信息列表 /// </summary> /// <returns></returns> public IEnumerable<Info> GetInspectInfoList() { var inspectInfoList = new List<Info>(); var inspectionService = new InspectionService(); var taskService = new TaskService(); long taskid = 0, employeeId = 0; var dateTime = new DateTime(); IOrderedEnumerable<inspection> inspectionAll = inspectionService.FindAll().OrderByDescending(m => m.Time); foreach (inspection inspection in inspectionAll) { if (taskid == inspection.TaskId && employeeId == inspection.EmployeeId && dateTime.Date.Equals(inspection.Time.Date)) continue; inspectInfoList.Add(new Info { TaskNumber = taskService.Find(inspection.TaskId).TaskNumber, EmployeeName = inspection.employee.Name, Time = inspection.Time, Meno = inspection.Memo }); taskid = inspection.TaskId; employeeId = inspection.EmployeeId; dateTime = inspection.Time; } return inspectInfoList; }