public ActionResult Delete(int id) { var message = "OK"; DataSource <TrainEventViewModel> Source = new DataSource <TrainEventViewModel>(); TrainEvent Eventobj = _hrUnitOfWork.TrainingRepository.GetTrainEvent(id); if (Eventobj != null) { AutoMapper(new Models.AutoMapperParm { Source = Eventobj, ObjectName = "TrainEvent", Transtype = TransType.Delete }); _hrUnitOfWork.TrainingRepository.Remove(Eventobj); } Source.Errors = SaveChanges(Language); if (Source.Errors.Count() > 0) { return(Json(Source)); } else { return(Json(message)); } }
public void Remove(TrainEvent trainEvent) { if (Context.Entry(trainEvent).State == EntityState.Detached) { context.TrainEvents.Attach(trainEvent); } context.TrainEvents.Remove(trainEvent); }
protected override void Awake() { base.Awake(); Died = new TrainEvent(); navMeshAgent = GetComponent <NavMeshAgent>(); navMeshAgent.speed = currentSpeed; baseWaypoint = firstWaypoint; waypointTarget = baseWaypoint; }
private void SignalEvent(TrainEvent evt,TrainControlSystem script) { try { foreach (var eventHandler in Locomotive.EventHandlers) { eventHandler.HandleEvent(evt,script); } } catch (Exception error) { Trace.TraceInformation("Sound event skipped due to thread safety problem" + error.Message); } }
public static TrainEventEntity FromTrainEvent( TrainEvent trainEvent) { if (trainEvent is null) { throw new ArgumentNullException(nameof(trainEvent)); } var rowKey = CreateEntityRowKey(trainEvent.DateTime); var partitionKey = CreateEntityPartitionKey( trainEvent.VehicleId, trainEvent.OrderNumberCurrent); return(new TrainEventEntity( partitionKey, rowKey, trainEvent.StationId, trainEvent.StationName, trainEvent.VehicleId, trainEvent.UnitNumber, trainEvent.DateTime, trainEvent.OrderNumberCurrent, trainEvent.OrderNumberTotal, trainEvent.Type)); }
/// <summary> /// Used when someone want to notify us of an event /// </summary> public override void SignalEvent(TrainEvent evt) { base.SignalEvent(evt); }
public ActionResult Details(TrainEventFormViewModel model, OptionsViewModel moreInfo) { List <Error> errors = new List <Error>(); if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.SiteRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "TrainEvents", TableName = "TrainEvents", ParentColumn = "CourseId", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } TrainEvent record; PeopleTraining PeopleTrainObj = new PeopleTraining(); var message = "OK"; //insert if (model.Id == 0) { record = new TrainEvent(); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "TrainEvents", Options = moreInfo, Transtype = TransType.Insert }); record.CreatedUser = UserName; record.CreatedTime = DateTime.Now; _hrUnitOfWork.TrainingRepository.Add(record); } //booking else if (model.book) { record = _hrUnitOfWork.Repository <TrainEvent>().FirstOrDefault(a => a.Id == model.Id); PeopleTrainObj.CreatedUser = UserName; PeopleTrainObj.CreatedTime = DateTime.Now; PeopleTrainObj.CompanyId = CompanyId; PeopleTrainObj.ApprovalStatus = 2; PeopleTrainObj.RequestDate = DateTime.Now; PeopleTrainObj.EmpId = (model.PersonId != null ? model.PersonId.Value: User.Identity.GetEmpId()); PeopleTrainObj.CourseEDate = model.TrainEndDate; PeopleTrainObj.CourseSDate = model.TrainStartDate; PeopleTrainObj.EventId = record.Id; PeopleTrainObj.CompanyId = CompanyId; PeopleTrainObj.Cost = record.Cost; PeopleTrainObj.Curr = record.Curr; PeopleTrainObj.CurrRate = record.CurrRate; PeopleTrainObj.Notes = record.Notes; PeopleTrainObj.CourseId = record.CourseId; PeopleTrainObj.Adwarding = record.Adwarding; _hrUnitOfWork.TrainingRepository.Add(PeopleTrainObj); } //update else { record = _hrUnitOfWork.Repository <TrainEvent>().FirstOrDefault(a => a.Id == model.Id); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "TrainEvents", Options = moreInfo, Transtype = TransType.Update }); record.ModifiedTime = DateTime.Now; record.ModifiedUser = UserName; _hrUnitOfWork.TrainingRepository.Attach(record); _hrUnitOfWork.TrainingRepository.Entry(record).State = EntityState.Modified; } errors = SaveChanges(Language); if (errors.Count > 0) { message = errors.First().errors.First().message; } if (model.book) { WfViewModel wf = new WfViewModel() { Source = "Training", SourceId = CompanyId, DocumentId = PeopleTrainObj.Id, RequesterEmpId = PeopleTrainObj.EmpId, ApprovalStatus = 2, CreatedUser = UserName, }; var wfTrans = _hrUnitOfWork.ComplaintRepository.AddWorkFlow(wf, Language); if (wfTrans == null && wf.WorkFlowStatus != "Success") { PeopleTrainObj.ApprovalStatus = 2; message = wf.WorkFlowStatus; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } errors = SaveChanges(Language); } return(Json(message)); } return(Json(Models.Utils.ParseFormErrors(ModelState))); }
public void HandleEvent(PowerSupplyEvent evt) { TrainEvent soundEvent = TrainEvent.None; switch (evt) { case PowerSupplyEvent.LowerPantograph: if (State == PantographState.Up || State == PantographState.Raising) { State = PantographState.Lowering; switch (Id) { default: case 1: soundEvent = TrainEvent.Pantograph1Down; break; case 2: soundEvent = TrainEvent.Pantograph2Down; break; case 3: soundEvent = TrainEvent.Pantograph3Down; break; case 4: soundEvent = TrainEvent.Pantograph4Down; break; } } break; case PowerSupplyEvent.RaisePantograph: if (State == PantographState.Down || State == PantographState.Lowering) { State = PantographState.Raising; switch (Id) { default: case 1: soundEvent = TrainEvent.Pantograph1Up; break; case 2: soundEvent = TrainEvent.Pantograph2Up; break; case 3: soundEvent = TrainEvent.Pantograph3Up; break; case 4: soundEvent = TrainEvent.Pantograph4Up; break; } } break; } if (soundEvent != TrainEvent.None) { try { foreach (var eventHandler in Wagon.EventHandlers) { eventHandler.HandleEvent(soundEvent); } } catch (Exception error) { Trace.TraceInformation("Sound event skipped due to thread safety problem" + error.Message); } } }
public DbEntityEntry <TrainEvent> Entry(TrainEvent trainEvent) { return(Context.Entry(trainEvent)); }
public void Attach(TrainEvent trainEvent) { context.TrainEvents.Attach(trainEvent); }
public void Add(TrainEvent trainEvent) { context.TrainEvents.Add(trainEvent); }
public IHttpActionResult SaveTrainEvent(TrainEventFormViewModel model) { List <Model.ViewModel.Error> errors = new List <Model.ViewModel.Error>(); if (!ModelState.IsValid) { return(Json(Utils.ParseFormError(ModelState))); } string message = "Ok"; PeopleTraining PeopleTrainObj = new PeopleTraining(); TrainEvent record = _hrUnitOfWork.Repository <TrainEvent>().FirstOrDefault(a => a.Id == model.Id); if (model.PersonId != null) { PeopleTrainObj.EmpId = model.PersonId.GetValueOrDefault(); } else { PeopleTrainObj.EmpId = 1042; } PeopleTrainObj.EmpId = User.Identity.GetEmpId(); PeopleTrainObj.CreatedUser = User.Identity.Name; PeopleTrainObj.CreatedTime = DateTime.Now; PeopleTrainObj.CompanyId = User.Identity.GetDefaultCompany(); PeopleTrainObj.ApprovalStatus = 2; PeopleTrainObj.RequestDate = DateTime.Now; PeopleTrainObj.CourseEDate = model.TrainEndDate; PeopleTrainObj.CourseSDate = model.TrainStartDate; PeopleTrainObj.EventId = record.Id; PeopleTrainObj.CompanyId = User.Identity.GetDefaultCompany(); PeopleTrainObj.Cost = record.Cost; PeopleTrainObj.Curr = record.Curr; PeopleTrainObj.CurrRate = record.CurrRate; PeopleTrainObj.Notes = record.Notes; PeopleTrainObj.CourseId = record.CourseId; PeopleTrainObj.Adwarding = record.Adwarding; _hrUnitOfWork.TrainingRepository.Add(PeopleTrainObj); errors = SaveChanges(User.Identity.GetLanguage()); if (errors.Count > 0) { message = errors.First().errors.First().message; } if (model.book) { WfViewModel wf = new WfViewModel() { Source = "Training", SourceId = User.Identity.GetDefaultCompany(), DocumentId = PeopleTrainObj.Id, RequesterEmpId = PeopleTrainObj.EmpId, ApprovalStatus = 2, CreatedUser = User.Identity.Name, }; var wfTrans = _hrUnitOfWork.ComplaintRepository.AddWorkFlow(wf, User.Identity.GetLanguage()); if (wfTrans == null && wf.WorkFlowStatus != "Success") { PeopleTrainObj.ApprovalStatus = 2; message = wf.WorkFlowStatus; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } errors = SaveChanges(User.Identity.GetLanguage()); } return(Ok(message)); }
public void HandleEvent(PowerSupplyEvent evt) { TrainEvent soundEvent = TrainEvent.None; switch (evt) { case PowerSupplyEvent.LowerPantograph: if (State == PantographState.Up || State == PantographState.Raising) { State = PantographState.Lowering; switch (Id) { default: case 1: soundEvent = TrainEvent.Pantograph1Down; Confirm(CabControl.Pantograph1, CabSetting.Off); break; case 2: soundEvent = TrainEvent.Pantograph2Down; Confirm(CabControl.Pantograph2, CabSetting.Off); break; case 3: soundEvent = TrainEvent.Pantograph3Down; Confirm(CabControl.Pantograph3, CabSetting.Off); break; case 4: soundEvent = TrainEvent.Pantograph4Down; Confirm(CabControl.Pantograph4, CabSetting.Off); break; } } break; case PowerSupplyEvent.RaisePantograph: if (State == PantographState.Down || State == PantographState.Lowering) { State = PantographState.Raising; switch (Id) { default: case 1: soundEvent = TrainEvent.Pantograph1Up; Confirm(CabControl.Pantograph1, CabSetting.On); break; case 2: soundEvent = TrainEvent.Pantograph2Up; Confirm(CabControl.Pantograph2, CabSetting.On); break; case 3: soundEvent = TrainEvent.Pantograph3Up; Confirm(CabControl.Pantograph3, CabSetting.On); break; case 4: soundEvent = TrainEvent.Pantograph4Up; Confirm(CabControl.Pantograph4, CabSetting.On); break; } if (!Simulator.Route.Electrified) { Simulator.Confirmer.Warning(Simulator.Catalog.GetString("No power line!")); } if (Simulator.Settings.OverrideNonElectrifiedRoutes) { Simulator.Confirmer.Information(Simulator.Catalog.GetString("Power line condition overridden.")); } } break; } if (soundEvent != TrainEvent.None) { try { foreach (var eventHandler in Wagon.EventHandlers) { eventHandler.HandleEvent(soundEvent); } } catch (Exception error) { Trace.TraceInformation("Sound event skipped due to thread safety problem" + error.Message); } } }