Exemple #1
0
        public bool UpdateExampaper(ResSurveyExampaper info)
        {
            //先删除该问卷下的所有问题
            var deleteWhere = "Res_SurveyQuestion.ExampaperID=" + info.ExampaperID;

            var optionDeleteWhere = "Res_SurveyQuestionAnswer.QuestionID IN (" +
                                    info.Questions.Select(p => p.QuestionID).GetString() + ")";

            _dataAccess.DeleteEntities <ResSurveyQuestion>(deleteWhere);
            _dataAccess.DeleteEntities <ResSurveyQuestionAnswer>(optionDeleteWhere);
            foreach (var question in info.Questions)
            {
                question.ExampaperID = info.ExampaperID;
                question.TenantId    = info.TenantId;
                question.userID      = info.UserID;
            }
            AddQuestions(info.Questions);
            return(_dataAccess.UpdateEntity(info) > 0);
        }
Exemple #2
0
        /// <summary>
        /// 批量添加授权信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddAllTenantToWare(List <Sys_TenantToWare> list, string wareids)
        {
            var result  = 0;
            var allList =
                _dataAccess.GetList <Sys_TenantToWare>(" WareID in (" + wareids.TrimEnd(',').TrimStart(',') + ")");

            foreach (var item in list)
            {
                var single = allList.FirstOrDefault(p => p.WareID == item.WareID);
                if (single == null)
                {
                    _dataAccess.AddEntity(item);
                }
                else
                {
                    var openList = (single.OpenObject.TrimEnd(',') + "," + item.OpenObject.TrimStart(',')).Split(',').ToList().Distinct();
                    single.OpenObject = string.Join(",", openList);
                    _dataAccess.UpdateEntity(single);
                }
                result++;
            }
            return(result == list.Count);
        }
Exemple #3
0
        /// <summary>
        /// 绑定用户到微信帐户,如果该openID已经绑定则取消原有,绑定新的
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="openId"></param>
        public void BindingUserAccount(int userId, string openId)
        {
            var model = _dataAccess.GetList <Wx_BindingAccount>(string.Format("openid = '{0}'", openId)).FirstOrDefault();

            if (model == null)
            {
                _dataAccess.AddEntity(new Wx_BindingAccount {
                    OpenID = openId, UserId = userId
                });
            }
            else if (model.UserId != userId)
            {
                model.UserId = userId;
                _dataAccess.UpdateEntity(model);
            }
        }
Exemple #4
0
        private static readonly int REMOVEDIFF  = 60; //多少秒执行一次删除不活动用户

        /// <summary>
        /// Checks the online.
        /// </summary>
        /// <param name="userId">User identifier.</param>
        /// <param name="tenantId">Tenant identifier.</param>
        public static void CheckOnline(int userId, int tenantId)
        {
            lock (lockHelper)
            {
                string sessionId = System.Web.HttpContext.Current.Session.SessionID;

                //数据表中是否有用户的记录
                OnlineUser onlineUser = _dataAccess.GetList <OnlineUser>("sys_onlineuser.UserId=" + userId).FirstOrDefault();// onlineUsers.Find(p => p.UserId == userId);
                if (onlineUser != null && onlineUser.SessionId != sessionId)
                {
                    //SESSION变了???
                    //onlineUsers.Remove(onlineUser);
                    _dataAccess.DeleteEntities <OnlineUser>("sys_onlineuser.UserId=" + userId);
                    onlineUser = null;
                }
                if (onlineUser != null)
                {
                    //有;更新我的状态
                    onlineUser.LastActiveTime = DateTime.Now;
                    onlineUser.UserWhere      = AtWhere();
                    onlineUser.UserId         = userId;
                    _dataAccess.UpdateEntity(onlineUser, "SessionId");
                }
                else
                {
                    //无;加入关于我的在线信息
                    onlineUser                = new OnlineUser();
                    onlineUser.SessionId      = sessionId;
                    onlineUser.TenantId       = tenantId;
                    onlineUser.UserId         = userId;
                    onlineUser.LastActiveTime = DateTime.Now;
                    onlineUser.LoginTime      = DateTime.Now;
                    onlineUser.VisitorIp      = System.Web.HttpContext.Current.Request.UserHostAddress;
                    onlineUser.UserWhere      = AtWhere();
                    _dataAccess.AddEntity(onlineUser);
                }
                //如果离上次删除的时间间隔超过设定值
                TimeSpan tsRemove = DateTime.Now - LastRemove;
                if (tsRemove.Seconds > REMOVEDIFF)
                {
                    _dataAccess.ExecuteSql(string.Format(@"DELETE FROM sys_onlineuser
where TIMESTAMPDIFF(SECOND,LastActiveTime,now())>{0};", OFFLINEDIFF * 60));
                    //重置上次删除时间
                    LastRemove = DateTime.Now;
                }
            }
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="keyWord"></param>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public static int AddWord(string keyWord, int tenantId)
        {
            if (string.IsNullOrWhiteSpace(keyWord))
            {
                return(0);
            }
            var exists = _dataAccess.GetList <Sys_SearchKeyWord>("KeyWord=@keyword AND TenantId=@tid", new { keyword = keyWord, tid = tenantId }).FirstOrDefault();

            if (exists == null)
            {
                exists = new Sys_SearchKeyWord
                {
                    KeyWord     = keyWord,
                    SearchCount = 1,
                    TenantId    = tenantId,
                    Lookup      = keyWord.GetPy(0) + " " + keyWord.GetPy(2)
                };
                return(_dataAccess.AddEntity(exists));
            }
            exists.SearchCount += 1;
            return(_dataAccess.UpdateEntity(exists));
        }
Exemple #6
0
 public int Update(LenLearnPlan model)
 {
     return(_dataAccess.UpdateEntity(model));
 }
Exemple #7
0
 /// <summary>
 /// 更新政策
 /// </summary>
 /// <param name="model"></param>
 public void UpdateNotes(Sys_Notes model)
 {
     _dataAccess.UpdateEntity(model);
 }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="admin"></param>
 /// <returns></returns>
 public bool UpdateAdmin(SysAdmin admin)
 {
     return(_dataAccess.UpdateEntity(admin) > 0);
 }
Exemple #9
0
 /// <summary>
 /// 更新一个课件
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateWare(ResCourseware model)
 {
     return(_dataAccess.UpdateEntity(model));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="template"></param>
 /// <returns></returns>
 public int UpdateTemplate(SysReasonTemplate template)
 {
     return(_dataAccess.UpdateEntity(template));
 }
 /// <summary>
 /// 修改LenLearningClass
 /// </summary>
 /// <param name="lenlearningclass"></param>
 /// <returns></returns>
 public int UpdateLenLearningClass(LearningClass lenlearningclass)
 {
     return(_dataAccess.UpdateEntity(lenlearningclass));
 }
Exemple #12
0
 /// <summary>
 ///     根据ID修改分类
 /// </summary>
 /// <returns></returns>
 public bool UpdateByID(KL_KnowledgeSort sort)
 {
     return(_dataAccess.UpdateEntity(sort) > 0);
 }
Exemple #13
0
 /// <summary>
 /// 修改权限
 /// </summary>
 /// <param name="menu"></param>
 public void UpdatePermission(Sys_OperPermission menu)
 {
     _dataAccess.UpdateEntity(menu);
 }
Exemple #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dept"></param>
 public void UpdateDept(SysDepartment dept)
 {
     _dataAccess.UpdateEntity(dept);
 }
Exemple #15
0
 public int UpdateUserLevel(UserLevel level)
 {
     return(_dataAccess.UpdateEntity(level));
 }
Exemple #16
0
 /// <summary>
 /// 更新系统角色
 /// </summary>
 /// <param name="role">角色实体</param>
 public void UpdateRole(SysRole role)
 {
     _dataAccess.UpdateEntity(role);
 }
Exemple #17
0
 /// <summary>
 ///     修改书籍
 /// </summary>
 /// <param name="book"></param>
 /// <returns></returns>
 public bool ModifyEBook(EBook book)
 {
     return(_dataAccess.UpdateEntity(book) > 0);
 }
Exemple #18
0
 /// <summary>
 /// 更新一个分类
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateSort(ResCourseCategory model)
 {
     return(_dataAccess.UpdateEntity(model));
 }
Exemple #19
0
 public bool UpdatePromotionWay(PromotionWay model)
 {
     return(_dataAccess.UpdateEntity(model) > 0);
 }
Exemple #20
0
 /// <summary>
 /// 更新分类
 /// </summary>
 /// <param name="sort"></param>
 /// <returns></returns>
 public int UpdateSort(Sys_TagSort sort)
 {
     return(_dataAccess.UpdateEntity(sort));
 }
Exemple #21
0
 public bool UpdateSurveySendUser(Models.Cde.Cde_SurveySendUsers send)
 {
     return(_dataAccess.UpdateEntity(send) > 0);
 }
Exemple #22
0
 public int UpdateConfig(Models.Sys_EvalConfig config)
 {
     return(_dataAccess.UpdateEntity(config, "TenantId"));
 }
Exemple #23
0
 /// <summary>
 /// 更新租户
 /// </summary>
 /// <param name="tenant">租户实体</param>
 /// <returns></returns>
 public bool UpdateTenant(SysTenant tenant)
 {
     return(_dataAccess.UpdateEntity(tenant) > 0);
 }
Exemple #24
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(RetechWing.Models.Ab.PromotionApply model)
 {
     return(_dataAccess.UpdateEntity(model) > 0);
 }
Exemple #25
0
 /// <summary>
 /// 更新考勤数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateUserAttend(Tr_TrainUserAttend model)
 {
     return(_dataAccess.UpdateEntity(model));
 }
Exemple #26
0
 /// <summary>
 /// 更新订单
 /// </summary>
 /// <param name="bookBuy"></param>
 /// <returns></returns>
 public int UpdateBookBuy(Res_BookBuy bookBuy)
 {
     return(_dataAccess.UpdateEntity(bookBuy));
 }
Exemple #27
0
 /// <summary>
 /// 更新学习卡
 /// </summary>
 /// <param name="card">实体</param>
 /// <returns></returns>
 public int UpdateCard(ResCard card)
 {
     return(_dataAccess.UpdateEntity(card));
 }
Exemple #28
0
 /// <summary>
 /// 更新资源包
 /// </summary>
 /// <param name="package"></param>
 /// <returns></returns>
 public int UpdateResourcePackage(ResResourcePackage package)
 {
     return(_dataAccess.UpdateEntity(package));
 }
Exemple #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="post"></param>
 public void UpdatePost(SysPost post)
 {
     _dataAccess.UpdateEntity(post);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="rule"></param>
 /// <returns></returns>
 public int UpdateRule(IntegralRule rule)
 {
     return(_dataAccess.UpdateEntity(rule));
 }