internal static EntityObject GetById <T>(int id) where T : EntityObject { if (typeof(T) == typeof(Article)) { return(ArticleRepository.GetById(id)); } if (typeof(T) == typeof(Site)) { return(SiteRepository.GetById(id)); } if (typeof(T) == typeof(Content)) { return(ContentRepository.GetById(id)); } if (typeof(T) == typeof(Field)) { return(FieldRepository.GetById(id)); } throw new Exception("Unsupported entity object type"); }
internal static int CreateDefaultFormat(int contentId, string backendUrl, string currentCustomerCode) { string objectName; using (var scope = new QPConnectionScope()) { objectName = Common.GetNewTemplateObjectName(scope.DbConnection, contentId); } var siteId = ContentRepository.GetById(contentId).SiteId; var pageTemplateId = Converter.ToInt32(QPContext.EFContext.PageTemplateSet.SingleOrDefault(t => t.SiteId == siteId && t.IsSystem).Id); var isDotNet = SiteRepository.GetById(siteId).IsDotNet; var obj = ObjectRepository.SaveObjectProperties(new BllObject { PageTemplateId = pageTemplateId, Name = objectName, Description = "Automatically Generated Object", TypeId = 2, AllowStageEdit = true, Global = false, LastModifiedBy = QPContext.CurrentUserId, Container = new Container { ContentId = contentId, OrderStatic = "c.modified desc", SelectTotal = "1", ScheduleDependence = true, RotateContent = 0, ApplySecurity = false, ShowArchived = false, CursorType = "adOpenForwardOnly", CursorLocation = "adUseClient", LockType = "adLockReadOnly" } }); obj.NetName = $"default_{obj.Id}"; ObjectRepository.UpdateObjectProperties(obj); string formatBody; var codeBehind = string.Empty; if (isDotNet) { using (var scope = new QPConnectionScope()) { formatBody = Common.FormatBodyNet(contentId, scope.DbConnection); } codeBehind = Common.CodeBehind(currentCustomerCode, backendUrl); } else { using (var scope = new QPConnectionScope()) { formatBody = Common.FormatBodyVbScript(contentId, currentCustomerCode, backendUrl, scope.DbConnection); } } var objectFormatId = FormatRepository.SaveObjectFormatProperties(new ObjectFormat { ObjectId = obj.Id, Name = "default", LastModifiedBy = QPContext.CurrentUserId, FormatBody = formatBody, NetLanguageId = isDotNet ? (int?)1 : null, NetFormatName = isDotNet ? "default" : null, CodeBehind = isDotNet ? codeBehind : null }).Id; ObjectRepository.UpdateDefaultFormatId(obj.Id, objectFormatId); using (var scope = new QPConnectionScope()) { Common.CreateContainerStatusBind(scope.DbConnection, obj.Id, contentId); } return(objectFormatId); }
internal static IEnumerable <EntityObject> GetList(string entityTypeCode, IList <int> ids) { if (entityTypeCode.Equals(EntityTypeCode.CustomerCode, StringComparison.InvariantCultureIgnoreCase) && ids.Any()) { return(new EntityObject[] { new CustomerObject { Id = ids.First(), Modified = DateTime.MinValue, IsReadOnly = true } }); } if (entityTypeCode.Equals(EntityTypeCode.Site, StringComparison.InvariantCultureIgnoreCase)) { return(SiteRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Content, StringComparison.InvariantCultureIgnoreCase)) { return(ContentRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Field, StringComparison.InvariantCultureIgnoreCase)) { return(FieldRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Article, StringComparison.InvariantCultureIgnoreCase)) { return(ArticleRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Notification, StringComparison.InvariantCultureIgnoreCase)) { return(NotificationRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VisualEditorPlugin, StringComparison.InvariantCultureIgnoreCase)) { return(VisualEditorRepository.GetPluginList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VisualEditorCommand, StringComparison.InvariantCultureIgnoreCase)) { return(VisualEditorRepository.GetCommandList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VisualEditorStyle, StringComparison.InvariantCultureIgnoreCase)) { return(VisualEditorRepository.GetStyleList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.StatusType, StringComparison.InvariantCultureIgnoreCase)) { return(StatusTypeRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Workflow, StringComparison.InvariantCultureIgnoreCase)) { return(WorkflowRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.PageTemplate, StringComparison.InvariantCultureIgnoreCase)) { return(PageTemplateRepository.GetPageTemplateList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.User, StringComparison.InvariantCultureIgnoreCase)) { return(UserRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.UserGroup, StringComparison.InvariantCultureIgnoreCase)) { return(UserGroupRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.TemplateObjectFormat, StringComparison.InvariantCultureIgnoreCase)) { return(FormatRepository.GetList(ids, false)); } if (entityTypeCode.Equals(EntityTypeCode.PageObjectFormat, StringComparison.InvariantCultureIgnoreCase)) { return(FormatRepository.GetList(ids, true)); } if (entityTypeCode.Equals(EntityTypeCode.PageObject, StringComparison.InvariantCultureIgnoreCase) || entityTypeCode.Equals(EntityTypeCode.TemplateObject, StringComparison.InvariantCultureIgnoreCase)) { return(ObjectRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VirtualContent, StringComparison.InvariantCultureIgnoreCase)) { return(VirtualContentRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Page, StringComparison.InvariantCultureIgnoreCase)) { return(PageRepository.GetList(ids)); } return(Enumerable.Empty <EntityObject>()); }