public async Task <int> Edit(MonitorItemViewModel viewModel)
        {
            _dbContext.Update(viewModel.Monitor);

            //  Message:保存监控配置
            Action <TemplateBase, string> ConvertTo = (l, k) =>
            {
                ehc_dv_monitorextention extend = _dbContext.ehc_dv_monitorextentions.Where(m => m.MonitorID == viewModel.Monitor.ID && m.TypeID == k).FirstOrDefault();

                extend.Value = ToolService.Instance.SerializeObject(l);
                extend.UDATE = DateTime.Now.ToDateTimeString();
                _dbContext.Update(extend);
            };

            //  Do:转换并保存
            ConvertTo(viewModel.HeartRange, "5d107bfa-3784-4e7c-8d40-5c9a38309cd6");
            ConvertTo(viewModel.BreathRange, "e126274b-1bc4-4724-8c84-6123a506615d");
            ConvertTo(viewModel.TimeRange1, "5e4d6b02-1c05-4630-bfda-9c71fc031408");
            ConvertTo(viewModel.TimeRange2, "ee2579bd-111b-457c-8fd1-befb12bbe64e");
            ConvertTo(viewModel.TimeRange3, "c1a239fe-5326-4bd0-8bb3-38b9e59e36e5");
            ConvertTo(viewModel.TimeRange4, "1b77e4ae-81b9-45c0-bcfe-867746582dbf");
            ConvertTo(viewModel.TimeRange5, "67216ec5-c33c-4965-b201-c7889e46d9ef");

            return(await _dbContext.SaveChangesAsync());
        }
예제 #2
0
        public void TestMethod111()
        {
            MonitorItemViewModel model = new MonitorItemViewModel();

            foreach (PropertyInfo p in typeof(MonitorItemViewModel).GetProperties())
            {
                //object[] Attribute1 = p.GetCustomAttributes(true);
                object[] Attribute2 = p.GetCustomAttributes(typeof(DescriptionAttribute), false);


                //if (Attribute1 != null)
                //{
                //    foreach (var item in Attribute1)
                //    {
                //        if (item is DescriptionAttribute)
                //            Debug.WriteLine((item as DescriptionAttribute).Description);
                //    }
                //}

                if (Attribute2 != null)
                {
                    foreach (var item in Attribute2)
                    {
                        if (item is DescriptionAttribute)
                        {
                            Debug.WriteLine((item as DescriptionAttribute).Description);
                        }
                    }
                }
            }


            string str = string.Empty;
        }
예제 #3
0
        public async Task <IActionResult> Edit(string id, MonitorItemViewModel viewModel)
        {
            if (id != viewModel.Monitor.ID.ToString())
            {
                return(NotFound());
            }

            if (viewModel.IsFormVisble())
            {
                try
                {
                    await _respository.Edit(viewModel);

                    await _respository.WriteUserLogger(this.GetUserID(), UserLoggerConfiger.EditMonitor, viewModel.Monitor.CUSTOMID);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_respository.Exist(id).Result)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            var result = await _respository.GetMonitorDeitalByID(id);

            if (result == null)
            {
                return(NotFound());
            }

            var monitors = await this._respository.GetListAsync();

            Func <ehc_dv_customer, bool> custom = l =>
            {
                return((!monitors.Exists(k => k.CUSTOMID == l.ID)) || l.ID == result.Monitor.CUSTOMID);
            };

            Func <ehc_dv_bed, bool> bed = l =>
            {
                return((!monitors.Exists(k => k.BEDID == l.ID)) || l.ID == result.Monitor.BEDID);
            };

            await this.RefreshDropList(custom, bed);

            return(View(viewModel));
        }
        MonitorItemViewModel GetMonitorDeital(ehc_dv_monitor monitor)
        {
            var extentions = _dbContext.ehc_dv_monitorextentions.Where(l => l.MonitorID == monitor.ID);

            MonitorItemViewModel viewModel = new MonitorItemViewModel();

            viewModel.Monitor = monitor;


            viewModel.CardID = this._dbContext.Customers.FirstOrDefault(l => l.ID == monitor.CUSTOMID)?.CARDID;

            var bed = this._dbContext.Beds.FirstOrDefault(l => l.ID == monitor.BEDID);

            viewModel.MatCode = bed?.MATID;

            var heartDb = extentions.Where(l => l.TypeID == "5d107bfa-3784-4e7c-8d40-5c9a38309cd6");

            viewModel.HeartRange = ToolService.Instance.DeSerializeObject <Splite2Template>(heartDb.FirstOrDefault().Value);

            var breathDb = extentions.Where(l => l.TypeID == "e126274b-1bc4-4724-8c84-6123a506615d");

            viewModel.BreathRange = ToolService.Instance.DeSerializeObject <Splite2Template>(breathDb.FirstOrDefault().Value);

            var timespan1Db = extentions.Where(l => l.TypeID == "5e4d6b02-1c05-4630-bfda-9c71fc031408");

            viewModel.TimeRange1 = ToolService.Instance.DeSerializeObject <TimeTemplate>(timespan1Db.FirstOrDefault().Value);

            var timespan2Db = extentions.Where(l => l.TypeID == "ee2579bd-111b-457c-8fd1-befb12bbe64e");

            viewModel.TimeRange2 = ToolService.Instance.DeSerializeObject <TimeTemplate>(timespan2Db.FirstOrDefault().Value);

            var timespan3Db = extentions.Where(l => l.TypeID == "c1a239fe-5326-4bd0-8bb3-38b9e59e36e5");

            viewModel.TimeRange3 = ToolService.Instance.DeSerializeObject <TimeTemplate>(timespan3Db.FirstOrDefault().Value);

            var timespan4Db = extentions.Where(l => l.TypeID == "1b77e4ae-81b9-45c0-bcfe-867746582dbf");

            viewModel.TimeRange4 = ToolService.Instance.DeSerializeObject <TimeTemplate>(timespan4Db.FirstOrDefault().Value);

            var timespan5Db = extentions.Where(l => l.TypeID == "67216ec5-c33c-4965-b201-c7889e46d9ef");

            viewModel.TimeRange5 = ToolService.Instance.DeSerializeObject <TimeTemplate>(timespan5Db.FirstOrDefault().Value);


            return(viewModel);
        }
예제 #5
0
        public async Task <IActionResult> Create(MonitorItemViewModel viewModel)
        {
            //if (ModelState.IsValid)
            //{
            //    await _respository.Create(viewModel);

            //    await _respository.WriteUserLogger(this.GetUserID(), "添加监控", viewModel.Monitor.ID);

            //    return RedirectToAction(nameof(Index));
            //}

            if (viewModel.IsFormVisble())
            {
                await _respository.Create(viewModel);

                await _respository.WriteUserLogger(this.GetUserID(), UserLoggerConfiger.AddMonitor, viewModel.Monitor.ID);

                return(RedirectToAction(nameof(Index)));
            }

            var monitors = await this._respository.GetListAsync();

            Func <ehc_dv_customer, bool> custom = l =>
            {
                return(!monitors.Exists(k => k.CUSTOMID == l.ID));
            };

            Func <ehc_dv_bed, bool> bed = l =>
            {
                return(!monitors.Exists(k => k.BEDID == l.ID));
            };

            await this.RefreshDropList(custom, bed);

            return(View(viewModel));
        }