Exemple #1
0
 public void Assign(List <string> p)
 {
     if (_type != MyParameterDataTypes.Strings)
     {
         throw new Exception("wrong parm type");
     }
     if (p == null || p.Count == 0)
     {
         throw new Exception("list parm can't be null or 0 items");
     }
     _content = p.ToSql();
 }
        /// <summary>
        /// Get a data table comprising the search results.
        /// </summary>
        /// <param name="staffName"></param>
        /// <param name="staffID"></param>
        /// <param name="staffTypes"></param>
        /// <param name="clusters"></param>
        /// <param name="schoolTypes"></param>
        /// <param name="schoolID"></param>
        /// <returns></returns>
        private DataTable GetResultsTable(string staffName, string staffID, List<string> staffTypes, List<string> clusters, List<string> schoolTypes, string schoolName)
        {
            // The stored proc doesn't like passing null. Pass empty strings for null values.
            if (staffName == null)
            {
                staffName = string.Empty;
            }

            if (staffID == null)
            {
                staffID = string.Empty;
            }

            // We have to generate a list of school ids for these criteria.
            List<Thinkgate.Base.Classes.School> schoolList = new List<Thinkgate.Base.Classes.School>();
            if (clusters != null && clusters.Count > 0)
            {
                schoolList.AddRange(SchoolMasterList.GetSchoolsForCriteria(clusters, null, null, null));
            }

            if (!string.IsNullOrEmpty(schoolName))
            {
                schoolList.AddRange(SchoolMasterList.GetSchoolsForCriteria(null, null, schoolName, null));
            }
            else if (schoolTypes != null && schoolTypes.Count > 0)
            {
                schoolList.AddRange(SchoolMasterList.GetSchoolsForCriteria(null, schoolTypes, null, null));
            }

            schoolList = schoolList.Distinct().ToList();
            List<int> schoolIdList = (from sc in schoolList select sc.ID).Distinct().ToList();

            // If we are not searching on school, we must list all possible schools for this user.
            if (schoolIdList.Count == 0)
            {
                schoolIdList = SchoolMasterList.GetSchoolTableIdsForUser(SessionObject.LoggedInUser);
            }

            DataSet filteredStaffDataSet = Thinkgate.Base.DataAccess.ThinkgateDataAccess.FetchDataSet(
                "E3_Staff_Search",
                new object[] { staffName, staffID, staffTypes.ToSql(), clusters.ToSql(), schoolTypes.ToSql(), schoolIdList.ToSql() });

            filteredStaffDataSet = RenameResultSets(filteredStaffDataSet);

            // Now we have to build a single data table to show in the grid.
            DataTable dt = new DataTable();
            DataColumn nameCol = dt.Columns.Add("Name");
            DataColumn userIDCol = dt.Columns.Add("UserID");
            DataColumn userPageCol = dt.Columns.Add("UserPage", typeof(int));
            DataColumn userTypeCol = dt.Columns.Add("UserType");
            DataColumn schoolCol = dt.Columns.Add("School");

            foreach (DataRow infoRow in filteredStaffDataSet.Tables["StaffInfo"].Rows)
            {
                DataRow resultRow = dt.NewRow();
                resultRow[nameCol] = infoRow["UserFullName"];
                resultRow[userIDCol] = infoRow["UserName"];
                resultRow[userPageCol] = infoRow["UserPage"];

                List<string> userTypes = (from t in filteredStaffDataSet.Tables["StaffRoles"].AsEnumerable()
                                          where t.Field<Guid>("UserID") == (Guid)infoRow["UserID"]
                                          select t.Field<string>("RoleName")).Distinct().ToList();

                resultRow[userTypeCol] = string.Join(", ", userTypes);

                List<string> schools = (from t in filteredStaffDataSet.Tables["StaffSchools"].AsEnumerable()
                                        where t.Field<Guid>("UserID") == (Guid)infoRow["UserID"]
                                        select t.Field<string>("SchoolName")).Distinct().ToList();

                resultRow[schoolCol] = string.Join(", ", schools);

                dt.Rows.Add(resultRow);
            }

            return dt;
        }
Exemple #3
0
 public void Assign( List<string> p )
 {
     if( _type != MyParameterDataTypes.Strings ) throw new Exception( "wrong parm type" );
     if( p == null || p.Count == 0 ) throw new Exception( "list parm can't be null or 0 items" );
     _content = p.ToSql();
 }
        private void LoadAssessments()
        {
            String gradeFilter = (String)ViewState[_gradeFilterKey];
            String subjectFilter = (String)ViewState[_subjectFilterKey];
            Thinkgate.Base.Classes.CourseList courses = Thinkgate.Base.Classes.CourseMasterList.CurrCourseList;
            courses = courses.FilterByGradeAndSubject((gradeFilter == "All") ? null : gradeFilter, (subjectFilter == "All") ? null : subjectFilter);
            List<Int32> courseIds = new List<int>();
            foreach (Thinkgate.Base.Classes.Course c in courses)
                courseIds.Add(c.ID);
            List<ThinkgateSchool> schools = SessionObject.LoggedInUser.Schools;
            List<Int32> schoolIds = new List<Int32>(); 
            //PLH - 01/15/2013 - Drill down to school for Classroom Assessments from Classes Folder ONLY
            if (_schoolID != 0)
            {
                schoolIds.Add(_schoolID);
            }
            else
            {
                schoolIds = (from s in schools select s.Id).ToList();
            }
            List<ThinkgateRole> roles = SessionObject.LoggedInUser.Roles;
            List<String> roleNames = (from r in roles select r.RoleName).ToList();

            dtAssessment = Thinkgate.Base.Classes.Assessment.LoadAssessments(_category, _level.ToString(), _levelID,
                                                                                                                 courseIds.ToSql(), (String)ViewState[_termFilterKey],
                                                                                                                 (String)ViewState[_testTypeFilterKey], (String)ViewState[_statusFilterKey],
                                                                                                                 schoolIds.ToSql(), roleNames.ToSql(), UserHasPermission(Permission.User_Cross_Schools), SessionObject.GlobalInputs, false);

            while (dtAssessment.Rows.Count > _maxAssessments)
                dtAssessment.Rows.RemoveAt(dtAssessment.Rows.Count - 1);

            dtAssessment = Standpoint.Core.Classes.Encryption.EncryptDataTableColumn(dtAssessment, "TestID", "TestID_Encrypted");

            // We must sometimes truncate the test description so that it can fit in the area provided.
            // When truncated we add ellipsis (...).
            DataColumn listDescCol = dtAssessment.Columns.Add("ListDescription");
            DataColumn graphicDescCol = dtAssessment.Columns.Add("GraphicDescription");
            DataColumn dateEdited = dtAssessment.Columns.Add("DateEdited");
            DataColumn percentage = dtAssessment.Columns.Add("Percentage", typeof(Int32));

            const Int32 listChars = 47, graphicChars = 36;
            for (Int32 i = 0; i < dtAssessment.Rows.Count; i++)
            {
                DataRow row = dtAssessment.Rows[i];
                String name = row["TestName"] != DBNull.Value ? (String)row["TestName"] : "";
                String listDesc = (row["Description"] is String && !String.IsNullOrEmpty((String)row["Description"])) ? " - " + (String)row["Description"] : "";
                String graphicDesc = listDesc;

                if (name.Length + listDesc.Length > listChars)
                    listDesc = listDesc.Substring(0, Math.Max(0, listChars - name.Length - 3)) + "...";
                row[listDescCol] = listDesc;

                if (name.Length + graphicDesc.Length > graphicChars)
                    graphicDesc = graphicDesc.Substring(0, Math.Max(0, graphicChars - name.Length - 3)) + "...";
                row[graphicDescCol] = graphicDesc;

                // Stored proc sometimes returns the number of scored students as null.
                if (!(row["Scored"] is Int32))
                    row["Scored"] = 0;
                if (!(row["Seated"] is Int32))
                    row["Seated"] = 0;

                row[dateEdited] = ((DateTime)row["DateUpdated"]).ToShortDateString();

                // Add the percentage scored entry.
                Int32 scored = (Int32)row["Scored"];
                Int32 seated = (Int32)row["Seated"];
                row[percentage] = (seated <= 0) ? 0 : (Int32)Math.Round(100.0 * scored / seated);
            }

            // Add an empty row at the end if we have the maximum number of assessments.
            // This is used as a placeholder for the 'More Results...' line.
            if (dtAssessment.Rows.Count >= _maxAssessments)
            {
                DataRow newRow = dtAssessment.NewRow();
                dtAssessment.Rows.Add(newRow);
            }

            Boolean isEmpty = dtAssessment.Rows.Count == 0;

            lbxList.DataSource = dtAssessment;
            lbxList.DataBind();
            lbxList.Visible = !isEmpty;
            pnlListNoResults.Visible = isEmpty;

            lbxGraphic.DataSource = dtAssessment;
            lbxGraphic.DataBind();
            lbxGraphic.Visible = !isEmpty;
            pnlGraphicNoResults.Visible = isEmpty;
        }
        private void LoadAssessments(bool IsSecure)
        {
            string selectedGrade = cmbGrade.SelectedItem.Value;
            string selectedSubject = cmbSubject.SelectedItem.Value;
            string selectedTerm = cmbTerm.SelectedItem.Value;
            string selectedTestType = cmbTestType.SelectedItem.Value;
            string selectedStatus = (_category == "District" && !UserHasPermission(Permission.Edit_AssessmentDistrict_Unproofed)) ? "Proofed" : cmbStatus.SelectedItem.Value;

            Thinkgate.Base.Classes.CourseList courses = Thinkgate.Base.Classes.CourseMasterList.GetCurrCoursesForUser(SessionObject.LoggedInUser);

            //PLH - quick hack to make Class Assessment Tiles populate correctly. TODO: Change to better method
            if (_level == EntityTypes.Class)
            {
                Base.Classes.Class selectedClass = Base.Classes.Class.GetClassByID(_levelID);
                courses = CourseMasterList.GetCurrCourseForClass(selectedClass);
            }
            else
            {
                string gradeParm = selectedGrade == "All" ? null : selectedGrade;
                string subjectParm = selectedSubject == "All" ? null : selectedSubject;
                courses = courses.FilterByGradeAndSubject(gradeParm, subjectParm);
            }

            List<int> courseIDs = new List<int>();
            foreach (Base.Classes.Course c in courses)
            {
                courseIDs.Add(c.ID);
            }

            List<int> schoolIDs = new List<int>();
            if (_schoolID != 0)
            {
                schoolIDs.Add(_schoolID);
            }
            else
            {
                schoolIDs = (from s in SessionObject.LoggedInUser.Schools select s.Id).ToList();
            }

            List<string> roleNames = (from r in SessionObject.LoggedInUser.Roles select r.RoleName).ToList();

            DataTable dtAssessment = Base.Classes.Assessment.LoadAssessments(_category,
                                                                            _level.ToString(),
                                                                            _levelID,
                                                                            courseIDs.ToSql(),
                                                                            selectedTerm,
                                                                            selectedTestType,
                                                                            selectedStatus,
                                                                            schoolIDs.ToSql(),
                                                                            roleNames.ToSql(),
                                                                            UserHasPermission(Permission.User_Cross_Schools),
                                                                            SessionObject.GlobalInputs,
                                                                            false, IsSecure);
            if (dtAssessment.Rows.Count > 0)
            {
                dtAssessment = Cryptography.EncryptDataTableColumn(dtAssessment, "TestID", "TestID_Encrypted",
                    SessionObject.LoggedInUser.CipherKey);
                ListOfTests = new List<int>();
                foreach (DataRow row in dtAssessment.Rows)
                {
                    ListOfTests.Add(DataIntegrity.ConvertToInt(row["TestID"]));
                }
            }
            dtPrintDateAllTest_district = Thinkgate.Base.Classes.Assessment.GetPrintSecurity_Secutity_Status_AllTest("Assessment", "District", ListOfTests);
            dtPrintDateAllTest_school = Thinkgate.Base.Classes.Assessment.GetPrintSecurity_Secutity_Status_AllTest("school", _schoolId.ToString(), ListOfTests);
            foreach (DataRow dr in dtAssessment.Rows)
            {
                if (dr["Description"].ToString().Length > 36)
                {
                    dr["Description"] = dr["Description"].ToString().Remove(35, dr["Description"].ToString().Length - 36);
                }
            }


            rlbSecure.Visible = dtAssessment.Rows.Count > 0;

            if (!IsSecure)
            {
                lbx.Visible = dtAssessment.Rows.Count > 0;
                pnlNoResults.Visible = dtAssessment.Rows.Count == 0;
                if (dtAssessment.Rows.Count > 0)
                {
                    lbx.DataSource = dtAssessment;
                    lbx.DataBind();

                }

            }
            else
            {

                rlbSecure.Visible = dtAssessment.Rows.Count > 0;
                pnlNoResultsSecure.Visible = dtAssessment.Rows.Count == 0;
                if (dtAssessment.Rows.Count > 0)
                {
                    rlbSecure.DataSource = dtAssessment;
                    rlbSecure.DataBind();

                }

            }
        }