protected override void OnInit(EventArgs e) { // Sanitycheck SanityCheck(); package = VerifyAppIDViability(appID); packageTitle = package.Title; SPSINStoreUtilities.InstallPackageInWeb(package, targetWebURL); }
protected override void CreateChildControls() { SPSIN_StorePanel.Controls.Clear(); Control allPackagesControls = new Control(); //if (!string.IsNullOrEmpty(HttpContext.Current.Request["SourceURL"])) //{ try { //using (SPSite site = new SPSite(HttpContext.Current.Request["SourceURL"])) SPSite site = SPContext.Current.Site; { //using (SPWeb activationWeb = site.OpenWeb()) SPWeb activationWeb = SPContext.Current.Web; { Dictionary <Guid, StorePackage> packages = SPSINStoreUtilities.GetPackages(SPContext.Current, activationWeb); foreach (StorePackage package in packages.Values) { if (package.SolutionType == SolutionType.Farm) { allPackagesControls.Controls.Add(GetControlForFarmPackage(package, activationWeb)); } else if (package.SolutionType == SolutionType.Sandbox) { allPackagesControls.Controls.Add(GetControlForSandboxPackage(package, activationWeb)); } else if (package.SolutionType == SolutionType.App) { allPackagesControls.Controls.Add(GetControlForAppPackage(package, activationWeb)); } } } } } catch (Exception e) { // Cannot connect to web. Permissions issue? throw new SPException("Whoops! We cannot read the list of packages from the repository", e); } //} SPSIN_StorePanel.Controls.Add(allPackagesControls); }
private StorePackage VerifyAppIDViability(Guid appID) { using (SPSite site = new SPSite(targetWebURL)) { using (SPWeb activationWeb = site.OpenWeb()) { Dictionary <Guid, StorePackage> packages = SPSINStoreUtilities.GetPackages(SPContext.Current, activationWeb); if (!packages.ContainsKey(appID)) { throw new SPException(string.Format("Cannot find the app with ID {0}. Please contact the app store owner and let them know that the app ID is missing.")); } else { return(packages[appID]); } } } }