/// <summary> /// 初始化资源信息 /// </summary> private void InitAssetInfo(byte[] buffer) { buffer = ZlibHelper.DeCompressBytes(buffer); MMO_MemoryStream ms = new MMO_MemoryStream(buffer); int len = ms.ReadInt(); int depLen = 0; for (int i = 0; i < len; i++) { AssetEntity entity = new AssetEntity(); entity.Category = (AssetCategory)ms.ReadByte(); entity.AssetFullName = ms.ReadUTF8String(); entity.AssetBundleName = ms.ReadUTF8String(); depLen = ms.ReadInt(); if (depLen > 0) { entity.DependsAssetList = new List <AssetDependsEntity>(depLen); for (int j = 0; j < depLen; j++) { AssetDependsEntity assetDepends = new AssetDependsEntity(); assetDepends.Category = (AssetCategory)ms.ReadByte(); assetDepends.AssetFullName = ms.ReadUTF8String(); entity.DependsAssetList.Add(assetDepends); } } //Debug.LogError("entity.Category=" + entity.Category); //Debug.LogError("entity.AssetFullName=" + entity.AssetFullName); m_AssetInfoDic[entity.Category][entity.AssetFullName] = entity; } }
public async Task Should_load_assets_from_ids_and_resolve_tags() { var found1 = new AssetEntity { Id = Guid.NewGuid() }; var found2 = new AssetEntity { Id = Guid.NewGuid() }; var enriched1 = new AssetEntity(); var enriched2 = new AssetEntity(); var ids = HashSet.Of(found1.Id, found2.Id); A.CallTo(() => assetRepository.QueryAsync(appId.Id, A <HashSet <Guid> > .That.IsSameSequenceAs(ids))) .Returns(ResultList.CreateFrom(8, found1, found2)); A.CallTo(() => assetEnricher.EnrichAsync(A <IEnumerable <IAssetEntity> > .That.IsSameSequenceAs(found1, found2), requestContext)) .Returns(new List <IEnrichedAssetEntity> { enriched1, enriched2 }); var result = await sut.QueryAsync(requestContext, null, Q.Empty.WithIds(ids)); Assert.Equal(8, result.Total); Assert.Equal(new[] { enriched1, enriched2 }, result.ToArray()); }
public async Task Should_load_assets_with_query_and_resolve_tags() { var found1 = new AssetEntity { Id = Guid.NewGuid() }; var found2 = new AssetEntity { Id = Guid.NewGuid() }; var enriched1 = new AssetEntity(); var enriched2 = new AssetEntity(); var parentId = Guid.NewGuid(); A.CallTo(() => assetRepository.QueryAsync(appId.Id, parentId, A <ClrQuery> .Ignored)) .Returns(ResultList.CreateFrom(8, found1, found2)); A.CallTo(() => assetEnricher.EnrichAsync(A <IEnumerable <IAssetEntity> > .That.IsSameSequenceAs(found1, found2), requestContext)) .Returns(new List <IEnrichedAssetEntity> { enriched1, enriched2 }); var result = await sut.QueryAsync(requestContext, parentId, Q.Empty); Assert.Equal(8, result.Total); Assert.Equal(new[] { enriched1, enriched2 }, result.ToArray()); }
private AssetOperation Operation(string script, AssetEntity asset, AnnotateAsset command) { var scripts = new AssetScripts { Annotate = script }; var app = Mocks.App(appId); A.CallTo(() => app.AssetScripts) .Returns(scripts); var serviceProvider = new ServiceCollection() .AddMemoryCache() .AddOptions() .AddOptions <MemoryCacheOptions>().Services .AddSingleton <IScriptEngine, JintScriptEngine>() .BuildServiceProvider(); command.Actor = actor; command.User = Mocks.FrontendUser(); return(new AssetOperation(serviceProvider, () => asset) { App = app, CommandId = asset.Id, Command = command }); }
public async Task Should_enrich_asset_with_tag_names() { var source = new AssetEntity { Tags = new HashSet <string> { "id1", "id2" }, AppId = appId }; A.CallTo(() => tagService.DenormalizeTagsAsync(appId.Id, TagGroups.Assets, A <HashSet <string> > .That.Is("id1", "id2"))) .Returns(new Dictionary <string, string> { ["id1"] = "name1", ["id2"] = "name2" }); var result = await sut.EnrichAsync(source, requestContext, default); Assert.Equal(new HashSet <string> { "name1", "name2" }, result.TagNames); }
protected static IEnrichedAssetEntity CreateAsset(Guid id) { var now = SystemClock.Instance.GetCurrentInstant(); var asset = new AssetEntity { Id = id, Version = 1, Created = now, CreatedBy = new RefToken(RefTokenType.Subject, "user1"), LastModified = now, LastModifiedBy = new RefToken(RefTokenType.Subject, "user2"), FileName = "MyFile.png", Slug = "myfile.png", FileSize = 1024, FileHash = "ABC123", FileVersion = 123, MimeType = "image/png", Type = AssetType.Image, MetadataText = "metadata-text", Metadata = new AssetMetadata() .SetPixelWidth(800) .SetPixelHeight(600), TagNames = new[] { "tag1", "tag2" }.ToHashSet() }; return(asset); }
public void Call(AssetEntity param0) { func.BeginPCall(); func.PushObject(param0); func.PCall(); func.EndPCall(); }
public static IEnrichedAssetEntity Create(DomainId id) { var now = SystemClock.Instance.GetCurrentInstant(); var asset = new AssetEntity { Id = id, AppId = TestApp.DefaultId, Version = 1, Created = now, CreatedBy = RefToken.User("user1"), LastModified = now, LastModifiedBy = RefToken.Client("client1"), FileName = "MyFile.png", Slug = "myfile.png", FileSize = 1024, FileHash = "ABC123", FileVersion = 123, MimeType = "image/png", Type = AssetType.Image, MetadataText = "metadata-text", Metadata = new AssetMetadata() .SetPixelWidth(800) .SetPixelHeight(600), TagNames = new[] { "tag1", "tag2" }.ToHashSet() }; return(asset); }
public async Task SyncAssets() { var providerService = _providerFactory.GetProviderService(_configuration["ProviderEmailDomain"]); var privateHackerOneAssets = await providerService.GetAssets(true); var publicHackerOneAssets = await providerService.GetAssets(false); var assets = await _assetRepository.GetAll(); foreach (var asset in assets) { var assetList = asset.Key.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList(); var privateAsset = privateHackerOneAssets.Where(x => assetList.Contains(x.Name.Trim())).ToList(); var publicAsset = publicHackerOneAssets.Where(x => assetList.Contains(x.Name.Trim())).ToList(); bool?isPublic = !publicAsset.Any() && !privateAsset.Any() ? null : publicAsset.Any(); var newAsset = new AssetEntity { IsOnHackerOne = isPublic.HasValue, IsOnPublicProgram = isPublic.HasValue && isPublic.Value, Programs = string.Join(Const.DatabaseSeparator, publicAsset.Select(p => p.Program).Concat(privateAsset.Select(p => p.Program)).Distinct()) }; if (NeedsToUpdate(newAsset, asset)) { await _assetRepository.Update(asset); } } }
public virtual bool Init(EntityParamEffect param, BattleEntity entity, uint target, EffectEntity parent) { this.param = param; this.entity = entity; this.parent = parent; this.mTarget = target; this.scale = entity.scale; IGameObject go = GetAgent(); if (go == null) { return(false); } OnInit(go); if (asset == null) { asset = new AssetEntity(); } asset.LoadAsset(param.asset, OnAssetLoad); OnBegin(); return(true); }
/// <summary> /// 根据主键值读取记录。如果数据库不存在这条数据将返回null /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public AssetEntity GetAssetByMemId(int memid) { string sql = @"SELECT [Id],[MemId],[BalanceAMT],[AvailableIntegral],[FreezingIntegral],[FreezingAMT] FROM dbo.[Asset] WITH(NOLOCK) WHERE [MemId]=@MemId" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@MemId", DbType.Int32, memid); AssetEntity entity = new AssetEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.MemId = StringUtils.GetDbInt(reader["MemId"]); entity.BalanceAMT = StringUtils.GetDbDecimal(reader["BalanceAMT"]); entity.AvailableIntegral = StringUtils.GetDbInt(reader["AvailableIntegral"]); entity.FreezingIntegral = StringUtils.GetDbInt(reader["FreezingIntegral"]); entity.FreezingAMT = StringUtils.GetDbDecimal(reader["FreezingAMT"]); } } return(entity); }
/// <summary> /// 判断当前节点是否已存在相同的 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int ExistNum(AssetEntity entity) { ///id=0,判断总数,ID>0判断除自己之外的总数 string sql = @"Select count(1) from dbo.[Asset] WITH(NOLOCK) "; string where = "where "; if (entity.Id == 0) { } else { } sql = sql + where; DbCommand cmd = db.GetSqlStringCommand(sql); if (entity.Id > 0) { db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); } object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
public async Task getAssetsInRoomTest_CorrectId4Ass() { AssetEntity[] assetEntityArr = await apiController.getAssetsInRoom(2); AssetEntity[] expected = new AssetEntity[4]; expected[0] = new AssetEntity { id = 9, type = new AssetTypeEntity { id = 3, letter = 'm', name = "monitor" } }; expected[1] = new AssetEntity { id = 10, type = new AssetTypeEntity { id = 4, letter = 'p', name = "projektor" } }; expected[2] = new AssetEntity { id = 11, type = new AssetTypeEntity { id = 5, letter = 's', name = "stół" } }; expected[3] = new AssetEntity { id = 12, type = new AssetTypeEntity { id = 6, letter = 't', name = "tablica" } }; Assert.AreEqual(expected, assetEntityArr); }
public async Task GetReportPositions_CorrectIdRoomWithoutNulls(int ReportId, int[] assetId, int[] assetTypeId, string[] assetName, char[] assetLetter, int[] prevRoom, int[] presentRoom, string[] roomName, int[] buildingId, string[] buildingName) { ReportPositionEntity[] reportPositionEntities = await apiController.getReportPositions(ReportId); for (int i = 0; i < assetId.Length; i++) { ReportPositionEntity tempReportPositionEntity = new ReportPositionEntity(); tempReportPositionEntity.present = Convert.ToBoolean(presentRoom[i]); AssetEntity tempAssetEntity = new AssetEntity(); tempAssetEntity.id = assetId[i]; AssetTypeEntity assetType = new AssetTypeEntity(); assetType.id = assetTypeId[i]; assetType.name = assetName[i]; assetType.letter = assetLetter[i]; tempAssetEntity.type = assetType; tempReportPositionEntity.asset = tempAssetEntity; RoomEntity tempRoomEntity = new RoomEntity(); tempRoomEntity.id = prevRoom[i]; tempRoomEntity.name = roomName[i]; BuildingEntity tempBuildingEntity = new BuildingEntity(); tempBuildingEntity.id = buildingId[i]; tempBuildingEntity.name = buildingName[i]; tempRoomEntity.building = tempBuildingEntity; tempReportPositionEntity.previous_room = tempRoomEntity; Assert.AreEqual(tempReportPositionEntity, reportPositionEntities[i]); } }
public void Update(float dt) { if (m_kLoaded.Count > 0) { AssetEntity _entity = m_kLoaded.Dequeue(); _entity.OnLoaded(); } }
public async Task getAssetsInRoomTest_CorrectIdNoAss() { AssetEntity[] assetEntityArr = await apiController.getAssetsInRoom(7); AssetEntity[] expected = new AssetEntity[0]; Assert.AreEqual(expected, assetEntityArr); }
/// <summary> /// Konstuktor prototypu srodka trwalego w raporcie /// </summary> /// <param name="asset">Srodek trwaly</param> /// <param name="previous">Poprzedni pokoj srodka trwalego</param> /// <param name="present">Czy srodek trwaly powinien znajdowac sie w tym pokoju</param> public ReportPositionPrototype(AssetEntity asset, RoomEntity previous, bool present) { this.id = asset.id; if (previous != null) { this.previous = previous.id; } this.present = present; }
public static VideoUploadResponse CreateInstanceFromAsset(AssetEntity assetEntity) { return(new VideoUploadResponse { VideoId = assetEntity.Id.ToString(), FileName = assetEntity.FileName, StreamingUrl = assetEntity.StreamingUrl.FirstOrDefault()?.Url }); }
/// <summary> /// 取消资源加载监听 /// </summary> /// <param name="_type">资源类型</param> /// <param name="_path">资源路径</param> /// <param name="call">要取消的回调函数</param> public void RemoveAsyncCallback(EAssetType assetType, string _path, DAssetsCallback call) { string _name = GetRelativePath(_path, assetType); AssetEntity _entity = null; if (m_kAssets.TryGetValue(_name, out _entity)) { _entity.RemoveListener(call); } }
/// <summary> /// 重置 /// </summary> private void Reset() { m_OnComplete = null; m_CurrAssetEntity = null; m_CurrResourceEntity = null; m_NeedLoadAssetDependCount = 0; m_CurrLoadAssetDependCount = 0; m_DependsResourceList.Clear(); GameEntry.Pool.EnqueueClassObject(this); }
public async Task Should_not_enrich_if_asset_contains_null_tags() { var source = new AssetEntity { AppId = appId }; var result = await sut.EnrichAsync(source, requestContext, default); Assert.Empty(result.TagNames); }
public async Task InsertAsync(AssetEntity asset) { bool isRepeatName = await _assetRepo.Select.AnyAsync(r => r.Name == asset.Name); if (isRepeatName)//资产名重复 { throw new KnownException("资产名称重复,请重新输入", ServiceResultCode.RepeatField); } await _assetRepo.InsertAsync(asset); }
public async Task Should_throw_exception_if_state_has_other_version() { var content = new AssetEntity { Version = 5 }; A.CallTo(() => grain.GetStateAsync(10)) .Returns(J.Of <IAssetEntity>(content)); await Assert.ThrowsAsync <DomainObjectNotFoundException>(() => sut.GetAsync(appId, id, 10)); }
public async Task Should_return_null_if_state_has_other_version() { var content = new AssetEntity { Version = 5 }; A.CallTo(() => grain.GetStateAsync(10)) .Returns(J.Of <IAssetEntity>(content)); Assert.Null(await sut.GetAsync(appId, id, 10)); }
public async Task Should_enrich_with_cache_dependencies() { var source = new AssetEntity { AppId = appId, Id = DomainId.NewGuid(), Version = 13 }; var result = await sut.EnrichAsync(source, requestContext, default); A.CallTo(() => requestCache.AddDependency(result.UniqueId, result.Version)) .MustHaveHappened(); }
private void OnPressedAtlasLoaded(AssetEntity _asset) { pressedSpriteInfo.atlas = _asset.GetInstantiate() as UIAtlas; if (pressedSpriteInfo.atlas != null) { newSpriteState.pressedSprite = pressedSpriteInfo.atlas.GetSpriteByName(pressedSpriteInfo.spriteName); } else { } }
public async Task UpdateAsync(AssetEntity asset) { var exist = await _assetRepo.Select.AnyAsync(s => s.Id == asset.Id && !s.IsDeleted); if (!exist) { throw new KnownException("没有找到该资产分类信息", ServiceResultCode.NotFound); } Expression <Func <AssetEntity, object> > ignoreExp = e => new { e.CreateUserId, e.CreateTime }; await _assetRepo.UpdateWithIgnoreAsync(asset, ignoreExp); }
public override async Task <AddAssetModel> Handle(AddAssetCommand command) { DeviceType deviceType = deviceTypeDataService.GetById(command.Model.DeviceTypeId); AssetEntity asset = await AddAsset(command, deviceType); return(new AddAssetModel { Id = asset.Id }); }
private void OnHighlightedAtlasLoaded(AssetEntity _asset) { highlightedSpriteInfo.atlas = _asset.GetInstantiate() as UIAtlas; if (highlightedSpriteInfo.atlas != null) { newSpriteState.highlightedSprite = highlightedSpriteInfo.atlas.GetSpriteByName(highlightedSpriteInfo.spriteName); } else { } }
private void OnDisableAtlasLoaded(AssetEntity _asset) { disabledSpriteInfo.atlas = _asset.GetInstantiate() as UIAtlas; if (disabledSpriteInfo.atlas != null) { newSpriteState.disabledSprite = disabledSpriteInfo.atlas.GetSpriteByName(disabledSpriteInfo.spriteName); } else { } }