public void SaveItem(dtoColumn dto) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(rootObject.EditMenuBar(View.IdMenubar, Service.GetMenubarType(View.IdMenubar))); } else { ItemColumn column = Service.SaveItem(dto); if (column != null) { View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = column.Id, Type = MenuItemType.ItemColumn }); } else { View.SaveError(); } } }
public void AddItem(long idOwner, MenuItemType itemOwner, MenuItemType itemToCreate) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(rootObject.EditMenuBar(View.IdMenubar, Service.GetMenubarType(View.IdMenubar))); } else { MenuBarType menubarType = Service.GetMenubarType(View.IdMenubar); Boolean loadProfileTypes = (menubarType == MenuBarType.Portal || menubarType == MenuBarType.PortalAdministration); switch (itemOwner) { case MenuItemType.Menubar: TopMenuItem item = Service.AddItemToMenubar(idOwner); if (item != null) { View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = idOwner, Type = itemOwner }); View.LoadMenuBarInfo(Service.GetDtoMenubar(View.IdMenubar)); //if (loadProfileTypes) // View.LoadTopMenuItem(Service.GetDtoTopMenuItem(item.Id) , Service.GetDtoTranslations(item.Id), Service.GetItemProfilesAssignments(item.Id)); //else // View.LoadTopMenuItem(Service.GetDtoTopMenuItem(item.Id), Service.GetDtoTranslations(item.Id)); } break; case MenuItemType.TopItemMenu: ItemColumn column = Service.AddItemToTopItem(idOwner); if (column != null) { View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = idOwner, Type = itemOwner }); SelectItem(new dtoItem() { Id = idOwner, Type = itemOwner }); //View.LoadColumnItem(Service.GetDtoColumn(column.Id)); } break; case MenuItemType.ItemColumn: MenuItem subColumnItem = Service.AddToColumn(idOwner, itemToCreate); if (subColumnItem != null) { //dtoMenuItem dto = Service.GetDtoMenuItem(subColumnItem.Id); View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = idOwner, Type = itemOwner }); //if (itemToCreate == MenuItemType.Separator) // View.LoadSeparatorItem(dto); //else if (loadProfileTypes) // View.LoadMenuItem(dto, Service.GetDtoTranslations(subColumnItem.Id), Service.GetItemProfilesAssignments(subColumnItem.Id), Service.GetItemAvailableProfileTypes(subColumnItem), Service.GetMenuItemAvailableTypes(subColumnItem)); //else // View.LoadMenuItem(dto, Service.GetDtoTranslations(subColumnItem.Id), Service.GetMenuItemAvailableTypes(subColumnItem)); SelectItem(new dtoItem() { Id = idOwner, Type = itemOwner }); } break; case MenuItemType.Link: case MenuItemType.Text: if (!(itemToCreate == MenuItemType.IconManage || itemToCreate == MenuItemType.IconNewItem || itemToCreate == MenuItemType.IconStatistic)) { View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = idOwner, Type = itemOwner }); break; } goto case MenuItemType.TextContainer; case MenuItemType.TextContainer: case MenuItemType.LinkContainer: MenuItem subItem = Service.AddToItem(idOwner, itemToCreate); if (subItem != null) { View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = idOwner, Type = itemOwner }); SelectItem(new dtoItem() { Id = idOwner, Type = itemOwner }); //if (itemToCreate == MenuItemType.Separator) // View.LoadSeparatorItem(Service.GetDtoMenuItem(subItem.Id)); //else if (loadProfileTypes) // View.LoadMenuItem(Service.GetDtoMenuItem(subItem.Id), Service.GetDtoTranslations(subItem.Id), Service.GetItemProfilesAssignments(subItem.Id), Service.GetItemAvailableProfileTypes(subItem), Service.GetMenuItemAvailableTypes(subItem)); //else // View.LoadMenuItem(Service.GetDtoMenuItem(subItem.Id), Service.GetDtoTranslations(subItem.Id), Service.GetMenuItemAvailableTypes(subItem)); } break; default: View.LoadMenubar(Service.MenubarToTree(View.IdMenubar), new dtoItem() { Id = idOwner, Type = itemOwner }); break; } } }
virtual public void Load() { try { lock (this.Lock) { // If the itemTable has been created via some other code path, then // attach to it here. if (_itemSet.Tables.Contains((string)this.TableName) && (this.ItemTable == null)) { this.ItemTable = _itemSet.Tables[(string)this.TableName]; } // If this is the first time we are loading this itemTable, then simply // add it to the itemSet. if (null == this.ItemTable) { // Build the in-memory dataset and load it from the SQLite database. // This call will also create the schema for the dataTable this.ItemTable = new ItemTable((string)this.TableName); this.CreateTableSchema(this.ItemTable); using (var statement = ((ISQLiteConnection)_vesselDB.Connection).Prepare(GetSelectAllSql())) { while (statement.Step() == SQLiteResult.ROW) { this.LoadTableRow(statement); } } this.ItemTable.AcceptChanges(); _itemSet.Tables.Add(this.ItemTable); } else { // We are trying to reload the dataset. Clear the existing one, and read the // rows from SQL. We don't need to rebuld the schema since the dataTable // already has been created. this.ItemTable.Clear(); using (var statement = ((ISQLiteConnection)_vesselDB.Connection).Prepare(GetSelectAllSql())) { while (statement.Step() == SQLiteResult.ROW) { this.LoadTableRow(statement); } this.ItemTable.AcceptChanges(); } } } // Build a primary key for this table so that records can be located based on // the primary key. ItemColumn primaryKey = this.ItemTable.Columns[PrimaryKeyName]; this.ItemTable.PrimaryKey = new ItemColumn[] { primaryKey }; } catch (Exception ex) { Telemetry.TrackException(ex); throw; } }