public HttpResponseMessage Save(CurrentStateModel aCurrentStateModel) { IUnitOfWork uWork = new UnitOfWork(); ICurrentStateRepository repo = new CurrentStateRepository(uWork); ICurrentStateService currentStateService = new CurrentStateService(repo); try { if (this.ModelState.IsValid) { var CurrentStateList = currentStateService.SaveCurrentState(aCurrentStateModel); if (CurrentStateList != null) { return(Request.CreateResponse(HttpStatusCode.OK, CurrentStateList)); } else { string message = "Error Saving Data"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public HttpResponseMessage DeleteCurrentStates(CurrentStateModel aCurrentStateModel) { IUnitOfWork uWork = new UnitOfWork(); ICurrentStateRepository repo = new CurrentStateRepository(uWork); ICurrentStateService currentStateService = new CurrentStateService(repo); try { if (this.ModelState.IsValid) { var result = currentStateService.DeleteCurrentState(aCurrentStateModel); if (result != null) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { string message = "Not deleted successfully"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
/// <summary> /// Constructor /// </summary> /// <param name="environment">Web host environment</param> public HomeController(IWebHostEnvironment environment, TestArchive archive) { if (!Directory.Exists($"{environment.WebRootPath}/Temp)")) { Directory.CreateDirectory($"{environment.WebRootPath}/Temp"); } this.environment = environment; this.archive = archive; currentState = new CurrentStateModel(environment); }
public HomeController(IWebHostEnvironment environment, Archive context) { this.environment = environment; if (!Directory.Exists($"{this.environment.WebRootPath}/Temp)")) { Directory.CreateDirectory($"{this.environment.WebRootPath}/Temp"); } this.infoContainer = new TestInfoContainer(); this.archive = context; this.currentState = new CurrentStateModel(environment); }
public CurrentStateModel GetCurrentStateModel(int machineId) { var result = new CurrentStateModel(); try { var query = _context.Set <CurrentState>().FirstOrDefault(w => w.MachineId == machineId); result = query?.Adapt <CurrentStateModel>(); } catch (Exception ex) { var errMessage = string.Format(ex.GetStringLog(), machineId.ToString()); LogService.WriteLog(errMessage, LogService.TypeLevel.Error, ex); } return(result); }
private long?getResTime(CurrentStateModel currentState, HistoryJobModel job) { if (currentState == null) { return(null); } if (job.Day == null || currentState.LastUpdated == null) { return(null); } if (job.Code == currentState.JobCode && job.TotalPieces == currentState.JobTotalPieces && job.Day.Value.Date == currentState.LastUpdated.Value.Date) { return(currentState.ResidueWorkingTimeJob); } return(null); }
private JobVueModel GetVueModel(MachineInfoModel machine, PeriodModel period) { var result = new JobVueModel(); var data = _jobService.GetAggregationJobs(machine, period); if (data.Count == 0) { return(result); } CurrentStateModel currentState = null; if (machine.Model.Name.ToUpper().Contains("FMC") || (machine.Model.Name.ToUpper().Contains("LMX"))) { currentState = GetCurrentState(machine.Id); } var jobs = data.Select(j => new JobDataModel() { code = j.Code, perc = getPercent(j), time = CommonViewService.getTimeViewModel(j.ElapsedTime), quantity = j.PiecesProduced ?? 0, pieces = j.TotalPieces != null && (j.TotalPieces > 0 && !j.Code.ToUpper().StartsWith("M#2")) ? (int)j.TotalPieces : (int)j.PiecesProduced, day = j.Day.GetValueOrDefault(), ResidueWorkingTimeJob = getResTime(currentState, j) }).ToList(); jobs = jobs.OrderBy(o => o.perc).ToList(); var sorting = new SortingViewModel { progress = enSorting.Ascending.GetDescription() }; result.jobs = jobs; result.sorting = sorting; return(result); }
public bool PostSaveState(CurrentStateModel data) { var res = false; try { MapHelper.CenterLat = data.CenterLat; MapHelper.CenterLng = data.CenterLng; MapHelper.Zoom = data.Zoom; MapHelper.HiddenLines = data.HiddenLines; MapHelper.HiddenStations = data.HiddenStations; MapHelper.HiddenStudents = data.HiddenStudents; MapHelper.ShowStationsWithoutLine = data.ShowStationsWithoutLine; res = true; } catch (Exception) { res = false; throw; } return(res); }
/// <summary> /// Constructor. /// </summary> /// <param name="testArchive">Test history database access object.</param> /// <param name="environment">Current environment.</param> public HomeController(TestArchive testArchive, IWebHostEnvironment environment) { this.testArchive = testArchive; this.environment = environment; currentState = new CurrentStateModel(environment); }