Exemple #1
0
        public async Task <IHttpActionResult> Upload()
        {
            try
            {
                Trace.TraceInformation(LoggerHelper.FormatMessage(this.RequestContext, "Starting update package upload"));
                string reqString = HttpContext.Current.Request.Form["Model"];
                CreateUpdatePackageRequest request      = JsonConvert.DeserializeObject <CreateUpdatePackageRequest>(reqString);
                HttpPostedFile             uploadedFile = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null;
                if (uploadedFile != null && uploadedFile.ContentLength > 0)
                {
                    Program program = await this.work.Programs.GetByTelemetryKey(request.TelemetryKey).ConfigureAwait(false);

                    ProgramUpdatePackageInfo pkg = await this.work.UpdatePackages.StorePackageAsync(program, uploadedFile.FileName, uploadedFile.InputStream
                                                                                                    , request.ToolkitVersionUsed, request.IsBeta, request.ReleaseNotes, this.fileSaver).ConfigureAwait(false);

                    await this.work.CompleteAsync().ConfigureAwait(false);

#pragma warning disable 618
                    return(this.Ok(pkg.Id));

#pragma warning restore 618
                }

                return(this.BadRequest("Empty attachment"));
            }
            catch (Exception ex)
            {
                return(this.BadRequest(ex.Message));
            }
        }
Exemple #2
0
        public async Task <IHttpActionResult> SetReleaseNotes(Guid packageId, ReleaseNotesRequest request)
        {
            ProgramUpdatePackageInfo pkg = await this.work.UpdatePackages.FirstOrDefaultAsync(x => x.PublicId == packageId).ConfigureAwait(false);

            Trace.TraceInformation(LoggerHelper.FormatMessage(this.RequestContext, $"Setting release notes on package {pkg.Id}"));

            pkg.ReleaseNotes = request.Notes;
            await this.work.CompleteAsync().ConfigureAwait(false);

            return(this.Ok(""));
        }
Exemple #3
0
        public async Task <bool> ToggleBetaSetting(Guid packageId, bool isBeta)
        {
            ProgramUpdatePackageInfo pkg = await this.work.UpdatePackages.FirstOrDefaultAsync(x => x.PublicId == packageId).ConfigureAwait(false);

            Trace.TraceInformation(LoggerHelper.FormatMessage(this.RequestContext, $"Setting IsBeta on package {packageId} to {isBeta}"));
            pkg.IsBeta = isBeta;

            await this.work.CompleteAsync().ConfigureAwait(false);

            pkg = await this.work.UpdatePackages.FirstOrDefaultAsync(x => x.PublicId == packageId).ConfigureAwait(false);

            if (pkg.IsBeta != isBeta)
            {
                throw new InvalidOperationException($"Error occurred while setting package 'beta' status to {isBeta}. Value was not saved correctly.");
            }

            Trace.TraceInformation(LoggerHelper.FormatMessage(this.RequestContext, $"Successfully set IsBeta on package {packageId} to {pkg.IsBeta}"));

            return(pkg.IsBeta);
        }