/// <summary>
        ///Connect to database and add html content.
        /// </summary>
        /// <param name="MenuItems">Object of MenuManagerInfo.</param>
        public static void AddHtmlContent(MenuManagerInfo MenuItems)
        {
            string     sp      = "[dbo].[usp_MenuMgrAddHtmlContent]";
            SQLHandler sagesql = new SQLHandler();

            try
            {
                List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >();
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuID", MenuItems.MenuID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuItemID", MenuItems.MenuItemID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@LinkType", MenuItems.LinkType));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Title", MenuItems.Title));
                ParamCollInput.Add(new KeyValuePair <string, object>("@HtmlContent", MenuItems.HtmlContent));
                ParamCollInput.Add(new KeyValuePair <string, object>("@ImageIcon", MenuItems.ImageIcon));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Caption", MenuItems.Caption));
                ParamCollInput.Add(new KeyValuePair <string, object>("@ParentID", MenuItems.ParentID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuLevel", MenuItems.MenuLevel));
                ParamCollInput.Add(new KeyValuePair <string, object>("@IsVisible", MenuItems.IsVisible));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Mode", MenuItems.Mode));
                ParamCollInput.Add(new KeyValuePair <string, object>("@IsActive", MenuItems.IsActive));

                sagesql.ExecuteNonQuery(sp, ParamCollInput);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static void AddExternalLink(MenuManagerInfo MenuItems)
        {
            string sp = "usp_MenuMgrAddExternalLink";
            OracleHandler sagesql = new OracleHandler();
            try
            {
                List<KeyValuePair<string, object>> ParamCollInput = new List<KeyValuePair<string, object>>();
                ParamCollInput.Add(new KeyValuePair<string, object>("MenuID", MenuItems.MenuID));
                ParamCollInput.Add(new KeyValuePair<string, object>("MenuItemID", MenuItems.MenuItemID));
                ParamCollInput.Add(new KeyValuePair<string, object>("LinkType", MenuItems.LinkType));
                ParamCollInput.Add(new KeyValuePair<string, object>("Title", MenuItems.Title));
                ParamCollInput.Add(new KeyValuePair<string, object>("LinkURL", MenuItems.LinkURL));
                ParamCollInput.Add(new KeyValuePair<string, object>("ImageIcon", MenuItems.ImageIcon));
                ParamCollInput.Add(new KeyValuePair<string, object>("Caption", MenuItems.Caption));
                ParamCollInput.Add(new KeyValuePair<string, object>("ParentID", MenuItems.ParentID));
                ParamCollInput.Add(new KeyValuePair<string, object>("MenuLevel", MenuItems.MenuLevel));
                ParamCollInput.Add(new KeyValuePair<string, object>("IsVisible", MenuItems.IsVisible));
                ParamCollInput.Add(new KeyValuePair<string, object>("IsActive", MenuItems.IsActive));
                ParamCollInput.Add(new KeyValuePair<string, object>("MenuOrder", MenuItems.MenuOrder));
                ParamCollInput.Add(new KeyValuePair<string, object>("Mode", MenuItems.Mode));

                sagesql.ExecuteNonQuery(sp, ParamCollInput);
            }
            catch (Exception)
            {

                throw;
            }

        }
Пример #3
0
        /// <summary>
        /// Connect to database and add menu item.
        /// </summary>
        /// <param name="MenuItems">Object of MenuManagerInfo.</param>
        public static int AddMenuItem(MenuManagerInfo MenuItems)
        {
            int        menuItemID = 0;
            string     sp         = "[dbo].[usp_MenuMgrAddMenuItem]";
            SQLHandler sagesql    = new SQLHandler();

            try
            {
                List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >();
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuID", MenuItems.MenuID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuItemID", MenuItems.MenuItemID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@LinkType", MenuItems.LinkType));
                ParamCollInput.Add(new KeyValuePair <string, object>("@PageID", MenuItems.PageID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Title", MenuItems.Title));
                ParamCollInput.Add(new KeyValuePair <string, object>("@LinkURL", MenuItems.LinkURL));
                ParamCollInput.Add(new KeyValuePair <string, object>("@ImageIcon", MenuItems.ImageIcon));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Caption", MenuItems.Caption));
                ParamCollInput.Add(new KeyValuePair <string, object>("@HtmlContent", MenuItems.HtmlContent));
                ParamCollInput.Add(new KeyValuePair <string, object>("@ParentID", MenuItems.ParentID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuLevel", MenuItems.MenuLevel));
                ParamCollInput.Add(new KeyValuePair <string, object>("@MenuOrder", MenuItems.MenuOrder));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Mode", MenuItems.Mode));
                ParamCollInput.Add(new KeyValuePair <string, object>("@PreservePageOrder", MenuItems.PreservePageOrder));
                ParamCollInput.Add(new KeyValuePair <string, object>("@MainParent", MenuItems.MainParent));
                ParamCollInput.Add(new KeyValuePair <string, object>("@IsActive", MenuItems.IsActive));
                ParamCollInput.Add(new KeyValuePair <string, object>("@IsVisible", MenuItems.IsVisible));
                menuItemID = sagesql.ExecuteNonQuery(sp, ParamCollInput, "@newmenuItemID");
            }
            catch (Exception)
            {
                throw;
            }
            return(menuItemID);
        }
 /// <summary>
 /// Add html content.
 /// </summary>
 /// <param name="MenuItems">Object of MenuManagerInfo.</param>
 public static void AddHtmlContent(MenuManagerInfo MenuItems)
 {
     try
     {
         MenuManagerDataProvider.AddHtmlContent(MenuItems);
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// Add external link.
 /// </summary>
 /// <param name="MenuItems">Object of MenuManagerInfo.</param>
 public static void AddExternalLink(MenuManagerInfo MenuItems)
 {
     try
     {
         MenuManagerDataProvider.AddExternalLink(MenuItems);
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// Connect to database and obtain admin pages.
        /// </summary>
        /// <param name="PortalID">PortalID</param>
        /// <param name="UserName">User name.</param>
        /// <param name="CultureCode">Culture code.</param>
        /// <returns>List of MenuManagerInfo class.</returns>
        public static List <MenuManagerInfo> GetAdminPage(int PortalID, string UserName, string CultureCode)
        {
            List <MenuManagerInfo> lstPages = new List <MenuManagerInfo>();
            string StoredProcedureName      = "[dbo].[usp_SageMenuGetAdminView]";
            List <KeyValuePair <string, object> > ParaMeterCollection = new List <KeyValuePair <string, object> >();

            ParaMeterCollection.Add(new KeyValuePair <string, object>("@prefix", "---"));
            ParaMeterCollection.Add(new KeyValuePair <string, object>("@IsDeleted", 0));
            ParaMeterCollection.Add(new KeyValuePair <string, object>("@PortalID", PortalID));
            ParaMeterCollection.Add(new KeyValuePair <string, object>("@UserName", UserName));
            ParaMeterCollection.Add(new KeyValuePair <string, object>("@CultureCode", CultureCode));
            SqlDataReader SQLReader = null;

            try
            {
                SQLHandler sagesql = new SQLHandler();
                SQLReader = sagesql.ExecuteAsDataReader(StoredProcedureName, ParaMeterCollection);
                while (SQLReader.Read())
                {
                    MenuManagerInfo objMenu = new MenuManagerInfo();
                    objMenu.PageID        = int.Parse(SQLReader["PageID"].ToString());
                    objMenu.PageOrder     = int.Parse(SQLReader["PageOrder"].ToString());
                    objMenu.PageName      = SQLReader["PageName"].ToString();
                    objMenu.ParentID      = int.Parse(SQLReader["ParentID"].ToString());
                    objMenu.Level         = int.Parse(SQLReader["Level"].ToString());
                    objMenu.TabPath       = SQLReader["TabPath"].ToString();
                    objMenu.SEOName       = SQLReader["SEOName"].ToString();
                    objMenu.IsVisible     = bool.Parse(SQLReader["IsVisible"].ToString());
                    objMenu.ShowInMenu    = bool.Parse(SQLReader["ShowInMenu"].ToString());
                    objMenu.LevelPageName = SQLReader["LevelPageName"].ToString();

                    lstPages.Add(objMenu);
                }
                return(lstPages);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (SQLReader != null)
                {
                    SQLReader.Close();
                }
            }
        }
        /// <summary>
        /// Connect to database and obtain menu setting based on PortalID and MenuID.
        /// </summary>
        /// <param name="PortalID">PortalID</param>
        /// <param name="MenuID">MenuID</param>
        /// <returns>Object of MenuManagerInfo.</returns>
        public static MenuManagerInfo GetMenuSetting(int PortalID, int MenuID)
        {
            MenuManagerInfo objSetting          = new MenuManagerInfo();
            string          StoredProcedureName = "[dbo].[usp_MenuMgrGetSetting]";
            SQLHandler      sagesql             = new SQLHandler();
            List <KeyValuePair <string, object> > ParaMeterCollection = new List <KeyValuePair <string, object> >();

            ParaMeterCollection.Add(new KeyValuePair <string, object>("@PortalID", PortalID));
            ParaMeterCollection.Add(new KeyValuePair <string, object>("@MenuID", MenuID));
            try
            {
                objSetting = sagesql.ExecuteAsObject <MenuManagerInfo>(StoredProcedureName, ParaMeterCollection);
            }
            catch (Exception e)
            {
                throw e;
            }


            return(objSetting);
        }
        /// <summary>
        /// Connect to database and obtain menu setting based on PortalID and MenuID.
        /// </summary>
        /// <param name="PortalID">PortalID</param>
        /// <param name="MenuID">MenuID</param>
        /// <returns>Object of MenuManagerInfo.</returns>
        public static MenuManagerInfo GetMenuSetting(int PortalID, int MenuID)
        {
            MenuManagerInfo objSetting = new MenuManagerInfo();
            string StoredProcedureName = "[dbo].[usp_MenuMgrGetSetting]";
            SQLHandler sagesql = new SQLHandler();
            List<KeyValuePair<string, object>> ParaMeterCollection = new List<KeyValuePair<string, object>>();
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@PortalID", PortalID));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@MenuID", MenuID));
            try
            {
                objSetting = sagesql.ExecuteAsObject<MenuManagerInfo>(StoredProcedureName, ParaMeterCollection);

            }
            catch (Exception e)
            {
                throw e;
            }


            return objSetting;
        }
        /// <summary>
        ///Connect to database and add html content.
        /// </summary>
        /// <param name="MenuItems">Object of MenuManagerInfo.</param>
        public static void AddHtmlContent(MenuManagerInfo MenuItems)
        {
            string sp = "[dbo].[usp_MenuMgrAddHtmlContent]";
            SQLHandler sagesql = new SQLHandler();
            try
            {
                List<KeyValuePair<string, object>> ParamCollInput = new List<KeyValuePair<string, object>>();
                ParamCollInput.Add(new KeyValuePair<string, object>("@MenuID", MenuItems.MenuID));
                ParamCollInput.Add(new KeyValuePair<string, object>("@MenuItemID", MenuItems.MenuItemID));
                ParamCollInput.Add(new KeyValuePair<string, object>("@LinkType", MenuItems.LinkType));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Title", MenuItems.Title));
                ParamCollInput.Add(new KeyValuePair<string, object>("@HtmlContent", MenuItems.HtmlContent));
                ParamCollInput.Add(new KeyValuePair<string, object>("@ImageIcon", MenuItems.ImageIcon));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Caption", MenuItems.Caption));
                ParamCollInput.Add(new KeyValuePair<string, object>("@ParentID", MenuItems.ParentID));
                ParamCollInput.Add(new KeyValuePair<string, object>("@MenuLevel", MenuItems.MenuLevel));
                ParamCollInput.Add(new KeyValuePair<string, object>("@IsVisible", MenuItems.IsVisible));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Mode", MenuItems.Mode));
                ParamCollInput.Add(new KeyValuePair<string, object>("@IsActive", MenuItems.IsActive));

                sagesql.ExecuteNonQuery(sp, ParamCollInput);
            }
            catch (Exception)
            {

                throw;
            }

        }
        /// <summary>
        /// Connect to database and obtain admin pages.
        /// </summary>
        /// <param name="PortalID">PortalID</param>
        /// <param name="UserName">User name.</param>
        /// <param name="CultureCode">Culture code.</param>
        /// <returns>List of MenuManagerInfo class.</returns>
        public static List<MenuManagerInfo> GetAdminPage(int PortalID, string UserName, string CultureCode)
        {
            List<MenuManagerInfo> lstPages = new List<MenuManagerInfo>();
            string StoredProcedureName = "[dbo].[usp_SageMenuGetAdminView]";
            List<KeyValuePair<string, object>> ParaMeterCollection = new List<KeyValuePair<string, object>>();
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@prefix", "---"));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@IsDeleted", 0));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@PortalID", PortalID));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@UserName", UserName));
            ParaMeterCollection.Add(new KeyValuePair<string, object>("@CultureCode", CultureCode));
            SqlDataReader SQLReader = null;
            try
            {
                SQLHandler sagesql = new SQLHandler();
                SQLReader = sagesql.ExecuteAsDataReader(StoredProcedureName, ParaMeterCollection);
                while (SQLReader.Read())
                {
                    MenuManagerInfo objMenu = new MenuManagerInfo();
                    objMenu.PageID = int.Parse(SQLReader["PageID"].ToString());
                    objMenu.PageOrder = int.Parse(SQLReader["PageOrder"].ToString());
                    objMenu.PageName = SQLReader["PageName"].ToString();
                    objMenu.ParentID = int.Parse(SQLReader["ParentID"].ToString());
                    objMenu.Level = int.Parse(SQLReader["Level"].ToString());
                    objMenu.TabPath = SQLReader["TabPath"].ToString();
                    objMenu.SEOName = SQLReader["SEOName"].ToString();
                    objMenu.IsVisible = bool.Parse(SQLReader["IsVisible"].ToString());
                    objMenu.ShowInMenu = bool.Parse(SQLReader["ShowInMenu"].ToString());
                    objMenu.LevelPageName = SQLReader["LevelPageName"].ToString();

                    lstPages.Add(objMenu);
                }
                return lstPages;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (SQLReader != null)
                {
                    SQLReader.Close();
                }
            }
        }
        public static void AddHtmlContent(MenuManagerInfo MenuItems)
        {
            try
            {
                MenuManagerDataProvider.AddHtmlContent(MenuItems);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public static void AddExternalLink(MenuManagerInfo MenuItems)
        {
            try
            {
                MenuManagerDataProvider.AddExternalLink(MenuItems);
            }
            catch (Exception)
            {

                throw;
            }
        }
 /// <summary>
 /// Add menu item.
 /// </summary>
 /// <param name="MenuItems">Object of MenuManagerInfo.</param>
 public static int AddMenuItem(MenuManagerInfo MenuItems)
 {
     return(MenuManagerDataProvider.AddMenuItem(MenuItems));
 }
 private string BuildMenuItem(int displayMode, MenuManagerInfo objMenuInfo, string pageLink, string caption)
 {
     StringBuilder html = new StringBuilder();
     if (objMenuInfo.IsActive != null)
     {
         if (!objMenuInfo.IsActive)
         {
             pageLink = "#";
         }
     }
     string title = objMenuInfo.PageName;
     pageLink = pageLink.Replace("&", "-and-");
     if (objMenuInfo.LinkType != null)
     {
         title = objMenuInfo.LinkType == "0" ? objMenuInfo.PageName : objMenuInfo.Title;
     }
     string image = appPath + "/PageImages/" + objMenuInfo.ImageIcon;
     string imageTag = objMenuInfo.ImageIcon != string.Empty ? "<img src=" + image + ">" : "";
     string arrowStyle = objMenuInfo.ChildCount > 0 ? "<span class='sf-sub-indicator'> »</span>" : "";
     switch (displayMode)
     {
         case 0://image only
             if (caption == "1")
             {
                 html.Append("<a  href='");
                 html.Append(pageLink);
                 html.Append("'><span class='sfPageicon'>");
                 html.Append(imageTag);
                 html.Append("<em>");
                 html.Append(objMenuInfo.Caption);
                 html.Append("</em>");
                 html.Append("</span>");
                 html.Append(arrowStyle);
                 html.Append("</a>");
             }
             else
             {
                 html.Append("<a  href='");
                 html.Append(pageLink);
                 html.Append("'><span class='sfPageicon'>");
                 html.Append(imageTag);
                 html.Append("</span>");
                 html.Append(arrowStyle);
                 html.Append("</a>");
             }
             break;
         case 1://text only
             if (caption == "1")
             {
                 html.Append("<a  href='");
                 html.Append(pageLink);
                 html.Append("'><span class='sfPagename'>");
                 html.Append(title);
                 html.Append("<em>");
                 html.Append(objMenuInfo.Caption);
                 html.Append("</em>");
                 html.Append("</span>");
                 html.Append(arrowStyle);
                 html.Append("</a>");
             }
             else
             {
                 html.Append("<a  href='");
                 html.Append(pageLink);
                 html.Append("'><span class='sfPagename'>");
                 html.Append(title);
                 html.Append("</span>");
                 html.Append(arrowStyle);
                 html.Append("</a>");
             }
             break;
         case 2: //text and image both
             if (caption == "1")
             {
                 html.Append("<a  href='");
                 html.Append(pageLink);
                 html.Append("'><span class='sfPageicon'>");
                 html.Append(imageTag);
                 html.Append("</span><span class='sfPagename'>");
                 html.Append(title);
                 html.Append("<em>");
                 html.Append(objMenuInfo.Caption);
                 html.Append("</em>");
                 html.Append("</span>");
                 html.Append(arrowStyle);
                 html.Append("</a>");
             }
             else
             {
                 html.Append("<a  href='");
                 html.Append(pageLink);
                 html.Append("'><span class='sfPageicon'>");
                 html.Append(imageTag);
                 html.Append("</span><span class='sfPagename'>");
                 html.Append(title);
                 html.Append("</span>");
                 html.Append(arrowStyle);
                 html.Append("</a>");
             }
             break;
     }
     return html.ToString();
 }
 private void GetChildPages(ref List<MenuManagerInfo> lstHierarchy, MenuManagerInfo parent, List<MenuManagerInfo> lstPages)
 {
     foreach (MenuManagerInfo obj in lstPages)
     {
         if (obj.ParentID == parent.MenuItemID)
         {
             lstHierarchy.Add(obj);
             GetChildPages(ref lstHierarchy, obj, lstPages);
         }
     }
 }