Esempio n. 1
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));
            }
        }