public ServiceResult Insert(UnitOfMeasure n) { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } if (string.IsNullOrWhiteSpace(n.AccountUUID) || n.AccountUUID == SystemFlag.Default.Account) { n.AccountUUID = CurrentUser.AccountUUID; } if (string.IsNullOrWhiteSpace(n.CreatedBy)) { n.CreatedBy = CurrentUser.UUID; } if (n.DateCreated == DateTime.MinValue) { n.DateCreated = DateTime.UtcNow; } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); return(UnitsOfMeasureManager.Insert(n, true)); }
public ServiceResult Update(UnitOfMeasure s) { if (s == null) { return(ServiceResponse.Error("Invalid UnitsOfMeasure sent to server.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = UnitsOfMeasureManager.Get(s.UUID); if (res.Code != 200) { return(res); } var dbS = (UnitOfMeasure)res.Result; if (dbS.DateCreated == DateTime.MinValue) { dbS.DateCreated = DateTime.UtcNow; } dbS.Deleted = s.Deleted; dbS.Name = s.Name; dbS.Status = s.Status; dbS.SortOrder = s.SortOrder; dbS.Category = s.Category; dbS.ShortName = s.ShortName; return(UnitsOfMeasureManager.Update(dbS)); }
public ServiceResult Update(UnitOfMeasure s) { if (s == null) { return(ServiceResponse.Error("Invalid UnitsOfMeasure sent to server.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); var dbS = (UnitOfMeasure)UnitsOfMeasureManager.GetBy(s.UUID); if (dbS == null) { return(ServiceResponse.Error("UnitsOfMeasure was not found.")); } if (dbS.DateCreated == DateTime.MinValue) { dbS.DateCreated = DateTime.UtcNow; } dbS.Deleted = s.Deleted; dbS.Name = s.Name; dbS.Status = s.Status; dbS.SortOrder = s.SortOrder; dbS.Category = s.Category; dbS.ShortName = s.ShortName; return(UnitsOfMeasureManager.Update(dbS)); }
/// <summary> /// Updates the plot with new data. /// </summary> /// <param name="data"></param> public void Update(double[] data, string xAxisLabel, string yAxisLabel) { liveChartValues.AddRange(data); ScottPlotChart.plt.Clear(); ScottPlotChart.plt.PlotSignal(liveChartValues.ToArray(), markerSize: 0); ScottPlotChart.plt.Style(chartStyle); ScottPlotChart.plt.Colorset(Colorset.Category10); ScottPlotChart.plt.YLabel(yAxisLabel); ScottPlotChart.plt.XLabel(xAxisLabel); ScottPlotChart.plt.Legend(); ScottPlotChart.Render(); SetAxisLimitsToAuto(); if (ValuesStackPanel.Children.Count == 0) { var unit = UnitOfMeasureManager.GetUnitOfMeasure(yAxisLabel); ValuesStackPanel.Children.Add(new ChartValue(yAxisLabel, /*liveChartValues.Last(),*/ unit == null ? "" : unit.UnitOfMeasure, "" /*, "#4d4d4d", 0*/)); } else { foreach (ChartValue item in ValuesStackPanel.Children) { item.SetChannelValue(liveChartValues.Last()); } } }
public ServiceResult AssignUOMsToProductCategories() { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } ServiceResult res = new ServiceResult(); res.Code = 200; StringBuilder msg = new StringBuilder(); try { Task <string> content = Request.Content.ReadAsStringAsync(); if (content == null) { return(ServiceResponse.Error("No data was sent.")); } string body = content.Result; if (string.IsNullOrEmpty(body)) { return(ServiceResponse.Error("Content body is empty.")); } List <UnitOfMeasure> uoms = JsonConvert.DeserializeObject <List <UnitOfMeasure> >(body); foreach (UnitOfMeasure u in uoms) { u.AccountUUID = CurrentUser.AccountUUID; u.CreatedBy = CurrentUser.UUID; u.DateCreated = DateTime.UtcNow; UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); ServiceResult tmpRes = UnitsOfMeasureManager.Insert(u); if (tmpRes.Code != 200) { res.Code = tmpRes.Code; msg.AppendLine(tmpRes.Message); } } } catch (Exception ex) { res = ServiceResponse.Error(ex.Message); Debug.Assert(false, ex.Message); SystemLogger logger = new SystemLogger(Globals.DBConnectionKey); logger.InsertError(ex.Message, "UnitsOfMeasureController", "AssignUOMsToProductCategories"); } res.Message = msg.ToString(); return(res); }
public ServiceResult Delete(UnitOfMeasure n) { if (n == null || string.IsNullOrWhiteSpace(n.UUID)) { return(ServiceResponse.Error("Invalid account was sent.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); return(UnitsOfMeasureManager.Delete(n)); }
public ServiceResult Delete(UnitOfMeasure n) { if (n == null || string.IsNullOrWhiteSpace(n.UUID)) { return(ServiceResponse.Error("Invalid account was sent.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); return(UnitsOfMeasureManager.Delete(n)); }
public ServiceResult GetBy(string uuid) { if (string.IsNullOrWhiteSpace(uuid)) { return(ServiceResponse.Error("You must provide a name for the UnitsOfMeasure.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); return(UnitsOfMeasureManager.Get(uuid)); }
public ServiceResult GetUnitsOfMeasure() { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); DataFilter filter = this.GetFilter(Request); List <dynamic> UnitOfMeasures = UnitsOfMeasureManager.GetUnitsOfMeasure(CurrentUser.AccountUUID, ref filter).Cast <dynamic>().ToList(); return(ServiceResponse.OK("", UnitOfMeasures, filter.TotalRecordCount)); }
private ChartValue AddEmptySideValue(string channelName) { var unit = UnitOfMeasureManager.GetUnitOfMeasure(channelName); if (unit == null) { unit = UnitOfMeasureManager.GetUnitOfMeasure(channelName.Replace("_", "")); } var chartValue = new ChartValue(channelName: channelName, unitOfMeasure: unit == null ? "" : unit.UnitOfMeasure, groupName: ChartName); return(chartValue); }
public InputFileChannelSettingsItem(Channel channel, int inputFileID) { InitializeComponent(); channelName = channel.Name; ChannelID = channel.ID; ID = inputFileID; colorCode = channel.Color; ChangeColor((Color)ColorConverter.ConvertFromString(colorCode)); ChannelName = channel.Name; var unitOfMeasure = UnitOfMeasureManager.GetUnitOfMeasure(channel.Name); if (unitOfMeasure != null) { unitOfMeasureFormula = unitOfMeasure.UnitOfMeasure; var formula = @"\color[HTML]{" + ColorManager.Secondary900[1..] + "}{" + unitOfMeasure.UnitOfMeasure + "}";
public ServiceResult Delete(string uuid) { if (string.IsNullOrWhiteSpace(uuid)) { return(ServiceResponse.Error("Invalid id was sent.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); UnitOfMeasure fa = (UnitOfMeasure)UnitsOfMeasureManager.GetBy(uuid); if (fa == null) { return(ServiceResponse.Error("Could not find measure.")); } return(UnitsOfMeasureManager.Delete(fa)); }
public ServiceResult GetBy(string uuid) { if (string.IsNullOrWhiteSpace(uuid)) { return(ServiceResponse.Error("You must provide a name for the UnitsOfMeasure.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); UnitOfMeasure s = (UnitOfMeasure)UnitsOfMeasureManager.GetBy(uuid); if (s == null) { return(ServiceResponse.Error("UnitsOfMeasure could not be located for the uuid " + uuid)); } return(ServiceResponse.OK("", s)); }
public ServiceResult Get(string name) { if (string.IsNullOrWhiteSpace(name)) { return(ServiceResponse.Error("You must provide a name for the UnitsOfMeasure.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); DataFilter filter = this.GetFilter(Request); List <UnitOfMeasure> s = UnitsOfMeasureManager.Search(name, ref filter); if (s == null || s.Count == 0) { return(ServiceResponse.Error("UnitsOfMeasure could not be located for the name " + name)); } return(ServiceResponse.OK("", s)); }
public ServiceResult GetUnitsOfMeasure(string filter = "") { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); List <dynamic> UnitOfMeasures = UnitsOfMeasureManager.GetUnitsOfMeasure(CurrentUser.AccountUUID).Cast <dynamic>().ToList(); int count; DataFilter tmpFilter = this.GetFilter(filter); UnitOfMeasures = FilterEx.FilterInput(UnitOfMeasures, tmpFilter, out count); return(ServiceResponse.OK("", UnitOfMeasures, count)); }
public ServiceResult Delete(string uuid) { if (string.IsNullOrWhiteSpace(uuid)) { return(ServiceResponse.Error("Invalid id was sent.")); } UnitOfMeasureManager UnitsOfMeasureManager = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = UnitsOfMeasureManager.Get(uuid); if (res.Code != 200) { return(res); } UnitOfMeasure fa = (UnitOfMeasure)res.Result; return(UnitsOfMeasureManager.Delete(fa)); }
public MainWindow() { InitializeComponent(); try { ConfigurationManager.LoadConfigurations(Path.Combine(MakeDirectoryPath("configuration_files"), TextManager.ConfigurationFileName)); Title = $"Telemetry {ConfigurationManager.Version}"; } catch (Exception exception) { ShowError.ShowErrorMessage(exception.Message); } try { UnitOfMeasureManager.InitializeUnitOfMeasures(Path.Combine(MakeDirectoryPath("default_files"), TextManager.UnitOfMeasuresFileName)); } catch (Exception exception) { ShowError.ShowErrorMessage(exception.Message); } try { DriverlessTrackManager.LoadTracks(Path.Combine(MakeDirectoryPath("default_files"), TextManager.DriverlessTracksFolderName)); } catch (Exception exception) { ShowError.ShowErrorMessage(exception.Message); } try { GroupManager.InitGroups(Path.Combine(MakeDirectoryPath("default_files"), TextManager.GroupsFileName)); } catch (Exception exception) { ShowError.ShowErrorMessage(exception.Message); } try { DefaultsManager.LoadDefaults(Path.Combine(MakeDirectoryPath("default_files"), TextManager.DefaultFileName)); } catch (Exception exception) { ShowError.ShowErrorMessage(exception.Message); } try { MenuManager.InitMainMenuTabs(MainMenuTabControl); } catch (Exception exception) { ShowError.ShowErrorMessage(exception.Message); } }
public ServiceResult Insert(DoseLogForm d) { string authToken = this.GetAuthToken(Request); //d.UserUUID <= patient id. for now make this a hidden field and use the cookie value. // for an app that uses multiple patients then we'll need make a combobox or some list to select //whom we're logging for. if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } UserSession us = SessionManager.GetSession(authToken); if (us == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } if (us.Captcha?.ToUpper() != d.Captcha?.ToUpper()) { return(ServiceResponse.Error("Invalid code.")); } if (string.IsNullOrWhiteSpace(d.AccountUUID)) { d.AccountUUID = CurrentUser.AccountUUID; } if (string.IsNullOrWhiteSpace(d.CreatedBy)) { d.CreatedBy = us.UUID; } if (d.DateCreated == DateTime.MinValue) { d.DateCreated = DateTime.UtcNow; } d.Active = true; d.Deleted = false; if (d.DoseDateTime == null || d.DoseDateTime == DateTime.MinValue) { return(ServiceResponse.Error("You must a date time for the dose.")); } if (string.IsNullOrWhiteSpace(d.ProductUUID)) { return(ServiceResponse.Error("You must select a product.")); } ProductManager productManager = new ProductManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = productManager.Get(d.ProductUUID); if (res.Code != 200) { return(res);// return ServiceResponse.Error("Product could not be found. You must select a product, or create one from the products page."); } Product p = (Product)res.Result; if (string.IsNullOrWhiteSpace(d.Name)) { d.Name = string.Format("{0} {1} {2}", p.Name, d.Quantity, d.UnitOfMeasure); } if (d.Quantity <= 0) { return(ServiceResponse.Error("You must enter a quantity")); } if (string.IsNullOrWhiteSpace(d.UnitOfMeasure)) { return(ServiceResponse.Error("You must select a unit of measure.")); } UnitOfMeasureManager uomm = new UnitOfMeasureManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); if (uomm.Get(d.UnitOfMeasure) == null) { var filter = new DataFilter(); UnitOfMeasure uom = (UnitOfMeasure)uomm.Search(d.UnitOfMeasure, ref filter)?.FirstOrDefault(); if (uom == null) { uom = new UnitOfMeasure(); uom.Name = d.UnitOfMeasure.Trim(); uom.AccountUUID = CurrentUser.AccountUUID; uom.Active = true; uom.Deleted = false; uom.Private = true; ServiceResult uomSr = uomm.Insert(uom); if (uomSr.Code != 200) { return(uomSr); } } d.UnitOfMeasure = uom.UUID; } var config = new MapperConfiguration(cfg => { cfg.CreateMap <DoseLogForm, DoseLog>(); }); IMapper mapper = config.CreateMapper(); var dest = mapper.Map <DoseLogForm, DoseLog>(d); DoseManager DoseManager = new DoseManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); ServiceResult sr = DoseManager.Insert(dest); if (sr.Code != 200) { return(sr); } SymptomManager sm = new SymptomManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); StringBuilder symptomErrors = new StringBuilder(); int index = 1; foreach (SymptomLog s in d.Symptoms) { if (string.IsNullOrWhiteSpace(s.UUID)) { symptomErrors.AppendLine("Symptom " + index + " UUID must be set!"); Debug.Assert(false, "SYMPTOM UUID MUST BE SET!!"); continue; } var res2 = sm.Get(s.UUID); if (res2.Code != 200) { continue; } Symptom stmp = (Symptom)res2.Result; s.Name = stmp.Name; if (s.SymptomDate == null || s.SymptomDate == DateTime.MinValue) { symptomErrors.AppendLine("Symptom " + s.UUID + " date must be set!"); continue; } //s.Status s.AccountUUID = CurrentUser.AccountUUID; s.Active = true; s.CreatedBy = CurrentUser.UUID; s.DateCreated = DateTime.UtcNow; s.Deleted = false; s.DoseUUID = dest.UUID; s.Private = true; ServiceResult slSr = sm.Insert(s); if (slSr.Code != 200) { symptomErrors.AppendLine("Symptom " + index + " failed to save. " + slSr.Message); } index++; } if (symptomErrors.Length > 0) { return(ServiceResponse.Error(symptomErrors.ToString())); } return(ServiceResponse.OK("", dest)); }