コード例 #1
0
    //
    // TODO: Add constructor logic here
    //
    public void PopulateStoreMenu2(EasyMenu ctrlMenu, EasyMenu[] ids)
    {
        //check if the product already exists in the cache
        System.Data.DataSet ds = (System.Data.DataSet)HttpContext.Current.Cache["MenuNavigation"];

        if (ds == null)
        {
            CategoryHelper categoryHelper = new CategoryHelper();
            ds = categoryHelper.GetNavigationItems(ZNodeConfigManager.SiteConfig.PortalID);

            //add the hierarchical relationship to the dataset
            ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]);

            HttpContext.Current.Cache["MenuNavigation"] = ds;
        }
        System.Data.DataSet dsBrands = (System.Data.DataSet)HttpContext.Current.Cache["SubMenuBrands"];

        if (dsBrands == null)
        {
            GoOpticCategoryHelper gocategoryHelper = new GoOpticCategoryHelper();
            dsBrands = gocategoryHelper.GetBrands(ZNodeConfigManager.SiteConfig.PortalID);

            //add the hierarchical relationship to the dataset
            //dsBrands.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]);

            HttpContext.Current.Cache["SubMenuBrands"] = dsBrands;
        }

        int CategoryNo = 0;
        foreach (DataRow dbRow in ds.Tables[0].Rows)
        {
            if (dbRow.IsNull("ParentCategoryID"))
            {
                if ((bool)dbRow["VisibleInd"])
                {
                    //create new menu item
                    // string itemText = dbRow["Name"].ToString();
                    int rows;
                    try
                    {
                        rows = Int32.Parse(dbRow["Rows"].ToString());
                    }
                    catch (Exception e)
                    { rows = 0; }
                    int columns;
                    try
                    {
                        columns = Int32.Parse(dbRow["Columns"].ToString());
                    }
                    catch (Exception e)
                    { columns = 0; }

                    string categoryId = dbRow["CategoryId"].ToString();
                    string seoURL = dbRow["SEOURL"].ToString();
                    string imageName=dbRow["ImageFile"].ToString();
                    string imageNameHOver = imageName.Replace(".","HOver.");
                    string imagePath = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath +imageName ;
                    imagePath = imagePath.Replace("~","");
                    string imagePathHOver = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath+imageNameHOver;
                    imagePathHOver = imagePathHOver.Replace("~", "");

                    string categoryText = dbRow["Name"].ToString();
                    if (categoryText.ToLower() == "home")
                        seoURL = "~/";
                    else
                        seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL);
                    imageName = imageName.Remove(imageName.IndexOf("."), imageName.Length - imageName.IndexOf("."));
                    string itemText = "<a href=\"" + seoURL.Replace("~","") + "\" onmouseover=\"roll_over('" + imageName + "', '" + imagePathHOver + "')\"  onmouseout=\"roll_over('" + imageName + "', '" + imagePath + "')\" ><img border=\"0\"  name =\"" + imageName + "\" src=\"" + imagePath + "\"/>";
                    //  itemText = itemText.Replace("default", imagePath);

                    categoryText = categoryText.Replace(" ", "");
                    string sepID = "sep" + categoryText;
                    string sepPath = "<img  src=\"~/Images/home/bete.png\"/>";
                    sepPath = sepPath.Replace("~", "");

                    if(CategoryNo!=0)
                        ctrlMenu.AddSeparator(sepID, sepPath);
                    OboutInc.EasyMenu_Pro.MenuItem mi = new OboutInc.EasyMenu_Pro.MenuItem(categoryText, itemText, "","", "", "");
                    ctrlMenu.AddItem(mi);

                    ids[CategoryNo].AttachTo = categoryText;
                    //recursively populate node
                    if (categoryText.ToLower() == "brands")
                    {
                        RecursivelyPopulateMenuBrands(ids[CategoryNo], rows, columns);
                    }
                    else
                    {
                        RecursivelyPopulateMenuSubCategory(dbRow, ids[CategoryNo], dsBrands, rows, columns);
                        // RecursivelyPopulateMenuBrands(ids[CategoryNo], categoryId, dsBrands);
                   }
                    CategoryNo++;
                }
            }
        }
    }