public List <VHR_EmployeeProfile> GetSpecificEmployees(VMLoggedUser vmf)
        {
            List <VHR_EmployeeProfile> vmList = new List <VHR_EmployeeProfile>();

            if (vmf.UserAccessTypeID == Convert.ToInt32(UserAccessType.AllEmployees))
            {
                vmList = VHREmployeeProfileReporsitory.GetAll().Where(aa => aa.Status == "Active" && aa.CompanyID != 3).ToList();
            }
            else if (vmf.UserAccessTypeID == Convert.ToInt32(UserAccessType.LocationBased))
            {
                if (vmf.UserLoctions != null)
                {
                    foreach (var userLocaion in vmf.UserLoctions)
                    {
                        Expression <Func <VHR_EmployeeProfile, bool> > SpecificEntries = c => c.LocationID == userLocaion.LocationID;
                        vmList.AddRange(VHREmployeeProfileReporsitory.FindBy(SpecificEntries).Where(aa => aa.Status == "Active" && aa.CompanyID != 3).OrderBy(aa => aa.JobTitleID).ToList());
                    }
                }
            }
            else if (vmf.UserAccessTypeID == Convert.ToInt32(UserAccessType.Normal))
            {
                vmList = EmployeeLM.GetReportingEmployees(VHREmployeeProfileReporsitory.GetAll().Where(aa => aa.Status == "Active" && aa.CompanyID != 3).OrderBy(aa => aa.JobTitleID).ToList(), vmf);
            }
            return(vmList);
        }
Beispiel #2
0
        public static List <VHR_EmployeeProfile> GetEmployeeInfo(VMLoggedUser loggedUser, List <VHR_EmployeeProfile> dbEmps)
        {
            List <VHR_EmployeeProfile> list     = new List <VHR_EmployeeProfile>();
            List <VHR_EmployeeProfile> tempList = new List <VHR_EmployeeProfile>();

            if (loggedUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.AllEmployees))
            {
                list = dbEmps.ToList();
            }
            else if (loggedUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.LocationBased))
            {
                if (loggedUser.UserLoctions != null)
                {
                    list = dbEmps.ToList();
                    foreach (var userLocaion in loggedUser.UserLoctions)
                    {
                        tempList.AddRange(list.Where(aa => aa.LocationID == userLocaion.LocationID));
                    }
                    list = tempList.ToList();
                }
            }
            else if (loggedUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.Normal))
            {
                list = EmployeeLM.GetReportingEmployees(dbEmps.ToList(), loggedUser);
            }
            return(list.OrderBy(aa => aa.EmployeeName).ToList());
        }
Beispiel #3
0
        // Gnereate Bar Chart based upon values stored in session
        public ActionResult LoadPieChart()
        {
            VMAttendanceDashboard vmDashboard = Session["VMATDashboard"] as VMAttendanceDashboard;

            dateS = vmDashboard.StartDate;
            dateE = vmDashboard.EndDate;
            DMPieChartParentModel      vm           = new DMPieChartParentModel();
            VMLoggedUser               LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;
            List <VAT_DailyAttendance> AttList      = new List <VAT_DailyAttendance>();

            // Apply User Access Role
            if (LoggedInUser.UserAccessTypeID == 1) // Normal
            {
                List <VHR_EmployeeProfile> emps = EmployeeLM.GetReportingEmployees(VHREmployeeProfileService.GetIndex(), LoggedInUser);
                string query = QueryBuilder.GetReportQueryForLoggedUser(LoggedInUser, emps);
                if (query != "")
                {
                    query = " and " + query;
                }
                DataTable dataTable = QueryBuilder.GetValuesfromDB("select * from VAT_DailyAttendance  where (AttDate >= " + "'" + vmDashboard.StartDate.ToString("yyyy-MM-dd") + "'" + " and AttDate <= " + "'" + vmDashboard.EndDate.ToString("yyyy-MM-dd") + "'" + " ) " + query);
                AttList = dataTable.ToList <VAT_DailyAttendance>();
            }
            else if (LoggedInUser.UserAccessTypeID == 2) // Location Access
            {
                foreach (var item in LoggedInUser.UserLoctions)
                {
                    Expression <Func <VAT_DailyAttendance, bool> > SpecificEntries = c => c.AttDate >= dateS && c.AttDate <= dateE && c.LocationID == item.LocationID;
                    AttList.AddRange(VATDailyAttendanceService.GetIndexSpecific(SpecificEntries));
                }
            }
            else if (LoggedInUser.UserAccessTypeID == 3) // All
            {
                Expression <Func <VAT_DailyAttendance, bool> > SpecificEntries = c => c.AttDate >= dateS && c.AttDate <= dateE;
                AttList = VATDailyAttendanceService.GetIndexSpecific(SpecificEntries);
            }
            else if (LoggedInUser.UserAccessTypeID == 4) // Department
            {
                foreach (var item in LoggedInUser.UserDepartments)
                {
                    Expression <Func <VAT_DailyAttendance, bool> > SpecificEntries = c => c.AttDate >= dateS && c.AttDate <= dateE && c.OUCommonID == item.DepartmentID;
                    AttList.AddRange(VATDailyAttendanceService.GetIndexSpecific(SpecificEntries));
                }
            }
            //Filter based on Graph Type
            vm = DashboardManager.ApplyGraphTypeItems(vm, AttList, vmDashboard.GraphType);
            // Filter based on Graph For
            vm = DashboardManager.ApplyGraphForItems(vm, vmDashboard.UserGraphType, vmDashboard);
            if (vm.ChildList != null && vm.ChildList.Count() > 0)
            {
                return(PartialView("RenderPieChart", vm));
            }
            else
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #4
0
        public static string GetReportQueryForLoggedUser2(VMLoggedUser loggedUser, List <VHR_EmployeeProfile> emps)
        {
            string      query = "and  (";
            List <int?> ids   = new List <int?>();

            if (loggedUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.AllEmployees))
            {
                query = "";
            }
            else if (loggedUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.LocationBased))
            {
                if (loggedUser.UserLoctions != null)
                {
                    foreach (var userLocaion in loggedUser.UserLoctions)
                    {
                        ids.Add(userLocaion.LocationID);
                    }
                    if (ids.Count == 1)
                    {
                        query = query + " LocationID = " + ids[0] + " )";
                    }
                    else if (ids.Count > 1)
                    {
                        query = query + " LocationID in (";
                        for (int i = 0; i < ids.Count - 1; i++)
                        {
                            query = query + ids[i] + " ,";
                        }
                        query = query + ids[ids.Count - 1] + "))";
                    }
                }
            }
            else if (loggedUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.Normal))
            {
                foreach (var empid in EmployeeLM.GetReportingEmployees(emps.ToList(), loggedUser).Select(aa => aa.PEmployeeID).Distinct())
                {
                    ids.Add(empid);
                }
                if (ids.Count == 1)
                {
                    query = query + " PEmployeeID = " + ids[0] + " )";
                }
                else if (ids.Count > 1)
                {
                    query = query + " PEmployeeID in (";
                    for (int i = 0; i < ids.Count - 1; i++)
                    {
                        query = query + ids[i] + " ,";
                    }
                    query = query + ids[ids.Count - 1] + "))";
                }
            }
            return(query);
        }
        private void BootstrapDashboardSession()

        {
            VMAttendanceDashboard vmATDashboard = new VMAttendanceDashboard();
            VMLoggedUser          LoggedInUser  = Session["LoggedInUser"] as VMLoggedUser;

            vmATDashboard.StartDate = DateTime.Today.AddDays(-7);
            vmATDashboard.EndDate   = DateTime.Today;
            vmATDashboard.EmpID     = (int)LoggedInUser.UserEmpID;
            if (LoggedInUser.UserAccessTypeID == Convert.ToInt32(UserAccessType.Normal))
            {
                List <VHR_EmployeeProfile> emps = EmployeeLM.GetReportingEmployees(VHREmployeeProfileService.GetIndex(), LoggedInUser);
                var dss = emps.Select(aa => aa.OUID).Distinct();
                if (emps.Count == 1)
                {
                    vmATDashboard.UserGraphType = UserGraphType.Single;
                }
                else if (emps.Select(aa => aa.OUID).Distinct().Count() == 1)
                {
                    vmATDashboard.UserGraphType = UserGraphType.SimpleLM;
                }
                else if (emps.Select(aa => aa.OUID).Distinct().Count() > 1)
                {
                    vmATDashboard.UserGraphType = UserGraphType.HasMultipleOU;
                }
                else if (emps.Select(aa => aa.OUID).Distinct().Count() == 1)
                {
                    vmATDashboard.UserGraphType = UserGraphType.HasMultipleOU;
                }
                else if (emps.Select(aa => aa.OUID).Distinct().Count() > 1)
                {
                    vmATDashboard.UserGraphType = UserGraphType.HasMultipleCommonOU;
                }
                else
                {
                    vmATDashboard.UserGraphType = UserGraphType.SimpleLM;
                }
            }
            else
            {
                vmATDashboard.UserGraphType = UserGraphType.HasMultipleCommonOU;
            }
            vmATDashboard.GraphType  = "LateIn";
            Session["VMATDashboard"] = vmATDashboard;
        }