/// <summary> /// 隐藏问题的答案 /// </summary> /// <param name="answerId"></param> /// <returns></returns> public int HideAnswer(int answerId) { var answer = GetUserAnswerById(answerId); var question = GetQuestionById(answer.QuestionId); if (answer.IsHide == 0) { _dataAccess.ExecuteSql( @"UPDATE Int_Question SET AnswerCount=AnswerCount-1 WHERE QuestionId=(SELECT QuestionId FROM Int_UserAnswer WHERE AnswerId=" + answerId + ")"); var result = _dataAccess.UpdateField("Int_UserAnswer", "IsHide", "1", "AnswerId=" + answerId); SetNewAnswer(question.QuestionId); return(result); } else { _dataAccess.ExecuteSql( @"UPDATE Int_Question SET AnswerCount=AnswerCount+1 WHERE QuestionId=(SELECT QuestionId FROM Int_UserAnswer WHERE AnswerId=" + answerId + ")"); SetNewAnswer(question.QuestionId); return(_dataAccess.UpdateField("Int_UserAnswer", "IsHide", "0", "AnswerId=" + answerId)); } }
/// <summary> /// 删除单个课程 /// </summary> /// <param name="courseId"></param> /// <returns></returns> public int DeleteCourse(int courseId) { BusinessCache.SystemCache.Instance.ClearCourses(); var result = _dataAccess.UpdateField("Res_Course", "Status", "1", "CourseId=" + courseId); DeleteCourseIndex(courseId); return(result); }
public bool DeleteAbilitys(IEnumerable <int> abilityId) { if (abilityId.Count() == 0) { return(false); } return(_dataAccess.UpdateField("Ab_AbilityInfo", "IsDelete", "1", string.Format("where AbilityId in ({0}) ", abilityId.GetString())) > 0); }
/// <summary> /// 删除版块 /// </summary> /// <param name="id"></param> /// <returns></returns> public int DeleteSection(int id) { var sqlwhere = " SectionId=" + id; //主版块下的所有子版块,一起删除 _dataAccess.UpdateField("bbs_SubSection", "IsDelete", "1", sqlwhere); return(_dataAccess.UpdateField("bbs_MainSection", "IsDelete", "1", sqlwhere)); }
/// <summary> /// 删除站内信 /// </summary> /// <param name="RecordId"></param> /// <param name="type">0:删除发件箱;1:删除收件箱</param> public void DeleteMessage(int[] RecordId, int type) { if (type == 0) { _dataAccess.UpdateField("Sys_UserMessage", "SendStatus", "1", "where RecordId in (" + RecordId.GetString() + ")"); } else { _dataAccess.UpdateField("Sys_UserMessage", "RecStatus", "2", "where RecordId in (" + RecordId.GetString() + ")"); } }
/// <summary> /// 批量冻结/解冻角色 /// </summary> /// <param name="RoleId"></param> /// <returns></returns> public bool FreezeRole(int[] RoleId) { if (RoleId.Length == 0) { return(false); } var users = _dataAccess.GetListBySql <SysRole>("select Status,RoleId from Sys_Roles where RoleId in (" + RoleId.GetString() + ") and IsDelete = 0"); var tmp1 = users.Where(p => p.Status == 0).Select(p => p.RoleId); var tmp2 = users.Where(p => p.Status == 1).Select(p => p.RoleId); _dataAccess.UpdateField("Sys_Roles", "Status", "1", "RoleId in (" + tmp1.GetString() + ")"); _dataAccess.UpdateField("Sys_Roles", "Status", "0", "RoleId in (" + tmp2.GetString() + ")"); return(true); }
/// <summary> /// 删除学习班 /// </summary> /// <param name="classIds"></param> public void DeleteLearningClass(int[] classIds) { if (classIds.Length > 0) { string ids = classIds.GetString(); //var deleteWhere = "Len_Students.ClassId in (" + ids + ")"; //_dataAccess.DeleteEntities<LenStudents>(deleteWhere); _dataAccess.UpdateField("Len_LearningClass", "IsDeleted", "1", " where Len_LearningClass.ClassId in (" + ids + ")"); } }
/// <summary> /// 批量冻结/解冻用户 /// </summary> /// <param name="userId"></param> /// <param name="flag">0-冻结 1-解冻</param> /// <returns></returns> public bool FreezeUser(int[] userId, int flag = 0) { if (userId.Length == 0) { return(false); } var users = _dataAccess.GetListBySql <SysUser>("select Status,UserId from Sys_Users where UserId in (" + userId.GetString() + ") and IsDelete = 0"); var tmp1 = users.Where(p => p.Status == 0).Select(p => p.UserId); var tmp2 = users.Where(p => p.Status == 1).Select(p => p.UserId); if (flag == 1) { _dataAccess.UpdateField("Sys_Users", "Status", "0", "UserId in (" + tmp2.GetString() + ")"); } else { _dataAccess.UpdateField("Sys_Users", "Status", "1", "UserId in (" + tmp1.GetString() + ")"); } return(true); }
/// <summary> /// 批量冻结/解冻服务中心 /// </summary> /// <param name="deptId"></param> /// <param name="flag">0-冻结 1-解冻</param> /// <returns></returns> public bool FreezeDept(int[] deptId, int flag = 0) { if (deptId.Length == 0) { return(false); } var users = _dataAccess.GetListBySql <SysDepartment>("select Status,DepartmentId from Sys_Department where DepartmentId in (" + deptId.GetString() + ") and IsDelete = 0"); var tmp1 = users.Where(p => p.Status == 0).Select(p => p.DepartmentId); var tmp2 = users.Where(p => p.Status == 1).Select(p => p.DepartmentId); if (flag == 1) { _dataAccess.UpdateField("Sys_Department", "Status", "0", "DepartmentId in (" + tmp2.GetString() + ")"); } else { _dataAccess.UpdateField("Sys_Department", "Status", "1", "DepartmentId in (" + tmp1.GetString() + ")"); } return(true); }
/// <summary> /// 删除一条数据 /// </summary> public bool DeleteGroup(int GroupId) { var doflag = _dataAccess.UpdateField("Int_Group", "IsDelete", "1", " GroupId = " + GroupId) > 0; if (doflag) { _dataAccess.UpdateField("Int_GroupTopic", "IsDelete", "1", " GroupId = " + GroupId); } return(doflag); }
/// <summary> /// 刷新在线时间 /// </summary> public static void SetAlive() { var session = new SessionManager.SessionExt(HttpContext.Current); if (!session.Exists("login-logId")) { return; } lock (lkhelp) { var exec = false;//是否需要执行数据库更新操作 var logId = (int)session["login-logId"]; if (lastUpDateTimes.ContainsKey(logId)) { var lastTime = lastUpDateTimes[logId]; if ((DateTime.Now - lastTime).TotalMinutes >= 1) { exec = true; lastUpDateTimes[logId] = DateTime.Now; } } else { lastUpDateTimes.Add(logId, DateTime.Now); exec = true; } if (exec) { SysLoginLog log = _dataAccess.Get <SysLoginLog>(logId); if (log == null) { return; } log.LogoutTime = DateTime.Now; _dataAccess.UpdateField("Sys_LoginLog", "LogoutTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "Sys_LoginLog.LogId=" + logId); } } }
public int ChangeResourcesSort(int sortId, int newSort) { _dataAccess.UpdateField("KL_Resource", "LastUpdateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "SortId=" + sortId); var result = _dataAccess.UpdateField("KL_Resource", "SortId", newSort.ToString(), "SortId=" + sortId); var sort = _dataAccess.Get <KL_KnowledgeSort>(newSort); var ks = _dataAccess.FetchListBySql <KL_Resource>("SortId=" + sortId); foreach (var resource in ks) { FullTextSearchProvider.UpdateIndex <KL_Resource>("knowledge", resource.ResourceId, new { sortId = newSort, sortName = sort.SortName, levelPath = sort.LevelPath }, true); } return(result); }
/// <summary> /// 批量修改租户状态 /// </summary> /// <param name="tids">租户id 数组</param> /// <param name="status">新状态</param> /// <returns></returns> public int ChangeStatus(int[] tids, int status) { var sqlwhere = "Sys_Tenant.TenantId IN (" + tids.GetString() + ")"; return(_dataAccess.UpdateField("Sys_Tenant", "Status", status.ToString(), sqlwhere)); }
/// <summary> /// 计算每个人的各项指标得分 /// <para>返回</para> /// <para>0:成功</para> /// <para>1:计算中</para> /// <para>2:已计算</para> /// <para>3:计算失败</para> /// </summary> /// <param name="examId"></param> /// <returns></returns> public int DoExamUserQuestionIndexScore(int examId) { var exam = _examinationDb.GetSingleById <TalExamination>(examId); int flag = 1; try { if (exam.ScoreCalculationStatus > 0) { return(exam.ScoreCalculationStatus); } exam.ScoreCalculationStatus = 1; _examinationDb.Modify <TalExamination>(exam); var examUserList = _examinationDb.GetAllList <TalExamSendStudent>(Query.And(Query.EQ("Status", 0), Query.EQ("SourceType", 0), Query.EQ("RelationID", examId))); var doExamUserIds = examUserList.Where(p => p.DoExamStatus >= 2).Select(p => p._id); var examUserQuestionScoreList = _examinationDb.GetAllList <TalExamSendStudentQuestionIndexScore>(Query.EQ("ExamId", examId)); var exampaper = _examinationDb.GetSingleById <TalExampaperRedundancy>(exam.PaperID); var examUserListTmp = examUserList.Where(p => !examUserQuestionScoreList.Any(eu => eu.ExamSendId == p._id)); var firstIndex = exampaper.QuestionIndexList.Where(p => p.FatherID == 0).Select(p => p._id); var secondIndex = exampaper.QuestionIndexList.Where(p => p.FatherID > 0).Select(p => p._id); //统计出每个人每个二级指标的实际得分 foreach (var item in examUserListTmp) { foreach (var qIndex in secondIndex) { examUserQuestionScoreList.Add(new TalExamSendStudentQuestionIndexScore { UserId = item.UserID, IndexId = qIndex, Score = 0 }); } } //根据9分法规则,统计出每个人每个二级指标的得分 foreach (var item in secondIndex) { var userScore = examUserQuestionScoreList.Where(p => p.IndexId == item && doExamUserIds.Contains(p.ExamSendId)); var tmpScore = userScore.Select(p => p.Score).Distinct().OrderByDescending(p => p).ToList(); if (tmpScore.Contains(0)) { tmpScore.Remove(0); } if (tmpScore.Count > 0) { var fen = new List <double> { 0.04, 0.11, 0.23, 0.4, 0.6, 0.77, 0.89, 0.96, 1 }; for (int i = 9; i >= 2; i--) { int index = (int)(tmpScore.Count * fen[9 - i]); index = index >= tmpScore.Count ? tmpScore.Count - 1 : index; var line = tmpScore[index]; foreach (var u in userScore) { if (u.NineScore == 0 && u.Score >= line) { u.NineScore = i; } if (u.NineScore == 0 && i == 2 && u.Score > 0) { u.NineScore = 1; } } } } } //通过权重,给每个人算一级指标的分值 foreach (var item in examUserList) { var userScore = examUserQuestionScoreList.Where(p => p.UserId == item.UserID).ToList(); foreach (var qIndex in firstIndex) { var tmp = exampaper.QuestionIndexList.Where(p => p.FatherID == qIndex); float all = 0; foreach (var u in userScore.Where(p => tmp.Any(t => t._id == p.IndexId))) { all += u.NineScore * tmp.First(p => p._id == u.IndexId).weight / 100; } userScore.Add(new TalExamSendStudentQuestionIndexScore { IndexId = qIndex, NineScore = all, UserId = item.UserID }); } item.UserQuestionIndexWeightScore.Clear(); float s = 0; foreach (var u in userScore) { var t = exampaper.QuestionIndexList.Find(p => p._id == u.IndexId); item.UserQuestionIndexWeightScore.Add(new TalUserQuestionIndexWeightScore { _id = u.IndexId, FatherID = t.FatherID, score = u.NineScore, weight = t.weight }); if (t.FatherID == 0) { s += u.NineScore * t.weight / 100; } } if (exam.ExamLength * 60 - item.RemainingTime < 600) { item.CancellationCause = 1; item.CancellationTime = DateTime.Now; item.CancellationStatus = 1; } if (exampaper.QuestionList.Count > 10 ? item.StudentAnswerList.Count(p => p.DoneFlag == 1) < 10 : false) { item.CancellationCause = 2; item.CancellationTime = DateTime.Now; item.CancellationStatus = 1; } if (item.CancellationStatus == 1) { _dataAccess.UpdateField("Sys_Users", "Freezed", "1", "UserId = " + item.UserID); } item.Score = s; //1星:总分∈[1,2.994),不推荐; //2星:总分∈[2.994,4.994),慎重使用; //3星:总分∈[4.994,6.494),推荐使用; //4星:总分∈[6.494,7.994),积极推荐; //5星:总分∈[7.994,9],强烈推荐 item.UserLevel = 0; if (item.Score >= 1 && item.Score < 2.994) { item.UserLevel = 1; } else if (item.Score >= 2.994 && item.Score < 4.994) { item.UserLevel = 2; } else if (item.Score >= 4.994 && item.Score < 6.494) { item.UserLevel = 3; } else if (item.Score >= 6.494 && item.Score < 7.994) { item.UserLevel = 4; } else if (item.Score >= 7.994) { item.UserLevel = 5; } _examinationDb.Modify <TalExamSendStudent>(item); } exam.ScoreCalculationStatus = 2; _examinationDb.Modify <TalExamination>(exam); flag = 0; } catch { flag = 3; } finally { if (flag == 3) { exam.ScoreCalculationStatus = 0; _examinationDb.Modify <TalExamination>(exam); } } return(flag); }
public bool ChangeSurveyStatus(int sendUserId, int status) { return (_dataAccess.UpdateField("Cde_SurveySendUsers", "Status", status.ToString(CultureInfo.InvariantCulture), "SendUserId=" + sendUserId.ToString(CultureInfo.InvariantCulture)) > 0); }
public bool DeleteSurveyInfo(SurveyInfo surveyInfo) { return(_dataAccess.UpdateField("Cde_SurveyInfo", "IsDelete", "1", "Cde_SurveyInfo.SurveyId=" + surveyInfo.SurveyId) > 0); }
public void DeleteNotes(int[] noteID) { _dataAccess.UpdateField("Sys_Notes", "IsDelete", "1", "where noteId in (" + noteID.GetString() + ")"); }
/// <summary> /// 批量删除书籍,返回受影响的行数 /// </summary> /// <param name="ids">书籍ids</param> /// <returns></returns> public bool DeleteEBook(int[] ids) { return(_dataAccess.UpdateField("Res_EBook", "IsDelete", "1", string.Format("where BookId in ({0})", ids.GetString())) > 0); }
public int DeleteUserLevel(int id) { return(_dataAccess.UpdateField("Int_UserLevel", "IsDelete", "1", "LevelId=" + id)); }
public bool DeleteExampaper(int id) { int result = _dataAccess.UpdateField("Cde_SurveyExampaper", "IsDelete", "1", "ExampaperID=" + id); return(result > 0); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="isEnabled"></param> /// <returns></returns> public int EnableRule(int id, bool isEnabled = true) { var sqlwhere = "Int_IntegralRule.RuleId=" + id; return(_dataAccess.UpdateField("Int_IntegralRule", "IsEnabled", isEnabled ? "1" : "0", sqlwhere)); }
/// <summary> /// 删除资源 /// </summary> /// <param name="ids"></param> /// <returns></returns> public int DeleteResource(string ids) { return(_dataAccess.UpdateField("Res_Resource", "Status", "-1", string.Format(" Id in ({0})", ids))); }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int applyId) { return(_dataAccess.UpdateField("Ab_PromotionApply", "IsDelete", "1", "ApplyId=" + applyId) > 0); }
/// <summary> /// /// </summary> /// <param name="ids"></param> /// <returns></returns> public int BatchDelete(int[] ids) { return(_dataAccess.UpdateField("Sys_Admin", "IsDelete", "1", "AdminId IN (" + ids.GetString() + ")")); }
public bool DeleteReport(int reportId) { return(_dataAccess.UpdateField("Cde_Report", "IsDelete", "1", "ReportId=" + reportId) > 0); }
public bool DeletePromotionWay(int promotionId) { return(_dataAccess.UpdateField("Ab_PromotionWay", "IsDelete", "1", "where PromotionId = " + promotionId) > 0); }
public int Delete(int planId) { return(_dataAccess.UpdateField("Len_LearnPlan", "Status", "1", " Len_LearnPlan.PlanId=" + planId)); }
/// <summary> /// /// </summary> /// <param name="ids"></param> /// <returns></returns> public int DeleteTemplate(int[] ids) { return(_dataAccess.UpdateField("Sys_ReasonTemplate", "Status", "1", string.Format(" TempId in ({0})", ids.GetString()))); }
/// <summary> /// /// </summary> /// <param name="deptId"></param> /// <param name="postId"></param> /// <returns></returns> public bool UpdatePostDeptId(int deptId, int[] postId) { return(_dataAccess.UpdateField("Sys_Posts", "DeptId", deptId.ToString(), "where PostId in (" + postId.GetString() + ")") > 0); }
/// <summary> /// 根据ID删除单个实体(假删) /// </summary> /// <param name="id"></param> /// <returns></returns> public bool DeleteByID(int id) { return(_dataAccess.UpdateField("KL_KnowledgeSort", "IsDelete", "1", "SortId=" + id) > 0); }