public virtual IList <LatestChangedResourceResult> GetAllLatestChangedResource(IEnumerable <long> projectIdList) { ResourceVersion resourceVersionAlias = null; Resource resourceAlias = null; Project projectAlias = null; ResourceVersion resourceVersionAlias2 = null; Resource resourceAlias2 = null; LatestChangedResourceResult resultAlias = null; var result = GetSession().QueryOver(() => resourceVersionAlias) .JoinAlias(() => resourceVersionAlias.Resource, () => resourceAlias) .JoinAlias(() => resourceAlias.Project, () => projectAlias) .WhereRestrictionOn(() => resourceAlias.Project.Id).IsInG(projectIdList) .And(() => projectAlias.IsRemoved == false) .And(x => x.Id == resourceAlias.LatestVersion.Id /*&& !resourceAlias.IsRemoved*/) .WithSubquery.Where(() => resourceVersionAlias.CreateTime == QueryOver.Of(() => resourceAlias2) .JoinAlias(() => resourceAlias2.LatestVersion, () => resourceVersionAlias2) .Where(() => resourceAlias2.Project.Id == resourceAlias.Project.Id) .Select(Projections.Max(() => resourceVersionAlias2.CreateTime)) .Take(1) .As <DateTime>()) .SelectList(list => list .SelectGroup(() => resourceAlias.Project.Id).WithAlias(() => resultAlias.ProjectId) .SelectMax(() => resourceVersionAlias.CreateTime).WithAlias(() => resultAlias.CreateTime) .SelectMin(() => resourceVersionAlias.CreatedByUser.Id).WithAlias(() => resultAlias.CreatedByUserId)) .TransformUsing(Transformers.AliasToBean <LatestChangedResourceResult>()) .List <LatestChangedResourceResult>(); return(result); }
protected override bool checkHandlerMethodDesktopInternal(MethodDefinition handler) { if (checkHandlerV3(handler)) { version = ResourceVersion.V3; return(true); } simpleDeobfuscator.deobfuscate(handler); if ((data40 = checkHandlerV40(handler)) != null) { version = ResourceVersion.V40; return(true); } var info = getHandlerArgs41(handler); Data41 data41Tmp; if (info != null && checkHandlerV41(info, out data41Tmp)) { version = ResourceVersion.V41; data41 = data41Tmp; return(true); } return(false); }
protected override bool CheckHandlerMethodDesktopInternal(MethodDef handler) { if (CheckHandlerV3(handler)) { version = ResourceVersion.V3; return(true); } simpleDeobfuscator.Deobfuscate(handler); if ((data40 = CheckHandlerV40(handler)) != null) { version = ResourceVersion.V40; return(true); } var info = GetHandlerArgs41(handler); if (info != null && CheckHandlerV41(info, out var data41Tmp)) { version = ResourceVersion.V41; data41 = data41Tmp; return(true); } return(false); }
private void TryRemoveResource(ResourceVersion resourceVersion) { if (resourceVersion == null) { return; } var resource = resourceVersion.Resource; resource.IsRemoved = true; m_resourceRepository.Update(resource); }
public virtual Permission FindPermissionForResourceVersionByGroupId(long resourceVersionId, int userGroupId) { UserGroup userGroupAlias = null; Project projectAlias = null; Resource resourceAlias = null; ResourceVersion resourceVersionAlias = null; return(GetSession().QueryOver <Permission>() .JoinAlias(x => x.UserGroup, () => userGroupAlias) .JoinAlias(x => x.Project, () => projectAlias) .JoinAlias(() => projectAlias.Resources, () => resourceAlias) .JoinAlias(() => resourceAlias.ResourceVersions, () => resourceVersionAlias) .Where(() => resourceVersionAlias.Id == resourceVersionId && userGroupAlias.Id == userGroupId && projectAlias.IsRemoved == false) .SingleOrDefault()); }
public void Resource_Add_ResourceVersion() { var ctx = new BadgerDataModel(); ResourceVersion _version = new ResourceVersion(); _version.ResourceID = 5; _version.RVersion = 1; _version.VersionComment = "Revised for some reason"; _version.ModifiedBy = "dick"; _version.ModDate = DateTime.Today; ctx.ResourceVersion.Add(_version); ctx.SaveChanges(); Assert.IsTrue(_version.ResourceVersionID != default); }
public void CreateOrUpdateOrder(ResourceDto resourceDTO) { var resource = ctx.Resource.FirstOrDefault(o => o.ResourceID == resourceDTO.ResourceID); if (resource == null) { resource = new Resource(); ctx.Resource.Add(resource); // Save to DB to get the new ID -- ctx.SaveChanges(); } //Map properties -------------------------------------------------- resource.Createdby = resourceDTO.Createdby; resource.CurrentVersion = resourceDTO.CurrentVersion; resource.ResourceDescription = resourceDTO.ResourceDescription; //resource.ResourceID = resourceDTO.ResourceID; //remove deleted details - resource.Versions .Where(d => !resourceDTO.Versions.Any(ResourceVersionDto => ResourceVersionDto.ResourceVersionID == d.ResourceVersionID)).ToList() .ForEach(deleted => ctx.ResourceVersion.Remove(deleted)); //update or add details resourceDTO.Versions.ToList().ForEach(ResourceVersionDTO => { var detail = resource.Versions.FirstOrDefault(d => d.ResourceVersionID == ResourceVersionDTO.ResourceVersionID); if (detail == null) { detail = new ResourceVersion(); resource.Versions.Add(detail); } detail.ResourceID = resource.ResourceID; detail.Resource = ResourceVersionDTO.Resource; //detail.ResourceVersionID = ResourceVersionDTO.ResourceVersionID; detail.RVersion = ResourceVersionDTO.RVersion; }); ctx.SaveChanges(); }
private RelatedResourceContract GetRelatedResourceContract(ResourceVersion resourceVersion) { Resource relatedResource = null; switch (resourceVersion) { case TextResource textResource: relatedResource = m_resourceRepository .InvokeUnitOfWork(x => x.GetLatestResourceVersion <PageResource>(textResource.ResourcePage.Id)).Resource; break; case ImageResource imageResource: relatedResource = m_resourceRepository .InvokeUnitOfWork(x => x.GetLatestResourceVersion <PageResource>(imageResource.ResourcePage.Id)).Resource; break; case AudioResource audioResource: relatedResource = m_resourceRepository .InvokeUnitOfWork(x => x.GetLatestResourceVersion <TrackResource>(audioResource.ResourceTrack.Id)).Resource; break; } if (relatedResource != null) { var result = m_mapper.Map <RelatedResourceContract>(relatedResource); switch (relatedResource.LatestVersion) { case PageResource pageResource: result.Sequence = pageResource.Position; break; case TrackResource trackResource: result.Sequence = trackResource.Position; break; } return(result); } return(null); }
public Resource PushVersion(Resource pushResource, Byte[] newfile, string comment, string user) { var resource = ctx.Resource.FirstOrDefault(o => o.ResourceID == pushResource.ResourceID); // Create a new Resource Version Object and populate it ResourceVersion version = new ResourceVersion(); version.ModDate = DateTime.Today; version.ModifiedBy = user; version.ResourceID = resource.ResourceID; version.RVersion = resource.CurrentVersion.GetValueOrDefault(); version.VersionComment = comment; version.Resource = newfile; ctx.ResourceVersion.Add(version); resource.CurrentVersion = version.RVersion; ctx.SaveChanges(); return(resource); }
public IList <SnapshotAggregatedInfo> GetSnapshotsResourcesCount(long[] snapshotIds) { ResourceVersion resourceVersionAlias = null; Resource resourceAlias = null; Project projectAlias = null; SnapshotAggregatedInfo contract = null; var result = GetSession().QueryOver <Snapshot>() .JoinAlias(x => x.ResourceVersions, () => resourceVersionAlias) .JoinAlias(() => resourceVersionAlias.Resource, () => resourceAlias) .JoinAlias(() => resourceAlias.Project, () => projectAlias) .Where(x => x.Id.IsIn(snapshotIds)) .And(() => projectAlias.IsRemoved == false) .SelectList(list => list.SelectGroup(x => x.Id).WithAlias(() => contract.Id) .SelectGroup(() => resourceAlias.ResourceType).WithAlias(() => contract.Type) .SelectCount(() => resourceVersionAlias.Id).WithAlias(() => contract.ResourcesCount)) .TransformUsing(Transformers.AliasToBean <SnapshotAggregatedInfo>()) .List <SnapshotAggregatedInfo>(); return(result); }
public UpdateMgr() { this.CurrentResVersion = new ResourceVersion(); }
protected override bool CheckHandlerMethodDesktopInternal(MethodDef handler) { if (CheckHandlerV3(handler)) { version = ResourceVersion.V3; return true; } simpleDeobfuscator.Deobfuscate(handler); if ((data40 = CheckHandlerV40(handler)) != null) { version = ResourceVersion.V40; return true; } var info = GetHandlerArgs41(handler); Data41 data41Tmp; if (info != null && CheckHandlerV41(info, out data41Tmp)) { version = ResourceVersion.V41; data41 = data41Tmp; return true; } return false; }