コード例 #1
0
ファイル: MenuStorage.cs プロジェクト: Nagabhushana/nag
        public virtual void UpdateMenu(MenuRecord menu)
        {
            Guard.NotNull(menu, nameof(MenuRecord));

            menu.SystemName = menu.SystemName.ToValidPath();

            var modProps = _services.DbContext.GetModifiedProperties(menu);

            _menuRepository.Update(menu);

            var systemNames = GetMenuSystemNames(false);

            if (systemNames != null)
            {
                if (modProps.TryGetValue(nameof(menu.Published), out var original))
                {
                    if (original.Convert <bool>() == true)
                    {
                        systemNames.Remove(menu.SystemName);
                    }
                    else
                    {
                        systemNames.Add(menu.SystemName);
                    }
                }
                else if (modProps.TryGetValue(nameof(menu.SystemName), out original))
                {
                    systemNames.Remove((string)original);
                    systemNames.Add(menu.SystemName);
                }
            }

            _services.Cache.RemoveByPattern(MENU_PATTERN_KEY);
        }
コード例 #2
0
        private void PrepareModel(MenuRecordModel model, MenuRecord entity)
        {
            var templateNames = new string[] { "LinkList", "ListGroup", "Dropdown", "Navbar" };

            if (entity != null && ModelState.IsValid)
            {
                model.SelectedStoreIds        = _storeMappingService.GetStoresIdsWithAccess(entity);
                model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccessTo(entity);

                model.IsCustomTemplate = entity.Template.HasValue() && !templateNames.Contains(entity.Template);
            }

            model.Locales = new List <MenuRecordLocalizedModel>();

            model.AllTemplates = templateNames
                                 .Select(x => new SelectListItem {
                Text = x, Value = x, Selected = x.IsCaseInsensitiveEqual(entity?.Template)
            })
                                 .ToList();

            model.AllProviders = _menuItemProviders.Values
                                 .Select(x => new SelectListItem
            {
                Text  = T("Providers.MenuItems.FriendlyName." + x.Metadata.ProviderName),
                Value = x.Metadata.ProviderName
            })
                                 .ToList();

            var entities = _menuStorage.GetMenuItems(model.Id, 0, true);

            model.ItemTree = entities.GetTree("EditMenu", _menuItemProviders);
        }
コード例 #3
0
 private void UpdateLocales(MenuRecord entity, MenuRecordModel model)
 {
     if (model.Locales != null)
     {
         foreach (var localized in model.Locales)
         {
             _localizedEntityService.SaveLocalizedValue(entity, x => x.Title, localized.Title, localized.LanguageId);
         }
     }
 }
コード例 #4
0
ファイル: MenuStorage.cs プロジェクト: Nagabhushana/nag
        public virtual void InsertMenu(MenuRecord menu)
        {
            Guard.NotNull(menu, nameof(MenuRecord));

            menu.SystemName = menu.SystemName.ToValidPath();

            _menuRepository.Insert(menu);

            var systemNames = GetMenuSystemNames(false);

            if (systemNames != null && menu.Published)
            {
                systemNames.Add(menu.SystemName);
            }

            _services.Cache.RemoveByPattern(MENU_PATTERN_KEY);
        }
コード例 #5
0
ファイル: MenuStorage.cs プロジェクト: Nagabhushana/nag
        public virtual void DeleteMenu(MenuRecord menu)
        {
            if (menu == null)
            {
                return;
            }

            _menuRepository.Delete(menu);

            var systemNames = GetMenuSystemNames(false);

            if (systemNames != null)
            {
                systemNames.Remove(menu.SystemName);
            }

            _services.Cache.RemoveByPattern(MENU_PATTERN_KEY);
        }
コード例 #6
0
        public string GetContextMenuHtml(string pageTitle, int menuId, DataTable dtMenu)
        {
            int id;

            foreach (DataRow dr in dtMenu.Rows)
            {
                id = Convert.ToInt32(dr[0]);
                MenuRecord mr = new MenuRecord(id, Convert.ToInt32(dr[1]), dr[2].ToString(), dr[3].ToString());
                menus.Add(id, mr);
            }

            StringBuilder sb = new StringBuilder();
            MenuRecord    mr1;

            while (menuId != NO_PARENT)
            {
                mr1 = (MenuRecord)menus[menuId];
                sb.Insert(0, "<a href='" + mr1.Url + "' class='contextmenu-link'>" + mr1.Text + "</a>&nbsp;&nbsp;>&nbsp;");
                menuId = mr1.ParentId;
            }
            sb.AppendFormat("<a class='contextmenu-link'>{0}</a>", pageTitle);
            sb.Insert(0, "<a href='default.aspx' class='contextmenu-link'>Home</a>&nbsp;&nbsp;>&nbsp;");
            return(sb.ToString());
        }
コード例 #7
0
        public void readRecords()
        {
            int readOffset = (int)this.offset;

            // NOTE: loop unrolled purposely
            switch (this.id)
            {
            case Database.TABLE_STATE_DATA_SPECIFIER:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new SDSRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_BINARY_DATA_SPECIFIER:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new BDSRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_NUMERIC_DATA_SPECIFIER:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new NDSRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_CONVERTERS_STATE:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new SCRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_CONVERTERS_NUMERIC:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new NCRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_STATE_ENTRY:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new StateEntryRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_STRINGS:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new StringRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_DATA_ACQUISITION_DESCRIPTION:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new DADRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_DES_INFO:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new DESRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_SERIVCE_CAT_STUFFS:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new ServiceCatRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_TRANSMIT:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new TXRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_MODULE_DATAELEMENT:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new ModuleDataElemRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_MODULE:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new ModuleRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_DRB_MENU:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new MenuRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_UNKNOWN_3:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new RecordUnknownWithString(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize), 2);
                }
                break;

            case Database.TABLE_UNKNOWN_21:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new RecordUnknownWithString(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize), 3);
                }
                break;

            default:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new Record(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;
            }
        }