protected void Page_Load(object sender, EventArgs e) { try { if (Session[SessionEnum.AccessToken.ToString()] != null) { _inBloomApi = new inBloomApi(Session[SessionEnum.AccessToken.ToString()].ToString()); _sqlHelper = new SqlHelper(); _user = (User)Session["UserDetail"]; //Label lbl = (Label)Master.FindControl("lblUser"); lblUser.Text = _user.FullName; _user = _inBloomApi.UserDetails(); if (_user == null) Response.Redirect("Search.aspx"); else if (Session["UserDetail"] == null) { Session.Add("UserDetail", _user); } if (!IsPostBack) { DropDownListSection.Items.Clear(); GetFlag(); if (Session["FlagId"] == null && Session["FlagType"] == null) { } else { String SelectFlag = Session["FlagId"].ToString() + "_" + Session["FlagType"].ToString(); DropDownListSection.SelectedValue = SelectFlag; } } if (Session["Success"] != null) { //lblSuccess.Text = Session["Success"].ToString(); hdnFieldMessage.Value = Session["Success"].ToString(); Session["Success"] = null; } else { hdnFieldMessage.Value = ""; } if (!IsPostBack) { if (_user.IsAdminUser || IsLeader()) { GetDistrictList(); } else { DropDownListDistrict.Visible = false; LabelDistrict.Visible = false; } //|| IsLeader() need to add if (IsEducator()) { dropDownListStaff.Visible = false; LabelStaff.Visible = false; } if (Session["School"] == null) { GetSchoolList(); } else { try { DropDownListSchool.Items.Clear(); School school = (School)Session["School"]; DropDownListSchool.Items.AddRange(school.GetSchoolList()); DropDownListSchool.SelectedValue = Session[SessionEnum.SchoolId.ToString()].ToString(); } catch (Exception Ex) { } } if (Session["Staff"] == null) { if (!IsEducator()) GetStaffList(); } else if (!IsEducator()) { dropDownListStaff.Items.Clear(); Staff staff = (Staff)Session["Staff"]; dropDownListStaff.Items.AddRange(staff.GetStaffList()); dropDownListStaff.SelectedValue = Session[SessionEnum.StaffID.ToString()].ToString(); } if (Session["Course"] == null) { GetCourseListNew(); //GetCourseList(); } else { try { Course course = (Course)Session["Course"]; ListItem[] _courseList = course.GetCourseList(); //DropDownListCourse.Items.AddRange(course.GetCourseList()); for (int i = 0; i < _courseList.Count(); i++) { if (_courseList[i] != null) DropDownListCourse.Items.Add(_courseList[i]); } DropDownListCourse.SelectedValue = Session[SessionEnum.CourseId.ToString()].ToString(); } catch (Exception Ex) { } } if (Session["Section"] == null) { GetSectionListNew(); //GetSectionList(); } else { try { Section section = (Section)Session["Section"]; ListItem[] _listSection = section.GetSectionList(); if (_listSection != null) { for (int Index = 0; Index < _listSection.Length; Index++) { if (_listSection[Index] != null) { DropDownListSection.Items.Add(new ListItem(_listSection[Index].Text, _listSection[Index].Value.ToString())); } } } DropDownListSection.SelectedValue = Session[SessionEnum.SectionId.ToString()].ToString(); } catch (Exception Ex) { } } try { Session.Add(SessionEnum.SchoolId.ToString(), DropDownListSchool.SelectedValue); Session.Add(SessionEnum.CourseId.ToString(), DropDownListCourse.SelectedValue); Session.Add(SessionEnum.SectionId.ToString(), DropDownListSection.SelectedValue); Session.Add(SessionEnum.StaffID.ToString(), dropDownListStaff.SelectedValue); } catch (Exception Ex) { } } } else { Response.Redirect("Search.aspx"); } } catch (Exception ex) { throw; //Response.Redirect("Search.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { _sqlHelper = new SqlHelper(); try { if (!IsPostBack) { if (Session[SessionEnum.AccessToken.ToString()] == null) { if (Request.QueryString[QueryStringTokenEnum.Code.ToString()] == null) { _authenticateUser.AuthorizeUser(); } else { Session.Add(SessionEnum.AccessToken.ToString(), _authenticateUser.GetAccessToken()); } } _slcApi = new inBloomApi(Session[SessionEnum.AccessToken.ToString()].ToString()); Session["ResultPage"] = null; _user = _slcApi.UserDetails(); if (_user == null) { Session[SessionEnum.AccessToken.ToString()] = null; Response.Redirect("Search.aspx"); } else if (Session["UserDetail"] == null) { Session.Add("UserDetail", _user); } _homeLinks = _slcApi.GetHomeLinks(); if (_homeLinks != null) { Session.Add("HomeLinks", _homeLinks); } _homeLinks = (JArray) Session["HomeLinks"]; String EducationOrganizationId = _slcApi.GetEducationOrganizationId(_homeLinks); if (EducationOrganizationId != null || EducationOrganizationId != "") { // not state level admin Session.Add("EducationOrganizationId", EducationOrganizationId); //_slcApi.GetFlagListForAdminUser(EducationOrganizationId, _user.ExternalId); } LoadFlagGrid(); } } catch (Exception Ex) { //if (Ex.ToString().Contains("The remote server returned an error: (403) Forbidden.")) //{ // Session.Add("ErrorStack", Ex.ToString()); // Session[SessionEnum.AccessToken.ToString()] = null; // Response.Redirect("ErrorPage.aspx"); //} //Response.Redirect("Search.aspx"); } }