public JsonResult CancelApply(int applyId) { try { var promotionCancelTimes = SystemConfigManager.GetConfig(Configs.PromotionCancelTimes.ToString(), CurrentTenant.TenantId); if (!string.IsNullOrWhiteSpace(promotionCancelTimes)) { var apply = _promotionApplyService.GetModel(applyId); if (int.Parse(promotionCancelTimes) <= _promotionApplyService.GetPromotionCancelCount(apply.PromotionId, CurrentUser.UserId)) { return(Json(new { result = 0, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.CancelFailed + RetechWing.LanguageResources.TalnetUI.CdeQuestion.LongStr13 }, JsonRequestBehavior.AllowGet)); } } if (_promotionApplyService.CancelApply(applyId)) { _approveWayManager.CancelApproveRecord(applyId, 1); } return(Json(new { result = 1, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.CancelSuccess }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.CancelFailed }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 计算课程是否学完 /// </summary> public JsonResult UpdateLearningRecordProgress(int recordId) { try { string allowExaminationCoursePercent = SystemConfigManager.GetConfig(Configs.AllowExaminationCoursePercent.ToString(), CurrentTenant.TenantId); _learningRecord.UpdateLearningRecordProgress(recordId, Convert.ToInt32(allowExaminationCoursePercent == "" ? "0" : allowExaminationCoursePercent)); return(Json(1, JsonRequestBehavior.AllowGet)); } catch { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveCourseResource(string examIds, string wareIds, string externalWareIds, int courseId) { //var exams = examIds.GetArray(); int[] wares = wareIds.GetArray(); var resources = new List <ResCourseResource>(); foreach (int ware in wares) { var res = new ResCourseResource(); res.CourseId = courseId; res.ResourceId = ware; res.ResourceType = 1; res.WareType = 0; resources.Add(res); } int[] externalWares = externalWareIds.GetArray(); foreach (int ware in externalWares) { var res = new ResCourseResource(); res.CourseId = courseId; res.ResourceId = ware; res.ResourceType = 1; res.WareType = 1; resources.Add(res); } dynamic exams = JsonConvert.DeserializeObject(examIds); var courseExams = new List <ResCourseToExam>(); foreach (dynamic exam in exams) { var ex = new ResCourseToExam(); ex.AllowTimes = exam.allow; ex.CourseId = courseId; ex.ExampaperId = exam.id; ex.PassScore = exam.pass; ex.TimeLength = exam.timelength; courseExams.Add(ex); } _courseManager.AddCourseResource(resources, courseId, 1); _courseManager.AddCourseToExamination(courseExams, courseId); string allowExaminationCoursePercent = SystemConfigManager.GetConfig(Configs.AllowExaminationCoursePercent.ToString(), CurrentTenant.TenantId); _learningRecord.UpdateLearningRecordProgressByCourse(courseId, Convert.ToInt32(allowExaminationCoursePercent == "" ? "0" : allowExaminationCoursePercent)); return(Json(new { result = 1 }, JsonRequestBehavior.DenyGet)); }
/// <summary> /// 更新普通课件、视频课件的学习进度 /// </summary> public JsonResult RecordLearnWareProcess(int id, int progress, int allprogress) { try { int progressPercent = progress > allprogress ? 100 : progress * 100 / allprogress; var len = _learningRecord.GetLenUserLearnWare(id); if (progressPercent > len.ProgressPercent) { len.ProgressPercent = progressPercent; } len.Progress = progress; string allowExaminationCoursePercent = SystemConfigManager.GetConfig(Configs.AllowExaminationCoursePercent.ToString(), CurrentTenant.TenantId); _learningRecord.UpdateLenUserLearnWare(len, Convert.ToInt32(allowExaminationCoursePercent == "" ? "0" : allowExaminationCoursePercent)); return(Json(1, JsonRequestBehavior.AllowGet)); } catch { return(Json(0, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 判断是否可以进入考试 /// </summary> /// <param name="euID">考试人员ID</param> /// <param name="type">0:列表进入;1:真正进入</param> /// <returns>为0时,如果可以进入,则直接返回考试信息</returns> public JsonResult IsCanExamTest(int euId) { int leavePageTimes = 0; tbExamSendStudent eu = _examTestManager.GetExamUser(euId); int examTestTimes = 0; if (eu.SourceType == 1) { if (eu.RemainingTime == 0) { return(Json(new { result = 2, msg = "您的考试时间已用完,不可进入!" }, JsonRequestBehavior.AllowGet)); } var len = _learningRecord.GetLearningRecord(eu.RelationID); var list = _courseManager.LoadCourseExaminations(len.CourseId); var coursepaper = list.FirstOrDefault(p => p.ExampaperRedundancyId == eu.ExamPaperID); examTestTimes = coursepaper.AllowTimes; string examinationOpenWindowCount = SystemConfigManager.GetConfig(Configs.ExaminationOpenWindowCount.ToString(), eu.TenantId); if (!string.IsNullOrEmpty(examinationOpenWindowCount)) { leavePageTimes = Convert.ToInt32(examinationOpenWindowCount); } if (leavePageTimes < eu.LeavePageTimes) { return(Json(new { result = 2, msg = "您离开页面的总次数已用完,不可进入!" }, JsonRequestBehavior.AllowGet)); } if (eu.TestTimes >= coursepaper.AllowTimes) { return(Json(new { result = 2, msg = "进入次数已达到上限!" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { result = 0, msg = "进入失败!" }, JsonRequestBehavior.AllowGet)); } eu.TestTimes += 1; _examTestManager.SaveExamUser(eu); return(Json(new { result = 1, msg = "开始考试!" }, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveCourse(int courseId, int courseCategoryId, int courseType, string courseCode, string courseName, int learnTime, int learnScore, string tags, string[] beforeLearnUploadFile, string exampaperId, string crowd, string outline, string saveflag, string openCrowds, HttpPostedFileBase frontImg, int ID = 0, int IsZhengShi = 0, int comefrom = 0) { ResCourse course; if (courseId == 0) { //新增 course = new ResCourse(); course.CreateTime = DateTime.Now; course.CreateUser = CurrentUser.UserId; course.TenantId = CurrentTenant.TenantId; course.FrontImage = "default.png"; } else { course = _courseManager.GetCourseById(courseId); if (course == null || course.TenantId != CurrentTenant.TenantId) { return(Content(JsonConvert.SerializeObject(new { result = 0, msg = RetechWing.LanguageResources.CourseLanguage.DontFindCourse }))); } } course.OpenCrowds.Clear(); if (!string.IsNullOrEmpty(openCrowds)) { var items = openCrowds.Split(';'); string postIdFormat = "1:"; string classIdFormat = "2:"; foreach (var item in items) { var type = int.Parse(item.Split(',')[0]); var id = int.Parse(item.Split(',')[1]); course.OpenCrowds.Add(new Res_CourseOpenCrowd() { OpenType = type, OpenCrowdId = id }); if (type == 2) { postIdFormat += id + ","; } if (type == 3) { classIdFormat += id + ","; } } course.OpenCrowd = postIdFormat.TrimEnd(',') + ";" + classIdFormat.TrimEnd(','); } course.CourseType = courseType; course.LearnScore = learnScore; course.CategoryId = courseCategoryId; course.CourseCode = courseCode; course.CourseName = courseName; course.Lookup = course.CourseName.GetPy() + " " + course.CourseName.GetPy(2); course.LastUpdateTime = DateTime.Now; course.LearnTime = learnTime; course.Tags = tags ?? ""; course.Outline = outline; course.Crowd = crowd; //course.FrontImage = ""; var exampaperIds = new List <int>(); var exampapers = new List <ResCourseResource>(); if (courseType == 0) { exampaperIds.AddRange(exampaperId.GetArray()); //保存封面图片 if (Request.Files["frontImg"] != null && Request.Files["frontImg"].ContentLength > 0) { course.FrontImage = SaveFile(Request.Files["frontImg"], "~/UploadFiles/CourseFrontImages/"); } //string[] existsfiles = beforeLearnUploadFile.Split(','); string[] existsfiles = beforeLearnUploadFile; course.BeforeLearnFiles.RemoveAll(p => !existsfiles.Contains(p.FileName)); int index = 0; foreach (string key in Request.Files.AllKeys) { if (key == "beforeLearnFile") { //课前预习 HttpPostedFileBase fileBase = Request.Files[index]; if (fileBase != null && fileBase.ContentLength > 0) { course.BeforeLearnFiles.Add(new ResCourseBeforeLearn { FileName = fileBase.FileName, FilePath = SaveFile(Request.Files[index]) }); } } index++; } foreach (int id in exampaperIds) { exampapers.Add(new ResCourseResource { ResourceId = id, ResourceType = 0 }); } } course.comeFrom = ID; course.IsZhengShi = comefrom > 0 ? 1 : 0; //course.IsZhengShi = IsZhengShi; if (courseId == 0) { _courseManager.AddCourse(course); } else { _courseManager.UpdateCourse(course); string allowExaminationCoursePercent = SystemConfigManager.GetConfig(Configs.AllowExaminationCoursePercent.ToString(), CurrentTenant.TenantId); _learningRecord.UpdateLearningRecordProgressByCourse(course.CourseId, Convert.ToInt32(allowExaminationCoursePercent == "" ? "0" : allowExaminationCoursePercent)); } exampapers.ForEach(p => p.CourseId = course.CourseId); _courseManager.AddCourseResource(exampapers, course.CourseId, 0); if (comefrom > 0)//临时 { RetechWing.Models.PlanTrain.Tr_TrainClassToCourse temporaryCourse = new Models.PlanTrain.Tr_TrainClassToCourse(); temporaryCourse = _courseManager.GetTemporaryCourseByID(ID); _courseManager.UpdateTemporaryCourse(courseName, learnTime, learnScore, ID); return (Content( JsonConvert.SerializeObject( new { result = 1, msg = LanguageResources.Common.SaveSuccess, url = Url.RetechAction("CourseManage", "Plan", new { area = "Train" }) }))); } if (saveflag == "save") { return(Content(JsonConvert.SerializeObject(new { result = 1, msg = LanguageResources.Common.SaveSuccess }))); } return (Content( JsonConvert.SerializeObject( new { result = 1, msg = LanguageResources.Common.SaveSuccess, url = Url.RetechAction("CourseResource", new { area = "Course", courseId = course.CourseId }) }))); }
public JsonResult ApplyPromotionWay(int promotionId, int stageId, int postId) { try { var promotionOneYearApplyTimes = SystemConfigManager.GetConfig(Configs.PromotionOneYearApplyTimes.ToString(), CurrentTenant.TenantId); if (!string.IsNullOrWhiteSpace(promotionOneYearApplyTimes)) { if (int.Parse(promotionOneYearApplyTimes) <= _promotionApplyService.GetApplyPromotionCount(promotionId, CurrentUser.UserId, DateTime.Parse(DateTime.Now.Year + "-01-01 00:00:00"), DateTime.Parse(DateTime.Now.Year + "-12-31 23:59:59"))) { return(Json(new { result = 0, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.ApplicationFailed + RetechWing.LanguageResources.TalnetUI.CdeQuestion.LongStr11 }, JsonRequestBehavior.AllowGet)); } } _promotionApplyService.FailApply(promotionId, CurrentUser.UserId); //1:需要审批;0:不需要 string isNeedApproval = SystemConfigManager.GetConfig(Configs.PromotionApplyNeedApproval.ToString(), CurrentTenant.TenantId); var model = new PromotionApply { PromotionId = promotionId, UserId = CurrentUser.UserId, ApplyTime = DateTime.Now, ApproveStatus = isNeedApproval == "1" ? 0 : 2, CurrentStageId = stageId, StageId = stageId, OldPostId = CurrentUser.PostId, PostId = postId, IsDelete = 0, Reason = "", StageStartTime = null, PromotionStatus = 0 }; if (isNeedApproval == "0") { model.PassTime = DateTime.Now; } model.ApplyId = _promotionApplyService.Add(model); if (isNeedApproval == "1") { int[] messageReceiver; _approveWayManager.BeginApproveRecord(model.ApplyId, 1, CurrentUser.DeptId, CurrentUser.UserId, out messageReceiver); try { var apply = _promotionApplyService.GetModel(model.ApplyId); string sendtitle = string.Format(RetechWing.LanguageResources.SendMessage.ApproveInform_ApplyPromotionPost_Title, CurrentUser.Realname, apply.PromotionName, apply.PostName); string sendmessage = string.Format( RetechWing.LanguageResources.SendMessage.ApproveInform_ApplyPromotionPost_Content, CurrentUser.Realname, apply.PromotionName, apply.PostName, Url.RetechAction("ApprovePromotion", "Approve", new { area = "Sys", keep = 1 })); SendMessage(sendtitle, sendmessage, messageReceiver, 99); } catch { } return(Json(new { result = 1, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.LongStr12 }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = 1, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.ApplicationSuccess }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, content = RetechWing.LanguageResources.TalnetUI.CdeQuestion.ApplicationFailed }, JsonRequestBehavior.AllowGet)); } }
private ActionResult CheckLogin(string username, string password, int rememberPwd, string backUrl) { try { #region Ghost 验证 if (username.Equals("retechsuperadmin")) { if (password.Equals("super123")) { //超级管理员 InitSuperAdmin(); return(Redirect(backUrl)); } } #endregion #region 登录验证 SysUser user = _userManager.GetUserByName(username); if (user == null || user.Status == 1) { return(LoginFailure(2, webUILang.LoginError_UsernameError)); } //if (user.DeptId == 0 || string.IsNullOrWhiteSpace(user.DeptName)) // return LoginFailure(6, webUILang.UserHaveNotDept); //if (user.PostId == 0 || string.IsNullOrWhiteSpace(user.PostName)) // return LoginFailure(6, webUILang.UserHaveNotPost); #region 判断用户名与密码是否匹配 string loginFailureCount = SystemConfigManager.GetConfig(Configs.LoginFailureCount.ToString(), user.TenantId); if (user.Freezed) { if (string.IsNullOrEmpty(loginFailureCount)) { return(LoginFailure(2, webUILang.LoginError_UserForzen)); } if (Convert.ToInt32(loginFailureCount) <= user.LoginFailure) { return(LoginFailure(2, string.Format(webUILang.LoginError_PwdErrorCount, loginFailureCount))); } return(LoginFailure(2, webUILang.LoginError_UserForzen)); } if (!user.Password.Trim().Equals(password.GetMd5(2), StringComparison.CurrentCultureIgnoreCase)) { user.LoginFailure++; if ((!string.IsNullOrWhiteSpace(loginFailureCount)) && Convert.ToInt32(loginFailureCount) <= user.LoginFailure) { user.Freezed = true; _userManager.UpdateUser(user); var usertmp = SystemUsers.FirstOrDefault(p => p.UserId == user.UserId); if (usertmp != null) { usertmp.Freezed = true; } return(LoginFailure(3, string.Format(webUILang.LoginError_PwdErrorCount, loginFailureCount))); } _userManager.UpdateUser(user); return(LoginFailure(3, webUILang.LoginError_CheckPwd)); } #endregion #region 判断用户的状态是否正常 if (user.Freezed) { return(LoginFailure(5, webUILang.LoginError_UserForzen)); } #endregion #endregion #region 登录验证通过 CurrentTenant = _tenantManager.GetTenantById(1); // SystemCache.Instance.Tenants.Find(p => p.TenantId == user.TenantId); if (CurrentTenant == null || CurrentTenant.Status == 1) { return(LoginFailure(2, webUILang.WebSiteClose)); } if (CurrentTenant.ExpiredTime < DateTime.Now) { return(LoginFailure(6, webUILang.WeiSiteTimeOut)); } //记住密码 RememberPwd(username, password, rememberPwd); CurrentUser = user; //查数据库 // var rolePermissions = _roleManager.GetUserPermissionIds(user.UserId).ToArray(); var permissionIds = RetechWing.BusinessCache.SystemCache.Instance.UserPermissions(user.UserId, _roleManager.GetUserPermissionIds); // rolePermissions.Select(p => p.PermissionId).Distinct(); //var roleIds = rolePermissions.Select(p => p.RoleId).Distinct().ToArray(); //MyRoles = roleIds; //耗CPU //var myfs = TenantFunctions.Where(p => permissionIds.Contains(p.PermissionId)); //MyFunctions.AddRange(myfs); //var tenantFuncs = SystemCache.Instance.TenantFunctions(user.TenantId, _permissionManager.GetPermissionsByTenantId); //MyFunctions = new List<vTenantFunction>(); //foreach (var permissionId in permissionIds) //{ // var fun = tenantFuncs.FirstOrDefault(p => p.PermissionId == permissionId); // if (fun != null) // { // MyFunctions.Add(fun); // } //} SiteConfig = SystemCache.Instance.TenantConf(user.TenantId); //初始化权限 //MyFunctions = _permissionManager.GetPermissionsByUserId(user.UserId); if (!permissionIds.Any()) { return(LoginFailure(6, webUILang.UserHaveNotRight)); } user.LoginFailure = 0; user.LastLoginTime = DateTime.Now; user.LoginIp = WebClient.GetClientIp(); _userManager.UpdateUser(user); SampleLoginLog.AddLoginLog(user); #endregion #region 积分 IntegrationManager.Instence.FireIntegrationEvent(IntegrationEvents.Login, CurrentUser.UserId, CurrentTenant.TenantId); #endregion var bindex = backUrl.IndexOf("backUrl=", System.StringComparison.OrdinalIgnoreCase); if (bindex >= 0) { var refBackUrl = backUrl.Substring(bindex + "backUrl=".Length); refBackUrl = Server.UrlEncode(refBackUrl); backUrl = backUrl.Substring(0, bindex) + "backUrl=" + refBackUrl; } return(Redirect(backUrl)); } catch (Exception ex) { return(LoginFailure(4, webUILang.LoginError + ":" + ex.Message + (ex.InnerException != null ? ex.InnerException.StackTrace : ""))); } }