protected virtual void Page_PreInit(object sender, EventArgs e) { bool haveReportId = false; foreach (string key in Request.Params.Keys) { if ("Id".Equals(key)) { haveReportId = true; } } if (haveReportId) { SoftwareSystemComponentState state = SoftwareSystemComponentStateFacade.FindOrCreate(Context.User.Identity.Name, Token()); AccessController.Instance().VerifyPermissions(state, Token()); Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey] = state; } else { Response.Redirect("~/Default.aspx", true); } }
protected void DealershipReportSelect_SelectedIndexChanged(object sender, EventArgs e) { if (!DealershipReportSelect.SelectedValue.Equals("0")) { SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; state.Save(); } }
protected void DefinitionListControl_ItemDataBound(object source, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { HyperLink link = (HyperLink)e.Item.FindControl("TitleInLink"); Label text = (Label)e.Item.FindControl("TitleNoLink"); Label desc = (Label)e.Item.FindControl("Description"); Image soon = (Image)e.Item.FindControl("ComingSoon"); Image newReport = (Image)e.Item.FindControl("NewReport"); if (link != null && text != null && soon != null) { IReportHandle handle = (IReportHandle)e.Item.DataItem; desc.Text = HttpUtility.HtmlEncode(handle.Description); if (handle.ComingSoon) { text.Text = HttpUtility.HtmlEncode(handle.Title); link.Visible = false; newReport.Visible = false; } else { SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; string token = state.SoftwareSystemComponent.GetValue().Token; string path; if (token.Equals(SoftwareSystemComponentStateFacade.DealerGroupComponentToken)) { if (handle.Report != null && handle.Report.Id.Equals("E8E56305-3117-48CF-AB00-CD117F15AE9E")) { path = "~/DealerGroupNewReport.aspx"; } else if (handle.Report != null && handle.Report.Name.Contains("Water")) { path = "~/DealerWaterGroupReport.aspx"; } else { path = "~/DealerGroupReport.aspx"; } } else { path = "~/DealerReport.aspx"; } link.Text = HttpUtility.HtmlEncode(handle.Title); link.NavigateUrl = path + "?Id=" + handle.Report.Id; text.Visible = false; soon.Visible = false; newReport.Visible = handle.Report.IsNew; } } } }
// // Page Initialize // protected void Page_Init(object sender, EventArgs e) { if (SoftwareSystemComponentState == null) { SoftwareSystemComponentState state = SoftwareSystemComponentStateFacade.FindOrCreate( User.Identity.Name, Token); AccessController.Instance().VerifyPermissions(state, Token); SoftwareSystemComponentState = state; } }
private string GetAccessibleDealersId() { string value = string.Empty; ICollection <BusinessUnit> accessibleDealers = SoftwareSystemComponentState.DealerGroupMember().AccessibleDealers(SoftwareSystemComponentState.DealerGroup.GetValue()); if (accessibleDealers != null) { value = string.Join(",", accessibleDealers.Select(x => x.Id)); } return(value); }
protected void Page_Load(object sender, EventArgs e) { SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; ReportGroupingFactory reportGroupingFactory = WebReportDefinitionFactory.NewReportGroupingFactory(); //IReportListHelper.PopulateReportList(InventoryOverview, reportGroupingFactory.BuildReportTree("AC3E9462-354C-425c-B667-DF1509FB206D", dealerGroupId)); //IReportListHelper.PopulateReportList(RepricingReports, reportGroupingFactory.BuildReportTree("F5B3F2BB-9D1D-4bf6-8BDB-D11793CD31A9", dealerGroupId)); //IReportListHelper.PopulateReportList(SalesReports, reportGroupingFactory.BuildReportTree("C73658DC-40E1-41d3-8D91-1841C44CE5C0", dealerGroupId)); //IReportListHelper.PopulateReportList(RedistributionReports, reportGroupingFactory.BuildReportTree("B763E0AC-9FBF-4211-9118-D190A672E473", dealerGroupId)); //// IReportListHelper.PopulateReportList(SourcingAndSelling, reportGroupingFactory.BuildReportTree("EAFF746F-00C6-4fd2-B9DC-B419F232B343", dealerGroupId)); //IReportListHelper.PopulateReportList(AppraisalsOverview, reportGroupingFactory.BuildReportTree("D4877301-62E6-455f-B319-F17936582FDF", dealerGroupId)); }
public override bool IsAccessibleToUser(HttpContext context) { bool accessible = base.IsAccessibleToUser(context); if (accessible) { SoftwareSystemComponentState state = (SoftwareSystemComponentState)context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; //Member member; //BusinessUnit dealer; //if (state != null) //{ // dealer = state.Dealer.GetValue(); // member = state.DealerGroupMember(); //} //else //{ // dealer = (BusinessUnit)context.Items[BusinessUnit.HttpContextKey]; // member = (Member)context.Items[MemberFacade.HttpContextKey]; //} //if (needsStores) //{ // dealer = (BusinessUnit)context.Items[BusinessUnit.HttpContextKey]; // IPrincipal user = context.User; // accessible &= ( // user.IsInRole("Administrator") || // user.IsInRole("AccountRepresentative") || // (member != null && member.AccessibleDealers(dealer.DealerGroup()).Count > 1) // ); //} //if (needsNormalUser) //{ // accessible &= (member != null && !member.HasRestrictedAccess()); //} //if (needsUpgrade.HasValue) //{ // accessible &= (dealer != null && dealer.HasDealerUpgrade((Upgrade)needsUpgrade.Value)); //} } return(accessible); }
public void VerifyPermissions(SoftwareSystemComponentState state, string resource) { bool reject = true; if (state != null && resource != null) { if (state.SoftwareSystemComponent.GetValue().Token.Equals(resource)) { reject = false; } } if (reject) { throw new PrivilegeNotHeldException(resource); } }
protected override object Evaluate(HttpContext context, Control control) { SoftwareSystemComponentState state = (SoftwareSystemComponentState)context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; //Member member = null; if (allowImpersonation) { //member = state.DealerGroupMember(); } else { // member = state.AuthorizedMember.GetValue(); } return(null); }
protected string GetDealerId(SoftwareSystemComponentState state, string param = "") { string value = String.Empty; Control c = ControllerUtils.FindControlRecursive(Page, param); if (c == null) { //value = Convert.ToString(state.Dealer.GetValue().Id); } else { if (Convert.ToString((c as DropDownList).SelectedValue as object) != "") { value = (c as DropDownList).SelectedValue; } else { //value = Convert.ToString(state.Dealer.GetValue().Id); } } return(value); }
public void OnPostAcquireRequestState(object sender, EventArgs args) { HttpRequest request = HttpContext.Current.Request; string configuration = WebConfigurationManager.AppSettings[Key]; int i = request.Path.IndexOf('/', 1) + 1; string path = request.Path.Substring(i, request.Path.Length - i); if (!string.IsNullOrEmpty(path)) { if (path.StartsWith("ErrorPage.aspx")) { return; } } else { path = "Default.aspx"; } try { string token = WebResourceRegistryCache.CacheCopy(configuration).SoftwareSystemComponent(path); SoftwareSystemComponentState state = SoftwareSystemComponentStateFacade.FindOrCreate(HttpContext.Current.User.Identity.Name, token); AccessController.Instance().VerifyPermissions(state, token); HttpContext.Current.Items.Add(SoftwareSystemComponentStateFacade.HttpContextKey, state); } catch (IndexOutOfRangeException) { // ignore the code } }
// // // protected string GetParameterValue(string parameter) { string value = null; // try the web-controls first if (IsInitComplete) { Control c = ControllerUtils.FindControlRecursive(Page, parameter); if (c != null) { if (c is TextBox) { value = ((TextBox)c).Text; } else if (c is DropDownList) { value = ((DropDownList)c).SelectedValue; } else if (c is CheckBox) { // concert bool check box to 0 or 1 for sql value = ("True".Equals(((CheckBox)c).Checked.ToString())) ? "1" : "0"; } } } // then the request parameters if (value == null) { foreach (string key in Request.QueryString.AllKeys) { if (key.Equals(parameter)) { value = Request.QueryString[key]; break; } } } // special check for encoded dealerId bool isDealerIdParam = (parameter.Equals("DealerIDs") || parameter.Equals("DealershipID") || parameter.Equals("DealerID") || parameter.Equals("UserSelectedDealerID")); if (isDealerIdParam && value == null) { value = Request.QueryString["ContextCode"]; } SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; // then the report center session if (value == null) { if (isDealerIdParam) { if (state.Dealer.GetValue() != null) { value = state.Dealer.GetValue().Id.ToString(); } } else if (parameter.Equals("DealerGroupID")) { if (state.DealerGroup.GetValue() != null) { value = state.DealerGroup.GetValue().Id.ToString(); } } else if (parameter.Equals("MemberId") || parameter.Equals("MemberID")) { value = state.DealerGroupMember().Id.ToString(); } else if (parameter.Equals("SelectedDealerId") || parameter.Equals("SelectedDealerID")) { value = GetSelectedDealersId(); } else if (parameter.Equals("AccessibleDealerId") || parameter.Equals("AccessibleDealerID")) { value = GetAccessibleDealersId(); } } return(value); }
protected void DealershipReportSelect_DataBound(object sender, EventArgs e) { SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; }
protected override object Evaluate(HttpContext context, Control control) { SoftwareSystemComponentState state = (SoftwareSystemComponentState)context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; return(null); //state.Dealer.GetValue(); }
protected void DefinitionListControl_ItemDataBound(object source, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { HyperLink link = (HyperLink)e.Item.FindControl("TitleInLink"); Label text = (Label)e.Item.FindControl("TitleNoLink"); Image soon = (Image)e.Item.FindControl("ComingSoon"); Image newReport = (Image)e.Item.FindControl("NewReport"); if (link != null && text != null && soon != null) { IReportHandle handle = (IReportHandle)e.Item.DataItem; if (handle.ComingSoon) { text.Text = HttpUtility.HtmlEncode(handle.Title); link.Visible = false; newReport.Visible = false; } else { SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; string token = state.SoftwareSystemComponent.GetValue().Token; string path; if (token.Equals(SoftwareSystemComponentStateFacade.DealerGroupComponentToken)) { if (handle.Title.ToUpper().Contains("WATER")) { path = "~/DealerWaterGroupReport.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr&cp=cc"; } else if (handle.Report.Id.Equals("C4DE8552-68E4-451E-9F22-F6CEE9359D89") || handle.Report.Id.Equals("B3D7BCDC-8BC9-4929-BFC5-0F6C0B1AD97E")) { path = "~/DealerGroupNewReport.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr"; } else if (handle.Report.Id.Equals("E44A8300-742C-4CB9-A8CB-3A87CAAA1DF6") || handle.Report.Id.Equals("D57CF3D5-A075-4032-938C-8A6A2AA5B32B")) { string qTradeOrPurchase = "&TradeOrPurchase="; qTradeOrPurchase += handle.Report.Id.Equals("E44A8300-742C-4CB9-A8CB-3A87CAAA1DF6") ? "1" : "2"; path = "~/DealerGroupNewReport.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr" + qTradeOrPurchase; } else if (handle.Report.Id.Equals("C82458C3-A914-4F38-8741-8AB2CCF7D5AD"))//New RetailInventorySalesAnalysis { string tradeOrPurchase = "&TradeOrPurchase="; tradeOrPurchase += "A"; path = "~/DealerGroupNewReport.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr&cp=cc" + tradeOrPurchase; } else if (handle.Report.Id.Equals("F6B512EC-D492-47D3-BB7F-5A437D531816") || handle.Report.Id.Equals("BE4CD8E3-37C4-4E06-876E-0E6F9746D7A5") || handle.Report.Id.Equals("A4CBC38A-81C0-47D0-BC48-15A7D6F2B701")) { path = "~/DealerGroupNewReport.aspx?SelectedDealerId=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr"; } else { path = "~/DealerGroupReport.aspx"; } } else { if (handle.Report.Id.Equals("C4DE8552-68E4-451E-9F22-F6CEE9359D89") || handle.Report.Id.Equals("B3D7BCDC-8BC9-4929-BFC5-0F6C0B1AD97E")) { path = "~/DealerLevelGroupPage.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr"; } else if (handle.Report.Id.Equals("F6B512EC-D492-47D3-BB7F-5A437D531816") || handle.Report.Id.Equals("BE4CD8E3-37C4-4E06-876E-0E6F9746D7A5") || handle.Report.Id.Equals("A4CBC38A-81C0-47D0-BC48-15A7D6F2B701")) { path = "~/DealerLevelGroupPage.aspx?SelectedDealerId=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr"; } else if (handle.Report.Id.Equals("E44A8300-742C-4CB9-A8CB-3A87CAAA1DF6") || handle.Report.Id.Equals("D57CF3D5-A075-4032-938C-8A6A2AA5B32B")) { string qTradeOrPurchase = "&TradeOrPurchase="; qTradeOrPurchase += handle.Report.Id.Equals("E44A8300-742C-4CB9-A8CB-3A87CAAA1DF6") ? "1" : "2"; path = "~/DealerLevelGroupPage.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr" + qTradeOrPurchase; } else if (handle.Report.Id.Equals("C82458C3-A914-4F38-8741-8AB2CCF7D5AD"))//New RetailInventorySalesAnalysis { string tradeOrPurchase = "&TradeOrPurchase="; tradeOrPurchase += "A"; path = "~/DealerLevelGroupPage.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr&cp=dr" + tradeOrPurchase; } else { path = handle.Title.ToUpper().Contains("WATER") ? "~/DealerWaterGroupReport.aspx?drillthrough=" + GetDealerId(state, "DealershipReportSelect") + "&type=pmr&cp=dr" : "~/DealerReport.aspx"; } } link.Text = HttpUtility.HtmlEncode(handle.Title); link.NavigateUrl = path + (path.Contains("?") ? "&Id=" : "?Id=") + handle.Report.Id; text.Visible = false; soon.Visible = false; newReport.Visible = handle.Report.IsNew; } } } }
protected string GetParameterValue(string parameter) { string value = null; // try the web-controls first if (IsInitComplete) { Control c = ControllerUtils.FindControlRecursive(Page, parameter); if (c != null) { if (c is TextBox) { value = ((TextBox)c).Text; } else if (c is DropDownList) { value = ((DropDownList)c).SelectedValue; } else if (c is CheckBox) { // concert bool check box to 0 or 1 for sql value = ("True".Equals(((CheckBox)c).Checked.ToString())) ? "1" : "0"; } else if (c is HiddenField) { value = ((HiddenField)(c)).Value; } } } // then the request parameters if (value == null) { foreach (string key in Request.QueryString.AllKeys) { if (key.Equals(parameter)) { value = Request.QueryString[key]; break; } } } //To check for the pingUrl if (parameter.ToLower().Equals("pingurlprefix")) { Uri uri = new Uri(Request.Url.ToString()); string url = string.Format("{0}://{1}", uri.Scheme, uri.Authority); url = url + "/IMT/EStock.go?isPopup=true&"; return(url); } // special check for encoded dealerId bool isDealerIdParam = (parameter.Equals("DealerIDs") || parameter.Equals("DealershipID") || parameter.Equals("DealerID") || parameter.Equals("UserSelectedDealerID")); if (isDealerIdParam && value == null) { value = Request.QueryString["ContextCode"]; } // ReSharper disable once UnusedVariable SoftwareSystemComponentState state = (SoftwareSystemComponentState)Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]; // then the report center session if (value == null) { if (isDealerIdParam) { //if (state.Dealer.GetValue() != null) //{ // value = state.Dealer.GetValue().Id.ToString(); //} } else if (parameter.Equals("DealerGroupID")) { //if (state.DealerGroup.GetValue() != null) //{ // value = state.DealerGroup.GetValue().Id.ToString(); //} } else if (parameter.Equals("MemberId") || parameter.Equals("MemberID")) { //value = state.DealerGroupMember().Id.ToString(); } else if (parameter.Equals("AccessibleDealerId") || parameter.Equals("AccessibleDealerID")) { value = GetAccessibleDealersId(); } } return(value); }