Exemplo n.º 1
0
        public ActionResult ManageUniversityLevels()
        {
            SetViewBag(title: "مدیریت سطوح دانشگاه ها", menuItem: "ManageUniversityLevels");
            ViewBag.Scores = _indicatorService.Get(g => g.CountOfType == "p" + (int)IndicatorProfessorName.رتبه_دانشگاه_محل_تحصیل).Scores.OrderBy(o => o.Id).ToList();
            var model = Mapper.Map <List <Models.Mapping> >(_mappingService.GetMany(g => g.MappingType.Id == 4).ToList());

            return(View(model));
        }
        public ActionResult GroupManagerRating()
        {
            SetViewBag("ثبت نظر مدیر گروه در خصوص اساتید", "GroupManagerRating");
            Term selectedTerm = null;

            if (string.IsNullOrEmpty(Request.QueryString["termId"]))
            {
                selectedTerm = GetCurrentTerm();
            }
            else
            {
                var termId = Convert.ToInt32(Request.QueryString["termId"]);
                selectedTerm = _termService.Get(g => g.Id == termId);
            }
            ViewBag.GroupList = new SelectList(_educationalGroupService.GetMany(w => w.Term.Id == selectedTerm.Id).Where(w => !StaticValue.IneligibleEducationalGroupCodes.Contains((int)w.EducationalGroupCode)), "EducationalGroupCode", "Name");
            ViewBag.TermList  = new SelectList(_termService.GetAll().OrderByDescending(o => o.TermCode), "Id", "Name");
            var user    = (Models.User)Session["UserInfo"];
            var groupQS = 0;

            ViewBag.TermId = selectedTerm.Id;
            if (Request.QueryString["group"] != null && int.TryParse(Request.QueryString["group"], out groupQS))
            {
                TempData["model"] = _educationalGroupService.GetMany(g => g.EducationalGroupCode == groupQS && g.Term.Id == selectedTerm.Id &&
                                                                     !StaticValue.IneligibleEducationalGroupCodes.Contains((int)g.EducationalGroupCode))
                                    .SelectMany(s => s.EducationalClasses).Where(w => w.Term.Id == selectedTerm.Id)
                                    .Select(s => s.Professor).Distinct()
                                    .Select(s => new Models.Professor
                {
                    //EducationalClasses = Mapper.Map<ICollection<Model.Models.EducationalClass>, ICollection<Models.EducationalClass>>(s.EducationalClasses),
                    //ProfessorScores = Mapper.Map<ICollection<Model.Models.ProfessorScore>, ICollection<Models.ProfessorScore>>(s.ProfessorScores),
                    Name                = s.Name,
                    Family              = s.Family,
                    NationalCode        = s.NationalCode,
                    GroupMangerComments = GetCurrentGroupManagerRating((int)s.ProfessorCode, "p" + (int)IndicatorProfessorName.نظر_مدیر_گروه, selectedTerm.Id, groupQS),
                    ProfessorCode       = s.ProfessorCode
                })
                                    .ToList();
                TempData["groupId"] = groupQS;
            }
            if ((user == null || user.EducationalGroupCode == null) && TempData["model"] == null)
            {
                return(View());
            }
            /// TODO:
            /// چک کردن وجود شاخص قبل از گرفتن لیست امتیازها
            ViewBag.Scores = _indicatorService.Get(g => g.CountOfType == "p" + (int)IndicatorProfessorName.نظر_مدیر_گروه).Scores.OrderByDescending(o => o.Point).ToList();
            if (TempData["model"] != null)
            {
                var professors = (List <Models.Professor>)TempData["model"];
                ViewBag.GroupId     = TempData["groupId"];
                TempData["model"]   = null;
                TempData["groupId"] = null;
                return(View(professors));
            }
            else
            {
                var groupId = user.EducationalGroupCode;
                ViewBag.GroupId = groupId;
                var professors = _educationalGroupService.GetMany(g => g.EducationalGroupCode == groupId && g.Term.Id == selectedTerm.Id)
                                 .SelectMany(s => s.EducationalClasses)
                                 .Where(w => w.Term.Id == selectedTerm.Id)
                                 .Select(s => s.Professor).Distinct()
                                 .Select(s => new Models.Professor
                {
                    //EducationalClasses = Mapper.Map<ICollection<Model.Models.EducationalClass>, ICollection<Models.EducationalClass>>(s.EducationalClasses),
                    //ProfessorScores = Mapper.Map<ICollection<Model.Models.ProfessorScore>, ICollection<Models.ProfessorScore>>(s.ProfessorScores),
                    Name                = s.Name,
                    Family              = s.Family,
                    NationalCode        = s.NationalCode,
                    GroupMangerComments = GetCurrentGroupManagerRating((int)s.ProfessorCode, "p" + (int)IndicatorProfessorName.نظر_مدیر_گروه, selectedTerm.Id, (int)groupId),
                    ProfessorCode       = s.ProfessorCode
                })
                                 .ToList();
                return(View(professors));
            }
        }
Exemplo n.º 3
0
        public void UpdateClassSessions(int classCode, int onlineHeld, int presentHeld, int other, string termId = null, bool manualUpdate = false)
        {
            Term currentTerm = null;

            if (string.IsNullOrEmpty(termId))
            {
                currentTerm = GetCurrentTerm();
            }
            else
            {
                var tid = Convert.ToInt32(termId);
                currentTerm = _termService.Get(g => g.Id == tid);
            }
            var obj = _educationalClassService.Get(g => g.CodeClass == classCode && g.Term.Id == currentTerm.Id);

            if ((manualUpdate && onlineHeld >= 0) || (!manualUpdate && onlineHeld > 0))
            {
                obj.OnlineHeldingCount = onlineHeld;
            }
            if ((manualUpdate && presentHeld >= 0) || (!manualUpdate && presentHeld > 0))
            {
                obj.PersentHeldingCount = presentHeld;
            }
            if ((manualUpdate && other >= 0) || (!manualUpdate && other > 0))
            {
                obj.OthersHeldingCount = other;
            }
            _educationalClassService.Update(obj);


            //var classes = _educationalClassService.GetMany(g => g.Professor.Id == obj.Professor.Id && g.Term.Id == currentTerm.Id && g.EducationalGroup.Id == obj.EducationalGroup.Id);
            //obj.Professor.OnlineSession = classes.Sum(s => s.OnlineHeldingCount);
            //obj.Professor.InPersonSession = classes.Sum(s => s.PersentHeldingCount);
            //obj.Professor.OthersSession = classes.Sum(s => s.OthersHeldingCount);
            //_professorService.Update(obj.Professor);

            var indicatorCountOfTypet = "p" + (int)IndicatorProfessorName.تعداد_جلسات_برگزار_شده_کلاس;
            var profAllScores         = _professorScoreService.GetMany(g =>
                                                                       g.Professor.Id == obj.Professor.Id &&
                                                                       g.Term.Id == currentTerm.Id &&
                                                                       g.Score.Indicator.CountOfType == indicatorCountOfTypet);

            Model.Models.ProfessorScore profScore = new Model.Models.ProfessorScore();
            if (profAllScores.Count() > 0)
            {
                profScore = profAllScores.Where(w => w.EducationalGroup.Id == obj.EducationalGroup.Id).FirstOrDefault();
            }

            //var totalCount = (obj.Professor.OnlineSession + obj.Professor.InPersonSession + obj.Professor.OthersSession) / classes.Count();
            //var score = _scoreService.Get(g => g.MinValue <= totalCount && g.MaxValue >= totalCount && g.Indicator.CountOfType == indicatorCountOfTypet);


            var listOfCountClass = new List <decimal>();


            var listOfClass = _educationalClassService.GetMany(x => x.Professor.Id == obj.Professor.Id &&
                                                               x.EducationalGroup.Id == obj.EducationalGroup.Id &&
                                                               x.Term.Id == currentTerm.Id &&
                                                               x.IsActive == true).ToList();

            var indicator7 = _indicatorService
                             .Get(y => y.CountOfType == ("p" + (int)IndicatorProfessorName.تعداد_جلسات_برگزار_شده_کلاس));
            var scores7 = indicator7.Scores;

            foreach (var c in listOfClass)
            {
                if (obj.HoldingExamDate == null)
                {
                    listOfCountClass.Add(((scores7.FirstOrDefault(p => p.Point == 80).MinValue.Value) + 1));
                }
                else
                {
                    listOfCountClass.Add(((obj.OnlineHeldingCount ?? 0) + (obj.PersentHeldingCount ?? 0) + (obj.OthersHeldingCount ?? 0)));
                }
            }
            var avg = Math.Round(listOfCountClass.Average(), 0);
            var s   = scores7
                      .FirstOrDefault(p => p.MinValue <= avg &&
                                      p.MaxValue >= avg
                                      );

            if (s != null)
            {
                if (profScore != null && profScore.Id > 0)
                {
                    profScore.Score = s;
                    var point = s.Point * indicator7.Ratio.Point;
                    if (point != null)
                    {
                        profScore.CurrentScore = (int)point;
                    }
                    _professorScoreService.Update(profScore);
                }
                else
                {
                    var point = s.Point * indicator7.Ratio.Point;
                    if (point != null)
                    {
                        var sPoint = (int)point;
                        _professorScoreService.Add(new Model.Models.ProfessorScore
                        {
                            EducationalGroup = obj.EducationalGroup,
                            Professor        = obj.Professor,
                            Term             = currentTerm,
                            Score            = s,
                            CurrentScore     = (int)point
                        });
                    }
                }
            }

            //var scores = _professorScoreService.GetMany(g =>
            //g.Professor.Id == obj.Professor.Id
            //&& g.Term.Id == currentTerm.Id
            //&& g.Score.Indicator.CountOfType == indicatorCountOfTypet).ToList();
            //foreach (var item in scores)
            //{
            //    item.CurrentScore = currentScore;
            //    _professorScoreService.Update(item);
            //}
        }
        public static void RunAll(
            ITermService termService,
            IMappingService mappingService,
            ICollegeService collegeService,
            IEducationalGroupService educationalGroupService,
            IProfessorService professorService,
            IEducationalClassService educationalClassService,
            IStudentEducationalClassService studentEducationalClassService,
            IProfessorScoreService professorScoreService,
            IIndicatorService indicatorService,
            IMappingTypeService mappingTypeService,
            IUniversityLevelMappingService universityLevelMappingService,
            IEducationalGroupScoreService educationalGroupScoreService,
            ILogService logService,
            ILogTypeService logTypeService,
            IUserService userService,
            string termCode)
        {
            //The order of the execution on the commands is important


            var user = userService.Get(x => x.Username.ToLower() == "Sync".ToLower());

            if (string.IsNullOrEmpty(termCode))
            {
                termCode = ClientHelper.GetScalarValue <string>(StaticValue.CurrentTerm);
            }



            //TermSync.SyncAddOrUpdateTerms(termService, logService, logTypeService, userService, user);
            //MappingSync.Run(mappingService, logService, logTypeService, userService, user);
            //CollegeSync.Run(collegeService, logService, logTypeService, userService, user);
            //ProfessorSync.SyncAddOrUpdateProfessor(professorService, logService, logTypeService, userService, user, termCode);
            //EducationalGroupSync.SyncAddOrUpdateEducationalGroup(educationalGroupService, logService, logTypeService, userService, user, termCode);
            EducationalClassSync.Run(educationalClassService, logService, logTypeService, userService, user, termCode);
            StudentEducationalClassSync.Run(studentEducationalClassService, logService, logTypeService, userService, user, termCode);

            ProfessorSync.SyncProfessorRemoveScore(professorService, logService, logTypeService, userService, user, termCode);

            ProfessorSync.SyncProfessorAddScore(professorService, professorScoreService, indicatorService, termService,
                                                mappingService, mappingTypeService, educationalClassService, universityLevelMappingService,
                                                logService, logTypeService, userService, user, termCode);

            EducationalGroupSync.SyncEducationalGroupRemoveScore(educationalGroupService
                                                                 , logService, logTypeService, userService, user, termCode);

            EducationalGroupSync.SyncEducationalGroupAddScore(educationalGroupService, educationalGroupScoreService,
                                                              indicatorService, termService, professorService, professorScoreService, educationalClassService
                                                              , logService, logTypeService, userService, user, termCode);


            var groupManagerScores     = indicatorService.Get(w => w.CountOfType == ("g" + (int)IndicatorGroupName.ضریب_مدیر_گروه) && w.IsActive == true).Scores.Select(s => s.Id).ToList();
            var groupmanagerGroupScore = educationalGroupScoreService.GetMany(g => groupManagerScores.Contains(g.Score.Id) && g.Term.TermCode == termCode)
                                         .Select(s => s.EducationalGroup.EducationalGroupCode);
            var groupManagerReCalculateList = educationalGroupService
                                              .GetMany(w => !groupmanagerGroupScore.Contains(w.EducationalGroupCode) && w.Term.TermCode == termCode && w.IsActive == true).ToList();

            if (groupManagerReCalculateList.Count() > 0)
            {
                var professores = ClientHelper.GetValue <ProfessorSyncModel>(StaticValue.ProfessorRelativeAddress + $"/{termCode}");
                var reCalcProfs = professores.Where(w => groupManagerReCalculateList.Where(ww => ww.GroupManger != null).Select(s => s.GroupManger.ProfessorCode).Contains(w.ProfessoreCode)).ToList();
                foreach (var item in reCalcProfs)
                {
                    ProfessorSync.SyncGroupManagerProfessorScores(professorService, professorScoreService, indicatorService, termService, mappingService, mappingTypeService
                                                                  , educationalClassService, universityLevelMappingService, item, logService, logTypeService, userService, user, educationalGroupService);
                }

                var groups       = ClientHelper.GetValue <GroupSyncModel>(StaticValue.GroupRelativeAddress + $"/{termCode}");
                var reCalcGroups = groups.Where(w => groupManagerReCalculateList.Where(ww => ww.GroupManger != null).Select(s => s.EducationalGroupCode).Contains(w.EducationalGroupCode)).ToList();
                foreach (var item in reCalcGroups)
                {
                    EducationalGroupSync.SyncGroupManagerEducationalGroupScores(educationalGroupService, educationalGroupScoreService, indicatorService, termService
                                                                                , professorService, professorScoreService, item, educationalClassService, logService, logTypeService, userService, user);
                }
            }
        }
        public ActionResult AddOrUpdateProfessorIndicator(int id = 0)
        {
            var ratios     = _ratioService.GetAll();
            var rationList = new List <SelectListItem>();

            foreach (var ratio in ratios)
            {
                rationList.Add(new SelectListItem
                {
                    Text  = ratio.Name,
                    Value = ratio.Id.ToString()
                });
            }

            ViewBag.ratio = rationList;
            var indicator = new Models.Indicator();

            indicator.Scores = new List <Models.Score>();
            if (id > 0)
            {
                var currentIndicator = _indicatorService.Get(g => g.Id == id);
                if (currentIndicator.Ratio != null)
                {
                    rationList.FirstOrDefault(x => x.Value == currentIndicator.Ratio.Id.ToString()).Selected = true;
                }
                indicator = Mapper.Map <Model.Models.Indicator, Models.Indicator>(currentIndicator);
            }
            ViewBag.ratio             = rationList;
            ViewBag.IndicatorHasLimit = IndicatorHasLimit(indicator.CountOfType);
            return(PartialView(indicator));
        }
        public ActionResult EducationalGroupManagerPresence()
        {
            SetViewBag(title: "مدیریت وضعیت حضور مدیران گروه ها", menuItem: "EducationalGroupManagerPresence");
            ViewBag.CollegeList = new SelectList(_collegeService.GetAll(), "CollegeCode", "Name");
            ViewBag.TermList    = new SelectList(_termService.GetAll().OrderByDescending(o => o.TermCode), "Id", "Name");
            var onlineIndicator          = _indicatorService.Get(g => g.CountOfType == "g" + (int)IndicatorGroupName.وضعیت_حضور_آنلاین_مدیر_گروه);
            var physicalIndicator        = _indicatorService.Get(g => g.CountOfType == "g" + (int)IndicatorGroupName.وضعیت_حضور_فیزیکی_مدیران_گروه);
            var otherIndicator           = _indicatorService.Get(g => g.CountOfType == "g" + (int)IndicatorGroupName.وضعیت_سایر_جلسات_حضور_مدیر_گروه);
            var OnlineHolidaysIndicator  = _indicatorService.Get(g => g.CountOfType == "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_آنلاین_مدیر_گروه);
            var OfflineHolidaysIndicator = _indicatorService.Get(g => g.CountOfType == "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_فیزیکی_مدیر_گروه);
            var EducationalAndResearchCouncilIndicator = _indicatorService.Get(g => g.CountOfType == "g" + (int)IndicatorGroupName.جلسات_شورای_آموزشی_پژوهشی);

            ViewBag.onlineScores   = onlineIndicator.Scores.ToList();
            ViewBag.physicalScores = physicalIndicator.Scores.ToList();
            ViewBag.otherScores    = otherIndicator.Scores.ToList();

            ViewBag.OnlineHolidays  = OnlineHolidaysIndicator.Scores.ToList();
            ViewBag.OfflineHolidays = OfflineHolidaysIndicator.Scores.ToList();
            ViewBag.EducationalAndResearchCouncil = EducationalAndResearchCouncilIndicator.Scores.ToList();

            var  user         = (Models.User)Session["UserInfo"];
            var  collegeQS    = 0;
            Term selectedTerm = null;

            if (string.IsNullOrEmpty(Request.QueryString["termId"]))
            {
                return(View());
            }
            //selectedTerm = GetCurrentTerm();
            else
            {
                var termId = Convert.ToInt32(Request.QueryString["termId"]);
                selectedTerm = _termService.Get(g => g.Id == termId);
            }
            ViewBag.TermId = selectedTerm.Id;
            if (Request.QueryString["college"] != null && int.TryParse(Request.QueryString["college"], out collegeQS))
            {
                var groups = _educationalGroupService.GetMany(g => g.College.CollegeCode == collegeQS && g.Term.Id == selectedTerm.Id &&
                                                              !StaticValue.IneligibleEducationalGroupCodes.Contains((int)g.EducationalGroupCode)).Select(s => new EducationalGroup
                {
                    EducationalGroupCode = s.EducationalGroupCode,
                    Name                          = s.Name,
                    GroupManger                   = s.GroupManger ?? new Professor(),
                    OnlinePresenceTime            = GetCurrentRating((int)s.EducationalGroupCode, "g" + (int)IndicatorGroupName.وضعیت_حضور_آنلاین_مدیر_گروه, selectedTerm.Id) / onlineIndicator.Ratio.Point,
                    PhysicalPresenceTime          = GetCurrentRating((int)s.EducationalGroupCode, "g" + (int)IndicatorGroupName.وضعیت_حضور_فیزیکی_مدیران_گروه, selectedTerm.Id) / physicalIndicator.Ratio.Point,
                    OtherPresenceTime             = GetCurrentRating((int)s.EducationalGroupCode, "g" + (int)IndicatorGroupName.وضعیت_سایر_جلسات_حضور_مدیر_گروه, selectedTerm.Id) / otherIndicator.Ratio.Point,
                    OnlineHolidays                = GetCurrentRating((int)s.EducationalGroupCode, "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_آنلاین_مدیر_گروه, selectedTerm.Id) / OnlineHolidaysIndicator.Ratio.Point,
                    OfflineHolidays               = GetCurrentRating((int)s.EducationalGroupCode, "g" + (int)IndicatorGroupName.تعطیلات_رسمی_کلاس_فیزیکی_مدیر_گروه, selectedTerm.Id) / OfflineHolidaysIndicator.Ratio.Point,
                    EducationalAndResearchCouncil = GetCurrentRating((int)s.EducationalGroupCode, "g" + (int)IndicatorGroupName.جلسات_شورای_آموزشی_پژوهشی, selectedTerm.Id) / EducationalAndResearchCouncilIndicator.Ratio.Point,
                    Id = s.Id
                }).ToList();
                TempData["model"]     = groups;
                TempData["collegeId"] = collegeQS;
            }
            if ((user == null || user.College == null) && TempData["model"] == null)
            {
                return(View());
            }
            if (TempData["model"] != null)
            {
                var groups = (List <Model.Models.EducationalGroup>)TempData["model"];
                ViewBag.CollegeId     = TempData["collegeId"];
                TempData["model"]     = null;
                TempData["collegeId"] = null;
                return(View(groups));
            }
            else
            {
                var collegeCode = user.College.Id;
                var groups      = _educationalGroupService.GetMany(g => g.College.CollegeCode == collegeCode && g.Term.Id == selectedTerm.Id &&
                                                                   !StaticValue.IneligibleEducationalGroupCodes.Contains((int)g.EducationalGroupCode)
                                                                   ).ToList();
                return(View(groups));
            }
        }