Exemplo n.º 1
0
        public void FilterParameter001()
        {
            // Arrange
            var    expected = JObject.Parse(@"
            {
              ""filter"": [
                ""_id_:X"",
                ""_score_:Y""
              ]
            }");
            string actual;
            var    jObject           = new JObject();
            var    expressionCache   = new ExpressionCache <TestDocument>();
            var    expressionBuilder = new ExpressionBuilder <TestDocument>(expressionCache);
            var    parameter1        = new FilterParameter <TestDocument>(expressionBuilder);
            var    parameter2        = new FilterParameter <TestDocument>(expressionBuilder);

            parameter1.Configure(new Single <TestDocument>(q => q.Id, "X"));
            parameter2.Configure(new Single <TestDocument>(q => q.Score, "Y"));

            // Act
            parameter1.Execute(jObject);
            parameter2.Execute(jObject);
            actual = jObject.ToString();

            // Assert
            Assert.Equal(expected.ToString(), actual);
        }
Exemplo n.º 2
0
        public void FilterQueryParameter001()
        {
            // Arrange
            var container         = new List <string>();
            var solrOptions       = new SolrExpressOptions();
            var solrConnection    = new FakeSolrConnection <TestDocument>();
            var expressionBuilder = new ExpressionBuilder <TestDocument>(solrOptions, solrConnection);

            expressionBuilder.LoadDocument();
            var parameter1 = new FilterParameter <TestDocument>();

            parameter1.Query = new SearchQuery <TestDocument>(expressionBuilder).Field(q => q.Id).AddValue("X");
            var parameter2 = new FilterParameter <TestDocument>();

            parameter2.Query = new SearchQuery <TestDocument>(expressionBuilder).Field(q => q.Score).AddValue("Y");

            // Act
            parameter1.Execute();
            parameter1.AddResultInContainer(container);
            parameter2.Execute();
            parameter2.AddResultInContainer(container);

            // Assert
            Assert.Equal(2, container.Count);
            Assert.Equal("fq=id:\"X\"", container[0]);
            Assert.Equal("fq=score:\"Y\"", container[1]);
        }
        public IActionResult GetClassworkResults([FromBody] FilterParameter filterParam)
        {
            QueryParameter qp      = ParseQueryString();
            var            records = _service.GetClassworkSummary(filterParam.StartDate, filterParam.EndDate);

            return(Ok(records));
        }
Exemplo n.º 4
0
        public JsonResult FilterContactsByAccount(FilterParameter searchParam)
        {
            var userViewModel = new List <UserViewModel>();
            var userModel     = _accountService.GetContactList(searchParam);

            Mapper.Map(userModel, userViewModel);
            return(Json(userViewModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public JsonResult FilterAccounts(FilterParameter searchParam)
        {
            var accountModel     = new List <AccountModel>();
            var accountViewModel = new List <AccountViewModel>();

            accountModel = _accountService.AccountFilter(searchParam);
            Mapper.Map(accountModel, accountViewModel);
            return(Json(new { Success = true, Accounts = accountViewModel, Message = "Successful" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
 private static bool DecideFilterDisplay(FilterParameter filterParameter)
 {
     return(filterParameter.Race != -1 ||
            filterParameter.Gender != -1 ||
            filterParameter.Hispanic != null ||
            filterParameter.FrlIndicator != null ||
            filterParameter.IEPIndicator != null ||
            filterParameter.LEPIndicator != null);
 }
Exemplo n.º 7
0
        public ActionResult SummaryReportById(int teacherId, bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(viewMeetExceedSummary);
                ViewBag.SummaryLink   = "SummaryReportById";
                ViewBag.TeacherFilter = teacherId;
                bool           unAuthorizedRequest = false;
                SiteUser       su              = ((SiteUser)Session["SiteUser"]);
                ModelServices  modelServices   = new ModelServices();
                StudentService studentService  = new StudentService(su, entities);
                int            defaultDistrict = su.Districts[0].Id;
                int            schoolYearId    = modelServices.SchoolYearId();
                int[]          userSchools     = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();

                var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict);
                unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == teacherId).Count() == 0 ? true : false;

                if (unAuthorizedRequest)
                {
                    return(RedirectToAction("AccessDenied", "Error"));
                }

                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear    = modelServices.SchoolYearDescription();
                data.DropDown      = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear       = schoolYearId;
                data.DropDown.District                = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.Teacher                 = new TeacherDropDown(dropdownTeachers);
                data.DropDown.Teacher.SelectedTeacher = teacherId;
                data.DropDown.Race        = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Gender      = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { teacherId }));

                var filterParameter = new FilterParameter
                {
                    ClassId    = classDefaultValue,
                    Teacher    = teacherId,
                    School     = userSchools.First(),
                    Year       = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList     = modelServices.GetSummaryReport(filterParameter);
                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return(View("SummaryReport", data));
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
        }
Exemplo n.º 8
0
        public FramebufferTextureSpecification(TextureFormat format, FilterParameter filter = FilterParameter.Linear)
        {
            Format = format;
            Filter = filter;

            Index = null;

            dontDraw = false;
        }
Exemplo n.º 9
0
        public void Initialize(Object passedObj)
        {
            FilterParameter filterParam = passedObj as FilterParameter;

            if (filterParam != null)
            {
                dockPanel = filterParam.dockPanel;
                Width     = filterParam.Width;
                Height    = filterParam.Height;
                m_History = filterParam.History;
                if (filterParam.SysConfig != null)
                {
                    m_defaultDensityDefaultValue  = filterParam.SysConfig.DensityAlarmDefaultValue;
                    m_defaultDensitySetOnCaseOpen = filterParam.SysConfig.DensityAlarmSetOnCaseOpen;
                    m_profile = filterParam.SysConfig.Profile;
                }
                else
                {
                    m_defaultDensityDefaultValue  = 0.0;
                    m_defaultDensitySetOnCaseOpen = false;
                }


                HistoryFilter filter = new HistoryFilter();
                filter.name = m_Name;
                if (m_defaultDensitySetOnCaseOpen)
                {
                    if (m_profile != null && m_profile.DensityAlarmValue != 0.0)
                    {
                        filter.parameter = m_profile.DensityAlarmValue.ToString();
                    }
                    else
                    {
                        filter.parameter = m_defaultDensityDefaultValue.ToString();
                    }
                }
                else
                {
                    filter.parameter = "0.0";
                }
                m_History.SetFirstStep(filter);

                m_ValueSlider.IsEnabled = false;
                if (m_profile != null && m_profile.DensityAlarmValue != 0.0)
                {
                    m_ValueSlider.Value = m_profile.DensityAlarmValue * 100.0;
                }
                else
                {
                    m_ValueSlider.Value = m_defaultDensityDefaultValue * 100.0;
                }
                m_ValueSlider.IsEnabled = true;

                m_ValTextBox.Text = (m_ValueSlider.Value).ToString("F0") + " %";
            }
        }
        private static bool DecideFilterDisplay(FilterParameter filterParameter)
        {

            return (filterParameter.Race != -1
                || filterParameter.Gender != -1
                || filterParameter.Hispanic != null
                || filterParameter.FrlIndicator != null
                || filterParameter.IEPIndicator != null
                || filterParameter.LEPIndicator != null);
        }
Exemplo n.º 11
0
        public void FilterParameter002()
        {
            // Arrange
            var expressionCache   = new ExpressionCache <TestDocument>();
            var expressionBuilder = new ExpressionBuilder <TestDocument>(expressionCache);
            var parameter         = new FilterParameter <TestDocument>(expressionBuilder);

            // Act / Assert
            Assert.Throws <ArgumentNullException>(() => parameter.Configure(null));
        }
Exemplo n.º 12
0
        public JsonResult FilterProducts(FilterParameter searchParam)
        {
            var productViewModel = new List <ProductViewModel>();

            var products = _productService.FilterProducts(searchParam);

            Mapper.Map(products, productViewModel);

            return(Json(new { Success = true, Products = productViewModel, Message = "Success" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
        public async Task <IActionResult> AllTeacherList(FilterParameter model)
        {
            int count;
            TeacherListModel teacherModel1 = new TeacherListModel();

            teacherModel1.TeacherModel = _classBookService.AllTeacherListModel(model, out count, model.PageIndex);
            teacherModel1.Pager        = new Pager(count, model.PageIndex);
            var result = await _viewRenderService.RenderToStringAsync("_TeacherListPartialView", teacherModel1);

            return(Content(result));
        }
        public async Task <IActionResult> AllCareerExpertList(FilterParameter model)
        {
            int count;
            CareerExpertListModel classmodel1 = new CareerExpertListModel();

            classmodel1.CareerExpertModel = _classBookService.AllCareerExpertListModel(model, out count, model.PageIndex);
            classmodel1.Pager             = new Pager(count, model.PageIndex);
            var result = await _viewRenderService.RenderToStringAsync("_CareerExpertListPartialView", classmodel1);

            return(Content(result));
        }
Exemplo n.º 15
0
        public IEnumerable <IDBObject> GetRecords(string searchSubstring)
        {
            // Блок отвечающий за создание массива объектов FilterParameter
            FilterParameter[] parameters = new FilterParameter[1];
            parameters[0] = new FilterParameter()
            {
                Name = "@searchSubstring", Type = FilterParameterType.String, Value = searchSubstring
            };

            var result = DataReader.ExecQuery <Person>(storedProcedureName, parameters);

            return(result);
        }
        public IActionResult AllCareerExpertList()
        {
            int count = 0;
            CareerExpertListModel model = new CareerExpertListModel();

            model.States      = _classBookModelFactory.PrepareStateDropDown();
            model.ClassesList = _classBookModelFactory.PrepareClassesDropDown();
            model.TeacherList = _classBookModelFactory.PrepareTeacherDropDown();
            FilterParameter filterParameterModel = new FilterParameter();

            model.CareerExpertModel = _classBookService.AllCareerExpertListModel(filterParameterModel, out count, 1);
            model.Pager             = new Pager(count, 1);
            return(View(model));
        }
Exemplo n.º 17
0
        public void AddEntitySetCache()
        {
            CacheContainer.Current.LoadCache();

            List <User>     users       = CacheContainer.Current.GetObjects <User>();
            FilterParameter p1          = FilterParameter.CreateFilterParamater <User>("ID", 0);
            FilterParameter p2          = FilterParameter.CreateFilterParamater <User>("Name", "Name1", FilterCondition.Like);
            IList           filterUsers = CacheContainer.Current.GetObjectsWithFilter <User>(p2);


            List <BfCodeInfo> codes       = CacheContainer.Current.GetObjects <BfCodeInfo>();
            FilterParameter   pc2         = FilterParameter.CreateFilterParamater <BfCodeInfo>("CODE", "2", FilterCondition.Like);
            IList             filterCodes = CacheContainer.Current.GetObjectsWithFilter <BfCodeInfo>(pc2);
        }
Exemplo n.º 18
0
        private List <object> CreateLabResultsFilter(string personId, string[] labResults)
        {
            Filter filter = new Filter();

            string conditions = "lower(observationidentifiertext) in (";

            string inCondition = "";

            for (int srIndex = 0; srIndex < labResults.Length; srIndex++)
            {
                inCondition = $"{inCondition},'{labResults[srIndex].ToLower().Replace("_"," ")}'";
            }

            inCondition = inCondition.TrimStart(',');

            conditions = $"{conditions} {inCondition}) and person_id = @person_id";

            filter.filterClause = conditions;

            Filters filters = new Filters();

            filters.filters.Add(filter);

            FilterParameter parameter = new FilterParameter();

            parameter.paramName  = "person_id";
            parameter.paramValue = personId;

            FilterParameters filterParameters = new FilterParameters();

            filterParameters.filterparams.Add(parameter);

            SelectStatement selectStatement = new SelectStatement();

            selectStatement.selectstatement = "SELECT distinct on (observationidentifiertext) observationidentifiertext, *";

            OrderByGroupByStatement orderByGroupByStatement = new OrderByGroupByStatement();

            orderByGroupByStatement.ordergroupbystatement = "ORDER BY observationidentifiertext, observationdatetime DESC";

            List <object> body = new List <object>();

            body.Add(filters);
            body.Add(filterParameters);
            body.Add(selectStatement);
            body.Add(orderByGroupByStatement);

            return(body);
        }
Exemplo n.º 19
0
        public IActionResult AllTeacherList()
        {
            int count = 0;
            TeacherListModel model = new TeacherListModel();

            model.States       = _classBookModelFactory.PrepareStateDropDown();
            model.BoardList    = _classBookModelFactory.PrepareBoardDropDown();
            model.MediumList   = _classBookModelFactory.PrepareMediumDropDown();
            model.StandardList = _classBookModelFactory.PrepareStandardDropDown();
            FilterParameter filterParameterModel = new FilterParameter();

            model.TeacherModel = _classBookService.AllTeacherListModel(filterParameterModel, out count, 1);
            model.Pager        = new Pager(count, 1);
            return(View(model));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 設定画面表示メソッド
        /// </summary>
        /// <returns></returns>
        public void Setting()
        {
            FilterParam = new FilterParameter(3);

            if (SettingForm == null)
            {
                SettingForm = new FilterSetting(FilterParam);
            }
            else if (SettingForm.IsDisposed)
            {
                SettingForm = new FilterSetting(FilterParam);
            }

            SettingForm.Show();
            return;
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            try
            {
                JObject jObject = JObject.Load(reader);
                FilterParameter fp = new FilterParameter();
                Regex rx = new Regex("and'(?<and>[\\w\\d]*)'or'(?<or>[\\w\\d]*)'");
                Match m = rx.Match(jObject.Properties().ElementAt(0).Name);
                if (m != null && m.Success)
                {
                    fp.AndGroupName = m.Groups["and"].Value;
                    fp.OrGroupName = m.Groups["or"].Value;
                }

                rx = new Regex("^(?<colname>[^\\s]*)\\s(?<op>[^\\s]*)\\s(?<valtype>[\\d\\w\\.]*)'(?<valval>.*)'$");
                m = rx.Match((string)jObject.Properties().ElementAt(0).Value);

                if (m != null && m.Success)
                {
                    fp.ColumnName = m.Groups["colname"].Value;
                    fp.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), m.Groups["op"].Value);
                    Type targetType = Type.GetType("System." + m.Groups["valtype"].Value);
                    object o = JsonConvert.DeserializeObject(m.Groups["valval"].Value);
                    if (o != null && targetType != null && o.GetType() != targetType)
                    {
                        if (targetType == typeof(Guid) && o.GetType() == typeof(string))
                        {
                            o = new Guid((string)o);
                        }
                        else
                        {
                            o = Convert.ChangeType(o, targetType);
                        }
                    }

                    fp.Value = o;
                }

                return fp;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public static ReportFilterViewModel PopulateReportFilterViewModel(FilterParameter filterParameter, ModelServices modelService, SiteUser siteUser)
 {
     string defaultText = "All";
     var reportFilterViewModel = new ReportFilterViewModel();
     reportFilterViewModel.TeacherName = modelService.GetUserNameByUserId(filterParameter.Teacher);
     reportFilterViewModel.ClassName = filterParameter.ClassId != -1 ? modelService.GetClassDesc(filterParameter.ClassId) : defaultText;
     reportFilterViewModel.Race = (filterParameter.Race == -1) ? defaultText : modelService.GetRaceDesc(filterParameter.Race);
     reportFilterViewModel.Gender = (filterParameter.Gender == -1) ? defaultText : modelService.GetGenderDesc(filterParameter.Gender);
     //TODO: till now first record with district name and Id is picked up. Need to refactor if user belongs to multiple district. 
     reportFilterViewModel.DistrictName = siteUser.Districts.First().Name;
     reportFilterViewModel.IsAdmin = HelperService.AllowUiEdits(siteUser.RoleDesc, "REPORT");
     reportFilterViewModel.DisplayAdminFilters = DecideFilterDisplay(filterParameter);
     reportFilterViewModel.FrlIndicator = filterParameter.FrlIndicator;
     reportFilterViewModel.LepIndicator = filterParameter.LEPIndicator;
     reportFilterViewModel.IepIndicator = filterParameter.IEPIndicator;
     reportFilterViewModel.Hispanic = filterParameter.Hispanic;
     reportFilterViewModel.SchoolYear = filterParameter.SchoolYear;
     return reportFilterViewModel;
 }
        private Dictionary<string, string> GetParameters(GetFeaturesByIDsParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("getFeatureMode", "\"ID\"");

            if (parameters.DatasetNames != null && parameters.DatasetNames.Count > 0)
            {
                string jsonDatasetNames = "[";
                List<string> list = new List<string>();
                for (int i = 0; i < parameters.DatasetNames.Count; i++)
                {
                    list.Add(string.Format("\"{0}\"", parameters.DatasetNames[i]));
                }
                jsonDatasetNames += string.Join(",", list.ToArray());
                jsonDatasetNames += "]";

                dictionary.Add("datasetNames", jsonDatasetNames);
            }
            if (parameters.IDs != null && parameters.IDs.Count > 0)
            {
                string jsonIDs = "[";
                List<string> list = new List<string>();
                for (int i = 0; i < parameters.IDs.Count; i++)
                {
                    list.Add(parameters.IDs[i].ToString());
                }
                jsonIDs += string.Join(",", list.ToArray());
                jsonIDs += "]";

                dictionary.Add("ids", jsonIDs);
            }

            if (parameters.Fields != null && parameters.Fields.Count > 0)
            {
                FilterParameter fp = new FilterParameter();
                fp.Fields = parameters.Fields;
                dictionary.Add("queryParameter", FilterParameter.ToJson(fp));
            }
            return dictionary;
        }
        public ActionResult SummaryReportById(int teacherId, bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(viewMeetExceedSummary);
                ViewBag.SummaryLink = "SummaryReportById";
                ViewBag.TeacherFilter = teacherId;
                bool unAuthorizedRequest = false;
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();
                StudentService studentService = new StudentService(su, entities);
                int defaultDistrict = su.Districts[0].Id;
                int schoolYearId = modelServices.SchoolYearId();
                int[] userSchools = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();

                var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict);
                unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == teacherId).Count() == 0 ? true : false;

                if (unAuthorizedRequest)
                {
                    return RedirectToAction("AccessDenied", "Error");
                }

                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear = modelServices.SchoolYearDescription();
                data.DropDown = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = schoolYearId;
                data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers);
                data.DropDown.Teacher.SelectedTeacher = teacherId;
                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { teacherId }));

                var filterParameter = new FilterParameter
                {
                    ClassId = classDefaultValue,
                    Teacher = teacherId,
                    School = userSchools.First(),
                    Year = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return View("SummaryReport", data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult SummaryReport(bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                ViewBag.SummaryLink = "SummaryReport";

                SetViewBag(viewMeetExceedSummary);
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();
                StudentService studentService = new StudentService(su, entities);

                int defaultDistrict = su.Districts[0].Id;
                int schoolYearId = modelServices.SchoolYearId();
                int[] userSchools = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();

               

                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear = modelServices.SchoolYearDescription();
                data.DropDown = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = schoolYearId;
                data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));

                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Race.SelectedRace = -1;
                data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.Gender.SelectedGender = -1;

                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                if (su.isTeacher)
                {
                    data.DropDown.Teacher = new TeacherDropDown(
                        new List<DropDownIdName>() { new DropDownIdName() { Id = su.EdsUserId, Name = su.UserFullName } });
                    data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { su.EdsUserId }));
                }
                else // data administrator and eds administrator
                {
                    int[] schoolsTeacher = modelServices.getTeachersBySchoolsId(userSchools).ToArray();
                    data.DropDown.Teacher = new TeacherDropDown(modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict));
                    data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, schoolsTeacher));
                }

                var filterParameter = new FilterParameter
                {
                    ClassId = classDefaultValue,
                    Teacher = su.EdsUserId,
                    School = userSchools.First(),
                    Year = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return View(data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult UpdateGrid(FilterParameter filterParameter)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(filterParameter.ViewMeetExceedSummary);
                ViewBag.SummaryLink = "UpdateGrid";
                bool unAuthorizedRequest = false;
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();
                TIRSummaryModel data = new TIRSummaryModel();

                int defaultDistrict = su.Districts[0].Id;
                data.DropDown = new DropDownData();
                ViewBag.FilterParameter = filterParameter;

                #region Initializations                
                var dropdownSchools = modelServices.GetSchoolDropDownData(su.EdsUserId, filterParameter.Year);
                var schoolCount = dropdownSchools.Where(x => x.Id == filterParameter.School).Count();
                unAuthorizedRequest = schoolCount == 0 ? true : false;
                if (unAuthorizedRequest)
                {
                    return RedirectToAction("AccessDenied", "Error");
                }

                if (!unAuthorizedRequest)
                {
                    if (su.isTeacher)
                    {
                        unAuthorizedRequest = (su.EdsUserId != filterParameter.Teacher) ? true : false;
                        if (!unAuthorizedRequest)
                            data.DropDown.Teacher = new TeacherDropDown(new List<DropDownIdName>() { new DropDownIdName() { Id = su.EdsUserId, Name = su.UserFullName } });
                    }
                    else
                    {
                        var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(new int[] { filterParameter.School }, filterParameter.Year, defaultDistrict);
                        unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == filterParameter.Teacher).Count() == 0 ? true : false;

                        if (!unAuthorizedRequest)
                        {
                            data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers);
                            data.DropDown.Teacher.SelectedTeacher = filterParameter.Teacher;
                        }
                    }
                }
                #endregion
                   
                //TODO: need to refactor below code if possible.
                ViewBag.TeacherFilter = filterParameter.Teacher;
                ViewBag.SchoolFilter = filterParameter.School;
                ViewBag.YearFilter = filterParameter.Year;
                ViewBag.ClassFilter = filterParameter.ClassId;
                ViewBag.Race = filterParameter.Race;
                ViewBag.Gender = filterParameter.Gender;
                ViewBag.FrlIndicator = filterParameter.FrlIndicator;
                ViewBag.IEPIndicator = filterParameter.IEPIndicator;
                ViewBag.LEPIndicator = filterParameter.LEPIndicator;
                ViewBag.Hispanic = filterParameter.Hispanic;


                #region Init Filter Parameters
                data.SchoolYear = modelServices.SchoolYearDescriptionByYearId(filterParameter.Year);
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = filterParameter.Year;
                data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.School = new SchoolDropDown(dropdownSchools);
                data.DropDown.School.SelectedSchool = filterParameter.School;
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
             
                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(filterParameter.Year, new[] { filterParameter.Teacher }));

                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Race.SelectedRace = filterParameter.Race;
                data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.Gender.SelectedGender = filterParameter.Gender;
                data.Hispanic = filterParameter.Hispanic;
                data.IepIndicator = filterParameter.IEPIndicator;
                data.LepIndicator = filterParameter.LEPIndicator;
                data.FrlIndicator = filterParameter.FrlIndicator;

                data.DropDown.SchoolClass.SelectedClass = filterParameter.ClassId;
                #endregion

                filterParameter.SchoolYear = data.SchoolYear;
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return View("SummaryReport", data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
Exemplo n.º 27
0
        internal List<TIRSummary> GetSummaryReport(FilterParameter filterParameter)
        {
            List<TIRSummary> tirSummaryList = new List<TIRSummary>();

            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("spGetTeacherSummaryView", connection);
            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.Add(new SqlParameter("@teacherId", filterParameter.Teacher));
            command.Parameters.Add(new SqlParameter("@schoolId", filterParameter.School));
            command.Parameters.Add(new SqlParameter("@schoolYearId", filterParameter.Year));
            command.Parameters.Add(new SqlParameter("@classId", filterParameter.ClassId));
            command.Parameters.Add(new SqlParameter("@ViewMeetExceedSummary", filterParameter.ViewMeetExceedSummary));
            command.Parameters.Add(new SqlParameter("@Race", filterParameter.Race == -1 ? (int?)null : filterParameter.Race));
            command.Parameters.Add(new SqlParameter("@Gender", filterParameter.Gender == -1 ? (int?)null : filterParameter.Gender));
            command.Parameters.Add(new SqlParameter("@FrlIndicator", filterParameter.FrlIndicator));
            command.Parameters.Add(new SqlParameter("@IepIndicator", filterParameter.IEPIndicator));
            command.Parameters.Add(new SqlParameter("@LepIndicator", filterParameter.LEPIndicator));
            command.Parameters.Add(new SqlParameter("@Hispanic", filterParameter.Hispanic));
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                TIRSummary tempSummary = new TIRSummary();
                tempSummary.GradeLevel = int.Parse(reader["Grade"].ToString());
                tempSummary.TeacherId = filterParameter.Teacher;
                tempSummary.YearId = filterParameter.Year;
                tempSummary.ClassId = filterParameter.ClassId;
                tempSummary.SubjectId = int.Parse(reader["SubjectId"].ToString());
                tempSummary.AssessmentCode = reader["AssessmentCode"].ToString();
                tempSummary.SubjectDesc = reader["ClassSubject"].ToString();
                tempSummary.Weighting = HelperService.GetRoundedValue(RoundingType.SiteDefaultDecimalPlace, Convert.ToDecimal(reader["Weighting"]));
                tempSummary.AssessmentTypeId = reader["AssessmentTypeId"].ToString();
                tempSummary.Impact = reader["Impact"] == DBNull.Value ? (decimal?)null : HelperService.GetRoundedValue(RoundingType.SiteDefaultDecimalPlace, Convert.ToDecimal(reader["Impact"]));
                tempSummary.NoOfStudent = reader["NoOfStudent"] == DBNull.Value ? 0 : int.Parse(reader["NoOfStudent"].ToString());
                tempSummary.Average = reader["Average"] == DBNull.Value ? (decimal?)null : HelperService.GetRoundedValue(RoundingType.SiteDefaultDecimalPlace, Convert.ToDecimal(reader["Average"]));
                tempSummary.AssessmentGradeWeightingId = int.Parse(reader["AssessmentGradeWeightingId"].ToString());
                tempSummary.MeetExceedPerc = reader["MeetExceedPerc"] == DBNull.Value ? (decimal)0.0 : HelperService.GetRoundedValue(RoundingType.SiteDefaultDecimalPlace, Convert.ToDecimal(reader["MeetExceedPerc"]));
                tempSummary.AverageOrMEValue = filterParameter.ViewMeetExceedSummary ? tempSummary.MeetExceedPerc : tempSummary.Average;
                tempSummary.MeetExceedPoints = reader["MeetExceedPoints"] == DBNull.Value ? (decimal?)null : HelperService.GetRoundedValue(RoundingType.DoubleDecimalplace, Convert.ToDecimal(reader["MeetExceedPoints"]));
                tempSummary.MeetExceedCategory = reader["MeetExceedCategory"] == DBNull.Value ? (int?)null : int.Parse(reader["MeetExceedCategory"].ToString());
                tempSummary.WeightedImpact = filterParameter.ViewMeetExceedSummary ? CalculateWeightedImpact(tempSummary.MeetExceedPoints, tempSummary.Weighting) : CalculateWeightedImpact(tempSummary.Average, tempSummary.Weighting);
                tempSummary.IsAssessmentExist = (bool)reader["IsAssessmentExist"];
                tempSummary.ReportTemplateId = Convert.ToInt32(reader["ReportTemplateId"]);
                tempSummary.AssessmentTypeDesc = Convert.ToString(reader["AssessmentTypeDesc"]);
                tirSummaryList.Add(tempSummary);
            }

            reader.Close();
            connection.Close();

            return tirSummaryList;
        }
        private void InitializeReportMetadata(TIRDetailModel model, TIRDetailReportParameter detailReportParameter)
        {
            base.SetNavigationLinksUrl();
            int decimalPlace = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SiteDecimalPlace"].ToString());

            SiteUser su = ((SiteUser)Session["SiteUser"]);
            ModelServices service = new ModelServices();

            model.SchoolYear = service.SchoolYearDescriptionByYearId(detailReportParameter.Year);

            SetDetailReportUrlData(detailReportParameter);
            UpdateReportTemplateConfigurations(service, detailReportParameter.ReportTemplateId);

            model.AssessmentList = service.GetDetailReportAssessmentList(su.Districts.First().Id, detailReportParameter);
            var list = (model.AssessmentList).Select(x => x.AssessmentDesc).ToList();

            var details = service.GetDetailReport(list, su.Districts.First().Id, detailReportParameter);
            model.details = details;
            model.Subject = service.GetSubjectDescriptionById(detailReportParameter.Subject);

            int[] studentCounts = new int[5];
            decimal[] impactSums = new decimal[5];
            decimal[] avgImpacts = new decimal[5];
            int[] countOfMeetOrExceed = new int[5];
            decimal[] percOfMeetOrExceed = new decimal[5];

            //TODO: Need to handle null check here if no data found in model.details list it will give object refrence not found error.
            studentCounts[0] = model.details.Count(d => d.ScoreData1.Impact != null);
            studentCounts[1] = model.details.Count(d => d.ScoreData2.Impact != null);
            studentCounts[2] = model.details.Count(d => d.ScoreData3.Impact != null);
            studentCounts[3] = model.details.Count(d => d.ScoreData4.Impact != null);
            studentCounts[4] = model.details.Count(d => d.ScoreData5.Impact != null);

            impactSums[0] = model.details.Sum(d => d.ScoreData1.Impact.GetValueOrDefault());
            impactSums[1] = model.details.Sum(d => d.ScoreData2.Impact.GetValueOrDefault());
            impactSums[2] = model.details.Sum(d => d.ScoreData3.Impact.GetValueOrDefault());
            impactSums[3] = model.details.Sum(d => d.ScoreData4.Impact.GetValueOrDefault());
            impactSums[4] = model.details.Sum(d => d.ScoreData5.Impact.GetValueOrDefault());

            for (int i = 0; i < studentCounts.Length; i++)
            {
                if (studentCounts[i] > 0)
                {
                    avgImpacts[i] = Math.Round(impactSums[i] / studentCounts[i], decimalPlace);
                }
            }
            countOfMeetOrExceed[0] = model.details.Where(tirDetail => tirDetail.ScoreData1.Impact >= -2).Count();
            countOfMeetOrExceed[1] = model.details.Where(tirDetail => tirDetail.ScoreData2.Impact >= -2).Count();
            countOfMeetOrExceed[2] = model.details.Where(tirDetail => tirDetail.ScoreData3.Impact >= -2).Count();
            countOfMeetOrExceed[3] = model.details.Where(tirDetail => tirDetail.ScoreData4.Impact >= -2).Count();
            countOfMeetOrExceed[4] = model.details.Where(tirDetail => tirDetail.ScoreData5.Impact >= -2).Count();

            service.IsChildAssessmentsExists(model.AssessmentList);

            for (int i = 0; i < model.AssessmentList.Count; i++)
            {
                if (studentCounts[i] > 0)
                {
                    percOfMeetOrExceed[i] = GetPerOfMeetValue(countOfMeetOrExceed[i], studentCounts[i], true);
                }
            }
            ViewBag.percOfMeetOrExceed = percOfMeetOrExceed;
            ViewBag.studentCounts = studentCounts;
            ViewBag.impactSums = impactSums;
            ViewBag.avgImpacts = avgImpacts;


            var filterParameter = new FilterParameter
            {
                ClassId = detailReportParameter.ClassId,
                Teacher = detailReportParameter.Teacher,
                Year = detailReportParameter.Year,
                Race = detailReportParameter.Race,
                Gender = detailReportParameter.Gender,
                FrlIndicator = detailReportParameter.FrlIndicator,
                IEPIndicator = detailReportParameter.IEPIndicator,
                LEPIndicator = detailReportParameter.LEPIndicator,
                Hispanic = detailReportParameter.Hispanic,
                SchoolYear = model.SchoolYear
            };

            var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, service, su);
            ViewBag.ReportFilters = reportFilterViewModel;
        }
        private Dictionary<string, string> GetParameters(GetFeaturesByGeometryParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            if (string.IsNullOrEmpty(parameters.AttributeFilter))
            {
                dictionary.Add("getFeatureMode", "\"SPATIAL\"");
            }
            else
            {
                dictionary.Add("getFeatureMode", "\"SPATIAL_ATTRIBUTEFILTER\"");
                dictionary.Add("attributeFilter", parameters.AttributeFilter);
            }
            if (parameters.DatasetNames != null && parameters.DatasetNames.Count > 0)
            {
                string jsonDatasetNames = "[";
                List<string> list = new List<string>();
                for (int i = 0; i < parameters.DatasetNames.Count; i++)
                {
                    list.Add(string.Format("\"{0}\"", parameters.DatasetNames[i]));
                }
                jsonDatasetNames += string.Join(",", list.ToArray());
                jsonDatasetNames += "]";

                dictionary.Add("datasetNames", jsonDatasetNames);
            }
            else
            {
                throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull);
            }
            dictionary.Add("spatialQueryMode", parameters.SpatialQueryMode.ToString().ToUpper());

            if (parameters.Geometry != null)
            {
                dictionary.Add("geometry", ServerGeometry.ToJson(Bridge.ToServerGeometry(parameters.Geometry)));
            }
            else
            {
                throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull);
            }

            if (parameters.Fields != null && parameters.Fields.Count > 0)
            {
                FilterParameter fp = new FilterParameter();
                fp.Fields = parameters.Fields;
                dictionary.Add("queryParameter", FilterParameter.ToJson(fp));
            }
            return dictionary;
        }
        private void InitializeReportMetadata(HeirarchicalTIRDetailModel model, TIRDetailReportParameter detailReportParameter)
        {
            base.SetNavigationLinksUrl();

            int decimalPlace = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SiteDecimalPlace"].ToString());

            SiteUser su = ((SiteUser)Session["SiteUser"]);
            ModelServices service = new ModelServices();

            model.SchoolYear = service.SchoolYearDescriptionByYearId(detailReportParameter.Year);

            SetDetailReportUrlData(detailReportParameter);
            UpdateReportTemplateConfigurations(service, detailReportParameter.ReportTemplateId);
            ViewBag.SchoolTermList = service.GetSchoolTerms(detailReportParameter);

            var details = service.GetHeirarchicalDetailReport(su.Districts.First().Id, detailReportParameter);
            model.details = details;
            model.Subject = service.GetSubjectDescriptionById(detailReportParameter.Subject);
            model.SubjectId = detailReportParameter.Subject;
            model.SchoolYearId = detailReportParameter.Year;
            model.AssessmentTypeId = detailReportParameter.AssessmentTypeId;
            model.CameFromTitle = detailReportParameter.CameFromTitle;
            if (details.Count > 0)
            {
                model.AssessmentList = new List<AssessmentMEPerc>();
                var firstTirDetail = details[0];
                var schoolTermId = firstTirDetail.SchoolTermId;
                detailReportParameter.InputTermId = schoolTermId;
                foreach (var score in firstTirDetail.ScoreDataCollection)
                {
                    AssignMePercentForAssessment(score, service, su, detailReportParameter, ref model.AssessmentList);
                }

                service.IsChildAssessmentsExists(model.AssessmentList);

                List<int> studentCounts = studentCounts = new List<int>();
                List<decimal> impactSums = new List<decimal>();
                List<decimal> avgImpacts = new List<decimal>();
                List<int> countOfMeetOrExceed = new List<int>();

                for (int i = 0; i < model.details[0].ScoreDataCollection.Count; i++)
                {
                    studentCounts.Add(model.details.Count(d => d.ScoreDataCollection[i].Impact != null));
                    impactSums.Add(model.details.Sum(d => d.ScoreDataCollection[i].Impact.GetValueOrDefault()));
                    countOfMeetOrExceed.Add(model.details.Where(d => d.ScoreDataCollection[i].Impact >= -2).Count());
                    if (studentCounts[i] > 0)
                    {
                        avgImpacts.Add(Math.Round(impactSums[i] / studentCounts[i], decimalPlace));
                    }
                    else
                    {
                        avgImpacts.Add(0);
                    }
                }
                ViewBag.avgImpacts = avgImpacts;
            }
            var filterParameter = new FilterParameter
            {
                ClassId = detailReportParameter.ClassId,
                Teacher = detailReportParameter.Teacher,
                Year = detailReportParameter.Year,
                Race = detailReportParameter.Race,
                Gender = detailReportParameter.Gender,
                FrlIndicator = detailReportParameter.FrlIndicator,
                IEPIndicator = detailReportParameter.IEPIndicator,
                LEPIndicator = detailReportParameter.LEPIndicator,
                Hispanic = detailReportParameter.Hispanic,
                SchoolYear = model.SchoolYear
            };

            var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, service, su);
            ViewBag.ReportFilters = reportFilterViewModel;
        }