public ActionResult ConfigDetail()
        {
            var model = _configManager.GetConfig(CurrentTenant.TenantId);

            if (model == null)
            {
                model = new Cde_Configuration();
            }
            return(View(model));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public ActionResult SurveyReport(int userSurveyId)
        {
            Cde_Report report     = _reportManager.GetReport(userSurveyId);
            UserSurvey userSurvey = _surveyManager.GetSurveyInfoByUserSurveyId(userSurveyId);

            report.Survey           = userSurvey.Survey;
            report.User             = _userManager.GetUserById(userSurvey.UserId);
            report.Survey.Exampaper = _exampaperManager.GetFullExampaper(userSurvey.Survey.ExampaperId);
            report.SendUsers.AddRange(_userSendSurveyManager.GetSurveySendUsers(userSurveyId));
            _surveyManager.LoadSendUsers(report.Survey);

            Cde_Configuration config = _configManager.GetConfig(CurrentTenant.TenantId);

            ViewBag.surveyConfig = config;
            List <Cde_SurveyReplyAnswer> userAnswers = _userSendSurveyManager.GetUsersReplyAnswers(userSurveyId);

            foreach (Cde_SurveyReplyAnswer answer in userAnswers)
            {
                Cde_SurveySendUsers anuser = report.SendUsers.Find(p => p.UserId == answer.UserID);
                if (anuser != null)
                {
                    answer.Relationship = anuser.Relationship;
                }
            }
            foreach (Cde_IndexQuestion question in report.Survey.Exampaper.Questions)
            {
                IEnumerable <Cde_SurveyReplyAnswer> qans = userAnswers.Where(p => p.QuestionId == question.QuestionId);
                question.ReplyAnswers.AddRange(qans);
                IEnumerable <Cde_SurveyReplyAnswer> lans    = qans.Where(p => p.Relationship == 0);
                IEnumerable <Cde_SurveyReplyAnswer> colans  = qans.Where(p => p.Relationship == 1);
                IEnumerable <Cde_SurveyReplyAnswer> subans  = qans.Where(p => p.Relationship == 2);
                IEnumerable <Cde_SurveyReplyAnswer> selfans = qans.Where(p => p.Relationship == 3);
                double ls  = lans.Any() ? lans.Average(p => p.Score) : 0d;
                double cs  = colans.Any() ? colans.Average(p => p.Score) : 0d;
                double sus = subans.Any() ? subans.Average(p => p.Score) : 0d;
                double ss  = selfans.Any() ? selfans.Average(p => p.Score) : 0d;
                question.AverageScore = (ls * config.LeaderWeight / 100d + cs * config.ColleagueWeight / 100d
                                         + sus * config.SubordinateWeight / 100d + ss * config.SelfWeight / 100d);
                question.OtherScore = (ls * config.LeaderWeight / 100d + cs * config.ColleagueWeight / 100d
                                       + sus * config.SubordinateWeight / 100d) * (1 - config.SelfWeight / 100d);
                question.SelfScore = ss;
            }
            foreach (Cde_ReportIndex index in report.IndexList)
            {
                index.OtherScore = (index.LeaderScore * config.LeaderWeight / 100m +
                                    index.ColleagueScore * config.ColleagueWeight / 100m +
                                    index.SubordinateScore * config.SubordinateWeight / 100m) / (1M - config.SelfWeight / 100m);
            }
            return(View(report));
        }
Exemple #4
0
        //设置我的评估中参与人员
        public ActionResult SetParticipate(int id)
        {
            SurveyInfo        surveyInfo = _surveyManager.GetCdeSurveyInfoById(id);
            Cde_Configuration config     = _configManager.GetConfig(CurrentTenant.TenantId);

            ViewBag.surveyConfig = config;
            int userSurveyId = _userSurveyManager.GetUserSurveyId(CurrentUser.UserId, id);

            ViewBag.userSurvey = _userSurveyManager.GetUserSurvey(userSurveyId);
            List <Cde_SurveySendUsers> list = _userSendSurveyManager.GetSurveySendUsers(userSurveyId);

            ViewBag.userSurveyId = userSurveyId;
            ViewBag.plist        = list;

            ViewBag.leader = _userManager.GetUserById(CurrentUser.Leader);

            return(View(surveyInfo));
        }
Exemple #5
0
        public JsonResult GetUserSurveyList(int status, string surveyTitle, DateTime?sstime,
                                            DateTime?setime, DateTime?estime, DateTime?eetime, int pageIndex, int pageSize, string jsRenderSortField)
        {
            int recordCount;
            IList <ViewUserSurvey> list = _userSendSurveyManager.GetUserSurveys(out recordCount, CurrentUser.UserId,
                                                                                status, surveyTitle, sstime, setime, estime, eetime, pageIndex, pageSize, jsRenderSortField);
            Cde_Configuration config = _configManager.GetConfig(CurrentTenant.TenantId);
            var dataList             = list.Select(p => new
            {
                p.RowIndex,
                p.SurveyId,
                p.UserSurveyId,
                p.SurveyTitle,
                p.ApproveFlag,
                p.ReportGenerated,
                ApproveStr = (p.ApproveStr == "审批通过" && config.PartUserIsApproval == 0) ? "已处理" : p.ApproveStr,
                StartTime  = p.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                EndTime    = p.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                IsInTime   = p.EndTime < DateTime.Now ? 0 : 1
            });

            return(Json(new { dataList, recordCount }, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
 public bool UpdateConfig(Cde_Configuration config)
 {
     return(_dataAccess.UpdateEntity(config, "TenantId") > 0);
 }
Exemple #7
0
        public JsonResult SaveParticipates(int userSurveyId, string users)
        {
            dynamic           us          = JsonConvert.DeserializeObject(users);
            var               list        = new List <Cde_SurveySendUsers>();
            UserSurvey        usy         = _surveyManager.GetSurveyInfoByUserSurveyId(userSurveyId);
            Cde_Configuration config      = _configManager.GetConfig(CurrentTenant.TenantId);
            int               approveflag = config.PartUserIsApproval == 0 ? 2 : 1;

            foreach (dynamic u in us)
            {
                list.Add(new Cde_SurveySendUsers
                {
                    UserSurveyId = userSurveyId,
                    UserId       = u.id,
                    Relationship = u.ship,
                    Status       = 1
                });
            }
            if (list.Count < config.PartUserCount)
            {
                return
                    (Json(
                         new
                {
                    result = 0,
                    msg = CdeQuestion.UserSurveyStr + config.PartUserCount + CdeQuestion.UserSurveyStr1
                },
                         JsonRequestBehavior.DenyGet));
            }
            //判断各关系的人数是否合法
            if (config.MaxLeaderCount < list.Count(p => p.Relationship == 0))
            {
                return
                    (Json(
                         new
                {
                    result = 0,
                    msg = CdeQuestion.UserSurveyStr2 + config.MaxLeaderCount + CdeQuestion.UserSurveyStr1
                },
                         JsonRequestBehavior.DenyGet));
            }
            if (config.MaxColleagueCount < list.Count(p => p.Relationship == 1))
            {
                return
                    (Json(
                         new
                {
                    result = 0,
                    msg = CdeQuestion.UserSurveyStr3 + config.MaxColleagueCount + CdeQuestion.UserSurveyStr1
                },
                         JsonRequestBehavior.DenyGet));
            }
            if (config.MaxSubordinateCount < list.Count(p => p.Relationship == 2))
            {
                return
                    (Json(
                         new
                {
                    result = 0,
                    msg = CdeQuestion.UserSurveyStr4 + config.MaxSubordinateCount + CdeQuestion.UserSurveyStr1
                },
                         JsonRequestBehavior.DenyGet));
            }
            if (config.SelfParticipate < list.Count(p => p.Relationship == 3))
            {
                return
                    (Json(
                         new
                {
                    result = 0,
                    msg = CdeQuestion.UserSurveyStr5 + config.SelfParticipate + CdeQuestion.UserSurveyStr1
                },
                         JsonRequestBehavior.DenyGet));
            }
            _userSendSurveyManager.AddSurveySendUsers(list);
            _userSurveyManager.ChangeUserSurveyApproveFlag(userSurveyId, approveflag);
            if (approveflag == 1)
            {
                try
                {
                    string title = string.Format(LanguageResources.SendMessage.CdeSurveyUserApprove_Title,
                                                 CurrentUser.Realname, usy.Survey.SurveyTitle);
                    string content = string.Format(LanguageResources.SendMessage.CdeSurveyUserApprove_Content
                                                   , CurrentUser.Realname, usy.Survey.SurveyTitle,
                                                   usy.Survey.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                                                   usy.Survey.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                                                   Url.RetechAction("ApproveUserSurveyList", "CdeUserSurvey") + "?keep=1");

                    SendMessage(title, content, new[] { CurrentUser.Leader }, 11);
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("发送360°评估审批参评人员消息时发生错误", ex);
                }
            }

            return(Json(new { result = 1, msg = Exampaper.SaveSuccess }, JsonRequestBehavior.DenyGet));
        }