private bool InsertSample(SamplesViewModel sample) { bool mret = false; DateTime today = new DateTime(); FileInfo fsSamples = new FileInfo(AppContext.BaseDirectory + @"\Services\Samples.txt"); StringBuilder s = new StringBuilder(); if (samples == null) { samples = new List <Sample>(BaseData()); } s.Append(samples.Count + 1 + ','); s.Append(sample.Barcode + ','); s.Append(today.ToString() + ','); s.Append(GetUser(sample.createdByUser) + ','); s.Append('0'); try { using (Stream stream = File.Open(fsSamples.FullName, FileMode.Append)) { byte[] newrecord = Encoding.ASCII.GetBytes(s.ToString()); stream.Write(newrecord, 0, newrecord.Length); } mret = true; } catch (Exception ex) { _logger.LogError(ex.Message); } return(mret); }
private IEnumerable <SamplesViewModel> SamplesByStatus(int value) { List <SamplesViewModel> mret = new List <SamplesViewModel>(); if (samples == null) { samples = new List <Sample>(BaseData()); samples = samples.Where(l => l.status == value).ToList(); } else { samples = samples.Where(l => l.status == value).ToList(); } foreach (var item in samples) { SamplesViewModel l = new SamplesViewModel(); l.ID = item.Id; l.Barcode = item.Barcode; l.CreatedAt = item.CreatedAt; l.createdByUser = GetUser(item.CreatedBy); l.labstatus = GetStatus(item.status); mret.Add(l); } return(mret); }
public async Task <IActionResult> Index() { var viewModel = new SamplesViewModel(); var samplesList = await this.sampleDate.GetSamples(); viewModel.EventList = samplesList; viewModel.SampledList = binParser.GetMeanPerBin(new TimeSpan(0, 5, 0), samplesList); return(View(viewModel)); }
public ProjectPropertiesViewModel(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; _project = DocumentCache.ProjectViewModel as ProjectViewModel; _samples = _project.Children.First().Samples; AddRunData = new DelegateCommand<IList>(OnAddRunData); _selectedDataPath = Properties.Settings.Default.LastBrowseDataPath; LoadFiles(); }
public IActionResult Post([FromBody] SamplesViewModel newsample) { if (ModelState.IsValid) { //return Created($"api/samples/{newsample.Barcode}", newsample); return(Ok(true)); } return(BadRequest("Bad data")); }
public IActionResult Edit(SamplesViewModel model) { var response = ResponseModelFactory.CreateInstance; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbITMContext) { var ene = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName); var entity = _dbITMContext.Samples.FirstOrDefault(x => x.Id == model.Id); entity.FoodIds = model.FoodIds; entity.FoodName = model.FoodName; entity.Note = model.Note; entity.Img = model.Img; entity.Weight = model.Weight; entity.Hours = model.Hours; entity.MealTime = model.MealTime; entity.MealTimeName = model.MealTimeName; var eneAuditorName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.AuditorName && x.OrganizationId == ene.OrganizationId); if (eneAuditorName != null) { entity.AuditorName = model.AuditorName; entity.AuditorId = Convert.ToInt32(eneAuditorName.UserId); } else { response.SetFailed("暂无该人员信息"); return(Ok(response)); } var eneSampleName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.SampleName && x.OrganizationId == ene.OrganizationId); if (eneSampleName != null) { entity.SampleName = model.SampleName; entity.SampleUserId = Convert.ToInt32(eneSampleName.UserId); } else { response.SetFailed("暂无该人员信息"); return(Ok(response)); } entity.SampledAt = model.SampledAt; entity.MaturedAt = model.MaturedAt; entity.EliminatedAt = model.EliminatedAt; entity.UpdatedAt = DateTime.Now; entity.Note = model.Note; _dbITMContext.SaveChanges(); response.SetSuccess("修改成功"); return(Ok(response)); } }
public MainMenu(INavigation navigation) { InitializeComponent(); _navigation = navigation; BindingContext = new SamplesViewModel(navigation); if (AccountService.Instance.Current_Account != null) { //toggler.BindingContext = Profile_MyProfile_ViewModel.Instance; } //CheckAvailablity(); }
public IHttpActionResult PostVisitSample(int id, SamplesViewModel sampleVM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } sampleVM.Description = db.SampleTypes.Find(sampleVM.TypeSampleId).Description; var sample = Mapper.Map <SamplesViewModel, Sample>(sampleVM); db.Samples.Add(sample); db.SaveChanges(); return(Ok(sampleVM)); }
private IEnumerable <SamplesViewModel> SamplesByUserSearch(string user) { List <SamplesViewModel> mret = new List <SamplesViewModel>(); samples = new List <Sample>(BaseData()); foreach (var item in samples) { SamplesViewModel l = new SamplesViewModel(); l.ID = item.Id; l.Barcode = item.Barcode; l.CreatedAt = item.CreatedAt; l.createdByUser = GetUser(item.CreatedBy).ToUpper(); l.labstatus = GetStatus(item.status); mret.Add(l); } mret = mret.FindAll(l => l.createdByUser.Split(new char[] { ' ' })[0].Equals(user.ToUpper()) || l.createdByUser.Split(new char[] { ' ' })[1].Equals(user.ToUpper())); return(mret); }
private IEnumerable <SamplesViewModel> AllSamples() { List <SamplesViewModel> mret = new List <SamplesViewModel>(); if (samples == null) { samples = new List <Sample>(BaseData()); } foreach (var item in samples) { SamplesViewModel l = new SamplesViewModel(); l.ID = item.Id; l.Barcode = item.Barcode; l.CreatedAt = item.CreatedAt; l.createdByUser = GetUser(item.CreatedBy); l.labstatus = GetStatus(item.status); mret.Add(l); } return(mret); }
public IActionResult Create(SamplesViewModel model) { var response = ResponseModelFactory.CreateInstance; if (AuthContextService.CurrentUser.SchoolGuid == null) { response.SetFailed("请登录学校账号"); return(Ok(response)); } using (_dbITMContext) { var ene = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName); var entity = new MYEntities.Samples(); entity.SampleId = 0; entity.OrganizationId = ene.OrganizationId; entity.FoodIds = model.FoodIds; entity.FoodName = model.FoodName; entity.Note = model.Note; entity.Img = model.Img; entity.Weight = model.Weight; entity.Hours = model.Hours; entity.Del = 1; entity.CreateUserId = 308343; entity.MealTime = model.MealTime; entity.MealTimeName = model.MealTimeName; entity.EliminateId = model.EliminateId; entity.EliminateName = model.EliminateName; var eneAuditorName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.AuditorName && x.OrganizationId == ene.OrganizationId); if (eneAuditorName != null) { entity.AuditorName = model.AuditorName; entity.AuditorId = Convert.ToInt32(eneAuditorName.UserId); } else { response.SetFailed("暂无该人员信息"); return(Ok(response)); } var eneSampleName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.SampleName && x.OrganizationId == ene.OrganizationId); if (eneSampleName != null) { entity.SampleName = model.SampleName; entity.SampleUserId = Convert.ToInt32(eneSampleName.UserId); } else { response.SetFailed("暂无该人员信息"); return(Ok(response)); } entity.SampledAt = model.SampledAt; entity.CreatedAt = DateTime.Now; entity.MaturedAt = model.MaturedAt; entity.EliminatedAt = model.EliminatedAt; entity.Note = model.Note; entity.Sync = 0; _dbITMContext.Samples.Add(entity); _dbITMContext.SaveChanges(); response.SetSuccess("添加成功"); return(Ok(response)); } }
public void TestInitialize() { project = TestHelper.CreateTestProject(); viewModel = new ProjectViewModel(project); samplesViewModel = viewModel.Children.First().Children.First() as SamplesViewModel; experiment = (Experiment)project.Experiments.First(); }
// GET: Materials public IActionResult Index(string material, double?mass, string property, int page = 1, SamplesSortState sortOrder = SamplesSortState.NameSampleAsc) { int pageSize = 10; IQueryable <Samples> source = _context.Samples.Include(s => s.IdMaterialNavigation); if (material != null) { source = source.Where(x => x.IdMaterialNavigation.NameMaterial == material); } if (mass != null && mass != 0) { source = source.Where(x => x.IdMaterialNavigation.MassMaterial.Value == mass.Value); } if (property != null) { source = source.Where(x => x.IdMaterialNavigation.Property == property); } switch (sortOrder) { case SamplesSortState.NameSampleAsc: source = source.OrderBy(x => x.NameSample); break; case SamplesSortState.NameSampleDesc: source = source.OrderByDescending(x => x.NameSample); break; case SamplesSortState.MassSampleAsc: source = source.OrderBy(x => x.MassSample); break; case SamplesSortState.MassSampleDesc: source = source.OrderByDescending(x => x.MassSample); break; case SamplesSortState.IdMaterialAsc: source = source.OrderBy(x => x.IdMaterial); break; case SamplesSortState.IdMaterialDesc: source = source.OrderByDescending(x => x.IdMaterial); break; default: source = source.OrderBy(x => x.NameSample); break; } var count = source.Count(); var items = source.Skip((page - 1) * pageSize).Take(pageSize); PageViewModel pageView = new PageViewModel(count, page, pageSize); SamplesViewModel ivm = new SamplesViewModel { PageViewModel = pageView, SortViewModel = new SortSamplesViewModel(sortOrder), FilterViewModel = new FilterSamplesViewModel(material, mass, property), Samples = items }; return(View(ivm)); }
public bool CreateSample(SamplesViewModel newSample) { throw new NotImplementedException(); }
public RecentUsedRLC() { InitializeComponent(); BindingContext = new SamplesViewModel(Navigation); }
public MainWindow() { InitializeComponent(); DataContext = _viewModel = new SamplesViewModel(); Loaded += MainWindow_Loaded; }