Exemple #1
0
        /// <summary>
        ///     批量删除角色
        /// </summary>
        /// <param name="roleIds"></param>
        /// <returns></returns>
        public bool BatchDeleteRole(int[] roleIds)
        {
            string sql = string.Format("Update Dept_Roles set IsDelete = 1 where RoleId in ({0})", roleIds.GetString());

            _dataAccess.DeleteEntities <DeptRoleUser>(" Dept_RoleUser.RoleId IN (" + roleIds.GetString() + ")");
            return(_dataAccess.ExecuteSql(sql) > 0);
        }
Exemple #2
0
        public bool DeleteSteps(int planId, IEnumerable <int> stepIds)
        {
            string sql = " Len_LearnPlanDetail.PlanId=" + planId + " and Len_LearnPlanDetail.StepId not in (" +
                         stepIds.GetString() + ")";

            _dataAccess.DeleteEntities <LenLearnPlanDetail>(sql);
            return(true);
        }
Exemple #3
0
        /// <summary>
        ///     批量删除服务中心
        /// </summary>
        /// <param name="deptIds"></param>
        /// <returns></returns>
        public bool BatchDeleteDept(int[] deptIds)
        {
            var    ids = deptIds.GetString();
            string sql = string.Format("Update Sys_Department set IsDelete=1 where DepartmentId in ({0})", ids);

            _dataAccess.DeleteEntities <SysDeptToCourse>(" Sys_DeptToCourse.DeptId IN (" + ids + ")");
            return(_dataAccess.ExecuteSql(sql) > 0);
        }
Exemple #4
0
        /// <summary>
        ///     批量删除用户
        /// </summary>
        /// <param name="userIds"></param>
        /// <returns></returns>
        public bool BatchDeleteUser(int[] userIds)
        {
            var    ids = userIds.GetString();
            string sql = string.Format("Update Sys_Users set Status = 1 where UserId in ({0})", ids);

            _dataAccess.DeleteEntities <SysRoleUser>(" Sys_RoleUser.UserId IN (" + ids + ")");
            return(_dataAccess.ExecuteSql(sql) > 0);
        }
Exemple #5
0
        public int UpdateExampaper(Cde_SurveyExampaper exampaper)
        {
            var count = _dataAccess.GetCount <SurveyInfo>("Cde_SurveyInfo.ExampaperId=" + exampaper.ExampaperID);

            if (count > 0)
            {
                //已被调用,不修改原记录
                return(AddExampaper(exampaper));
            }
            else
            {
                //修改时,把问卷和问题的关联删除,重新添加关联
                var sqlwhere = "Cde_SurveyQuestion.ExampaperID=" + exampaper.ExampaperID;
                _dataAccess.DeleteEntities <Cde_SurveyQuestion>(sqlwhere);
                _dataAccess.UpdateEntity(exampaper);
                var questions = new List <Cde_SurveyQuestion>();
                for (int index = 0; index < exampaper.Questions.Count; index++)
                {
                    var question = exampaper.Questions[index];
                    questions.Add(new Cde_SurveyQuestion()
                    {
                        ExampaperID = exampaper.ExampaperID,
                        QuestionID  = question.QuestionId,
                        ShowOrder   = index
                    });
                }
                _dataAccess.AddEntities(questions);
                return(_dataAccess.UpdateEntity(exampaper));
            }
        }
Exemple #6
0
        public void AddAbilityLevels(List <AbilityLevel> list)
        {
            if (list.Count == 0)
            {
                return;
            }
            var deleteIds = new List <int>();
            var levelList = GetAbilityLevelList(list[0].TenantId);

            foreach (var item in levelList)
            {
                var tmp = list.FirstOrDefault(p => p.LevelName == item.LevelName);
                if (tmp != null)
                {
                    item.OrderNum = tmp.OrderNum;
                    _dataAccess.UpdateEntity(item);
                    list.Remove(tmp);
                }
                else
                {
                    deleteIds.Add(item.LevelId);
                }
            }
            if (deleteIds.Count > 0)
            {
                _dataAccess.DeleteEntities <AbilityLevel>(string.Format(" LevelId in ({0})", deleteIds.GetString()));
            }
            if (list.Count > 0)
            {
                _dataAccess.AddEntities(list);
            }
        }
        /// <summary>
        /// 从学习班移除成员
        /// </summary>
        /// <param name="classId"></param>
        /// <param name="userIds"></param>
        public void RemoveStudents(int classId, params int[] userIds)
        {
            //if (userIds == null || userIds.Length == 0) return;
            string deleteWhere = "Len_Students.ClassId=" + classId + ((userIds == null || userIds.Length == 0) ? "" : " AND Len_Students.UserId IN (" + userIds.GetString() + ")");

            _dataAccess.DeleteEntities <LenStudents>(deleteWhere);
        }
Exemple #8
0
        /// <summary>
        /// 修改问题。如果问题被问卷引用,则不对原问题修改,直接新增一个问题,否则直接修改
        /// </summary>
        /// <param name="question"></param>
        /// <returns></returns>
        public bool UpdateQuestion(Models.Cde.Cde_IndexQuestion question)
        {
            int usecount =
                (int)
                _dataAccess.ExecuteScalar(@"SELECT count(1) FROM Cde_SurveyQuestion sq JOIN Cde_SurveyExampaper  se ON sq.ExampaperID=se.ExampaperID
WHERE se.IsDelete=0 AND se.TenantId=1" + question.TenantId);

            if (usecount > 0)
            {
                AddQuestion(question);
            }
            else
            {
                //直接修改
                var sqlwhere = "Cde_IndexQuestionAnswer.QuestionId=" + question.QuestionId;
                _dataAccess.DeleteEntities <Cde_IndexQuestionAnswer>(sqlwhere);
                _dataAccess.UpdateEntity(question);
                foreach (var answer in question.Answers)
                {
                    answer.QuestionId = question.QuestionId;
                }
                _dataAccess.AddEntities(question.Answers);
            }

            return(true);
        }
Exemple #9
0
        public void AddSurveyAnswers(int userSurveyId, int sendUserId, List <Cde_SurveyReplyAnswer> list)
        {
            var sqlwhere = "Cde_SurveyReplyAnswer.UserSurveyID=" + userSurveyId + " AND Cde_SurveyReplyAnswer.SendUserId=" + sendUserId;

            _dataAccess.DeleteEntities <Cde_SurveyReplyAnswer>(sqlwhere);
            _dataAccess.AddEntities(list);
        }
Exemple #10
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 #11
0
        /// <summary>
        ///     批量删除订单
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        public bool BatchDeleteBookBuy(int[] Ids)
        {
            var    ids = Ids.GetString();
            string sql = string.Format("DELETE FROM Res_BookBuy WHERE Id in ({0})", ids);

            _dataAccess.DeleteEntities <Res_BookDeptDetials>(" Res_BookDeptDetials.BookBuyID IN (" + ids + ")");
            return(_dataAccess.ExecuteSql(sql) > 0);
        }
        public int SavePostAbilityAssessment(List <PostAbilityAssessment> pa)
        {
            int postId    = pa[0].AbilityId;
            int AbilityId = pa[0].PostId;

            _dataAccess.DeleteEntities <PostAbilityAssessment>(" AbilityId=" + AbilityId + " and PostId=" + postId);
            return(_dataAccess.AddEntities(pa));
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="course"></param>
        /// <returns></returns>
        public int UpdateCourse(ResCourse course)
        {
            var deleteSql = "CourseId = " + course.CourseId;

            _dataAccess.DeleteEntities <ResExampaperToCourse>(deleteSql);
            _dataAccess.DeleteEntities <ResCourseBeforeLearn>(deleteSql);
            _dataAccess.DeleteEntities <Res_CourseOpenCrowd>(deleteSql);
            course.LastUpdateTime = DateTime.Now;
            _dataAccess.UpdateEntity(course);

            foreach (var exampaper in course.Exampapers)
            {
                exampaper.CourseId = course.CourseId;
            }
            foreach (var file in course.BeforeLearnFiles)
            {
                file.CourseId = course.CourseId;
            }
            foreach (var crowd in course.OpenCrowds)
            {
                crowd.CourseId = course.CourseId;
            }
            _dataAccess.AddEntities(course.BeforeLearnFiles);
            _dataAccess.AddEntities(course.OpenCrowds);

            return(_dataAccess.AddEntities(course.Exampapers));
        }
Exemple #14
0
 public int SaveRatingEntryData(List <Ab_AbilityRating> list)
 {
     if (list.Count() > 0)
     {
         _dataAccess.DeleteEntities <Ab_AbilityRating>(" PromotionId=" + list[0].PromotionId + " and PostId=" +
                                                       list[0].PostId + " and UserId=" + list[0].UserId);
     }
     return(_dataAccess.AddEntities(list));
 }
Exemple #15
0
        /// <summary>
        /// 取消赞某一动态
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="userId"></param>
        /// <param name="operSuccess">是否成功:如果是false,则表明用户未赞过了,不能取消赞</param>
        /// <returns></returns>
        public int CancelPraiseActivity(int activityId, int userId, out bool operSuccess)
        {
            var sqlwhere = string.Format("Int_ActivityPraise.ActivityId={0} AND Int_ActivityPraise.UserId={1}",
                                         activityId, userId);
            var model = _dataAccess.GetList <ActivityPraise>(sqlwhere).FirstOrDefault();

            if (model != null)
            {
                _dataAccess.DeleteEntities <ActivityPraise>(sqlwhere);
                //更新冗余
                _dataAccess.UpdateFieldCalc("Int_UserActivity", "PraiseCount", "PraiseCount-1", "ActivityId=" + activityId);
                operSuccess = true;
            }
            else
            {
                operSuccess = false;
            }
            return((int)_dataAccess.ExecuteScalar("SELECT PraiseCount FROM Int_UserActivity WHERE ActivityId=" + activityId));
        }
Exemple #16
0
 public int AddResourceOpenUsers(List <KL_KnowledgeOpenUser> openUsers)
 {
     if (openUsers.Count > 0)
     {
         var sqlwhere = "ResourceId=" + openUsers[0].ResourceId;
         _dataAccess.DeleteEntities <KL_KnowledgeOpenUser>(sqlwhere);
         return(_dataAccess.AddEntities(openUsers));
     }
     return(0);
 }
Exemple #17
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 #18
0
        public int AddSurveySendUsers(List <Cde_SurveySendUsers> list)
        {
            if (list.Count == 0)
            {
                return(0);
            }
            var sqlwhere = "UserSurveyId=" + list[0].UserSurveyId;

            _dataAccess.DeleteEntities <Cde_SurveySendUsers>(sqlwhere);
            return(_dataAccess.AddEntities(list));
        }
Exemple #19
0
 public bool UpdateReport(Cde_Report report)
 {
     var where = "Cde_ReportIndex.ReportId=" + report.ReportId;
     _dataAccess.DeleteEntities <Cde_ReportIndex>(where);
     _dataAccess.UpdateEntity(report);
     foreach (var index in report.IndexList)
     {
         index.ReportId = report.ReportId;
     }
     _dataAccess.AddEntities(report.IndexList);
     return(true);
 }
Exemple #20
0
        public bool UpdateSurveyInfo(SurveyInfo userSurveyInfo)
        {
            foreach (var user in userSurveyInfo.EvalUsers)
            {
                user.SurveyId = userSurveyInfo.SurveyId;
            }

            string sqlwhere = "SurveyId=" + userSurveyInfo.SurveyId;

            _dataAccess.DeleteEntities <UserSurvey>(sqlwhere);
            _dataAccess.AddEntities(userSurveyInfo.EvalUsers);

            return(_dataAccess.UpdateEntity(userSurveyInfo) > 0);
        }
Exemple #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="adminId"></param>
        /// <param name="permissionIds"></param>
        /// <returns></returns>
        public int SaveAdminPermissions(int adminId, int[] permissionIds)
        {
            var delsqlwhere = "Sys_OperRolePermission.RoleId=" + adminId;

            _dataAccess.DeleteEntities <Models.Oper.Sys_OperRolePermission>(delsqlwhere);
            var rrs = new List <Models.Oper.Sys_OperRolePermission>();

            foreach (var item in permissionIds)
            {
                var rr = new Models.Oper.Sys_OperRolePermission();
                rr.PermissionId = item;
                rr.RoleId       = adminId;
                rrs.Add(rr);
            }
            return(_dataAccess.AddEntities(rrs));
        }
        public static void AddConfigs(List <Models.SysConfig> configs)
        {
            if (configs == null || configs.Count == 0)
            {
                return;
            }
            var names = "";

            foreach (var sysConfig in configs)
            {
                names += "'" + sysConfig.ConfigName + "',";
                var configKey = "SystemConfig:Tenant:" + configs.First().TenantId + ":name:" + sysConfig.ConfigName;
                CacheHelper.CacheService.Remove(configKey);
            }
            if (names.EndsWith(","))
            {
                names = names.TrimEnd(',');
            }
            var sqlwhere = "Sys_Config.ConfigName IN (" + names + ") AND Sys_Config.TenantId=" + configs.First().TenantId;

            DataAccess.DeleteEntities <Models.SysConfig>(sqlwhere);
            DataAccess.AddEntities(configs);
        }
Exemple #23
0
 /// <summary>
 /// 删除考勤数据
 /// </summary>
 /// <param name="classId"></param>
 /// <param name="objectId"></param>
 /// <returns></returns>
 public int DeleteUserAttendByClassId(int classId, int objectId)
 {
     return(_dataAccess.DeleteEntities <Tr_TrainUserAttend>(" ClassId=" + classId + " and ObjectId=" + objectId));
 }
Exemple #24
0
 /// <summary>
 /// 根据简历ID删除证书信息
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public int DeleteResumeCertificateById(string id)
 {
     return(_dataAccess.DeleteEntities <ResumeCertificateModel>(string.Format(" resume_id='{0}' ", id)));
 }
Exemple #25
0
 /// <summary>
 ///     删除用户角色
 /// </summary>
 /// <param name="userIds">用户Id</param>
 public void DeleteRolesToUser(int[] userIds)
 {
     _dataAccess.DeleteEntities <Sys_AdminRole>(" Sys_AdminRole.AdminId IN (" + userIds.GetString() + ")");
 }
Exemple #26
0
 /// <summary>
 /// 移除收藏
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public bool RemoveCollectEBook(int userId)
 {
     return(_dataAccess.DeleteEntities <EBookCollect>(string.Format("where UserId = {0}", userId)) > 0);
 }
Exemple #27
0
 /// <summary>
 /// 取消绑定
 /// </summary>
 /// <param name="openId"></param>
 public void UnBindingUserAccount(string openId)
 {
     _dataAccess.DeleteEntities <Wx_BindingAccount>(string.Format("openid = '{0}'", openId));
 }
Exemple #28
0
        /// <summary>
        /// 根据Id删除权限
        /// </summary>
        /// <param name="menuId"></param>
        public void DeletePermission(int menuId)
        {
            Sys_OperPermission menu = GetPermissionById(menuId);

            _dataAccess.DeleteEntities <Sys_OperPermission>(" PermissionId=" + menuId);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public int DeleteRule(int id)
 {
     return(_dataAccess.DeleteEntities <IntegralRule>("Int_IntegralRule.RuleId=" + id));
 }
Exemple #30
0
 /// <summary>
 ///     删除用户角色
 /// </summary>
 /// <param name="userIds">用户Id</param>
 public void DeleteRolesToUser(int[] userIds)
 {
     _dataAccess.DeleteEntities <SysRoleUser>(" Sys_RoleUser.UserId IN (" + userIds.GetString() + ")");
 }