public GalleryWebAppStatus GetGalleryApplicationStatus(string id) { GalleryWebAppStatus status = GalleryWebAppStatus.NotDownloaded; // try { WebApplicationGallery module = new WebApplicationGallery(GalleryXmlFeedUrl); // GalleryApplication appObject = module.GetApplicationByProductId(id); // if (appObject == null) return GalleryWebAppStatus.Failed; // string appPackageDistr = module.GetApplicationPackagePath(appObject); // Check whether distributive exists locally if (!File.Exists(appPackageDistr)) return GalleryWebAppStatus.NotDownloaded; // Check whether distributive is in download queue if (AppPackagesDownloader.IsApplicationInDownloadQueue(id)) return GalleryWebAppStatus.Downloading; // From this point distibutive is considered as existed locally and it's not in download queue, // so lets ensure the downloaded file either is not corrupted during the download process #region Atom Feed Version 0.2 if (appObject.InstallerItems.Count > 0) { string md5CheckSum = appObject.InstallerItems[0].InstallerFile.MD5; // Check MD5 check sum of the distributive if (AppPackagesDownloader.CheckApplicationPackageHashSum_MD5(appPackageDistr, md5CheckSum)) status = GalleryWebAppStatus.Downloaded; } #endregion #region Atom Feed Version 2.0.1.0 else if (appObject.Installers.Count > 0) { string sha1CheckSum = appObject.Installers[0].InstallerFile.SHA1; // Check SHA1 check sum of the distributive if (AppPackagesDownloader.CheckApplicationPackageHashSum_SHA1(appPackageDistr, sha1CheckSum)) status = GalleryWebAppStatus.Downloaded; } #endregion // If MD5 check sum is failed then we have to resume distibutive download else status = GalleryWebAppStatus.NotDownloaded; } catch (Exception ex) { Log.WriteError(ex); // return GalleryWebAppStatus.Failed; } // return status; }
public GalleryWebAppStatus DownloadGalleryApplication(string id) { WebApplicationGallery module = new WebApplicationGallery(GalleryXmlFeedUrl); // GalleryApplication appObject = module.GetApplicationByProductId(id); if (appObject == null) return GalleryWebAppStatus.Failed; // string localAppDistr = module.GetApplicationPackagePath(appObject); // InstallerFile installerFile = null; #region Atom Feed Version 0.2 // if (appObject.InstallerItems.Count > 0) { InstallerItem installerItem_0 = appObject.InstallerItems[0]; // if (installerItem_0 == null) { Log.WriteWarning(WEB_PI_APP_PACK_ROOT_INSTALLER_ITEM_MISSING, appObject.Title); return GalleryWebAppStatus.Failed; } // installerFile = installerItem_0.InstallerFile; } #endregion #region Atom Feed Version 2.0.1.0 // if (appObject.Installers.Count > 0) { Installer installerItem_0 = appObject.Installers[0]; // if (installerItem_0 == null) { Log.WriteWarning(WEB_PI_APP_PACK_ROOT_INSTALLER_ITEM_MISSING, appObject.Title); return GalleryWebAppStatus.Failed; } // installerFile = installerItem_0.InstallerFile; } #endregion // if (installerFile == null || String.IsNullOrEmpty(installerFile.InstallerUrl)) { Log.WriteWarning(WEB_PI_APP_PACK_DISPLAY_URL_MISSING, appObject.Title); return GalleryWebAppStatus.Failed; } // try { string appCacheRoot = Path.GetDirectoryName(localAppDistr); // if (!Directory.Exists(appCacheRoot)) Directory.CreateDirectory(appCacheRoot); // Log.WriteInfo("Local distributive path: {0}", localAppDistr); AppPackagesDownloader.StartApplicationDownload(id, installerFile.InstallerUrl, localAppDistr); } catch (Exception ex) { Log.WriteError(ex); // return GalleryWebAppStatus.Failed; } // return GalleryWebAppStatus.Downloading; }
public GalleryApplicationResult GetGalleryApplication(string id) { GalleryApplicationResult result = new GalleryApplicationResult(); // try { WebApplicationGallery module = new WebApplicationGallery(GalleryXmlFeedUrl); // result.Value = module.GetApplicationByProductId(id); result.IsSuccess = true; } catch (Exception ex) { result.IsSuccess = false; result.AddError(GalleryErrors.ProcessingFeedXMLError, ex); } // return result; }