示例#1
0
        public ActionResult UserManagement()
        {
            SetViewBag(title: "مدیریت کاربران", menuItem: "UserManagement");
            var currentTerm = _termService.Get(g => g.IsCurrentTerm);
            var groups      = _educationalGroupService.GetMany(g => g.Term.Id == currentTerm.Id).Select(s => new { s.EducationalGroupCode, s.Name }).ToList();
            var users       = new List <Models.User>();

            if (((Models.User)Session["UserInfo"]).IsAdministrator)
            {
                users = _userService.GetAll().Where(w => w.Username.ToLower() != "sync" && w.Username.ToLower() != "student").ToList().Select(s => new Models.User
                {
                    Username             = s.Username,
                    EducationalGroupCode = s.EducationalGroupCode,
                    EducationalGroupName = groups.Where(w => w.EducationalGroupCode == s.EducationalGroupCode).FirstOrDefault()?.Name,//_educationalGroupService.GetMany(g=> g.EducationalGroupCode == s.EducationalGroupCode).FirstOrDefault()?.Name,
                    FirstName            = s.FirstName,
                    LastName             = s.LastName,
                    ID = s.ID,
                    IsAdministrator = s.IsAdministrator,
                    IsPowerUser     = s.IsPowerUser,
                    //College = Mapper.Map<Models.College>(s.College)
                    College = s.College != null ? new Models.College {
                        Id = s.College.Id, CollegeCode = s.College.CollegeCode, Name = s.College.Name
                    } : null
                }).ToList();
            }
            //else
            //{
            //    var userRoles = _userRoleService.GetMany(w => w.User.ID == ((Models.User)Session["UserInfo"]).ID).Select(s => s.Role.Id);
            //    var childRoles = new List<int>();
            //    foreach (var id in userRoles)
            //        childRoles.AddRange(_roleService.GetMany(g => g.ParentRole_Id == id).Select(s => s.Id));
            //    users = _userRoleService.GetMany(g=> childRoles.Contains(g.Role.Id) && g.User.Username.ToLower() != "sync").Select(s=> s.User).ToList() //_userService.GetMany(w => w.Username.ToLower() != "sync" && w.Roles.).ToList()
            //        .Select(s => new Models.User
            //        {
            //            Username = s.Username,
            //            EducationalGroupCode = s.EducationalGroupCode,
            //            EducationalGroupName = groups.Where(w => w.EducationalGroupCode == s.EducationalGroupCode).FirstOrDefault()?.Name,//_educationalGroupService.GetMany(g=> g.EducationalGroupCode == s.EducationalGroupCode).FirstOrDefault()?.Name,
            //            FirstName = s.FirstName,
            //            LastName = s.LastName,
            //            ID = s.ID,
            //            IsAdministrator = s.IsAdministrator,
            //            IsPowerUser = s.IsPowerUser,
            //            //College = Mapper.Map<Models.College>(s.College)
            //            College = s.College != null ? new Models.College { Id = s.College.Id, CollegeCode = s.College.CollegeCode, Name = s.College.Name } : null
            //        }).ToList();
            //}
            return(View(users));
        }
示例#2
0
        public ActionResult EducationalClassesManagement()
        {
            SetViewBag("مدیریت جلسات برگزاری کلاس ها", "EducationalClassesManagement");
            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);
            }
            var user    = (Models.User)Session["UserInfo"];
            var groupQS = 0;

            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");
            ViewBag.TermId    = selectedTerm.Id;
            if (Request.QueryString["group"] != null && int.TryParse(Request.QueryString["group"], out groupQS))
            {
                TempData["model"]   = _educationalClassService.GetMany(w => w.Term.Id == selectedTerm.Id && w.EducationalGroup.EducationalGroupCode == groupQS).ToList();
                TempData["groupId"] = groupQS;
            }
            if ((user == null || user.EducationalGroupCode == null) && TempData["model"] == null)
            {
                return(View());
            }
            if (TempData["model"] != null)
            {
                var classes = (List <Model.Models.EducationalClass>)TempData["model"];
                ViewBag.GroupId     = TempData["groupId"];
                TempData["model"]   = null;
                TempData["groupId"] = null;
                return(View(classes));
            }
            else
            {
                var groupId = _educationalGroupService.Get(x => x.EducationalGroupCode == user.EducationalGroupCode && x.Term.Id == selectedTerm.Id).Id;
                var classes = _educationalGroupService.Get(g => g.Id == groupId).EducationalClasses.Where(w => w.Term.Id == selectedTerm.Id).ToList();
                return(View(classes));
            }
        }
        public CompleteProfessorResult GetProfessorReport(int termId, List <int> indictorList = null, List <int> scoreList = null,
                                                          List <int> collegeList      = null, List <int> groupList    = null, List <int> professoresList = null
                                                          , bool allColleges          = true, bool allGroups          = true, bool allProfessors = true,
                                                          bool allProfessorIndicators = true, bool allProfessorScores = true, int countShow = 101, int orderingType = 1)
        {
            if (indictorList == null)
            {
                indictorList = new List <int>();
            }
            if (scoreList == null)
            {
                scoreList = new List <int>();
            }
            if (collegeList == null)
            {
                collegeList = new List <int>();
            }
            if (groupList == null)
            {
                groupList = new List <int>();
            }
            if (professoresList == null)
            {
                professoresList = new List <int>();
            }

            var pAllColleges                  = string.Empty;
            var pAllGroups                    = string.Empty;
            var pAllProfessors                = string.Empty;
            var pAllProfessorIndicators       = String.Empty;
            var pAllProfessorScores           = String.Empty;
            var pAllProfessorForGroupsCollege = string.Empty;


            if (!allColleges)
            {
                pAllColleges = " and c.Id in @colleges ";
            }

            if (!allGroups)
            {
                pAllGroups = " and g.Id in @groups and ps.EducationalGroup_Id in @groups ";
            }

            if (!allProfessors)
            {
                pAllProfessors = " and p.Id in @professores ";
            }

            if (indictorList.Any())
            {
                pAllProfessorIndicators = " and i.Id in @indicators ";
            }
            if (scoreList.Any())
            {
                pAllProfessorScores = " and p.Id in @specialProfessors ";
            }

            if (!allColleges && allGroups)
            {
                pAllProfessorForGroupsCollege = "and ps.EducationalGroup_Id in @groups ";
                var groups = _educationalGroupService.GetMany(x => collegeList.Contains(x.College.Id)).Select(p => p.Id);
                groupList.AddRange(groups);
                var grp = groupList.Distinct();
                groupList = grp.ToList();
            }


            var professorResualt = GetProfessorReport(termId,
                                                      indictorList.ToArray(),
                                                      scoreList.ToArray(),
                                                      collegeList, groupList, professoresList.ToArray(),
                                                      pAllColleges, pAllGroups, pAllProfessors, pAllProfessorIndicators, pAllProfessorScores, pAllProfessorForGroupsCollege);


            var proResualt = new List <ProfessorDetialReportModel>();

            if (professorResualt != null)
            {
                if (orderingType == 2)
                {
                    if (countShow != 101)
                    {
                        proResualt = professorResualt.OrderBy(x => x.ProfessorScore)
                                     .Take(countShow).ToList();
                    }
                    else
                    {
                        proResualt = professorResualt.OrderBy(x => x.ProfessorScore).ToList();
                    }
                }
                else
                {
                    if (countShow != 101)
                    {
                        proResualt = professorResualt.OrderByDescending(x => x.ProfessorScore)
                                     .Take(countShow).ToList();
                    }
                    else
                    {
                        proResualt = professorResualt.OrderByDescending(x => x.ProfessorScore).ToList();
                    }
                }
            }

            var resualt = new CompleteProfessorResult
            {
                Detial = GetProfessorDetials(termId,
                                             indictorList.ToArray(), collegeList, groupList
                                             , pAllColleges, pAllGroups, pAllProfessorIndicators),
                General = proResualt
            };

            return(resualt);
        }
        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));
            }
        }
        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 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));
            }
        }