Exemplo n.º 1
0
        private void SetPortalCofig()
        {
            Hashtable hstPortals = GetPortals();
            SageUserControl suc = new SageUserControl();

            suc.PagePath = PagePath;
            int portalID = 1;
            //ptlid=-9&ptSEO=contruction&pgnm=faqs
            if (string.IsNullOrEmpty(Request.QueryString["ptSEO"]))
            {
                if (string.IsNullOrEmpty(PortalSEOName))
                {
                    PortalSEOName = "default";
                }
                else if (!hstPortals.ContainsKey(PortalSEOName.ToLower().Trim()))
                {
                    PortalSEOName = "default";
                }
                else
                {
                    portalID = int.Parse(hstPortals[PortalSEOName.ToLower().Trim()].ToString());
                }
            }
            else
            {
                PortalSEOName = Request.QueryString["ptSEO"].ToString().ToLower().Trim();
                portalID = Int32.Parse(Request.QueryString["ptlid"].ToString());
            }
            suc.SetPortalSEOName(PortalSEOName.ToLower().Trim());
            Session["SageFrame.PortalSEOName"] = PortalSEOName.ToLower().Trim();
            Session["SageFrame.PortalID"] = portalID;
            suc.SetPortalID(portalID);
            SetPortalID(portalID);

            int storeID = portalID;
            //TODO:: set StoreID According the URL HERE
            Session["SageFrame.StoreID"] = storeID;
            suc.SetStoreID(storeID);
            SetStoreID(storeID);

            if (HttpContext.Current.User != null)
            {
                SettingProvider objSP = new SettingProvider();
                int customerID = 0;
                if (Membership.GetUser() != null)
                {
                    string strRoles = string.Empty;
                    //RolesManagementDataContext dbRole = new RolesManagementDataContext(SystemSetting.SageFrameConnectionString);
                    //var userRoles = dbRole.sp_RoleGetByUsername(HttpContext.Current.User.Identity.Name, GetPortalID).ToList();
                    //foreach (var userRole in userRoles)
                    //{
                    //    strRoles += userRole.RoleId + ",";
                    //}
                    List<SageUserRole> sageUserRolles = objSP.RoleListGetByUsername(HttpContext.Current.User.Identity.Name, GetPortalID);
                    if (sageUserRolles != null)
                    {
                        foreach (SageUserRole userRole in sageUserRolles)
                        {
                            strRoles += userRole.RoleId + ",";
                        }
                    }
                    if (strRoles.Length > 1)
                    {
                        strRoles = strRoles.Substring(0, strRoles.Length - 1);
                    }
                    if (strRoles.Length > 0)
                    {
                        SetUserRoles(strRoles);
                    }

                    //TO Get Customer Details

                    CustomerGeneralInfo sageUserCust = objSP.CustomerIDGetByUsername(HttpContext.Current.User.Identity.Name, GetPortalID, GetStoreID);
                    if (sageUserCust != null)
                    {
                        customerID = sageUserCust.CustomerID;
                    }
                    Session["SageFrame.CustomerID"] = customerID;
                    suc.SetCustomerID(customerID);
                    SetCustomerID(customerID);
                }
                else
                {
                    //TO Get Customer Details
                    CustomerGeneralInfo sageUserCust = objSP.CustomerIDGetByUsername("anonymoususer", GetPortalID, GetStoreID);
                    if (sageUserCust != null)
                    {
                        customerID = sageUserCust.CustomerID;
                    }
                    Session["SageFrame.CustomerID"] = customerID;
                    suc.SetCustomerID(customerID);
                    SetCustomerID(customerID);
                }
            }
        }
 private void SetCustomerID()
 {
     SageUserControl suc = new SageUserControl();
     int customerID = 0;
     SecurityPolicy objSecurity = new SecurityPolicy();
     FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
     if (ticket != null)
     {
         CustomerGeneralInfo sageUserCust = CustomerGeneralInfoController.CustomerIDGetByUsername(ticket.Name,
                                                                                                  GetPortalID,
                                                                                                  GetStoreID);
         if (sageUserCust != null)
         {
             customerID = sageUserCust.CustomerID;
         }
         Session[SessionKeys.SageFrame_CustomerID] = customerID;
         suc.SetCustomerID(customerID);
         SetCustomerID(customerID);
     }
 }