private static void AssertNonNullProperties(MaintenanceSchedule maintenanceSchedule) { Assert.IsNotNull(maintenanceSchedule.MaintenanceEvents[0].EventId); Assert.IsNotNull(maintenanceSchedule.MaintenanceEvents[0].EventStatus); Assert.IsNotNull(maintenanceSchedule.MaintenanceEvents[0].EventType); Assert.IsNotNull(maintenanceSchedule.MaintenanceEvents[0].NotBefore); }
private void UpdateSchedule(object parameter) { if (ValidateReportId(ReportId)) { if (Description != null) { using (KongBuBankEntities db = new KongBuBankEntities()) { MaintenanceSchedule schedule = db.MaintenanceSchedules.Find(ReportId); if (Selected) { schedule.Status = "Pending"; } else { schedule.Status = "Finish"; } db.SaveChanges(); MessageBox.Show("Maintenance Schedule Updated!", "Success"); } } else { MessageBox.Show("Description must be filled!", "Error"); } } }
public void TestParseEmptyMaintenanceEvent() { string payload = File.ReadAllText("EmptyMaintenanceEvent.json"); MaintenanceSchedule schedule = JsonConvert.DeserializeObject <MaintenanceSchedule>(payload); Assert.AreEqual("1", schedule.DocumentIncarnation); Assert.AreEqual(0, schedule.MaintenanceEvents.Count); }
public MaintenanceSchedule addMaintenanceSchedule(MaintenanceSchedule schedule) { Connection con = Connection.getConnection(); con.db.MaintenanceSchedule.Add(schedule); con.db.SaveChanges(); return(schedule); }
public void TestParseSingleMaintenanceEventMultipleAffectedResources() { string payload = File.ReadAllText("SingleMaintenanceEventMultipleAffectedResources.json"); MaintenanceSchedule schedule = JsonConvert.DeserializeObject <MaintenanceSchedule>(payload); Assert.AreEqual("1", schedule.DocumentIncarnation); Assert.AreEqual(1, schedule.MaintenanceEvents.Count); Assert.AreEqual(2, schedule.MaintenanceEvents[0].AffectedResources.Count); AssertNonNullProperties(schedule); }
public int getLastID() { Connection con = Connection.getConnection(); MaintenanceSchedule schedule = (from m in con.db.MaintenanceSchedule orderby m.scheduleID descending select m).FirstOrDefault(); if (schedule == null) { return(0); } return(schedule.scheduleID); }
public MaintenanceSchedule createNewMaintenanceSchedule(int attractionID, DateTime?scheduleDate) { MaintenanceScheduleMediator mediator = new MaintenanceScheduleMediator(); MaintenanceSchedule ms = new MaintenanceSchedule(); ms.scheduleID = mediator.getLastID() + 1; ms.attractionID = attractionID; ms.scheduleDate = scheduleDate; ms.status = "Not Done"; return(ms); }
public MaintenanceSchedule updateMaintenanceSchedule(int scheduleID, MaintenanceSchedule schedule) { Connection con = Connection.getConnection(); MaintenanceSchedule newSchedule = con.db.MaintenanceSchedule.Find(scheduleID); newSchedule = schedule; con.db.SaveChanges(); return(newSchedule); }
private bool ValidateReportId(string _reportId) { using (KongBuBankEntities db = new KongBuBankEntities()) { MaintenanceSchedule schedule = db.MaintenanceSchedules.Find(_reportId); if (schedule == null) { MessageBox.Show("Maintenance Schedule Not Found!", "Error"); return(false); } return(true); } }
public static void createScheduleMaintenanceAtt(int id, string name, DateTime date, string timeStart, string timeEnd, string note) { MaintenanceSchedule newMs = new MaintenanceSchedule(); newMs.AttractionId = id; newMs.AttractionName = name; newMs.MaintenanceDate = date; newMs.MaintenanceNote = note; newMs.MaintenaceStartTime = timeStart; newMs.MaintenanceEndTime = timeEnd; DatabaseConnectionHandler.GetInstance().MaintenanceSchedule.Add(newMs); DatabaseConnectionHandler.GetInstance().SaveChanges(); }
private void SubmitSchedule(object parameter) { if (ValidateDateTime()) { if (ValidateReportId(ReportId)) { if (EstimateCost >= 0) { if (Description != null) { using (KongBuBankEntities db = new KongBuBankEntities()) { //Create new MaintenanceSchedule MaintenanceSchedule schedule = new MaintenanceSchedule(); schedule.ReportId = ReportId; schedule.Status = "Pending"; schedule.StartDate = StartTime; schedule.EndDate = EndTime; schedule.EstimateCost = EstimateCost; schedule.Description = Description; //Update MaintenanceReport Status MaintenanceReport report = db.MaintenanceReports.Find(schedule.ReportId); report.Status = true; db.MaintenanceSchedules.Add(schedule); Console.WriteLine(schedule.ReportId); Console.WriteLine(schedule.StartDate); db.SaveChanges(); MessageBox.Show("Maintenance Schedule Set Success!", "Success"); } } else { MessageBox.Show("Description must be filled!", "Error"); } } else { MessageBox.Show("Cost Amount Invalid!", "Error"); } } } }
private void submitBtn_Click(object sender, RoutedEventArgs e) { string attractionIDStr = attractionIDTxt.Text.Trim(); int attractionID; DateTime?scheduleDate = scheduleDatePicker.SelectedDate; bool success = int.TryParse(attractionIDStr, out attractionID); if (!success) { errorLbl.Text = "Schedule ID must be a number!"; } else if (!scheduleDate.HasValue) { errorLbl.Text = "Please input all field!"; } else { AttractionRideMediator amediator = new AttractionRideMediator(); if (amediator.getAttractionOrRide(attractionID) == null) { errorLbl.Text = "Invalid attraction ID"; } else { MaintenanceScheduleMediator mediator = new MaintenanceScheduleMediator(); MaintenanceScheduleFactory factory = new MaintenanceScheduleFactory(); MaintenanceSchedule schedule = mediator.addMaintenanceSchedule(factory.createNewMaintenanceSchedule(attractionID, scheduleDate)); if (schedule == null) { MessageBox.Show("Add maintenance schedule failed!"); } else { MessageBox.Show("Add maintenance schedule success!"); } this.Close(); } } }
/// <summary> /// Mason Allen /// Created: /// 03/09/17 /// /// /// Retrieves a maintenance schedule by vehicle id /// </summary> /// /// <remarks> /// Aaron Usher /// Updated: /// 2017/04/14 /// /// Standardized method. /// </remarks> /// /// <param name="vehicleId">ID of the vehicle you are searching by</param> /// <returns>Maintenance schedule</returns> public static MaintenanceSchedule RetrieveMaintenanceScheduleByVehicleId(int vehicleId) { MaintenanceSchedule maintenanceSchedule = null; var conn = DBConnection.GetConnection(); var cmdText = @"sp_retrieve_maintenance_schedule_by_vehicle_id"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VEHICLE_ID", vehicleId); try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); maintenanceSchedule = new MaintenanceSchedule() { MaintenanceScheduleId = reader.GetInt32(0), VehicleId = reader.GetInt32(1) }; } } catch (Exception) { throw; } finally { conn.Close(); } return(maintenanceSchedule); }
private void submitBtn_Click(object sender, RoutedEventArgs e) { string scheduleIDStr = scheduleIDTxt.Text.Trim(); string attractionIDStr = attractionIDTxt.Text.Trim(); int scheduleID, attractionID; DateTime?scheduleDate = scheduleDatePicker.SelectedDate; bool success = int.TryParse(scheduleIDStr, out scheduleID); bool success2 = int.TryParse(attractionIDStr, out attractionID); if (!success || !success2) { errorLbl.Text = "Schedule ID must be a number!"; } else if (!scheduleDate.HasValue) { errorLbl.Text = "Please input all field!"; } else { MaintenanceScheduleMediator mediator = new MaintenanceScheduleMediator(); MaintenanceSchedule schedule = mediator.getMaintenanceSchedule(scheduleID); schedule.attractionID = attractionID; schedule.scheduleDate = scheduleDate; schedule = mediator.updateMaintenanceSchedule(scheduleID, schedule); if (schedule == null) { MessageBox.Show("Update maintenance schedule failed!"); } else { MessageBox.Show("Update maintenance schedule success!"); } refresh(); } }
/// <summary> /// Alissa Duffy /// Updated: 2017/04/24 /// /// Saves Changes made to the Add Maintenance Record form. /// Standardized method. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { try { MaintenanceSchedule currentMaintenanceSchedule = _myMaintenanceScheduleManager.RetrieveMaintenanceScheduleByVehicleId(vehicleId); if (currentMaintenanceSchedule == null) { _myMaintenanceScheduleManager.CreateMaintenanceSchedule(vehicleId); currentMaintenanceSchedule = _myMaintenanceScheduleManager.RetrieveMaintenanceScheduleByVehicleId(vehicleId); } _myMaintenanceScheduleLineManager.CreateMaintenanceScheduleLine(new MaintenanceScheduleLine { MaintenanceScheduleId = currentMaintenanceSchedule.MaintenanceScheduleId, Description = txtMaintenanceDescription.Text, MaintenanceDate = DateTime.Today }); MessageBox.Show("Maintenance record saved successfully."); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace); } }
public void MarkForMaintenance(MaintenanceSchedule schedule) { }
public IHttpActionResult ScheduleObjectMaintenance(SCOMObjectSchedMaintenanceModel Data) { //Validate post if (!ModelState.IsValid) { HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.BadRequest); message.Content = new StringContent("Missing a required parameter?"); throw new HttpResponseException(message); } //LOOP through the id array and add each GUID to the object list System.Collections.Generic.List <System.Guid> ObjectList = new System.Collections.Generic.List <System.Guid>(); string[] array = Data.id; foreach (string s in array) { var item = new Guid(s); ObjectList.Add(item); } //create a recurrencePattern this is 'sourced' from OmCommands.10.dll ( new-scommaintenanceSchedule CMDLET ) //read more: https://docs.microsoft.com/en-us/powershell/systemcenter/systemcenter2016/operationsmanager/vlatest/new-scommaintenanceschedule OnceRecurrence recurrencePattern; recurrencePattern = new OnceRecurrence(1, 1, 0, 0, 0, 0); //Getting data from Json post string comments = Data.comment; bool isRecurrence = false; bool isEnabled = true; bool recursive = true; string displayname = Data.scheduleName; //Create a timspan and return duration DateTime activeStartTime = Data.StartTime; DateTime activeEndDate = Data.EndTime; TimeSpan span = activeEndDate.Subtract(activeStartTime); int duration = (int)span.TotalMinutes; //Create the Maintenance schedule MaintenanceSchedule Sched = new MaintenanceSchedule(mg, displayname, recursive, isEnabled, ObjectList, duration, activeStartTime, activeEndDate, MaintenanceModeReason.PlannedOther, comments, isRecurrence, recurrencePattern); //Create the maintenance schedule System.Guid guid = MaintenanceSchedule.CreateMaintenanceSchedule(Sched, mg); //Add properties to class var shed = MaintenanceSchedule.GetMaintenanceScheduleById(guid, mg); List <SCOMObjectSchedMaintenanceModel> MaintenanceScheduleList = new List <SCOMObjectSchedMaintenanceModel>(); SCOMObjectSchedMaintenanceModel mSched = new SCOMObjectSchedMaintenanceModel(); mSched.scheduleId = guid; mSched.scheduleName = shed.ScheduleName; mSched.id = array; mSched.StartTime = shed.ActiveStartTime; mSched.EndTime = shed.ScheduledEndTime; mSched.comment = shed.Comments; MaintenanceScheduleList.Add(mSched); //return the post/class as Json return(Json(MaintenanceScheduleList)); }
public MaintenanceSchedule addMaintenanceSchedule(MaintenanceSchedule schedule) { MaintenanceScheduleRepository repository = new MaintenanceScheduleRepository(); return(repository.addMaintenanceSchedule(schedule)); }
public MaintenanceSchedule updateMaintenanceSchedule(int scheduleID, MaintenanceSchedule schedule) { MaintenanceScheduleRepository repository = new MaintenanceScheduleRepository(); return(repository.updateMaintenanceSchedule(scheduleID, schedule)); }