private static void InstallApplication(HttpContext context) { String strApp = context.Request["app"]; if (strApp == null) { context.Response.Write("No app name"); } else { if (MyWeb.GetApplication(strApp) != null) { context.Response.Write("App already exists"); } else { MyWebManifest manifest = MyWeb.GetManifest(strApp); if (manifest == null) { context.Response.Write("Manifest not found"); } else { if (manifest.Install() != null) { context.Response.Write("Installed successfully"); } else { context.Response.Write("Couldnt install"); } } } } }
private static void UpdateApplication(HttpContext context) { String strApp = context.Request["app"]; if (strApp == null) { context.Response.Write("No app name"); return; } MyWebApplication app = MyWeb.GetApplication(strApp); if (app == null) { context.Response.Write("App not found"); return; } MyWebManifest manifest = MyWeb.GetManifest(strApp); if (manifest == null) { context.Response.Write("manifest not found"); return; } String strC = context.Request["confirmed"]; if (strC == null || strC.Equals("y") == false) { context.Response.Write("Current installed version: " + app.Manifest.Version); context.Response.Write("<p>Version on server: " + manifest.Version); if (!manifest.Version.Equals(app.Manifest.Version)) { context.Response.Write("<a href=\"myweb://Home/myweb.axd?Action=update&app=" + strApp + "&confirmed=y\"/> Update now (recommended) </a>"); } else { context.Response.Write("<a href=\"myweb://Home/myweb.axd?Action=update&app=" + strApp + "&confirmed=y\"/> Update now (not-recommended) </a>"); } } else { app.Remove(); if (manifest.Install() != null) { context.Response.Write("Successfully updated"); } else { context.Response.Write("couldnt update: app has been removed"); } } }
/// <include file='doc\install.uex' path='docs/doc[@for="installPage.Install"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Install(Object sender, EventArgs e) { MyWebManifest manifest = MyWeb.GetManifest(HiddenUrl.Value); if (manifest == null) { Response.Redirect("myweb://Home/myweb1.aspx?success=no"); } else { if (manifest.Install() == null) { Response.Redirect("myweb://Home/myweb1.aspx?success=no"); } else { Response.Redirect("myweb://Home/myweb1.aspx?success=yes&URL=" + HiddenUrl.Value); } } }
/// <include file='doc\update.uex' path='docs/doc[@for="updatePage.Page_Load"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { String appurl = Request.QueryString["url"]; MyWebApplication app = MyWeb.GetApplication(appurl); //checking if local if (app.LocalApplication) { Response.Redirect("myweb://Home/myweb2.aspx?success=local"); } else if (app != null && appurl != null && appurl.Length > 0) { UrlHidden.Value = appurl; AppName.Text = (app.Manifest.Name.Length > 0) ? (app.Manifest.Name):"the Local Application selected";; String oldVersion = app.Manifest.Version; oldVersion = oldVersion.ToLower(CultureInfo.InvariantCulture); MyWebManifest newManifest = MyWeb.GetManifest(appurl); if (newManifest == null) { Response.Redirect("myweb://Home/myweb2.aspx?success=notfound"); } else { String newVersion = newManifest.Version; newVersion = newVersion.ToLower(CultureInfo.InvariantCulture); if (!oldVersion.Equals(newVersion)) { update = true; NewVersion.Text = newVersion; OldVersion.Text = oldVersion; } } } } }
/// <include file='doc\install.uex' path='docs/doc[@for="installPage.Page_Load"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { String NoURL = Request["NoURL"]; if (NoURL == "1") { HiddenUrl.Value = Request["LocalPath"]; addlocal = true; manifest = MyWeb.GetManifestForLocalApplication(HiddenUrl.Value); localInstall.Text = "<center><p>A local application is being installed. A URL must be entered for each local application.<br> Enter the URL for this application below: </p></center>"; } else if (NoURL == "2") { HiddenUrl.Value = Request["LocalPath"]; addlocal = true; manifest = MyWeb.GetManifestForLocalApplication(HiddenUrl.Value); localInstall.Text = "<center><p>The URL entered already exists. Please enter a different URL.</p></center>"; } else if (NoURL == "3") { String SpecChar = Request["SpecChar"]; HiddenUrl.Value = Request["LocalPath"]; addlocal = true; manifest = MyWeb.GetManifestForLocalApplication(HiddenUrl.Value); localInstall.Text = "<center><p>The URL entered contains the following special character:<b>'" + SpecChar + "'</b><br> Please omit this character from the URL.</p></center>"; UrlText.Text = Request["localURL"]; } else { bool fShowInstall = true; int iAction = 0; String appurl = Request["installurl"]; if (appurl == null) { appurl = Request["MyWebPage"]; } if (appurl != null && appurl.Length > 0) { app = MyWeb.GetApplication(appurl); if (app != null) { iAction = 1; fShowInstall = true; } else { if (appurl.StartsWith("\\\\") && (appurl.LastIndexOf('\\') < 2)) { addlocal = true; } else if ((appurl[1] == ':') && (appurl.Length == 2)) { fShowInstall = true; iAction = 4; } else if (appurl[1] == ':' && appurl[2] != '/') { if (Directory.Exists(appurl)) { addlocal = true; } else { if (File.Exists(appurl)) { addlocal = true; int slash = appurl.LastIndexOf('\\'); appurl = appurl.Substring(0, slash); } else { //directory is not valid fShowInstall = true; iAction = 4; } } } if (addlocal) { manifest = MyWeb.GetManifestForLocalApplication(appurl); //checking if the manifest exists if (manifest.Url != null && manifest.Url.Length > 0) { if (!(FindSpecialChar(manifest.Url) == "a")) { Response.Redirect("myweb://Home/myweb1.aspx?success=specialChar&SpecChar=" + FindSpecialChar(manifest.Url) + "&Path=" + appurl); } else { HiddenUrl.Value = appurl; fShowInstall = false; String temp = appurl.Replace('\\', '/'); UrlText.Text = "localhost/" + temp.Substring(3); localInstall.Text = "<center><p>A local path has been detected. A URL must be entered for each local application.<br> Below is the suggested URL. You may choose to edit it or leave it unmodified.</p></center>"; } } else { if (File.Exists(appurl + "\\default.aspx")) { HiddenUrl.Value = appurl; fShowInstall = false; String temp = appurl.Replace('\\', '/'); UrlText.Text = "localhost/" + temp.Substring(3); localInstall.Text = "<center><p>A local path has been detected. A URL must be entered for each local application.<br> Below is the suggested URL. You may choose to edit it or leave it unmodified.</p></center>"; } else { fShowInstall = true; iAction = 3; } } if (!fShowInstall) { //if the app exists, checking that local application has not been already installed MyWebApplication [] apps = MyWeb.GetInstalledApplications(); if (apps != null) { for (int i = 0; i < apps.Length; i++) { if (apps[i].LocalApplication) { String Oldtemp = apps[i].Manifest.InstalledLocation.ToLower(CultureInfo.InvariantCulture); String Newtemp = appurl.ToLower(CultureInfo.InvariantCulture); if (Oldtemp.EndsWith("\\") && !Newtemp.EndsWith("\\")) { Newtemp = Newtemp + "\\"; } else if (Newtemp.EndsWith("\\") && !Oldtemp.EndsWith("\\")) { Oldtemp = Oldtemp + "\\"; } if (Oldtemp.Equals(Newtemp)) { iAction = 1; fShowInstall = true; } } } } } } if ((!addlocal) && (iAction != 3) && (iAction != 4)) { manifest = MyWeb.GetManifest(appurl); if (manifest != null) { if (!(FindSpecialChar(manifest.Url) == "a")) { Response.Redirect("myweb://Home/myweb1.aspx?success=specialChar&SpecChar=" + FindSpecialChar(manifest.Url) + "&Path=" + appurl); } else { HiddenUrl.Value = appurl; fShowInstall = false; // populate the details } } else { iAction = 2; } } } } if (fShowInstall) { String strRedirect = "myweb://Home/addlocal.aspx?Reason=" + iAction; if (appurl != null && appurl.Length > 0) { strRedirect += "&installurl=" + appurl; } Response.Redirect(strRedirect); return; } if (manifest.Url != null && manifest.Url.Length > 0) { DataBind(); } } } }
/// <include file='doc\sync.uex' path='docs/doc[@for="syncPage.Page_Load"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { MyWebApplication [] apps = MyWeb.GetInstalledApplications(); ArrayList appsNotFound = new ArrayList(); if (apps == null) { SyncLabel.Text = "There are no applications to be updated."; update = false; } else { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("Application", typeof(string))); dt.Columns.Add(new DataColumn("InstalledVersion", typeof(string))); dt.Columns.Add(new DataColumn("NewVersion", typeof(string))); for (int i = 0; i < apps.Length; i++) { if (!apps[i].LocalApplication) { String oldVersion = apps[i].Manifest.Version; oldVersion = oldVersion.ToLower(CultureInfo.InvariantCulture); MyWebManifest newManifest = MyWeb.GetManifest(apps[i].Manifest.ApplicationUrl); if (newManifest == null) { appsNotFound.Add(apps[i].Manifest.Name); } else { String newVersion = newManifest.Version; if (newManifest.Version.Length <= 0 && newManifest.Version == null) { appsNotFound.Add(apps[i].Manifest.Name); } else { newVersion = newVersion.ToLower(CultureInfo.InvariantCulture); if (!oldVersion.Equals(newVersion)) { dr = dt.NewRow(); dr[0] = apps[i].Manifest.Name; dr[1] = apps[i].Manifest.Version; dr[2] = newManifest.Version; dt.Rows.Add(dr); appsForUpdate.Add(apps[i]); } } } } } if (appsForUpdate.Count <= 0) { SyncLabel.Text = "None of the installed applications are eligible for update."; update = false; } else { UpdateDataList.DataSource = new DataView(dt); UpdateDataList.DataBind(); update = true; SyncLabel.Text = "The following applications are eligible for update. Deselect the applications you do not wish to update."; Application["appsForUpdate"] = appsForUpdate; } } } }