/// <summary> /// Contructs the maintenance with the given values /// </summary> public Maintenance(Medewerker medewerker, DateTime date, Tram tram, MaintenanceType type) { Medewerker = medewerker; Date = date; Tram = tram; Type = type; }
/// <summary> /// Добавить обслуживание /// </summary> /// <param name="maintenanceType"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="unplannedReason"></param> public void AddMaintenance( MaintenanceType maintenanceType, DateTime start, DateTime?end = null, MaintenanceReason unplannedReason = null ) { var targetInterval = Intervals.SingleOrDefault(x => x.MaintenanceType == maintenanceType); if (targetInterval == null) { throw new Exception("Не найден интервал для данного вида обслуживания"); } //Добавить запись в журнал обслуживания var newMaintenance = new MaintenanceActual(this) { MaintenanceType = maintenanceType, StartMaintenance = start, UnplannedReason = unplannedReason }; maintenance.Add(newMaintenance); //Изменить состояние объекта ремонта ChangeOperatingState(OperatingState.Maintenance, start); CurrentMaintenance = newMaintenance; //Если обслуживание окончено (известна дата окончания) то производим процедуру завершения обслуживания if (end != null) { FinalizeMaintenance(end.Value); } }
protected override void Build(IRepository repository) { T_Repair = new MaintenanceType { Name = "Текущий ремонт", Designation = "Т" }; C_Repair = new MaintenanceType { Name = "Средний ремонт", Designation = "C" }; K_Repair = new MaintenanceType { Name = "Капитальный ремонт", Designation = "K" }; TO1_Repair = new MaintenanceType { Name = "Первое техническое обслуживание", Designation = "ТО1" }; TO2_Repair = new MaintenanceType { Name = "Второе техническое обслуживание", Designation = "ТО2" }; CO_Repair = new MaintenanceType { Name = "Средний ремонт", Designation = "СР" }; TR_Repair = new MaintenanceType { Name = "Текущий ремонт", Designation = "ТР" }; repository.Save(T_Repair); repository.Save(C_Repair); repository.Save(K_Repair); repository.Save(TO1_Repair); repository.Save(TO2_Repair); repository.Save(CO_Repair); repository.Save(TR_Repair); }
public void Create(Substation t) { MaintenanceType type = dataBase.MaintenanceTypes.GetAll().First(x => x.Name == "осмотр"); MaintenanceRecord record; int section = 12 / t.InspectionsFrequency.Count; for (int year = t.InputYear.Value; year <= DateTime.Now.Year + 10; year++) { for (int i = 1; i <= t.InspectionsFrequency.Count; i++) { record = new MaintenanceRecord(); if (year < DateTime.Now.Year) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); record.PlannedMaintenanceType = type; record.ActualMaintenanceDate = new DateTime(year, section * i, 1); record.ActualMaintenanceType = type; record.IsPlanned = true; } else if (year == DateTime.Now.Year && DateTime.Now.Month > 2) { if (DateTime.Now.Month > section * i) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); record.ActualMaintenanceDate = new DateTime(year, section * i, 1); record.PlannedMaintenanceType = type; record.ActualMaintenanceType = type; } else if (t.InspectionsFrequency.Count == 1) { record.PlannedMaintenanceDate = new DateTime(year, section * i / 2, 1); } else { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); } record.PlannedMaintenanceType = type; record.IsPlanned = true; } else { if (t.InspectionsFrequency.Count == 12) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); } else { record.PlannedMaintenanceDate = new DateTime(year, 1, 1); } record.PlannedMaintenanceType = type; record.IsPlanned = false; } record.IsRescheduled = false; record.MaintainedEquipment = t; dataBase.MaintenanceRecords.Create(record); } } dataBase.Substations.Create(t); dataBase.Save(); }
public async Task <IActionResult> PostMainType(MaintenanceType maintenance) { _context.MaintenanceTypes.Add(maintenance); await _context.SaveChangesAsync(); return(Ok()); }
public IActionResult Add(AddMaintenanceViewModel addMaintenanceViewModel) { if (ModelState.IsValid) { MaintenanceType MaintenanceTypeChosen = context.MaintenanceTypes.Where(x => x.MaintenanceTypeID == addMaintenanceViewModel.MaintenanceTypeID).FirstOrDefault(); int MaintenaceFutureMiles = addMaintenanceViewModel.MaintenacePerformedMiles + MaintenanceTypeChosen.MilesInterval; int MaintenaceFutureDate = MaintenanceTypeChosen.DateIntervalDays; //addMaintenanceViewModel.MaintenancePerformedDate Maintenance newMaintenance = new Maintenance() { MaintenacePerformedMiles = addMaintenanceViewModel.MaintenacePerformedMiles, MaintenancePerformedDate = addMaintenanceViewModel.MaintenancePerformedDate, MaintenanceCost = addMaintenanceViewModel.MaintenanceCost, MaintenanceTypeID = addMaintenanceViewModel.MaintenanceTypeID, CarID = addMaintenanceViewModel.CarID, MaintenaceFutureMiles = MaintenaceFutureMiles, MaintenaceFutureDate = MaintenaceFutureDate }; context.Maintenances.Add(newMaintenance); context.SaveChanges(); return(Redirect("/Home/MainPage")); } ; return(View()); }
public ServiceHistory(string vehicleId, double travelledDistance, DateTime date, MaintenanceType maintenanceType) { _vehicleId = vehicleId; _travelledDistanceAtMaintenance = travelledDistance; _date = date; _maintenanceType = maintenanceType; }
public MaintenanceType Post(MaintenanceType maintenanceType) { if (maintenanceType == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(maintenanceTypeService.AddUpdateMaintenanceType(maintenanceType.CreateFrom()).CreateFrom()); }
public Boolean Delete(MaintenanceType maintenanceType) { if (maintenanceType == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } maintenanceTypeService.DeleteMaintenanceType(maintenanceType.MaintenanceTypeId); return(true); }
/// <summary> /// Initializes a new instance of the UnitMaintenanceModel class. /// </summary> /// <param name="fromProperty">Date and time the scheduled maintenance /// window starts<br />Specify a date and time (without /// fractional second part) in UTC or with UTC offset as defined in /// <a /// href="https://en.wikipedia.org/wiki/ISO_8601">ISO8601:2004</a></param> /// <param name="id">The id for the scheduled maintenance</param> /// <param name="to">Date and time the scheduled maintenance window /// ends<br />Specify a date and time (without fractional second /// part) in UTC or with UTC offset as defined in <a /// href="https://en.wikipedia.org/wiki/ISO_8601">ISO8601:2004</a></param> /// <param name="type">The type of maintenance that is planned for the /// unit. A small repair (OutOfService), /// a bigger disfunction that does not allow to sell the unit /// (OutOfOrder) or is it /// even under construction and should reduce the house count /// (OutOfInventory). Possible values include: 'OutOfService', /// 'OutOfOrder', 'OutOfInventory'</param> /// <param name="description">The description text for the /// maintenance</param> public UnitMaintenanceModel(System.DateTime fromProperty, string id, System.DateTime to, MaintenanceType type, string description = default(string)) { Description = description; FromProperty = fromProperty; Id = id; To = to; Type = type; CustomInit(); }
/// <summary> /// Update Maintenance Type Properties while updating the instance /// </summary> private void UpdateMaintenanceTypeProperties(MaintenanceType maintenanceType, MaintenanceType dbVersion) { dbVersion.RecLastUpdatedBy = maintenanceTypeRepository.LoggedInUserIdentity; dbVersion.RecLastUpdatedDt = DateTime.Now; dbVersion.RowVersion = dbVersion.RowVersion + 1; dbVersion.MaintenanceTypeCode = maintenanceType.MaintenanceTypeCode; dbVersion.MaintenanceTypeName = maintenanceType.MaintenanceTypeName; dbVersion.MaintenanceTypeDescription = maintenanceType.MaintenanceTypeDescription; dbVersion.MaintenanceTypeGroupId = maintenanceType.MaintenanceTypeGroupId; }
public void ResetMaintenancesDataGrid(MaintenanceType typeOfMaintenance) { dgvMaintenances.DataSource = Maintenance.GetMaintenances(typeOfMaintenance); dgvMaintenances.Columns["ID"].Width = 30; dgvMaintenances.Columns["OrderID"].Width = 80; dgvMaintenances.Columns["ProductCode"].Width = 100; dgvMaintenances.Columns["Duration"].Width = 70; dgvMaintenances.Columns["StartDateTimeOfOperation"].HeaderText = "StartDate"; }
public static SoundInfo OnCamera(MaintenanceType maint = MaintenanceType.None) { SoundInfo result = default(SoundInfo); result.IsOnCamera = true; result.Maintenance = maint; result.Maker = TargetInfo.Invalid; result.testPlay = false; result.volumeFactor = (result.pitchFactor = 1f); return(result); }
private MaintenanceYear AddMaintenanceYear(int year, string type) { MaintenanceYear maintenanceYear = new MaintenanceYear(); maintenanceYear.Year = year; MaintenanceType maintenanceType = new MaintenanceType(); maintenanceType.Name = type; maintenanceYear.MaintenanceType = maintenanceType; return(maintenanceYear); }
public static SoundInfo InMap(TargetInfo maker, MaintenanceType maint = MaintenanceType.None) { SoundInfo result = default(SoundInfo); result.IsOnCamera = false; result.Maintenance = maint; result.Maker = maker; result.testPlay = false; result.volumeFactor = (result.pitchFactor = 1f); return(result); }
/// <summary> /// 指定開啟的查詢控件 /// </summary> /// <param name="_maintenance_type"></param> public void setFormType(MaintenanceType _maintenance_type) { try { this._maintenance_type = _maintenance_type; } catch (Exception ex) { logger.Error(ex, "Exception"); } }
/// <summary> /// Create from web model /// </summary> public static Cares.Models.DomainModels.MaintenanceType CreateFrom(this MaintenanceType source) { return(new Cares.Models.DomainModels.MaintenanceType { MaintenanceTypeId = source.MaintenanceTypeId, MaintenanceTypeCode = source.MaintenanceTypeCode, MaintenanceTypeName = source.MaintenanceTypeName, MaintenanceTypeDescription = source.MaintenanceTypeDescription, MaintenanceTypeGroupId = source.MaintenanceTypeGroupId, }); }
public IActionResult Create([FromBody] MaintenanceType item) { if (item == null) { return(BadRequest()); } _context.MaintenanceTypes.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetMaintenanceType", new { id = item.Id }, item)); }
public async Task <IActionResult> PutMaintenanceType(int id, MaintenanceType maintenance) { if (id != maintenance.Id) { return(BadRequest()); } _context.Entry(maintenance).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok()); }
/// <summary> /// Delete Maintenance Type /// </summary> public void DeleteMaintenanceType(long maintenanceTypeId) { MaintenanceType dbversion = maintenanceTypeRepository.Find(maintenanceTypeId); CheckMaintenanceTypeAssociations(maintenanceTypeId); if (dbversion == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Maintenance Type with Id {0} not found!", maintenanceTypeId)); } maintenanceTypeRepository.Delete(dbversion); maintenanceTypeRepository.SaveChanges(); }
public void MarkActualRecord(Substation substation, DateTime date) { MaintenanceRecord record = substation.MaintenanceRecords.FirstOrDefault(x => x.ActualMaintenanceDate == null && x.IsPlanned == true && x.IsRescheduled == false); if (record == null) { return; } MaintenanceType type = dataBase.MaintenanceTypes.GetAll().First(x => x.Name == "осмотр"); record.ActualMaintenanceDate = date; record.ActualMaintenanceType = type; dataBase.Save(); }
public IActionResult Update(int id, [FromBody] MaintenanceType item) { if (item == null || item.Id != id) { return(BadRequest()); } var type = _context.MaintenanceTypes.FirstOrDefault(x => x.Id == id); type.Description = item.Description; _context.MaintenanceTypes.Update(type); _context.SaveChanges(); return(new NoContentResult()); }
internal static string ToSerializedValue(this MaintenanceType value) { switch (value) { case MaintenanceType.OutOfService: return("OutOfService"); case MaintenanceType.OutOfOrder: return("OutOfOrder"); case MaintenanceType.OutOfInventory: return("OutOfInventory"); } return(null); }
public void SetActualType(ScheduleRecordModel scheduleRecordModel, string type) { if (scheduleRecordModel == null || string.IsNullOrEmpty(type)) { return; } MaintenanceRecord record = GetCurrentRecord(scheduleRecordModel); MaintenanceType maintenanceType = dataBase.MaintenanceTypes.GetAll().FirstOrDefault(x => x.Name == type); if (maintenanceType != null) { record.ActualMaintenanceType = maintenanceType; dataBase.MaintenanceRecords.Update(record); dataBase.Save(); } }
public void Update(Substation t) { List <MaintenanceRecord> deleteMaintenanceRecords = t.MaintenanceRecords.Where(x => x.ActualMaintenanceDate == null && !(x.IsPlanned || x.IsRescheduled)).ToList(); foreach (MaintenanceRecord deletedRecord in deleteMaintenanceRecords) { dataBase.MaintenanceRecords.Delete(deletedRecord); } dataBase.Save(); MaintenanceType type = dataBase.MaintenanceTypes.GetAll().First(x => x.Name == "осмотр"); List <MaintenanceRecord> maintenanceRecords = dataBase.Substations.Read(t.MaintainedEquipmentId).MaintenanceRecords; MaintenanceRecord record; int section = 12 / t.InspectionsFrequency.Count; int currentYear = 0; if (maintenanceRecords.Count == 0) { currentYear = t.InputYear.Value; } else { currentYear = t.MaintenanceRecords.Max(x => x.PlannedMaintenanceDate.Year) + 1; } for (int year = currentYear; year <= currentYear + 10; year++) { for (int i = 1; i <= t.InspectionsFrequency.Count; i++) { record = new MaintenanceRecord(); if (t.InspectionsFrequency.Count == 12) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); } else { record.PlannedMaintenanceDate = new DateTime(year, 1, 1); } record.PlannedMaintenanceType = type; record.IsPlanned = false; record.IsRescheduled = false; record.MaintainedEquipment = t; dataBase.MaintenanceRecords.Create(record); } } dataBase.Substations.Update(t); dataBase.Save(); }
public Maintenance(MaintenanceType maintenanceType) { InitializeComponent(); switch (maintenanceType) { case MaintenanceType.AvatarFix: worker.DoWork += avatarFix; break; case MaintenanceType.RestoreLocalScoresFromReplays: worker.DoWork += restoreScores; break; case MaintenanceType.Update: if (!OsuMain.Started) { TopMost = false; } ShowInTaskbar = true; Text = @"osu! updater"; worker.DoWork += update; break; case MaintenanceType.Uninstall: if (!OsuMain.Started) { TopMost = false; } ShowInTaskbar = true; Text = @"osu! uninstaller"; worker.DoWork += uninstall; break; } worker.WorkerReportsProgress = true; worker.ProgressChanged += worker_ProgressChanged; worker.RunWorkerCompleted += worker_RunWorkerCompleted; worker.RunWorkerAsync(); updateTimer.Tick += updateTimer_Tick; updateTimer.Interval = 10; updateTimer.Start(); }
public static List <Maintenance> GetMaintenances(MaintenanceType typeOfMaintenance) { List <Maintenance> maintenances = new List <Maintenance>(); string tableName = "Maintenance"; DataHandler.ResetDataSet(); DataSet ds = new DataSet(); switch (typeOfMaintenance) { case MaintenanceType.COMPLETED: ds = DataHandler.GetDataSet(tableName, "SELECT * FROM Maintenance WHERE Duration IS NOT NULL"); break; case MaintenanceType.SCHEDULED: ds = DataHandler.GetDataSet(tableName, "SELECT * FROM Maintenance WHERE Duration IS NULL"); break; default: ds = DataHandler.GetDataSet(tableName); break; } foreach (DataRow row in ds.Tables[tableName].Rows) { string duration = row["Duration"].ToString(); if (duration == null || duration == "") { maintenances.Add(new Maintenance(int.Parse(row["MaintenanceID"].ToString()), int.Parse(row["OrderID"].ToString()), row["ProductCode"].ToString(), row["TechnicianID"].ToString(), DateTime.Parse(row["DateOfMaintenance"].ToString()), null, null)); } else { maintenances.Add(new Maintenance(int.Parse(row["MaintenanceID"].ToString()), int.Parse(row["OrderID"].ToString()), row["ProductCode"].ToString(), row["TechnicianID"].ToString(), DateTime.Parse(row["DateOfMaintenance"].ToString()), int.Parse(duration), null)); } } return(maintenances); }
/// <summary> /// Author: Dalton Cleveland /// Created : 3/5/2019 /// RetrieveAllMaintenanceTypes will select all of the MaintenanceTypes from our Database who have an Complete Status of 1 and return them /// </summary> /// <returns>Returns a List of all Members</returns> public List <MaintenanceType> RetrieveAllMaintenanceTypes() { List <MaintenanceType> maintenanceTypes = new List <MaintenanceType>(); var conn = DBConnection.GetDbConnection(); // command text string cmdText2 = @"sp_retrieve_maintenance_types"; // command objects var cmd2 = new SqlCommand(cmdText2, conn); // set the command type cmd2.CommandType = CommandType.StoredProcedure; try { conn.Open(); SqlDataReader reader2 = cmd2.ExecuteReader(); if (reader2.HasRows) { while (reader2.Read()) { MaintenanceType maintenanceType = new MaintenanceType(); maintenanceType.MaintenanceTypeID = reader2.GetString(0); maintenanceType.Description = reader2.GetString(1); maintenanceTypes.Add(maintenanceType); } } } catch (Exception) { throw; } finally { conn.Close(); } return(maintenanceTypes); }
public void MaintainPlane(int Id) { Plane PlaneToBeMaintained = _planes.GetById(Id); IEnumerable <MaintenanceType> MaintenanceTypes = _context.MaintenanceTypes; List <MaintenanceType> MaintenanceTypesList = MaintenanceTypes.ToList(); MaintenanceType MaintenanceType = MaintenanceTypesList[RandomIndexFromRange(MaintenanceTypesList.Count())]; Maintenance maintenance = new Maintenance { PlaneId = PlaneToBeMaintained.Id, Plane = PlaneToBeMaintained, MaintenanceTypeId = MaintenanceType.Id, MaintenanceType = _context.MaintenanceTypes.FirstOrDefault(maintenancetype => maintenancetype.Id == MaintenanceType.Id), Date = DateTime.Now }; _context.Add(maintenance); // Allocate ground crew IEnumerable <Employee> FreeGroundCrew = _context.Employees.Where(employee => employee.Status == 0).Where(employee => employee.Job == 3); IEnumerable <Employee> GroundCrew = RandomEmployees(5, FreeGroundCrew); List <Employee> GroundCrewList = GroundCrew.ToList(); for (int i = 0; i < GroundCrewList.Count(); i++) { MaintenanceEmployee maintenanceEmployee = new MaintenanceEmployee { EmployeeId = GroundCrewList[i].Id, Employee = _employees.GetById(GroundCrewList[i].Id), MaintenanceId = maintenance.Id, Maintenance = maintenance }; _context.Add(maintenanceEmployee); _employees.ChangeStatus(GroundCrewList[i].Id); } _context.SaveChanges(); }
public IActionResult NewMaintenance([FromQuery] MaintenanceType type, [FromBody] NewMaintenanceViewModel viewModel) { try { if (ModelState.IsValid) { Vehicle _vehicle = _vehicleService.GetByLicensePlate(viewModel.LicensePlate); if (_vehicle is null) { return(NotFound("Veículo não encontrado")); } Maintenance _maintenance = new Maintenance() { //MaintenanceType = type, MaintenanceDate = DateTime.Now, VehicleId = _vehicle.Id, Vehicle = _vehicle, Cost = viewModel.Cost, PreventivaOrCorretiva = viewModel.PreventivaOrCorretiva, TiresChanged = viewModel.TiresChanged, OilChanged = viewModel.OilChanged, OperationDescription = viewModel.OperationDescription, }; return(Created("", _maintenanceService.NewMaintenance(_maintenance))); } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest(ex.InnerException)); } }