private void WriteFileToResponse(string filePath, HttpContext context, AppDataContract app) { const string sampleETag = "\"SampleETag\""; byte[] buffer = new byte[4096]; using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { var fullContentLength = fileStream.Length; var offset = 0; var contentLength = fullContentLength; // Check if we have a request for partial content (resume scenarios). if (string.CompareOrdinal(sampleETag, context.Request.Headers["If-Range"]) == 0) { GetRange(context.Request.Headers["Range"], fullContentLength, out offset, out contentLength); } if (offset > 0) { // Resume Download context.Response.StatusCode = (int)HttpStatusCode.PartialContent;; context.Response.Headers["Content-Range"] = string.Format(System.Globalization.CultureInfo.InvariantCulture, "bytes {0}-{1}/{2}", offset, offset + contentLength - 1, fullContentLength); } else { // Start Download context.Response.StatusCode = (int)HttpStatusCode.OK; } context.Response.ContentType = "application/octet-stream"; context.Response.Headers["Content-Length"] = contentLength.ToString(System.Globalization.CultureInfo.InvariantCulture); context.Response.Headers["Accept-Ranges"] = "bytes"; context.Response.Headers["ETag"] = sampleETag; context.Response.Buffer = false; var transferLength = contentLength; if (offset > 0) { fileStream.Seek(offset, SeekOrigin.Begin); } while (transferLength > 0) { //Thread.Sleep(50); // For Debug fileStream.Read(buffer, 0, buffer.Length); var sendLength = (int)Math.Min(transferLength, buffer.Length); context.Response.OutputStream.Write(buffer, 0, sendLength); transferLength -= sendLength; } AppDomainService.IncrementAppLatestVersionDownloads(app.Guid); } }
public async static Task <App> ToAppAsync(this AppDataContract appDataContract) { return(new App() { Id = appDataContract.Id, AppCategoryId = appDataContract.AppCategory.Id, Description = appDataContract.Description, IconBytes = await appDataContract.Icon128X128.AsBitmapImageAsync(), Name = appDataContract.Name, Title = appDataContract.Name, }); }
public static App ToApp(this AppDataContract appDataContract) { return(new App() { Id = appDataContract.Id, Guid = appDataContract.Guid, Name = appDataContract.Name, Description = appDataContract.Description, DeveloperId = appDataContract.DeveloperId, Icon128X128 = appDataContract.Icon128X128 }); }
public static StoreApp GetStoreApp(this AppDataContract dataContract) { return(new StoreApp() { AppCategory = dataContract.AppCategory?.GetAppCategory(), Description = dataContract.Description, DeveloperId = dataContract.DeveloperId, DeveloperName = dataContract.DeveloperName, Icon128x128Bytes = dataContract.Icon128X128, Icon256x256Bytes = dataContract.Icon256X256, Id = dataContract.Id, Guid = dataContract.Guid, Name = dataContract.Name, Price = dataContract.Price, LatestVersion = dataContract.LatestVersion?.GetAppVersion(), NumberOfMobileScreenshots = dataContract.NumberOfMobileScreenshots }); }
public static AppDataContract ToAppDataContract(this App app) { var dataContract = new AppDataContract() { Id = app.Id, Guid = app.Guid, Description = app.Description, Icon128X128 = app.Icon128X128, Name = app.Name, DeveloperId = app.DeveloperId, AppCategory = app.AppCategory?.ToAppCategoryDataContract(), NumberOfMobileScreenshots = app.Screenshots.Where(ss => ss.Type == ScreenshotType.Mobile).Count() }; if (app.Developer is NaturalPerson) { dataContract.DeveloperName = (app.Developer as NaturalPerson).FullName; } if (app.Developer is LegalPerson) { dataContract.DeveloperName = (app.Developer as LegalPerson).Name; } return(dataContract); }
public Task RegisterAppAsync(AppDataContract appDataContract) { throw new NotImplementedException(); }
public void RegisterApp(AppDataContract appDataContract) { AppDomainService.RegisterApp(appDataContract); }
private string GetAppPackagePath(AppDataContract app) { return($"{_appsDirectoryPath}\\{app.Guid}\\arm.pstl"); }
public void RegisterApp(AppDataContract appDataContract) { AppBiz.Create(appDataContract.ToApp()); _context.SaveChanges(); }