예제 #1
0
        void PublishCore <T>(OutgoingMqEnvelop <T> envelop, PublishTarget pubTarget) where T : class
        {
            if (envelop == null)
            {
                throw new ArgumentNullException(nameof(envelop));
            }

            if (string.IsNullOrEmpty(pubTarget.Routing) && string.IsNullOrEmpty(pubTarget.Exchange))
            {
                throw new InvalidOperationException($"Publishing target not defined. Payload type '{typeof(T).FullName}'");
            }

            var channel = _channelProvider.Provide();

            var basicProperties = CreateBasicProperties <T>(envelop, channel);

            var payloadStr = JsonConvert.SerializeObject(envelop.Message.Payload, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            var payloadBin = Encoding.UTF8.GetBytes(payloadStr);

            channel.BasicPublish(
                pubTarget.Exchange,
                pubTarget.Routing,
                basicProperties,
                payloadBin
                );
        }
예제 #2
0
        public static void Pack(PublishTarget target)
        {
            if (target.IsOptimzed)
            {
                Optimze();
            }


            Logger.LogInfoLine("Packing:");
            var merger = new ImageMerger();

            foreach (var imageGroup in ImageGroups)
            {
                if (imageGroup.Value.Count > 1 || PublishTarget.Current.IsPVR)
                {
                    var resultImages = merger.Generate(imageGroup.Key, imageGroup.Value);
                    foreach (var resultImage in resultImages)
                    {
                        resultImage.Key.Save();
                        resultImage.Key.TryConvertSelfToPVR();

                        uint id = FileSystemGenerator.AddFileAndTag(resultImage.Key);
                        if (id != uint.MaxValue)
                        {
                            foreach (var subImage in resultImage.Value.UsedImages)
                            {
                                FileSystemGenerator.AddImageTagItem(subImage, id);
                            }
                        }
                    }
                }
                else
                {
                    if (imageGroup.Value.Count > 0)
                    {
                        imageGroup.Value[0].IsPacked = false;
                    }
                    //FileSystemGenerator.AddFileAndTag(imageGroup.Value[0]);
                }

                OnPackingProgressEvent(1);
            }


            foreach (var image in Images)
            {
                if (!image.Key.IsPacked)
                {
                    FileSystemGenerator.CopyFileToOutput(image.Key);
                }
                else
                {
                    if (!PublishTarget.Current.IsPack)
                    {
                        Logger.LogErrorLine("Lose file:{0}", image.Key.FileInfo.FullName);
                    }
                }
            }
        }
        public async Task OnGet([FromQuery(Name = "edit")] string targetName = null)
        {
            Target         = new PublishTarget();
            PublishTargets = await _db.PublishTargets.ToArrayAsync();

            if (!string.IsNullOrEmpty(targetName) && PublishTargets.Any(x => x.Name == targetName))
            {
                Target = PublishTargets.First(x => x.Name == targetName);
            }
        }
예제 #4
0
        public static void AddImage(ImageFile imageFile, PublishTarget target, bool isPacked = true, bool isOptimzed = true, bool isPVREnabled = false, bool isPOT = false, bool isSquare = false)
        {
            if (!Images.ContainsKey(imageFile) && !ImageFilePathDict.ContainsKey(imageFile.FileInfo.FullName) && !ImageFileNameDict.ContainsKey(imageFile.FileInfo.Name))
            {
                Images.Add(imageFile, false);
                ImageFilePathDict.Add(imageFile.FileInfo.FullName, imageFile);
                ImageFileNameDict.Add(imageFile.FileInfo.Name, imageFile);
                imageFile.IsPacked     = isPacked;
                imageFile.IsOptimzed   = isOptimzed;
                imageFile.IsPVREnabled = isPVREnabled;
                imageFile.IsPOT        = isPOT;
                imageFile.IsSquare     = isSquare;
            }
            else
            {
                Logger.LogErrorLine("\tDuplicate File name: {0}\tVS\t{1}", imageFile,
                                    Images[imageFile]);
            }

            if (imageFile.PublishGroup != null && !imageFile.PublishGroup.PublishInfo.IsPublish(target))
            {
                //Logger.LogInfoLine("DON'T pack {0}", imageFile.FileInfo.Name);
                return;
            }

            if (!isPacked)
            {
                //Logger.LogInfoLine("DON'T pack {0}", imageFile.FileInfo.Name);
                return;
            }

            MySortedList <ImageFile> groupFiles;

            if (!ImageGroups.TryGetValue(imageFile.PublishGroup, out groupFiles))
            {
                groupFiles = new MySortedList <ImageFile>();
                ImageGroups.Add(imageFile.PublishGroup, groupFiles);
            }
            groupFiles.Add(imageFile);
        }
        public async Task OnPost([Bind(nameof(PublishTarget.PublishEndpoint), nameof(PublishTarget.Name), nameof(PublishTarget.ApiToken), nameof(PublishTarget.Legacy))] PublishTarget target)
        {
            Target = new PublishTarget();
            var existingTarget = await _db.PublishTargets.FirstOrDefaultAsync(x => x.Name == target.Name);

            if (existingTarget is null)
            {
                target.AddedBy = User.FindFirstValue("name");
                _db.PublishTargets.Add(target);
            }
            else
            {
                existingTarget.PublishEndpoint = target.PublishEndpoint;
                existingTarget.Legacy          = target.Legacy;
                existingTarget.ApiToken        = target.ApiToken;
                existingTarget.Timestamp       = DateTimeOffset.Now;
                _db.PublishTargets.Update(existingTarget);
            }

            await _db.SaveChangesAsync();

            PublishTargets = await _db.PublishTargets.ToArrayAsync();
        }
예제 #6
0
        private async Task <bool> PushSymbolsToSource(string packageId, NuGetVersion packageVersion, PublishTarget target)
        {
            var client = new NuGetClient(target.PublishEndpoint.ToString());

            return(await client.UploadSymbolsPackageAsync(packageId, packageVersion, target.ApiToken, _symbolStorageService));
        }
        public PublishTargetsModel(FeedContext db)
        {
            _db = db;

            Target = new PublishTarget();
        }
예제 #8
0
 AbsolutePath GetPublishSampleDir(PublishTarget publishCombination) => ArtifactsDirectory / $"sampleapp-{publishCombination.Runtime}";