public string SaveContent([FromBody] SaveContentRequestBody data) { var contentType = ContentTypeProvider.Get(data.ContentTypeId); var b = (IContent)JsonConvert.DeserializeObject(data.Content, contentType.Type); if (b.Id != null) { var a = (IContent)typeof(IContainerSpecificContentGetter).GetMethod(nameof(ContainerSpecificContentGetter.Get)).MakeGenericMethod(contentType.Type).Invoke(ContainerSpecificContentGetter, new[] { data.Id, null, contentType.Container }); foreach (var propertyDefinition in PropertyDefinitionProvider.GetFor(contentType.Id)) { var display = propertyDefinition.Attributes.OfType <DisplayAttribute>().FirstOrDefault(); if (display != null && display.GetAutoGenerateField() == false) { continue; } propertyDefinition.Setter(a, propertyDefinition.Getter(b)); } ContainerSpecificContentUpdater.Update(a, contentType.Container); return("Updated"); } else { ContainerSpecificContentCreator.Create(b, contentType.Container); return("Saved"); } }
public IEnumerable <FormResponseItem> GetOptions(IEnumerable <string> types) { var result = new List <FormResponseItem>(); foreach (var form in FormProvider.GetAll()) { if (ContentTypeProvider.Get(form.Type) != null) { continue; } if (!types.Contains(form.Id)) { continue; } result.Add(new FormResponseItem { Type = form.Id, Name = form.Type.GetCustomAttribute <DisplayAttribute>()?.Name ?? Humanizer.Humanize(form.Type.Name), }); } return(result.OrderBy(f => f.Name).ToList().AsReadOnly()); }
public object RemoveContent([FromBody] RemoveContentInput removeContentInput) { if (!ModelState.IsValid) { return(new { success = false, errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => new { description = e.ErrorMessage }), }); } var contentType = ContentTypeProvider.Get(removeContentInput.ContentTypeId); var content = ContainerSpecificContentGetter.Get <IContent>(removeContentInput.Id, null, contentType.Container); if (content.ContentTypeId != contentType.Id) { throw new Exception($"Content is not of type {contentType.Id}"); } ContainerSpecificContentDeleter.Delete(content.Id, contentType.Container); return(new { success = true, }); }
public async Task <object> GetAsync(string contentTypeId, params object[] keyValues) { var contentType = ContentTypeProvider.Get(contentTypeId); var dbSet = DbSetProvider.Get(contentType.Type); return(await dbSet.FindAsync(keyValues).ConfigureAwait(false)); }
public async Task <IEnumerable <IContent> > GetAncestorsAsync(IContent content) { var result = new List <IContent>(); var position = content; var contentType = ContentTypeProvider.Get(content.ContentTypeId); while (true) { var document = (await DocumentFinder.Find(contentType.Container).WhereEquals <IContent, string>(x => x.Id, ((IHierarchical)position).ParentId).WhereExists <IHierarchical, string>(x => x.ParentId).GetResultAsync().ConfigureAwait(false)).FirstOrDefault(); if (document == null) { break; } contentType = ContentTypeProvider.Get((string)document.GlobalFacet.Interfaces["IContent"].Properties["ContentTypeId"]); position = ContentDeserializer.Deserialize(document, contentType, null); result.Add(position); if (((IHierarchical)position).ParentId == null) { break; } } return(result); }
public string GetUrl(string id, string contentTypeId) { var contentType = ContentTypeProvider.Get(contentTypeId); var content = ContainerSpecificContentGetter.Get <IContent>(id, null, contentType.Container); return(UrlProvider.Get(content)); }
public IContent GetSingleton(string id) { var contentType = ContentTypeProvider.Get(id); var singleton = SingletonProvider.Get(id); return(ContainerSpecificContentGetter.Get <IContent>(singleton.Id, null, contentType.Container)); }
public Uri Save(IContentData contentData) { IContentTypeProvider contentTypeProvider = new ContentTypeProvider(); IContentSerializer contentSerializer = new FrontMatterContentSerializer(contentTypeProvider); if (string.IsNullOrEmpty(contentData.Layout)) { contentData.Layout = contentData.GetType().Name; } var fileContent = contentSerializer.Serialize(contentData); string contentPath; if (contentData.ContentUri != null) { // if the slug has been updated, rename the file if (!contentData.ContentUri.Segments.Last().Equals(contentData.Slug, StringComparison.InvariantCultureIgnoreCase)) { contentData.ContentUri = RenameContentAssets(contentData.ContentUri, contentData.Slug); } contentPath = ContentUri.GetAbsolutePath(contentData.ContentUri, true); } else if (contentData.ParentUri != null) { var parentPath = ContentUri.GetAbsolutePath(contentData.ParentUri); if (string.IsNullOrEmpty(contentData.Slug) && string.IsNullOrEmpty(contentData.Title)) { throw new InvalidOperationException("Could not create a URL slug for content. Please supply either Title or Slug to save the content."); } if (string.IsNullOrEmpty(contentData.Slug)) { contentData.Slug = contentData.Title.ToUrlSlug(); } contentPath = Path.Combine(parentPath, Path.ChangeExtension(contentData.Slug, _fileExtension)); } else { throw new InvalidOperationException("Cannot save content when both ParentUri and ContentUri is missing."); } var directoryPath = Path.GetDirectoryName(contentPath); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } File.WriteAllText(contentPath, fileContent); return(NormalizeContentUri(new Uri(contentPath))); }
private string GetContentType(string path) { ContentTypeProvider.TryGetContentType(path, out var contentType); if (string.IsNullOrWhiteSpace(contentType)) { return("application/octet-stream"); } return(contentType); }
public async Task Get(string[] contentTypeIds, string parent) { var contentTypes = contentTypeIds.Select(t => ContentTypeProvider.Get(t)).ToList().AsReadOnly(); if (contentTypes.Count > 1) { throw new NotImplementedException("Multi type queries are not yet implemented"); } var items = new List <object>(); var itemChildrenCounts = new Dictionary <string, int>(); var documentsQuery = ContentFinder.Find(contentTypes.Single().Type); if (parent != null) { documentsQuery.WhereParent(parent); } else { documentsQuery.WhereHasNoParent(); } var documents = (await documentsQuery.GetResultAsync().ConfigureAwait(false)).ToList(); foreach (var content in documents) { items.Add(content); if (content is IHierarchical) { var id = PrimaryKeyGetter.Get(content); itemChildrenCounts[string.Join(",", id)] = await ContentChildrenCounter.CountChildrenForAsync(id).ConfigureAwait(false); } } //var sortByPropertyName = typeof(INameable).IsAssignableFrom(contentType.Type) ? "Name" : "Id"; //var sortByProperty = PropertyDefinitionProvider.GetFor(contentType.Id).FirstOrDefault(p => p.Name == sortByPropertyName); //if (sortByProperty != null) //{ // result = result.OrderBy(i => sortByProperty.Getter(i)).ToList(); //} Response.ContentType = "application/json"; await Response.WriteAsync(JsonConvert.SerializeObject(new ContentListResult { Items = items, ItemChildrenCounts = itemChildrenCounts }, new JsonSerializerSettings { Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new List <JsonConverter> { PolymorphicFormConverter } })); }
public async Task DeleteAsync(string contentTypeId, string id) { var contentType = ContentTypeProvider.Get(contentTypeId); if (contentType == null) { throw new ArgumentException(nameof(contentTypeId)); } await DocumentDeleter.DeleteAsync(contentType.Container, id); }
public IEnumerable <ContentTypeResponseItem> GetAll() { var result = new List <ContentTypeResponseItem>(); foreach (var contentType in ContentTypeProvider.GetAll()) { result.Add(GetItem(contentType)); } return(result.AsReadOnly()); }
public async Task DeleteAsync <T>(string id) where T : class, IContent { var contentType = ContentTypeProvider.Get(typeof(T)); if (contentType == null) { throw new TypeNotRegisteredContentTypeException(typeof(T)); } await DocumentDeleter.DeleteAsync(contentType.Container, id); }
public EncelConfiguration InitializeDefaults() { Channel = new Channel(); ContentPathProvider = new AppDataContentPathProvider(); ContentRepositoryFactory = new ContentRepositoryFactory(); ContentTypeProvider = new ContentTypeProvider(); ContentSerializerFactory = new FrontMatterContentSerializerFactory(); ContentControllerResolver = new ContentControllerResolver(new ContentTypeProvider()); return(this); }
public async Task <Item> Get(string type, string value) { var contentType = ContentTypeProvider.Get(type); var content = await ContainerSpecificContentGetter.GetAsync <IContent>(value, null, contentType.Container).ConfigureAwait(false); if (content == null) { return(null); } return(new Item((content as INameable)?.Name ?? content.Id, null, content.Id, (content as IImageable)?.Image)); }
public ContentTypeModel(int contentTypeId, DataRow row, GeneralConnection generalConnection, ContentTypeProvider contentTypeProvider, ErrorInfoList errors) { _contentTypeId = contentTypeId; if (generalConnection != null) _generalConnection = generalConnection; if (contentTypeProvider != null) _contentTypeProvider = contentTypeProvider; if (errors != null) ErrorInfoList = errors; IsEdit = true; Init(row); }
public ContentResponseMessage SaveContent([FromBody] SaveContentRequestBody data) { if (!ModelState.IsValid) { return(ContentResponseMessage.CreateFrom(ModelState)); } var contentType = ContentTypeProvider.Get(data.ContentTypeId); var b = (IContent)JsonConvert.DeserializeObject(data.Content, contentType.Type, PolymorphicFormConverter); if (b.Id != null) { var a = (IContent)typeof(IContainerSpecificContentGetter).GetMethod(nameof(ContainerSpecificContentGetter.Get)).MakeGenericMethod(contentType.Type).Invoke(ContainerSpecificContentGetter, new[] { data.Id, null, contentType.Container }); foreach (var coreInterface in ContentTypeCoreInterfaceProvider.GetFor(contentType.Id)) { foreach (var propertyDefinition in coreInterface.PropertyDefinitions) { var display = propertyDefinition.Attributes.OfType <DisplayAttribute>().FirstOrDefault(); if (display != null && display.GetAutoGenerateField() == false) { continue; } propertyDefinition.Setter(a, propertyDefinition.Getter(b)); } } foreach (var propertyDefinition in PropertyDefinitionProvider.GetFor(contentType.Id)) { var display = propertyDefinition.Attributes.OfType <DisplayAttribute>().FirstOrDefault(); if (display != null && display.GetAutoGenerateField() == false) { continue; } propertyDefinition.Setter(a, propertyDefinition.Getter(b)); } ContainerSpecificContentUpdater.Update(a, contentType.Container); return(new ContentResponseMessage(true, "Updated")); } else { ContainerSpecificContentCreator.Create(b, contentType.Container); return(new ContentResponseMessage(true, "Created")); } }
public ContentTypeProviderTests() { _lowerCaseHeaders = new Dictionary <string, string[]> { ["content-type"] = new[] { "application/json; charset=utf-8" } }; _upperCaseHeaders = new Dictionary <string, string[]> { ["CONTENT-TYPE"] = new[] { "application/json; charset=utf-8" } }; _underTest = new ContentTypeProvider(); }
public async Task <IEnumerable <Item> > GetAll(string type, ItemQuery query) { var result = new List <Item>(); var contentType = ContentTypeProvider.Get(type); foreach (var content in await ContentFinder.Find(contentType.Type).GetResultAsync().ConfigureAwait(false)) { result.Add(GetItem(content)); } return(result.AsReadOnly()); }
public ContentTypeModel(int contentTypeId, GeneralConnection generalConnection, ContentTypeProvider contentTypeProvider, ErrorInfoList errors) { _contentTypeId = contentTypeId; if (generalConnection != null) _generalConnection = generalConnection; if (contentTypeProvider != null) _contentTypeProvider = contentTypeProvider; if (errors != null) ErrorInfoList = errors; ContentId = 0; _dataRow = null; IsEdit = false; Init(null); }
public IEnumerable <ContentTypeDescriptor> GetContentTypesFor(string contentTypeGroupId) { var result = new List <ContentTypeDescriptor>(); var contentTypeGroup = ContentTypeGroupProvider.Get(contentTypeGroupId); foreach (var contentType in ContentTypeProvider.GetAll()) { if (contentTypeGroup.Type.IsAssignableFrom(contentType.Type)) { result.Add(contentType); } } return(result.AsReadOnly()); }
public IEnumerable <T> GetChildren <T>(string id, string language) where T : class { var contentTypes = ContentTypeProvider.GetAll().Where(t => typeof(T).IsAssignableFrom(t.Type)); var documents = DocumentFinder.Find(ContainerConstants.Content).WhereEquals <IHierarchical, string>(x => x.ParentId, id).WhereIn <IContent, string>(x => x.ContentTypeId, contentTypes.Select(t => t.Id)).GetResultAsync().Result.ToList(); var result = new List <T>(); foreach (var document in documents) { var contentTypeId = document.GlobalFacet.Interfaces["IContent"].Properties["ContentTypeId"] as string; result.Add((T)ContentDeserializer.Deserialize(document, ContentTypeProvider.Get(contentTypeId), language)); } return(result.AsReadOnly()); }
protected override void Init() { base.Init(); if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); if (IsEdit) { Title = "Edit Content Type | Frebo Cms"; ltlTitle.Text = "Edit"; } else { Title = "New Content Type | Frebo Cms"; ltlTitle.Text = "New"; } }
public async Task <IEnumerable <Item> > GetAll(string type) { var result = new List <Item>(); var contentType = ContentTypeProvider.Get(type); foreach (var document in await DocumentFinder.Find(contentType.Container).GetResultAsync().ConfigureAwait(false)) { if (document.GlobalFacet.Interfaces[nameof(IContent)].Properties[nameof(IContent.ContentTypeId)] as string != type) { continue; } var content = ContentDeserializer.Deserialize(document, contentType, null); result.Add(new Item((content as INameable)?.Name ?? content.Id, null, content.Id, (content as IImageable)?.Image)); } return(result.AsReadOnly()); }
public async Task InitializeAsync() { var containers = ContentTypeProvider.GetAll().Select(t => t.Container).Distinct(); foreach (var container in containers) { var reference = $"cloudy{container}"; var name = $"{reference}.cloudy-cms.net"; var body = new { apiVersion = "apiextensions.k8s.io/v1beta1", metadata = new { name }, spec = new { group = "cloudy-cms.net", names = new { kind = reference, plural = reference, singular = reference }, scope = "Namespaced", versions = new[] { new { name = "v1", served = true, storage = true } } } }; if ((await Client.Http.GetAsync($"apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/{name}", HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false)).StatusCode == HttpStatusCode.OK) { continue; } if (Logger.IsEnabled(LogLevel.Information)) { Logger.LogInformation($"Sending to Kubernetes:\n\n{JsonConvert.SerializeObject(body)}"); } var response = await Client.Http.PostAsync("apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions", new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json")).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { throw new Exception($"{(int)response.StatusCode} {response.ReasonPhrase}: {await response.Content.ReadAsStringAsync().ConfigureAwait(false)}"); } } }
public async Task <IEnumerable <string> > GetUrl(string[] id, string contentTypeId) { var contentType = ContentTypeProvider.Get(contentTypeId); var content = await ContentGetter.GetAsync(contentTypeId, PrimaryKeyConverter.Convert(id, contentTypeId)).ConfigureAwait(false); var contentRouteSegment = await UrlProvider.GetAsync(content).ConfigureAwait(false); var contentRoutes = ContentRouteMatcher.GetFor(contentType); var result = new List <string>(); foreach (var contentRoute in contentRoutes) { result.Add(contentRoute.Apply(contentRouteSegment)); } return(result.AsReadOnly()); }
public async Task InitializeAsync() { foreach (var singleton in SingletonProvider.GetAll()) { var content = await ContentGetter.GetAsync(singleton.ContentTypeId, singleton.KeyValues); var contentType = ContentTypeProvider.Get(singleton.ContentTypeId); if (content != null) { continue; } content = ContentInstanceCreator.Create(contentType); PrimaryKeySetter.Set(singleton.KeyValues, content); await ContentInserter.InsertAsync(content).ConfigureAwait(false); } }
public async Task <IActionResult> DownloadAsync(string directory, string filename) { FileSystemEntity entity = null; switch (directory) { case "AuditLogs": entity = Repository.AuditLogs.GetFileByFilename(filename); break; } if (entity == null) { return(NotFound()); } var contentType = ContentTypeProvider.TryGetContentType(entity.Filename, out string type) ? type : "application/octet-stream"; return(File(entity.Content, contentType)); }
public IEnumerable <ContentTypeResponseItem> GetContentTypes() { var result = new List <ContentTypeResponseItem>(); foreach (var contentType in ContentTypeProvider.GetAll()) { var name = contentType.Type.GetCustomAttribute <DisplayAttribute>()?.Name ?? contentType.Type.Name; string pluralName; if (name.Contains(':') && !contentType.Id.Contains(':')) { var nameSplit = name.Split(':'); name = nameSplit.First(); pluralName = nameSplit.Last(); } else { name = Humanizer.Humanize(name); pluralName = Pluralizer.Pluralize(name); } var singleton = SingletonProvider.Get(contentType.Id); result.Add(new ContentTypeResponseItem { Id = contentType.Id, Name = name, PluralName = pluralName, IsNameable = typeof(INameable).IsAssignableFrom(contentType.Type), NameablePropertyName = typeof(INameable).IsAssignableFrom(contentType.Type) ? CamelCaseNamingStrategy.GetPropertyName(NameExpressionParser.Parse(contentType.Type), false) : null, IsRoutable = typeof(IRoutable).IsAssignableFrom(contentType.Type), IsSingleton = singleton != null, Count = -1, ContentTypeActionModules = ContentTypeActionModuleProvider.GetContentTypeActionModulesFor(contentType.Id), ListActionModules = ListActionModuleProvider.GetListActionModulesFor(contentType.Id), }); } return(result.AsReadOnly()); }
public IEnumerable <string> FindFor(Type type) { var result = new List <string>(); foreach (var contentType in ContentTypeProvider.GetAll()) { if (type.IsAssignableFrom(contentType.Type)) { throw new CannotInlineContentTypesException(type, contentType); } } foreach (var form in FormProvider.GetAll()) { if (type.IsAssignableFrom(form.Type)) { result.Add(form.Id); } } return(result.AsReadOnly()); }
public IEnumerable <object> GetContentList(string contentTypeId) { var contentType = ContentTypeProvider.Get(contentTypeId); var documents = DocumentFinder.Find(contentType.Container).WhereEquals <IContent, string>(x => x.ContentTypeId, contentType.Id).GetResultAsync().Result.ToList(); var result = new List <object>(); foreach (var document in documents) { result.Add(ContentDeserializer.Deserialize(document, contentType, DocumentLanguageConstants.Global)); } var sortByPropertyName = typeof(INameable).IsAssignableFrom(contentType.Type) ? "Name" : "Id"; var sortByProperty = PropertyDefinitionProvider.GetFor(contentType.Id).FirstOrDefault(p => p.Name == sortByPropertyName); if (sortByProperty != null) { result = result.OrderBy(i => sortByProperty.Getter(i)).ToList(); } return(result.AsReadOnly()); }
protected void Page_Load(object sender, EventArgs e) { ContentTypeProvider contentTypeProvider = new ContentTypeProvider(); List<ContentTypeInfo> contentTypeInfos = contentTypeProvider.SelectAll(new ErrorInfoList()); var htmlBuilder = new StringBuilder(); if (contentTypeInfos != null) { int index = 0; foreach (ContentTypeInfo item in contentTypeInfos) { htmlBuilder.AppendFormat( @"<li class='node'><a href='/administrator/content/default.aspx?contenttypeid={0}' class='icon-16-content'>{1}</a><ul class='menu-component'><li><a href='/administrator/content/action.aspx?contenttypeid={0}&type=entry' class='icon-16-newarticle'> Add New {1}</a></li></ul></li>", item.Id, item.Name); if (index == contentTypeInfos.Count - 1) htmlBuilder.Append("<li class=\"separator\"><span></span></li>"); index++; } ltlContents.Text = htmlBuilder.ToString(); } }
public IEnumerable <Option> GetAll() { var contentTypes = ContentTypeProvider.GetAll().Where(t => typeof(IHierarchical).IsAssignableFrom(t.Type)); var result = new List <Option>(); foreach (var contentType in contentTypes) { var documents = ContentFinder.Find(contentType.Type).GetResultAsync().Result.ToList(); foreach (var content in documents) { var id = "{" + string.Join(",", PrimaryKeyGetter.Get(content)) + "}"; result.Add(new Option((content as INameable).Name ?? id, id)); } } result = result.OrderBy(i => i.Value).ToList(); result.Insert(0, new Option("(root)", null)); return(result.AsReadOnly()); }
protected void Page_Load(object sender, EventArgs e) { ContentTypeProvider contentTypeProvider = new ContentTypeProvider(); List<ContentTypeInfo> contentTypeInfos = contentTypeProvider.SelectAll(new ErrorInfoList()); if (contentTypeInfos != null) { var htmlBuilder = new StringBuilder(); foreach (ContentTypeInfo item in contentTypeInfos) { htmlBuilder.AppendFormat( @"<li class='node'><a href='/administrator/content/default.aspx?contenttypeid={0}'>{1}</a></li>", item.Id, item.Name); } ltlContentMenu.Text = htmlBuilder.ToString(); htmlBuilder.Clear(); foreach (ContentTypeInfo item in contentTypeInfos) { htmlBuilder.AppendFormat( @"<li class='disabled'><a>{0}</a> </li>", item.Name); } ltlHiddenMenu.Text = htmlBuilder.ToString(); } }
public IEnumerable <Option> GetAll() { var contentTypes = ContentTypeProvider.GetAll().Where(t => typeof(IHierarchical).IsAssignableFrom(t.Type)); var result = new List <Option>(); foreach (var contentType in contentTypes) { var documents = DocumentFinder.Find(contentType.Container).WhereEquals <IContent, string>(x => x.ContentTypeId, contentType.Id).GetResultAsync().Result.ToList(); foreach (var document in documents) { var content = ContentDeserializer.Deserialize(document, contentType, DocumentLanguageConstants.Global); result.Add(new Option((content as INameable).Name ?? content.Id, content.Id)); } } result = result.OrderBy(i => i.Value).ToList(); result.Insert(0, new Option("(root)", null)); return(result.AsReadOnly()); }
public edit(string properties, ErrorInfoList errorInfoList) : base(properties, errorInfoList) { _contentTypeProvider = new ContentTypeProvider(); _formProvider = new FormProvider(); }
protected override void Init() { base.Init(); if (_userProfileProvider == null) _userProfileProvider = new UserProfileProvider(); if (_roleProfileProvider == null) _roleProfileProvider = new RoleProfileProvider(); if (_generalConnection == null) _generalConnection = new GeneralConnection(); if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); if (IsEdit) { Title = "Edit User | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "Edit"; } else { Title = "New User | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "New"; } if (IsEdit) { UserProfileInfo userProfileInfo = _userProfileProvider.SelectByUserId(Id, ErrorList); string[] selectedRoles = Roles.GetRolesForUser(Id); if (selectedRoles.Length > 0) { RoleProfileInfo roleProfileInfo = _roleProfileProvider.SelectByRoleId(selectedRoles[0], ErrorList); if (userProfileInfo != null && roleProfileInfo != null) { ContentTypeId = roleProfileInfo.ContentTypeId; ContentId = userProfileInfo.ContentId; pnlContentType.Visible = true; ShowContentType(); } } } }
protected override void Init() { base.Init(); if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); if (IsEdit) { Title = "Edit Field | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "Edit Field"; } else { Title = "New Field | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "New Field"; } }
public edit() : base("", null) { _contentTypeProvider = new ContentTypeProvider(); _formProvider = new FormProvider(); }
private void Init(DataRow row) { if (_contentTypeInfo == null) { if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); if (_generalConnection == null) _generalConnection = new GeneralConnection(); } if (_contentTypeInfo == null) _contentTypeInfo = _contentTypeProvider.Select(_contentTypeId, ErrorInfoList); _dataSet = FormHelper.GetDataSet(_contentTypeInfo.XmlSchema); _dataTable = _dataSet.Tables[0]; _dataRow = _dataTable.NewRow(); _dataTable.Rows.Add(_dataRow); Name = _contentTypeInfo.Name; TableName = _contentTypeInfo.TableName; FillColumns(); if (IsEdit) { if (ContentId != 0) { var parameters = new object[1, 3]; parameters[0, 0] = "@Id"; parameters[0, 1] = _contentId; DataTable dt = _generalConnection.ExecuteDataTableQuery(TableName + ".select", parameters, ErrorInfoList); if (dt != null && dt.Rows.Count > 0) FillDefaultRowValues(dt.Rows[0]); } else { FillDefaultRowValues(row); } } IsPublished = ValidationHelper.GetBoolean(GetValue("IsPublished"), false); }
protected override void Init() { base.Init(); if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); }
protected override void Init() { base.Init(); if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); if (_transformationProvider == null) _transformationProvider = new TransformationProvider(); }