/// <summary> /// 根据课程Id获取课程 /// </summary> /// <param name="courseId"></param> /// <returns></returns> public ResCourse GetCourseById(int courseId) { var source = BusinessCache.SystemCache.Instance.Courses; var course = source.FirstOrDefault(p => p.CourseId == courseId); if (course == null) { course = _dataAccess.Get <ResCourse>(courseId); } var sqlwhere = "CourseId=" + courseId; var list = _dataAccess.GetList <ResCourseResource>(sqlwhere + " AND ResourceType=0"); course.Exampapers.Clear(); if (list.Count > 0) { course.Exampapers.AddRange(list); } var files = _dataAccess.GetList <ResCourseBeforeLearn>(sqlwhere); course.BeforeLearnFiles.Clear(); if (files.Count > 0) { course.BeforeLearnFiles.AddRange(files); } //var opencwds = _dataAccess.GetList<Res_CourseOpenCrowd>(sqlwhere); //course.OpenCrowds.Clear(); //if (opencwds.Count > 0) // course.OpenCrowds.AddRange(opencwds); return(course); }
public LenLearnPlanDetail GetSupperStep(int stepId, int planId) { var step = _dataAccess.Get <LenLearnPlanDetail>(stepId); step.LenLearnPlanCourse = _dataAccess.GetList <LenLearnPlanCourse>(" Len_LearnPlanCourse.PlanId = " + planId + " and Len_LearnPlanCourse.StepId = " + step.StepId); return(step); }
public bool RemovePostAbility(int recordId) { var model = _dataAccess.Get <Ab_PostAbility>(recordId); model.IsDelete = 1; var doflag = _dataAccess.UpdateEntity(model) > 0; if (doflag) { _dataAccess.ExecuteSql("delete from Ab_PostElectiveCourse where PostId = " + model.PostId + " and AbilityId = " + model.AbilityId); } return(doflag); }
public int AddConfig(Cde_Configuration config) { var model = _dataAccess.Get <Cde_Configuration>(config.TenantId, "TenantId"); if (model == null) { _dataAccess.AddEntity(config); } else { _dataAccess.UpdateEntity(config, "TenantId"); } return(1); }
/// <summary> /// 根据部门id获得审批流程 /// </summary> /// <param name="deptId">部门id</param> /// <param name="wayType"> /// 路径类型 /// 0:培训 /// 1:晋升学习 /// </param> /// <param name="approveStepList">返回流程的步骤</param> /// <param name="approveDeptList">返回流程的适用部门</param> /// <param name="canUpdate">是否能修改流程,代表是自己新建的还是强制被覆盖的</param> /// <returns>返回0代表可以新建流程,否则返回流程wayid</returns> public ApproveWay GetApproveWay(int deptId, int wayType, out List <ApproveStep> approveStepList, out List <ApproveDept> approveDeptList, out bool canUpdate) { //找到部门所用流程 var approvedepts = _dataAccess.GetList <ApproveDept>("Ap_ApproveDept.DeptId=" + deptId + " and Ap_ApproveWay.WayType=" + wayType + " and Ap_ApproveDept.IsDelete=0 and Ap_ApproveWay.IsDelete=0"); //没有限定流程,可以新建 if (approvedepts.Count == 0) { approveDeptList = new List <ApproveDept> { new ApproveDept { DeptId = deptId } }; approveStepList = new List <ApproveStep>(); canUpdate = true; return(new ApproveWay()); } //限定流程 if (approvedepts.Count == 1) { var approvedept = approvedepts.FirstOrDefault(); //如果是自己创建的,可以修改 if (approvedept.DeptId == approvedept.ApproveWay_DeptId) { canUpdate = true; approveDeptList = _dataAccess.GetList <ApproveDept>("Ap_ApproveDept.WayId=" + approvedept.WayId + " and Ap_ApproveDept.IsDelete=0"); } //不是自己创建的,只能查看 else { canUpdate = false; approveDeptList = new List <ApproveDept>(); } //步骤获取 approveStepList = _dataAccess.GetList <ApproveStep>("Ap_ApproveStep.WayId=" + approvedept.WayId + " Order by Ap_ApproveStep.OrderNum"); return(_dataAccess.Get <ApproveWay>(approvedept.WayId)); } throw new Exception(RetechWing.LanguageResources.Other.MultipleApprovalProcess); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public SysLog GetLogById(int id) { var log = _dataAccess.Get <SysLog>(id); //log.OperatorUser = _dataAccess.Get<SysUser>(log.Opener); return(log); }
/// <summary> /// 根据租户Id获取租户信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public SysTenant GetTenantById(int id) { return(_dataAccess.Get <SysTenant>(id)); //return _dataAccess.GetList<SysTenant>( // "Sys_Tenant.TenantId=@id" // , new { id }).FirstOrDefault(); }
public int GetUserPromotionStageLenRecordId(int userId, int stageId) { var stage = _dataAccess.Get <PromotionStage>(stageId); return((int)_dataAccess.ExecuteScalar(string.Format(@"select RecordId from Ab_PromotionStageLenRecord where ApplyId in (select ApplyId from Ab_PromotionApply where IsDelete = 0 and PromotionId = {0} and ApproveStatus = 2 and UserId = {2}) and PromotionId = {0} and Stageid = {1} and UserId = {2}", stage.PromotionId, stageId, userId))); }
/// <summary> /// 创建小组,创建用户,并把两者进行关联 /// 审批 or 发布 成功时,执行 /// </summary> /// <param name="trainId"></param> public void TrainUserJoinGroup(int trainId) { if (string.IsNullOrWhiteSpace(mysqlconnectionString)) { return; } var train = _dataAccess.Get <TrTrainingInfo>(trainId); if (train.Status != 4) { return; } var detailList = _dataAccess.GetList <TrTrainDetail>("Tr_TrainDetail.IsDeleted = 0 and Tr_TrainDetail.TrainId = " + trainId); var userids = _dataAccess.FetchListBySql <int>(string.Format(@" select userId from Tr_TrainUser where trainId = {0} union select userId from Tr_TrainRegister where ApplyStatus = 2 and Tr_TrainRegister.TrainId = {0}", trainId)); var ofuser = GetofUsers(); var ofuserids = new List <int>(); int o; foreach (var item in ofuser) { if (int.TryParse(item.username, out o)) { ofuserids.Add(o); } } //var ofuserids = GetofUsers().Select(p => Convert.ToInt32(p.username)); var tmpuserid = userids.Where(p => !ofuserids.Contains(p)).ToList(); if (tmpuserid.Any()) { AddUsers(tmpuserid); } JoinUserGroup(detailList.Where(p => p.TrainFrom > 0).Select(p => p.DetailId), userids); }
public Cde_IndexQuestion GetQuestion(int qid) { var q = _dataAccess.Get <Cde_IndexQuestion>(qid); if (q == null) { return(null); } var options = _dataAccess.GetList <Cde_IndexQuestionAnswer>("Cde_IndexQuestionAnswer.QuestionId=" + qid); q.Answers.AddRange(options); return(q); }
/// <summary> /// /// </summary> /// <param name="activityId"></param> /// <param name="userId"></param> /// <returns></returns> public IntUserActivity ForwardActivity(int activityId, int userId) { var activity = _dataAccess.Get <IntUserActivity>(activityId); activity.IsForward = 1; activity.SourceId = activityId; activity.ActionTime = DateTime.Now; activity.ReplyCount = 0; activity.PraiseCount = 0; _dataAccess.AddEntity(activity); _dataAccess.UpdateFieldCalc("Int_UserActivity", "ForwardCount", "ForwardCount+1", "ActivityId=" + activityId); return(activity); }
public ResSurveyExampaper GetSurveyExampaperById(int id) { var model = _dataAccess.Get <ResSurveyExampaper>(id); var list = _dataAccess.GetList <ResSurveyQuestion>("Res_SurveyQuestion.Status=0 AND Res_SurveyQuestion.ExampaperID=" + id); var qids = list.Select(p => p.QuestionID).GetString(); string sqlwhere = " QuestionId IN ( " + qids + ")"; var answers = _dataAccess.GetList <ResSurveyQuestionAnswer>(sqlwhere); foreach (var question in list) { question.Options.Clear(); question.Options.AddRange(answers.Where(p => p.QuestionID == question.QuestionID)); } model.Questions.AddRange(list); return(model); }
public Models.Sys_EvalConfig GetConfig(int tenantId) { var model = _dataAccess.Get <Models.Sys_EvalConfig>(tenantId, "TenantId"); if (model == null) { model = new Models.Sys_EvalConfig() { TenantId = tenantId }; AddConfig(model); } return(model); }
/// <summary> /// 获取一条信息 /// </summary> /// <param name="messageId"></param> /// <returns></returns> public SysUserMessage GetUserMessageByMessageId(int messageId) { var model = _dataAccess.GetListBySql <SysUserMessage>(string.Format(@" WITH info AS( select Sys_UserMessage.MessageId ,Sys_Users.Realname as RecUserRealName from Sys_UserMessage left join Sys_Users on Sys_Users.UserId = Sys_UserMessage.RecUserId where Sys_UserMessage.messageId = {0} ) SELECT DISTINCT t.MessageId ,RecUserRealName=(select RecUserRealName+',' from info where MessageId=t.MessageId for xml path('')) ,Sys_UserMessageContent.Title ,Sys_UserMessageContent.CreateTime from info t left join Sys_UserMessage on t.MessageId = Sys_UserMessage.MessageId left join Sys_UserMessageContent on Sys_UserMessage.MessageId = Sys_UserMessageContent.MessageId", messageId)).FirstOrDefault(); model.MessageContent = _dataAccess.Get <SysUserMessageContent>(model.MessageId).MessageContent; return(model); }
public List <Post> GetPost() { //change this function to Get(string ProcedureName) //add another PostDataAccess file, change current file to BaseDataAccess //call BaseDataAccess from PostDataAccess and write a test case for PostDataAccess.GetPosts() List <Post> posts = new List <Post>(); DataTable dtposts = new DataTable(); try { using (SqlCommand command = new SqlCommand("GetPosts")) { dtposts = _baseDataAccess.Get(command); if (dtposts != null && dtposts.Rows.Count > 0) { foreach (DataRow row in dtposts.Rows) { Post post = new Post(); post.id = int.Parse(row["id"].ToString()); post.imgURL = Convert.ToString(row["imgURL"]); post.numberOfComments = int.Parse(row["numberOfComments"].ToString()); post.postContent = Convert.ToString(row["postContent"]); post.postPreviewContent = Convert.ToString(row["postPreviewContent"]); post.title = Convert.ToString(row["title"]); post.date = Convert.ToDateTime(row["date"]); posts.Add(post); } } } } catch (Exception ex) { throw ex; } return(posts); }
/// <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); } } }
/// <summary> /// 根据Id获取角色 /// </summary> /// <param name="roleId">角色Id</param> /// <returns></returns> public SysRole GetRoleById(int roleId) { return(_dataAccess.Get <SysRole>(roleId)); }
public virtual async Task <T> Get(int id) { return(await _dataAccess.Get(id)); }
/// <summary> /// 获取单个学习卡 /// </summary> /// <param name="id">id</param> /// <returns></returns> public ResCard GetCard(int id = 0) { return(_dataAccess.Get <ResCard>(id)); }
public Sys_Notes GetNoteById(int id) { return(_dataAccess.Get <Sys_Notes>(id)); }
/// <summary> /// /// </summary> /// <param name="adminId"></param> /// <returns></returns> public SysAdmin GetAdminById(int adminId) { return(_dataAccess.Get <SysAdmin>(adminId)); }
/// <summary> /// 获取资源 /// </summary> /// <returns></returns> public ResResource GetsingleResource(int Id) { return(_dataAccess.Get <ResResource>(Id)); }
/// <summary> /// 获取单个课程学习记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public Len_LearningRecord GetLearningRecord(int id) { return(_dataAccess.Get <Len_LearningRecord>(id)); }
public Cde_SurveySendUsers GetSendUserById(int sendId) { return(_dataAccess.Get <Cde_SurveySendUsers>(sendId)); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public SysReasonTemplate GetTemplateById(int id) { return(_dataAccess.Get <SysReasonTemplate>(id)); }
public PromotionWay GetPromotionWay(int promotionId) { return(_dataAccess.Get <PromotionWay>(promotionId)); }
/// <summary> /// 根据Id获取LenLearningClass /// </summary> /// <param name="id"></param> /// <returns></returns> public LearningClass GetLenLearningClassById(int id) { return(_dataAccess.Get <LearningClass>(id)); }
public Cde_SurveyExampaper GetExampaper(int id) { return(_dataAccess.Get <Cde_SurveyExampaper>(id)); }
/// <summary> /// /// </summary> /// <param name="postId"></param> /// <returns></returns> public SysPost GetPostById(int postId) { return(_dataAccess.Get <SysPost>(postId)); }
/// <summary> /// 获取书籍Model by Id /// </summary> /// <param name="id"></param> /// <returns></returns> public EBook GetModel(int id) { return(_dataAccess.Get <EBook>(id)); }