/// Get the Hummingbird user permissions
        /// </summary>
        /// <param name="userId"></param>
        public HBUserPermissionObject GetUserPermissions(int userId)
        {
            var parameters = new Hashtable {
            { "data[user_id]", userId },
            { "data[module_name]", ConfigurationManager.AppSettings["HummingbirdModuleName"] },
            { "data[module_code]", ConfigurationManager.AppSettings["HummingbirdModuleCode"] },
            { "data[action]", ConfigurationManager.AppSettings["HummingbirdAction"] }
            };

            HBUserPermissionObject hbUserPermissionObject = new HBUserPermissionObject();

            string service = "GetHummingbirdUserPermission";
            LogUtil.CallingService(service, LogUtil.getHashtableString(parameters));

            try
            {
                var result = CallHummingbirdUserService("getUserPermissions", parameters);
                LogUtil.CallSuccess(service, result.ToString());
                hbUserPermissionObject = ProcessUserPermissionsResponse(result);
            }
            catch (Exception e)
            {
                LogUtil.CallFail(service, e);
                throw;
            }
            return hbUserPermissionObject;
        }
예제 #2
0
        private void SetUserSessionData(HBUserPermissionObject hbUserPermissionObject, HttpCookie phpCookie, string colorScheme)
        {
            HttpContext.Current.Session.Add("HTMLHead", hbUserPermissionObject.HtmlHead);
            HttpContext.Current.Session.Add("Header", hbUserPermissionObject.Header);
            HttpContext.Current.Session.Add("Footer", hbUserPermissionObject.Footer);
            HttpContext.Current.Session.Add("ColorScheme", colorScheme);

            string Permissions = String.Join(",", User.GetPermissions(hbUserPermissionObject.UserRightsList).ToArray());
            HttpContext.Current.Session.Add("Permissions", Permissions);

            if (phpCookie != null)
            {
                HttpContext.Current.Session.Add("PHPSESSID", phpCookie.Value);
            }
        }
        /// <summary>
        /// Get the HB user rights and html head and footer 
        /// </summary>
        /// <param name="result"></param>
        /// <returns>HBUserPermissionsObject</returns>
        private HBUserPermissionObject ProcessUserPermissionsResponse(XDocument result)
        {
            HBUserPermissionObject hbUserPermissionObject = new HBUserPermissionObject();

            try
            {

                hbUserPermissionObject = (from userPermissions in result.Descendants("Data")
                                           select new HBUserPermissionObject()
                                           {
                                               HtmlHead = XmlUtil.GetSafeStringNodeValue(userPermissions.Element("HtmlHead")),
                                               Header = XmlUtil.GetSafeStringNodeValue(userPermissions.Element("Header")),
                                               Footer = XmlUtil.GetSafeStringNodeValue(userPermissions.Element("Footer")),
                                               UserRightsList = (from permission in userPermissions.Descendants("Item")
                                                                select new HBUserRightsItemObject()
                                                                 {
                                                                     UserRightsItem = XmlUtil.GetSafeStringNodeValue(permission)
                                                                 }).ToList()

                                           }).FirstOrDefault();

                if (hbUserPermissionObject == null)
                    return new HBUserPermissionObject();

            }
            catch (Exception)
            {
                throw;
            }

            return hbUserPermissionObject;
        }