示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="moduleDefId"></param>
        /// <param name="pageId"></param>
        /// <param name="title"></param>
        /// <param name="alsoIfExists"></param>
        /// <returns></returns>
        public static int AddModuleToPage(int moduleDefId, int pageId, string title, bool alsoIfExists)
        {
            var module = default(rb_Modules);
            using (var context = new AppleseedDBContext()) {
                module = context.rb_Modules.Where(d => d.TabID == pageId && d.ModuleDefID == moduleDefId).FirstOrDefault();
            }

            if (module == default(rb_Modules) || alsoIfExists) {
                var sdb = new ModulesDB();
                return  sdb.AddModule(pageId, 0, "ContentPane", title, moduleDefId, 0, "Admins", "All Users", "Admins", "Admins", "Admins", "Admins", "Admins", false, string.Empty, true, false, false);
            } else {
                return module.ModuleID;
            }
        }
示例#2
0
        internal static int AddModuleDefinition(Guid generalModuleDefId, int portalId)
        {
            var moduleDefId = -1;
            using (AppleseedDBContext context = new AppleseedDBContext()) {
                var current = context.rb_ModuleDefinitions.Where(d => d.GeneralModDefID == generalModuleDefId && d.PortalID == portalId).FirstOrDefault();

                if (current != default(rb_ModuleDefinitions)) {
                    moduleDefId = current.ModuleDefID;
                } else {
                    var entity = new rb_ModuleDefinitions() { PortalID = portalId, GeneralModDefID = generalModuleDefId };
                    context.rb_ModuleDefinitions.AddObject(entity);
                    context.SaveChanges();
                    moduleDefId = entity.ModuleDefID;
                }
            }

            return moduleDefId;
        }
        /// <summary>
        /// Gets the module instances exc.
        /// </summary>
        /// <param name="ItemID">The item ID.</param>
        /// <param name="ExcludeItem">The exclude item.</param>
        /// <param name="PortalID">The portal ID.</param>
        /// <returns></returns>
        /// ExcludeItem == ModuleID of selected Module to use for source.
        //Since we do not want to allow copy from A->A,B->B we exclude that item.
        public IQueryable GetModuleInstancesExc(int ItemID, int ExcludeItem, int PortalID)
        {
            var ctx = new AppleseedDBContext();

            var result = (from pages in ctx.rb_Pages
                          from modules in ctx.rb_Modules
                          from moduleDefs in ctx.rb_ModuleDefinitions
                          from contMan in ctx.rb_ContentManager

                          where contMan.ItemID == ItemID &&
                                contMan.ItemID != ExcludeItem &&
                                contMan.SourceGeneralModDefID == moduleDefs.GeneralModDefID &&
                                moduleDefs.ModuleDefID == modules.ModuleDefID &&
                                moduleDefs.PortalID == PortalID &&
                                modules.TabID == pages.PageID

                          select new
                          {
                              modules.ModuleID,
                              TabModule = pages.PageName + "\\" + modules.ModuleTitle
                          }

                ).AsQueryable().OrderBy(r => r.TabModule);

            return result;
        }
示例#4
0
 private static IModuleSettings ConvertRb_ModuleToModuleSettings(rb_Modules rbModules, AppleseedDBContext context)
 {
     var guidid = new ModulesDB().GetModuleGuid(rbModules.ModuleID);
     var newmodule = new ModuleSettings
     {
         PageID = rbModules.TabID,
         ModuleID = rbModules.ModuleID,
         PaneName = rbModules.PaneName,
         ModuleTitle = rbModules.ModuleTitle,
         AuthorizedEditRoles = rbModules.AuthorizedEditRoles,
         AuthorizedViewRoles = rbModules.AuthorizedViewRoles,
         AuthorizedAddRoles = rbModules.AuthorizedAddRoles,
         AuthorizedDeleteRoles = rbModules.AuthorizedDeleteModuleRoles,
         AuthorizedPropertiesRoles = rbModules.AuthorizedPropertiesRoles,
         CacheTime = rbModules.CacheTime,
         ModuleOrder = rbModules.ModuleOrder,
         ShowMobile = rbModules.ShowMobile != null && ((rbModules.ShowMobile == null) && (bool)rbModules.ShowMobile),
         DesktopSrc = context.rb_GeneralModuleDefinitions.First(d => d.GeneralModDefID == guidid).DesktopSrc,
         //MobileSrc =  // not supported yet
         SupportCollapsable = rbModules.SupportCollapsable != null && (bool)rbModules.SupportCollapsable,
         ShowEveryWhere = rbModules.ShowEveryWhere != null && (bool)rbModules.ShowEveryWhere,
         GuidID = guidid,
     };
     return newmodule;
 }
示例#5
0
 public static Object GetPage(int pageId)
 {
     var context = new AppleseedDBContext();
     var page = context.rb_Pages.First(p => p.PageID == pageId);
     return page;
 }
示例#6
0
 public static List<IModuleSettings> GetModulesToPage(int pageId)
 {
     var result = new List<IModuleSettings>();
     var context = new AppleseedDBContext();
     var modules = context.rb_Modules.Where(d => d.TabID == pageId);
     foreach (var rbModulese in modules)
     {
         var newmodule = ConvertRb_ModuleToModuleSettings(rbModulese, context);
         result.Add(newmodule);
     }
     return result;
 }