예제 #1
0
 /// <summary>
 /// 根据ID获取元数据
 /// </summary>
 /// <param name="keyWord"></param>
 /// <returns></returns>
 public ConditionItem Get(int id)
 {
     using (DbContext db = new CRDatabase())
     {
         CTMS_CONDITIONITEM entity = db.Set <CTMS_CONDITIONITEM>().Find(id);
         if (entity == null || entity.ID <= 0)
         {
             return(null);
         }
         return(EntityToModel(entity));
     }
 }
예제 #2
0
 /// <summary>
 /// 根据ID获取功能
 /// </summary>
 /// <param name="keyWord"></param>
 /// <returns></returns>
 public Function Get(string id)
 {
     using (DbContext db = new CRDatabase())
     {
         CTMS_SYS_FUNCTION entity = db.Set <CTMS_SYS_FUNCTION>().Find(id);
         if (entity == null || string.IsNullOrEmpty(entity.FUNCTIONID))
         {
             return(null);
         }
         return(EntityToModel(entity));
     }
 }
예제 #3
0
        //private CRDatabase _context = new CRDatabase();

        /// <summary>
        /// 获取模板栏目列表
        /// </summary>
        /// <returns></returns>
        public IList <ExamineCategory> GetExamCatetoryList()
        {
            var list = new List <ExamineCategory>();

            using (CRDatabase _context = new CRDatabase())
            {
                _context.HR_EXAMINECATEGORY.Where(u => u.PARENTCODE != null && u.PARENTID != 0 && u.ISDELETED == 0)
                .ToList()
                .ForEach(p => list.Add(EntityToModel(p)));
            }
            return(list);
        }
예제 #4
0
 /// <summary>
 /// 获取查询列表
 /// </summary>
 /// <param name="keyWord"></param>
 /// <returns></returns>
 public MenuInfo GetOne(string ID)
 {
     using (DbContext db = new CRDatabase())
     {
         CTMS_SYS_FUNCTION entity = db.Set <CTMS_SYS_FUNCTION>().Find(ID);
         if (entity == null || string.IsNullOrEmpty(entity.FUNCTIONID))
         {
             return(null);
         }
         return(EntityToModel(entity));
     }
 }
예제 #5
0
        /// <summary>
        /// 获取模板检查项列表
        /// </summary>
        /// <param name="templateid">模板ID</param>
        /// <returns></returns>
        public IList <TemplateItem> GetTemplateItemList(string templateid)
        {
            using (CRDatabase _context = new CRDatabase())
            {
                var list = new List <TemplateItem>();
                //_context.HR_TEMPLATEITEM.Where(p => p.TEMPLATEID == templateid)
                //    .ToList()
                //    .ForEach(p => list.Add(EntityToModel(p)));

                return(list);
            }
        }
예제 #6
0
        /// <summary>
        /// 获取查询列表
        /// </summary>
        /// <param name="keyWord"></param>
        /// <returns></returns>
        public List <MenuInfo> GetList(Expression <Func <CTMS_SYS_FUNCTION, bool> > predicate)
        {
            using (DbContext db = new CRDatabase())
            {
                var query = db.Set <CTMS_SYS_FUNCTION>().AsNoTracking()
                            .Where(predicate);

                List <MenuInfo> list = query.Select(EntityToModel).ToList();

                return(list);
            }
        }
예제 #7
0
        /// <summary>
        /// 保存父类parentid
        /// </summary>
        /// <param name="id"></param>
        /// <param name="parentList"></param>
        /// <returns></returns>
        public bool SaveParentGuideLine(string id, List <ParentGuideLine> parentList)
        {
            using (var context = new CRDatabase())
            {
                context.CTMS_PARENTGUIDELINE.Where(p => p.GUIDELINEID == id)
                .ForEachAsync(k => context.CTMS_PARENTGUIDELINE.Remove(k));

                parentList.ForEach(p => p.GuideLineId = id);
                parentList.ForEach(p => context.CTMS_PARENTGUIDELINE.Add(ModelToEntity(p)));

                return(context.SaveChanges() > 0);
            }
        }
예제 #8
0
        public static DbContext GetCurrentDbContext()
        {
            //callContext 存在于线程中的独立数据槽,该位置的变量由当前线程中共享,当该线程销毁的时候,该变量也销毁
            //https://msdn.microsoft.com/zh-cn/library/system.runtime.remoting.messaging.callcontext(VS.80).aspx
            var dbContext = CallContext.GetData("DbContext") as DbContext;

            if (dbContext == null)
            {
                dbContext = new CRDatabase();
                CallContext.SetData("DbContext", dbContext);
            }
            return(dbContext);
        }
예제 #9
0
 /// <summary>
 /// 新增元数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(ConditionItem model)
 {
     if (model == null)
     {
         return(0);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Set <CTMS_CONDITIONITEM>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.ID);
     }
 }
예제 #10
0
 /// <summary>
 /// 删除会员
 /// </summary>
 /// <param name="memberId"></param>
 /// <returns></returns>
 public bool DeleteMember(string memberId)
 {
     using (var context = new CRDatabase())
     {
         var entity = context.Set <CTMS_MEMBER>().Find(memberId);
         if (entity != null)
         {
             context.Set <CTMS_MEMBER>().Remove(entity);
             context.CTMS_MEMBERPRODUCTS.Where(p => p.MEMBERID == memberId).ToList().ForEach(k => context.CTMS_MEMBERPRODUCTS.Remove(k));
         }
         return(context.SaveChanges() > 0);
     }
 }
예제 #11
0
 /// <summary>
 /// 获取单个依据模板
 /// </summary>
 /// <param name="baseTemplateID"></param>
 /// <returns></returns>
 public List <BaseTemplateResult> GetBaseOnTemplate(string historyId)
 {
     using (var db = new CRDatabase())
     {
         List <BaseTemplateResult> list = new List <BaseTemplateResult>();
         db.CTMS_BASETEMPLATERESULT.Where(p => p.HISTORYID == historyId).ToList().ForEach(k => list.Add(EntityToModel(k)));
         foreach (var item in list)
         {
             item.Name = db.CTMS_ADM_EXAMINETEMPLATES.FirstOrDefault(p => p.ID == item.EXAMINETEMPLATESID).NAME;
         }
         return(list);
     }
 }
예제 #12
0
 /// <summary>
 /// 获取全部检查项
 /// </summary>
 /// <param name="page"></param>
 /// <param name="itemNo"></param>
 /// <param name="itemName"></param>
 /// <returns></returns>
 public IList <ExamineItems> GetExamItemsList(PageInfo page, string itemNo, string itemName)
 {
     using (CRDatabase _context = new CRDatabase())
     {
         var list = new List <ExamineItems>();
         _context.HR_EXAMINEITEMS.Where(
             p =>
             (string.IsNullOrEmpty(itemNo) || p.ITEMNO.Contains(itemNo)) &&
             (string.IsNullOrEmpty(itemName) || p.ITEMNAME.Contains(itemName)))
         .Paging(ref page).ToList().ForEach(k => list.Add(EntityToModel(k)));
         return(list);
     }
 }
예제 #13
0
 /// <summary>
 /// 修改菜单
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Edit(MenuInfo model)
 {
     if (string.IsNullOrEmpty(model.ID))
     {
         LogService.WriteInfoLog("访问MenuInfoBLL类", "试图修改为空的Function实体!");
         throw new KeyNotFoundException();
     }
     using (DbContext db = new CRDatabase())
     {
         db.Entry(ModelToEntity(model)).State = EntityState.Modified;
         return(db.SaveChanges() > 0);
     }
 }
예제 #14
0
 /// <summary>
 /// 编辑用户基因
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Edit(UserGene model)
 {
     if (model == null)
     {
         LogService.WriteInfoLog(logTitle, "试图修改为空的UserGene实体!");
         return(false);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Entry(ModelToEntity(model)).State = EntityState.Modified;
         return(db.SaveChanges() > 0);
     }
 }
예제 #15
0
 /// <summary>
 /// 修改随访方案
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Edit(QATestSolution model)
 {
     if (string.IsNullOrEmpty(model.SolutionID))
     {
         LogService.WriteInfoLog(logTitle, "试图修改为空的QATestSolution实体!");
         throw new KeyNotFoundException();
     }
     using (DbContext db = new CRDatabase())
     {
         db.Entry(ModelToEntity(model)).State = EntityState.Modified;
         return(db.SaveChanges() > 0);
     }
 }
예제 #16
0
 /// <summary>
 /// 新增随访方案
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Add(QATestSolution model)
 {
     if (model == null)
     {
         return(string.Empty);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Set <CTMS_QA_TESTSOLUTION>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.SolutionID);
     }
 }
예제 #17
0
 /// <summary>
 /// 修改元数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Edit(MetaData model)
 {
     if (model == null || model.ID <= 0)
     {
         LogService.WriteInfoLog(logTitle, "试图修改为空的MetaData实体!");
         throw new KeyNotFoundException();
     }
     using (DbContext db = new CRDatabase())
     {
         db.Entry(ModelToEntity(model)).State = EntityState.Modified;
         return(db.SaveChanges() > 0);
     }
 }
예제 #18
0
 /// <summary>
 /// 新增管家
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Add(MyHouseKeeper model)
 {
     if (model == null)
     {
         return(string.Empty);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Set <CTMS_MYHOUSEKEEPER>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.ID);
     }
 }
예제 #19
0
 /// <summary>
 /// 新增元数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(MetaData model)
 {
     if (model == null)
     {
         return(0);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Set <CTMS_METADATA>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.ID);
     }
 }
예제 #20
0
 /// <summary>
 /// 新增我的产品
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Add(MyProduct model)
 {
     if (model == null)
     {
         return(string.Empty);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Set <CTMS_MYPRODUCT>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.ID);
     }
 }
예제 #21
0
 /// <summary>
 /// 新增随访方案
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Add(QATestPaper model)
 {
     if (model == null)
     {
         return(string.Empty);
     }
     using (DbContext db = new CRDatabase())
     {
         db.Set <CTMS_QA_TESTPAPER>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.TestPaperID);
     }
 }
예제 #22
0
 public bool CloseApply(string applyId)
 {
     using (var context = new CRDatabase())
     {
         var entity = context.CTMS_USERAPPLY.FirstOrDefault(p => p.ID == applyId);
         if (entity == null)
         {
             return(false);
         }
         entity.STATUS = "3";
         return(context.SaveChanges() > 0);
     }
 }
예제 #23
0
 /// <summary>
 /// 获取查询列表
 /// </summary>
 /// <param name="keyWord"></param>
 /// <returns></returns>
 public List <MyHouseKeeper> GetList(string userID)
 {
     using (DbContext db = new CRDatabase())
     {
         if (string.IsNullOrEmpty(userID))
         {
             return(new List <MyHouseKeeper>());
         }
         var user = db.Set <CTMS_SYS_USERINFO>().Find(userID);
         if (user == null)
         {
             return(new List <MyHouseKeeper>());
         }
         var query = db.Set <CTMS_MYHOUSEKEEPER>().AsNoTracking().Where(o => !o.ISDELETED && o.USERID.Equals(userID)).ToList();
         if (query.Count == 0)  //Todo 临时取第一个医生和客服
         {
             List <MyHouseKeeper> list = new List <MyHouseKeeper>();
             var doctor   = db.Set <CTMS_SYS_USERINFO>().FirstOrDefault(o => !o.ISDELETED && o.USERTYPE == 1); //医生
             var customer = db.Set <CTMS_SYS_USERINFO>().FirstOrDefault(o => !o.ISDELETED && o.USERTYPE == 4); //客户
             if (doctor != null)
             {
                 list.Add(new MyHouseKeeper()
                 {
                     ID              = Guid.NewGuid().ToString(),
                     LoginName       = user.LOGINNAME,
                     ObjectLoginName = doctor.LOGINNAME,
                     ObjectUserID    = doctor.USERID,
                     ObjectType      = "医生",
                     UserID          = user.USERID,
                 });
             }
             if (customer != null)
             {
                 list.Add(new MyHouseKeeper()
                 {
                     ID              = Guid.NewGuid().ToString(),
                     LoginName       = user.LOGINNAME,
                     ObjectLoginName = customer.LOGINNAME,
                     ObjectUserID    = customer.USERID,
                     ObjectType      = "客服",
                     UserID          = user.USERID,
                 });
             }
             return(list);
         }
         else
         {
             return(query.Select(EntityToModel).ToList());
         }
     }
 }
예제 #24
0
        public IList <ExamineTemplate> GetTemplateListForDocResult( )
        {
            var list = new List <ExamineTemplate>();

            using (CRDatabase _context = new CRDatabase())
            {
                _context.HR_EXAMINETEMPLATE.Where(p => p.ISDELETED == "0")
                .ToList()
                .ForEach(p => list.Add(EntityToModel(p)));

                foreach (var examineTemplate in list)
                {
                    examineTemplate.TemplateItems = new List <HR_TemplateItemDTO>();

                    (from temp in _context.HR_TEMPLATEITEM
                     join unit in _context.HR_TEMPLATEITEMUNIT

                     on temp.ITEMID equals unit.ITEMID into JoinedTmpUnit

                     from temps in JoinedTmpUnit.DefaultIfEmpty()
                     where temp.TEMPLATEID == examineTemplate.TEMPLATEID

                     select new
                    {
                        ITEMID = temp.ITEMID,
                        TEMPLATEID = temp.TEMPLATEID,
                        ITEMNAME = temp.ITEMNAME,
                        ITEMNAMEENG = temp.ITEMNAMEENG,
                        ITEMUNITID = temps.ITEMUNITID,
                        UNITNAME = temps.UNITNAME,
                        UNITDESC = temps.UNITDESC
                    }
                    ).ToList().ForEach(p => examineTemplate.TemplateItems.Add(new HR_TemplateItemDTO()
                    {
                        ITEMID      = p.ITEMID,
                        TEMPLATEID  = p.TEMPLATEID,
                        ITEMNAME    = p.ITEMNAME,
                        ITEMNAMEENG = p.ITEMNAMEENG,
                        ITEMUNITID  = p.ITEMUNITID,
                        UNITNAME    = p.UNITNAME,
                        UNITDESC    = p.UNITDESC
                    }));
                    //_context.HR_TEMPLATEITEM.Where(p => p.TEMPLATEID == examineTemplate.TEMPLATEID).ToList().ForEach(k => examineTemplate.TemplateItems.Add(EntityToModel(k)));

                    //examineTemplate.TemplateItems.ToList()
                    //    .ForEach(p => _context.HR_TEMPLATEITEMUNIT.Where(k => k.ITEMID == p.ITEMID).ToList()
                    //        .ForEach(m => p.ItemUnit.Add(EntityToModel(m))));
                }
            }
            return(list);
        }
예제 #25
0
        /// <summary>
        /// 添加用户待办信息
        /// </summary>
        public void AddUserEvent(UserEvent model, UserType userType)
        {
            using (var context = new CRDatabase())
            {
                //1.根据UserTypetype找到人
                var toUserId = context.CTMS_SYS_USERINFO.FirstOrDefault(p => p.USERTYPE == (decimal)userType);

                //2.将事件类型ActionInfo插入表中
                model.ToUser = toUserId.USERID;
                context.CTMS_USEREVENT.Add(ModelToEntity(model));

                context.SaveChanges();
            }
        }
예제 #26
0
 /// <summary>
 /// 新增功能权限
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Add(FunctionPermission model)
 {
     if (model == null)
     {
         return(string.Empty);
     }
     using (DbContext db = new CRDatabase())
     {
         model.FunctionPermissionID = Guid.NewGuid().ToString();
         db.Set <CTMS_SYS_FUNCTIONPERMISSION>().Add(ModelToEntity(model));
         db.SaveChanges();
         return(model.FunctionPermissionID);
     }
 }
예제 #27
0
        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public List <SeeDoctorHistory> GetList(PageInfo pageInfo, Expression <Func <HR_SEEDOCTORHISTORY, bool> > predicate = null)
        {
            using (var db = new CRDatabase())
            {
                List <SeeDoctorHistory> list = new List <SeeDoctorHistory>();
                db.HR_SEEDOCTORHISTORY.Where(predicate)
                .Paging(ref pageInfo)
                .ToList().ForEach(k => list.Add(EntityToModel(k)));

                list.ForEach(k => k.PERSONID = GetUserName(db.CTMS_SYS_USERINFO.Where(p => p.USERID.Equals(k.PERSONID)).FirstOrDefault()));

                return(list);
            }
        }
예제 #28
0
        /// <summary>
        /// 返回就诊史列表
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <param name="keyWord"></param>
        /// <returns></returns>
        public List <SeeDoctorHistory> GetSeeDoctorHistories(PageInfo pageInfo, string keyWord, string personId)
        {
            using (var db = new CRDatabase())
            {
                List <SeeDoctorHistory> list = new List <SeeDoctorHistory>();

                db.HR_SEEDOCTORHISTORY.Where(p => (string.IsNullOrEmpty(keyWord) || p.HOSPITAL.Contains(keyWord)) && p.PERSONID == personId)
                .Paging(ref pageInfo)
                .ToList().ForEach(k => list.Add(EntityToModel(k)));

                list.ForEach(k => k.ICD10 = GetIcdSting(db.HR_SEEDOCHISICD.Where(p => p.HISTORYID == k.HISTORYID).ToList()));
                return(list);
            }
        }
예제 #29
0
 /// <summary>
 /// 将上面一条设置成已完成
 /// </summary>
 /// <param name="eventId"></param>
 /// <returns>更新结果</returns>
 public bool CloseEvent(string eventId)
 {
     using (var context = new CRDatabase())
     {
         var entity = context.CTMS_USEREVENT.FirstOrDefault(p => p.EVENTID == eventId);
         if (entity == null)
         {
             return(false);
         }
         entity.ACTIONSTATUS = ((int)ActionStatus.Complete).ToString();
         entity.ENDTIME      = System.DateTime.Now;
         return(context.SaveChanges() > 0);
     }
 }
예제 #30
0
        /// <summary>
        /// 新增角色
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add(Role model)
        {
            if (model == null)
            {
                return(string.Empty);
            }
            using (DbContext db = new CRDatabase())
            {
                model.RoleID = Guid.NewGuid().ToString();
                db.Set <CTMS_SYS_ROLE>().Add(ModelToEntity(model));

                db.SaveChanges();
                return(model.RoleID);
            }
        }