/// <summary> /// Gets the CNMM menu object /// </summary> /// <returns>A Common Nordic Metamodel Menu object</returns> private static Item GetCnmmMenu(string dbid, string language, string nodeId, string menuid) { string dbLang = language; TableLink tblFix = null; //Create database objecst to return DatamodelMenu menu = ConfigDatamodelMenu.Create( dbLang, PCAxis.Sql.DbConfig.SqlDbConfigsStatic.DataBases[dbid], m => { m.RootSelection = nodeId == "" ? new ItemSelection() : new ItemSelection(menuid, nodeId); m.AlterItemBeforeStorage = item => { if (item is TableLink) { TableLink tbl = (TableLink)item; if (string.Compare(tbl.ID.Selection, nodeId, true) == 0) { tblFix = tbl; } if (tbl.StartTime == tbl.EndTime) { tbl.Text = tbl.Text + " " + tbl.StartTime; } else { tbl.Text = tbl.Text + " " + tbl.StartTime + " - " + tbl.EndTime; } if (tbl.Published.HasValue) { tbl.SetAttribute("modified", tbl.Published.Value.ToShortDateString()); } } if (String.IsNullOrEmpty(item.SortCode)) { item.SortCode = item.Text; } }; }); return(tblFix != null ? tblFix : menu.CurrentItem); }
private static PxMenuBase GetCnmmMenuAndItem(string dbid, string nodeId, string lang, out PCAxis.Menu.Item currentItem) { //Get selected language in PX-Web //string pxLang = PCAxis.Web.Core.Management.LocalizationManager.GetTwoLetterLanguageCode(); //string dbLang = PxContext.GetCnmmDbLanguage(dbid, pxLang); string dbLang = PxContext.GetCnmmDbLanguage(dbid, lang); TableLink tblFix = null; //Create database object to return DatamodelMenu menu = ConfigDatamodelMenu.Create( dbLang, PCAxis.Sql.DbConfig.SqlDbConfigsStatic.DataBases[dbid], m => { m.RootSelection = string.IsNullOrEmpty(nodeId) ? new ItemSelection() : PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.CNMM).GetSelection(nodeId); m.AlterItemBeforeStorage = item => { if (item is PCAxis.Menu.Url) { PCAxis.Menu.Url url = (PCAxis.Menu.Url)item; } if (item is TableLink) { TableLink tbl = (TableLink)item; string tblId = tbl.ID.Selection; if (!string.IsNullOrEmpty(dbid)) { tbl.ID = new ItemSelection(item.ID.Menu, dbid + ":" + tbl.ID.Selection); // Hantering av flera databaser! } CustomizeTableTitle(tbl, false); if (tbl.Published.HasValue) { // Store date in the PC-Axis date format tbl.SetAttribute("modified", tbl.Published.Value.ToString(PCAxis.Paxiom.PXConstant.PXDATEFORMAT)); } if (string.Compare(tblId + item.ID.Menu, PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.CNMM).GetSelection(nodeId).Selection + PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.CNMM).GetSelection(nodeId).Menu, true) == 0) { tblFix = tbl; } } if (String.IsNullOrEmpty(item.SortCode)) { item.SortCode = item.Text; } }; m.Restriction = item => { return(true); }; }); if (tblFix != null) { currentItem = tblFix; } else { currentItem = menu.CurrentItem; } menu.RootItem.Sort(); return(menu); }