Пример #1
0
        public void Delete(GraphicAsset graphic)
        {
            var updateGraphic = context.FirstOrDefault(x => x.Id == graphic.Id);

            if (updateGraphic != default(GraphicAsset))
            {
                updateGraphic.AssetInfo.IsAvailable = false;
            }
        }
Пример #2
0
 public GraphicAsset Create(GraphicAsset graphic)
 {
     context.Add(graphic);
     foreach (var resoGraphic in graphic.Graphics)
     {
         _warehouseUploader.Upload2Warehouse(graphic.Id, resoGraphic.GraphicPath, resoGraphic.Resolution);
     }
     return(graphic);
 }
Пример #3
0
        public GraphicAsset Update(GraphicAsset graphic)
        {
            var updateGraphic = context.FirstOrDefault(x => x.Id == graphic.Id);

            if (updateGraphic == default(GraphicAsset))
            {
                context.Add(graphic);
            }
            else
            {
                updateGraphic = graphic;
            }
            return(graphic);
        }
Пример #4
0
        public void ConvertResolution_GenerateAllResoluationGrapics_GetThreeResolutionGraphics()
        {
            var sourceData = new GraphicAsset()
            {
                SourceFilePath = _sourcePath
            };
            var    entity      = new GraphicAssetEntity(sourceData, _repoMock.Object);
            var    convertMock = new Mock <IResulotionConverter>();
            string newResoFile = "bbb.bb.temp";

            convertMock.Setup(x => x.ConvertGraphicSource(It.Is <string>(s => s.Equals(_sourcePath)), It.IsAny <Resolution>())).Returns(newResoFile);

            entity.ConvertResolution(convertMock.Object);

            Assert.That(sourceData.Graphics.Count, Is.EqualTo(3));
            Assert.That(sourceData.Graphics[0].GraphicPath, Is.EqualTo(newResoFile));
        }
Пример #5
0
        public void ConvertResolution_GenerateHighResoIsNull_GetTwoResolutionGraphics()
        {
            var sourceData = new GraphicAsset()
            {
                SourceFilePath = _sourcePath
            };
            var    entity      = new GraphicAssetEntity(sourceData, _repoMock.Object);
            var    convertMock = new Mock <IResulotionConverter>();
            string newResoFile = "bbb.bb.temp";

            convertMock.Setup(x => x.ConvertGraphicSource(It.Is <string>(s => s.Equals(_sourcePath)), It.IsAny <Resolution>())).Returns(newResoFile);
            convertMock.Setup(x => x.ConvertGraphicSource(It.Is <string>(s => s.Equals(_sourcePath)), It.Is <Resolution>(re => re.Equals(Resolution.HighReso)))).Returns("");

            entity.ConvertResolution(convertMock.Object);

            Assert.That(sourceData.Graphics.Count, Is.EqualTo(2));
            Assert.That(sourceData.Graphics.FirstOrDefault(x => x.Resolution == Resolution.HighReso), Is.EqualTo(null));
        }
Пример #6
0
        public async Task <ResponseBase> ReleaseVedioAsyncSampleConvter(ReleaseVedioRequest request)
        {
            string strTag = "ReleaseVedio";
            var    guid   = HttpContext.Items["x-guid"];

            HttpContext.Items["x-str-tag"] = strTag;

            _logger.LogInformation($"[{guid}] {strTag} Request : name= {request.Name}");

            var filePath = Path.Combine(_baseFolder, $"{guid.ToString()}.temp");

            using (var stream = new FileStream(filePath, FileMode.OpenOrCreate))
            {
                await request.Vedio.CopyToAsync(stream);
            }

            var serviceMetadata = Mapper.Map <AssetMetadata>(request);
            var serviceRequest  = new GraphicAsset()
            {
                AssetInfo = serviceMetadata
            };

            serviceRequest.SourceFilePath = filePath;
            serviceRequest.UploadTime     = DateTime.Now;
            var converter = new SimpleResulotionConverter(_configuration, _env);

            var result = new ResponseBase();

            var releaseResult = _service.ReleaseAsset(serviceRequest, converter);

            if (releaseResult.Result)
            {
                result.ReturnCode = "00";
            }
            else
            {
                result.ReturnCode = "99";
            }

            _logger.LogInformation($"[{guid}] {strTag} Response : {JsonConvert.SerializeObject(result)}");

            return(result);
        }
Пример #7
0
 public GraphicAssetEntity(GraphicAsset graphicAsset, IGraphicAssetRepository graphicAssetRepository)
 {
     _graphicAsset           = graphicAsset;
     _graphicAssetRepository = graphicAssetRepository;
 }