public IList <ResourceBE> Resources_GetByChangeSet(uint changeSetId, ResourceBE.Type resourceType) { if (changeSetId == 0) { return(new List <ResourceBE>()); } return(new ResourceQuery() .WithChangeSetIds(changeSetId) .WithResourceType(resourceType) .SelectList(Catalog, "Resources_GetByChangeSet")); }
// -- Constructors -- public State() { resourceBE = ResourceBE.New(ResourceBE.Type.UNDEFINED); resourceDeletionFilter = DeletionFilter.ANY; revisionVisibilityFilter = VisibilityFilter.ANY; resourceIds = null; nameFilter = null; parentIds = null; parentType = ResourceBE.Type.UNDEFINED; resourceTypes = null; changeSetId = null; changeType = ResourceBE.ChangeOperations.UNDEFINED; populateResourceCountOnly = false; populateContent = true; populateRevisions = false; populateChildResourcesForRev = false; populateChildResources = false; orderClauses = null; limit = null; offset = null; }
public State(State s) { resourceBE = ResourceBE.NewFrom(s.resourceBE); resourceDeletionFilter = s.resourceDeletionFilter; revisionVisibilityFilter = s.revisionVisibilityFilter; populateContent = s.populateContent; populateRevisions = s.populateRevisions; populateChildResources = s.populateChildResources; populateChildResourcesForRev = s.populateChildResourcesForRev; populateResourceCountOnly = s.populateResourceCountOnly; parentType = s.parentType; if(!ArrayUtil.IsNullOrEmpty(s.resourceIds)) { resourceIds = new List<uint>(s.resourceIds); } if(!ArrayUtil.IsNullOrEmpty(s.parentIds)) { parentIds = new List<uint>(s.parentIds); } if(!ArrayUtil.IsNullOrEmpty(s.resourceTypes)) { resourceTypes = new List<ResourceBE.Type>(s.resourceTypes); } if(!ArrayUtil.IsNullOrEmpty(s.nameFilter)) { nameFilter = new List<string>(s.nameFilter); } if(!ArrayUtil.IsNullOrEmpty(s.orderClauses)) { orderClauses = (ResourceOrderClause[]) s.orderClauses.Clone(); } if(!ArrayUtil.IsNullOrEmpty(s.changeSetId)) { changeSetId = new List<uint>(s.changeSetId).ToArray(); } changeType = s.changeType; limit = s.limit; offset = s.offset; }
public ResourceQuery WithResourceType(ResourceBE.Type resourceType) { return(WithResourceType(new[] { resourceType })); }
private static ResourceBE Resources_Populate(IDataReader dr) { ResourceBE.Type resourceType = (ResourceBE.Type)DbUtils.Convert.To <byte>(dr["res_type"]); ResourceBE res = new ResourceBE(resourceType); MimeType mimeTypeTmp = null; for (int i = 0; i < dr.FieldCount; i++) { #region ResourceBE and ResourceContentBE entity mapping switch (dr.GetName(i).ToLowerInvariant()) { case "res_id": res.ResourceId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "resrev_res_id": res.ResourceId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "resrev_rev": res.Revision = DbUtils.Convert.To <int>(dr.GetValue(i)) ?? 0; break; case "resrev_user_id": res.UserId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "resrev_change_mask": res.ChangeMask = (ResourceBE.ChangeOperations)(DbUtils.Convert.To <ushort>(dr.GetValue(i)) ?? (ushort)ResourceBE.ChangeOperations.UNDEFINED); break; case "resrev_name": res.Name = dr.GetValue(i) as string; break; case "resrev_change_description": res.ChangeDescription = dr.GetValue(i) as string; break; case "resrev_timestamp": res.Timestamp = new DateTime(dr.GetDateTime(i).Ticks, DateTimeKind.Utc); break; case "resrev_content_id": res.ContentId = DbUtils.Convert.To <uint>(dr.GetValue(i), 0); break; case "resrev_deleted": res.Deleted = DbUtils.Convert.To <bool>(dr.GetValue(i), false); break; case "resrev_size": res.Size = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "resrev_mimetype": MimeType.TryParse(dr.GetValue(i) as string, out mimeTypeTmp); res.MimeType = mimeTypeTmp; break; case "resrev_changeset_id": res.ChangeSetId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "resrev_parent_id": res.ParentId = DbUtils.Convert.To <uint>(dr.GetValue(i)); break; case "resrev_parent_page_id": res.ParentPageId = DbUtils.Convert.To <uint>(dr.GetValue(i)); break; case "resrev_parent_user_id": res.ParentUserId = DbUtils.Convert.To <uint>(dr.GetValue(i)); break; case "res_headrev": res.ResourceHeadRevision = DbUtils.Convert.To <int>(dr.GetValue(i)) ?? 0; break; case "res_type": // this column was already read break; case "res_deleted": res.ResourceIsDeleted = DbUtils.Convert.To <bool>(dr.GetValue(i), false); break; case "res_create_timestamp": res.ResourceCreateTimestamp = new DateTime(dr.GetDateTime(i).Ticks, DateTimeKind.Utc); break; case "res_update_timestamp": res.ResourceUpdateTimestamp = new DateTime(dr.GetDateTime(i).Ticks, DateTimeKind.Utc); break; case "res_create_user_id": res.ResourceCreateUserId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "res_update_user_id": res.ResourceUpdateUserId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "resrev_language": res.Language = dr.GetValue(i) as string; break; case "resrev_is_hidden": res.IsHidden = DbUtils.Convert.To <bool>(dr.GetValue(i), false); break; case "resrev_meta": res.Meta = dr.GetValue(i) as string; break; case "rescontent_id": res.Content.ContentId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "rescontent_res_id": res.Content.ResourceId = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "rescontent_res_rev": res.Content.Revision = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; case "rescontent_value": res.Content.SetData(dr.GetValue(i) as byte[]); break; case "rescontent_location": res.Content.Location = dr.GetValue(i) as string; break; case "rescontent_mimetype": MimeType.TryParse(dr.GetValue(i) as string, out mimeTypeTmp); res.Content.MimeType = mimeTypeTmp; break; case "rescontent_size": res.Content.Size = DbUtils.Convert.To <uint>(dr.GetValue(i)) ?? 0; break; default: break; } #endregion } //Resource contents may not always be retrieved. Make sure it's null if it's not there. if (res.Content != null && res.Content.IsNewContent()) { res.Content = null; } return(res); }
public IList <ResourceBE> GetResourcesByChangeSet(uint changeSetId, ResourceBE.Type resourceType) { return(DbUtils.CurrentSession.Resources_GetByChangeSet(changeSetId, resourceType).ToArray()); }
public ResourceBE GetResource(uint?parentId, ResourceBE.ParentType?parentType, ResourceBE.Type resourceType, string name, DeletionFilter deletionStateFilter) { if (name == null) { throw new ArgumentNullException("name"); } uint[] parentids = parentId == null ? new uint[] { } : new[] { parentId.Value }; return(GetResources(parentids, parentType, new[] { resourceType }, new[] { name }, deletionStateFilter, null, null, null).FirstOrDefault()); }
private ResourceBE BuildRevForNewResource(string resourcename, MimeType mimeType, uint size, string description, ResourceBE.Type resourceType, uint userId, ResourceContentBE content) { ResourceBE newResource = new ResourceBE(resourceType); newResource.Name = resourcename; newResource.ChangeMask = newResource.ChangeMask | ResourceBE.ChangeOperations.NAME; newResource.Size = size; newResource.MimeType = mimeType; newResource.ChangeDescription = description; newResource.ResourceCreateUserId = newResource.ResourceUpdateUserId = newResource.UserId = userId; newResource.ChangeSetId = 0; newResource.Timestamp = newResource.ResourceCreateTimestamp = newResource.ResourceUpdateTimestamp = DateTime.UtcNow; newResource.Content = content; newResource.ChangeMask = newResource.ChangeMask | ResourceBE.ChangeOperations.CONTENT; newResource.ResourceHeadRevision = ResourceBE.TAILREVISION; newResource.Revision = ResourceBE.TAILREVISION; newResource.IsHidden = false; return(newResource); }
public virtual ResourceBE BuildRevForNewResource(uint?parentId, ResourceBE.ParentType parentType, string resourcename, MimeType mimeType, uint size, string description, ResourceBE.Type resourceType, uint userId, ResourceContentBE content) { ResourceBE newResource = BuildRevForNewResource(resourcename, mimeType, size, description, resourceType, userId, content); switch (parentType) { case ResourceBE.ParentType.PAGE: newResource.ParentPageId = parentId; break; case ResourceBE.ParentType.USER: newResource.ParentUserId = parentId; break; default: newResource.ParentId = parentId; break; } newResource.ChangeMask = newResource.ChangeMask | ResourceBE.ChangeOperations.PARENT; return(newResource); }