/// <summary> /// Populates states in the form /// </summary> protected void PopulateStates() { //Get all States but CMS State. if (IsCMSLevelUser) { string StateFIPSForCMS = State.GetStateFIPSForCMS(); //List<KeyValuePair<string, string>> AllStatesOption = new List<KeyValuePair<string, string>>(); //AllStatesOption.Add(new KeyValuePair<string,string>(StateFIPSForCMS, "All States")); IEnumerable <KeyValuePair <string, string> > StatesForUser = null; IEnumerable <KeyValuePair <string, string> > StatesData = State.GetStatesWithFIPSKey().Where(p => p.Key != StateFIPSForCMS); if (AccountInfo.Scope.IsEqual(Scope.CMSRegional)) { List <string> StateFIPSForCMSRegions = new List <string>(); IEnumerable <UserRegionalAccessProfile> profiles = UserCMSBLL.GetUserCMSRegionalProfiles(AccountInfo.UserId, false); foreach (UserRegionalAccessProfile profile in profiles) { IEnumerable <string> CMSStateFIPS = LookupBLL.GetStatesForCMSRegion(profile.RegionId); if (CMSStateFIPS != null) { StateFIPSForCMSRegions.AddRange(CMSStateFIPS); } } if (StateFIPSForCMSRegions.Count > 0) { StatesForUser = ( from stFIPS in StatesData from cmsStFIPS in StateFIPSForCMSRegions where stFIPS.Key == cmsStFIPS select stFIPS ); } } else { StatesForUser = (from states in StatesData where (states.Key != State.GetStateFIPSForCMS()) select states); } //if (StatesForUser != null) //{ // StatesForUser = StatesForUser.Union(AllStatesOption); //} ddlStates.DataSource = StatesForUser; } }
/// <summary> /// Binds the dependent data for the form. /// </summary> protected void BindDependentData() { //if user is Cms Regional user populate only his states if (AccountInfo.Scope == Scope.CMSRegional) { string StateFIPSForCMS = State.GetStateFIPSForCMS(); IEnumerable <KeyValuePair <string, string> > StatesData = State.GetStatesWithFIPSKey().Where(p => p.Key != StateFIPSForCMS); IEnumerable <KeyValuePair <string, string> > StatesForUser = null; List <string> StateFIPSForCMSRegions = new List <string>(); IEnumerable <UserRegionalAccessProfile> profiles = UserCMSBLL.GetUserCMSRegionalProfiles(AccountInfo.UserId, false); foreach (UserRegionalAccessProfile profile in profiles) { IEnumerable <string> CMSStateFIPS = LookupBLL.GetStatesForCMSRegion(profile.RegionId); if (CMSStateFIPS != null) { StateFIPSForCMSRegions.AddRange(CMSStateFIPS); } } if (StateFIPSForCMSRegions.Count > 0) { StatesForUser = ( from stFIPS in StatesData from cmsStFIPS in StateFIPSForCMSRegions where stFIPS.Key == cmsStFIPS select stFIPS ); } dropDownListState.DataSource = StatesForUser; } else { dropDownListState.DataSource = Logic.GetStates(); } dropDownListState.DataBind(); aAddAgency.DataBind(); aAddSubStateRegion.DataBind(); }
/// <summary> /// Called when page is initialized for the first time. /// </summary> protected void OnViewInitialized() { btnNew.Visible = false; AgencyBLL StatesInfo = new AgencyBLL(); IEnumerable <KeyValuePair <string, string> > StatesData = StatesInfo.GetStates(); //if user is Cms Regional user populate only his states if (AccountInfo.Scope == Scope.CMSRegional) { IEnumerable <KeyValuePair <string, string> > StatesForUser = null; List <string> StateFIPSForCMSRegions = new List <string>(); IEnumerable <UserRegionalAccessProfile> profiles = UserCMSBLL.GetUserCMSRegionalProfiles(AccountInfo.UserId, false); foreach (UserRegionalAccessProfile profile in profiles) { IEnumerable <string> CMSStateFIPS = LookupBLL.GetStatesForCMSRegion(profile.RegionId); if (CMSStateFIPS != null) { StateFIPSForCMSRegions.AddRange(CMSStateFIPS); } } if (StateFIPSForCMSRegions.Count > 0) { StatesForUser = ( from stFIPS in StatesData from cmsStFIPS in StateFIPSForCMSRegions where stFIPS.Key == State.GetState(cmsStFIPS).Key select stFIPS ); } //ddlStates.DataSource = StatesForUser; foreach (System.Collections.Generic.KeyValuePair <string, string> StateValueFound in StatesForUser) { ddlStates.Items.Add(new ListItem(StateValueFound.Value, StateValueFound.Key)); } } else { // ddlStates.DataSource = StatesData; foreach (System.Collections.Generic.KeyValuePair <string, string> StateValueFound in StatesData) { ddlStates.Items.Add(new ListItem(StateValueFound.Value, StateValueFound.Key)); } } ddlStates.Items.Insert(0, "--Select A State--"); ddlStates.Items[0].Selected = true; InitializeDropDownList(); IsAdmin = AccountInfo.IsAdmin; Scope = (Scope)AccountInfo.ScopeId; if (AccountInfo.Scope == Scope.State) { //LookupBLL.GetStateFipsCodeByShortName( //April 15, TODO - Have states loaded from db so statename and id can be bound to dropdownlist - This may help if text changes. KeyValuePair <string, string> StateValue = State.GetState(AccountInfo.StateFIPS); lblDefaultState.Text = " <strong>:</strong> " + StateValue.Value; lblDefaultState.Visible = true; ListItem FoundState = ddlStates.Items.FindByText(StateValue.Value); ddlStates.Items[0].Selected = false; FoundState.Selected = true; ddlStates.Enabled = false; ddlStates.Visible = false; StateContentCell.Align = "Left"; if (AccountInfo.IsAdmin) { btnNew.Visible = true; } return; } if (AccountInfo.IsAdmin) { ddlStates.Visible = true; btnNew.Visible = true; return; } }
/// <summary> /// Binds the dependent data for the form. /// </summary> protected void BindDependentData() { #region drop down population logic. //switch (Scope) //{ // case Scope.CMS: // { // Counselors = Logic.GetClientContactCounselors(); // Submitters = Logic.GetClientContactSubmitters(); // break; // } // case Scope.State: // { // Counselors = Logic.GetClientContactCounselors(DefaultState); // Submitters = Logic.GetClientContactSubmitters(DefaultState); // break; // } // default : // { // //Determine if the current user is a super data editor. // if (AgencyLogic.IsSuperDataEditor(UserId)) // { // Counselors = Logic.GetCounselorsForSuperDataEditor(UserId); // Submitters = Logic.GetSubmittersForSuperDataEditor(UserId); // } // else // { // //Set the Descriptors needed to determine form population and options. // var isCounselor = IsDescriptor(Descriptor.Counselor); // var isSubmitter = IsDescriptor(Descriptor.DataSubmitter); // var isReviewer = IsDescriptor(Descriptor.DataEditor_Reviewer); // if (isCounselor && isSubmitter) // { // IsCounselorOnly = false; // IsSubmitterOnly = false; // //Get the Counselors for where the current user is a DataSubmitter. // Counselors = Logic.GetCounselors(Scope, (from id in GetAgencies(Descriptor.DataSubmitter) select id).ToList()); // //Check if the current user is in the counselors list; otherwise add them manually. // if ( // (from counselor in Counselors where counselor.Key == UserId select counselor.Key).Count() == 0) // { // var profile = UserBLL.GetUserProfile(UserId); // Counselors = new List<KeyValuePair<int, string>> // { // (new KeyValuePair<int, string>(UserId, // string.Format("{0} {1}", profile.FirstName, profile.LastName))) // }; // } // //Get the Submitters for where the current user is a Counselor. // Submitters = Logic.GetSubmitters(Scope, (from id in GetAgencies(Descriptor.Counselor) select id).ToList()); // //Check if the current user is in the submitter list; otherwise add them manually. // if ((from submitter in Submitters where submitter.Key == UserId select submitter.Key).Count() == 0) // { // var profile = UserBLL.GetUserProfile(UserId); // Submitters = new List<KeyValuePair<int, string>> // { // (new KeyValuePair<int, string>(UserId, // string.Format("{0} {1}", profile.FirstName, profile.LastName))) // }; // } // } // else if (isCounselor) // { // //check if the current user is a reviewer too. // if (isReviewer) // { // //Get submitters from agencies in which the current user is a counselor. // //No Counselors are to be retrieved. // Counselors = null; // //Get the submitters for whom the current user is a counselor. // Submitters = Logic.GetSubmitters(Scope, (from id in GetAgencies(Descriptor.Counselor) select id).ToList()); // } // else // { // IsCounselorOnly = true; // //Get the Counselors for where the current user is a DataSubmitter. // Counselors = Logic.GetCounselors(Scope, (from id in GetAgencies(Descriptor.DataSubmitter) select id).ToList()); // //Check if the current user is in the counselors list; otherwise add them manually. // if ( // (from counselor in Counselors where counselor.Key == UserId select counselor.Key).Count() == 0) // { // var profile = UserBLL.GetUserProfile(UserId); // Counselors = new List<KeyValuePair<int, string>> // { // (new KeyValuePair<int, string>(UserId, // string.Format("{0} {1}", profile.FirstName, profile.LastName))) // }; // } // //Get the Submitters for the current user's agencies. // Submitters = Logic.GetSubmitters(Scope, (from id in ActiveAgencyDescriptors.Keys select id).ToList()); // } // } // else if (isSubmitter) // { // //check if the current user is a reviewer too. // if (isReviewer) // { // //Get the counselors for whom the curent user is a submitter // Counselors = Logic.GetCounselors(Scope, (from id in GetAgencies(Descriptor.DataSubmitter) select id).ToList()); // //Get the submitters for whom the current user is a supervisor. // Submitters = Logic.GetReviewerSubmitters(Scope, (from id in GetAgencies(Descriptor.DataEditor_Reviewer) select id).ToList(), UserId); // } // else // { // IsSubmitterOnly = true; // //Get the Counselors for the current user's agencies. // Counselors = Logic.GetCounselors(Scope, (from id in ActiveAgencyDescriptors.Keys select id).ToList()); // //Get the Submitters for where the current user is a Counselor. // Submitters = Logic.GetSubmitters(Scope, (from id in GetAgencies(Descriptor.Counselor) select id).ToList()); // //Check if the current user is in the submitter list; otherwise add them manually. // if ( // (from submitter in Submitters where submitter.Key == UserId select submitter.Key).Count() == 0) // { // var profile = UserBLL.GetUserProfile(UserId); // Submitters = new List<KeyValuePair<int, string>> // { // (new KeyValuePair<int, string>(UserId, string.Format("{0} {1}", profile.FirstName, profile.LastName))) // }; // } // } // } // else if (isReviewer) //not a counselor or submitter. // { // IsReviewerOnly = true; // //No Counselors are to be retrieved. // Counselors = null; // //Get the submitters for whom the current user is a supervisor. // Submitters = Logic.GetReviewerSubmitters(Scope, (from id in GetAgencies(Descriptor.DataEditor_Reviewer) select id).ToList(), UserId); // } // } // break; // } //} #endregion //PopulateCounselorDropDown(); //PopulateSubmitterDropDown(); //if user is Cms Regional user populate only his states if (AccountInfo.Scope == Scope.CMSRegional) { IEnumerable <KeyValuePair <string, string> > StatesData = AgencyLogic.GetStates(); IEnumerable <KeyValuePair <string, string> > StatesForUser = null; List <string> StateFIPSForCMSRegions = new List <string>(); IEnumerable <UserRegionalAccessProfile> profiles = UserCMSBLL.GetUserCMSRegionalProfiles(AccountInfo.UserId, false); foreach (UserRegionalAccessProfile profile in profiles) { IEnumerable <string> CMSStateFIPS = LookupBLL.GetStatesForCMSRegion(profile.RegionId); if (CMSStateFIPS != null) { StateFIPSForCMSRegions.AddRange(CMSStateFIPS); } } if (StateFIPSForCMSRegions.Count > 0) { StatesForUser = ( from stFIPS in StatesData from cmsStFIPS in StateFIPSForCMSRegions where stFIPS.Key == State.GetState(cmsStFIPS).Key select stFIPS ); } States = StatesForUser; } else { States = AgencyLogic.GetStates(); } aAddCCF.DataBind(); //check the correct authorization if (AccountInfo.IsStateAdmin || (AccountInfo.IsCMSScope && AccountInfo.IsAdmin) || AccountInfo.IsShipDirector) { aAddSpecialField.Visible = true; aAddSpecialField.DataBind(); } //9/11/2013- commented the below line- Bimal noticed that the NPR code is searching for all a user’s recent records the moment that the CC tab is clicked. //Since many users may not actually need a prior client search (i.e. they may click the “Add a new client never seen here before “link), Bimal will move the search from a default to a specific request if the user makes any of the three search selections (by agency counselor submitter). //It appears that the database has reached a size that even with indexing the default background search is consuming too many system resources and risks not only the spinning and slow load but also a timeout and error page as well. panelSearchCriteria.DataBind(); if (Scope.IsLowerOrEqualTo(Scope.State)) { BindStateDependentData(new State(dropDownListState.SelectedValue)); } }