public void launchApplication(Credentials user, string application, string host, string farmName) { try { var validationCode = LicenseManager.CheckLicense(MacAddress); //var validationCode = LicenseValidationCode.Ok; switch (validationCode) { case LicenseValidationCode.Ok: Logger.Default.Info(LogLocation, "License has been validated successeful."); break; case LicenseValidationCode.SoonBeExpired: Logger.Default.Info(LogLocation, "License will expire at " + LicenseManager.LicenseExpirationDate); break; case LicenseValidationCode.Expired: Logger.Default.Info(LogLocation, "License expired."); break; case LicenseValidationCode.NotValid: Logger.Default.Info(LogLocation, "License is not valid."); break; } if ((validationCode != LicenseValidationCode.NotValid) && (validationCode != LicenseValidationCode.Expired)) { ApplicationItem appInfo = service.GetApplicationInfo(application, user, host, "", null, null, null, farmName); if (!string.IsNullOrEmpty(appInfo.ContentAddress)) { String address = appInfo.ContentAddress; if (address != null) { this.Page.Response.Redirect(address); } } else { string app = service.LaunchApplication(application, user, host, "", farmName); /*this.Page.Response.Clear(); * this.Page.Response.ClearContent(); * this.Page.Response.ClearHeaders(); * this.Page.Response.ContentType = "application/x-ica";*/ //this.Page.Response.AddHeader("Content-disposition", "attachment; filename=launch.ica"); /* this.Page.Response.BinaryWrite(this.Page.Response.ContentEncoding.GetBytes(app)); * this.Page.Response.End();*/ string folderPath = SPUtility.GetGenericSetupPath("ISAPI\\Extentrix"); var fileName = string.Format("{0}_{1}.ica", Regex.Replace(SPContext.Current.Web.CurrentUser.LoginName, @"[#:.\\/|]", "_"), application); var path = Path.Combine(folderPath, fileName); using (StreamWriter icaFile = new StreamWriter(new FileStream(path, FileMode.Create, FileAccess.ReadWrite))) { icaFile.Write(app); if (!string.IsNullOrEmpty(DefaultIcaFile)) { icaFile.Write(DefaultIcaFile); } icaFile.Flush(); icaFile.Close(); } this.Page.Response.Redirect("/_vti_bin/Extentrix/" + fileName); } } else { Controls.Add(Page.LoadControl(_ascxLicenseValidPath)); } } catch (ThreadAbortException) { //Do nothing } catch (Exception e) { Logger.Default.Error(LogLocation, "User - " + Page.Request.LogonUserIdentity.Name + " ; Error = " + e.Message, e); Controls.Add(Page.LoadControl(_ascxErrPath)); //Controls.Add(Page.LoadControl(_ascxPath)); } }
protected override void CreateChildControls() { Control control = null; try { var validationCode = LicenseManager.CheckLicense(MacAddress); //var validationCode = LicenseValidationCode.Ok; switch (validationCode) { case LicenseValidationCode.Ok: Logger.Default.Info(LogLocation, "License has been validated successeful."); break; case LicenseValidationCode.SoonBeExpired: Logger.Default.Info(LogLocation, "License will expire at " + LicenseManager.LicenseExpirationDate); break; case LicenseValidationCode.Expired: Logger.Default.Info(LogLocation, "License expired."); break; case LicenseValidationCode.NotValid: Logger.Default.Info(LogLocation, "License is not valid."); break; } if ((validationCode != LicenseValidationCode.NotValid) && (validationCode != LicenseValidationCode.Expired)) { //if (LogLocation == LogLocationEnum.Text) // Logger.Default.Info("License has been validated successeful."); //else // EventLogger.logEvent("License has been validated successeful.", 1); var queryString = Page.Request.QueryString; if (queryString.HasKeys() && !string.IsNullOrEmpty(queryString["EWISP"])) { if (queryString["EWISP"].ToString().Equals("hide")) { return; } } var watch = Stopwatch.StartNew(); Logger.Default.Info(LogLocation, string.Format("Start load web part={0}", DateTime.Now)); if (SPContext.Current.Web.CurrentUser != null) { service = new WebServiceAPI(); control = Page.LoadControl(_ascxPath); if (control is ExtentrixWIWebPartUserControl) { if (validationCode == LicenseValidationCode.SoonBeExpired) { ((ExtentrixWIWebPartUserControl)control).LicenseExpirationDaysLeft = LicenseManager.WarningDaysNumber.ToString(); } ((ExtentrixWIWebPartUserControl)control).MainBodyBorderWidth = MainBodyBorderWidth; Color color = ColorTranslator.FromHtml(MainBodyBorderColor); ((ExtentrixWIWebPartUserControl)control).MainBodyBorderColor = color; color = ColorTranslator.FromHtml(MainBodyBackColor); ((ExtentrixWIWebPartUserControl)control).MainBodyBackColor = color; color = ColorTranslator.FromHtml(ToolbarBackColor); ((ExtentrixWIWebPartUserControl)control).ToolBarBackColor = color; ((ExtentrixWIWebPartUserControl)control).LogLocation = LogLocation; ((ExtentrixWIWebPartUserControl)control).IsAppFilterApplied = IsAppFilterApplied; ((ExtentrixWIWebPartUserControl)control).AppFilter = AppFilter; ((ExtentrixWIWebPartUserControl)control).PrefixClientName = PrefixClientName; ((ExtentrixWIWebPartUserControl)control).IcaClientUrl = IcaClientUrl; ((ExtentrixWIWebPartUserControl)control).IcaClientVersion = IcaClientVersion; ((ExtentrixWIWebPartUserControl)control).IsUseSecureStore = UseSecureStore; ((ExtentrixWIWebPartUserControl)control).CredentialLiveTime = CredentialLiveTime; var views = new Dictionary <string, View>(); if (ShowIcons) { views.Add("0", View.Icons); } if (ShowList) { views.Add("1", View.List); } if (ShowDetails) { views.Add("5", View.Details); } if (ShowTree) { views.Add("2", View.Tree); } if (ShowFavourites) { views.Add("3", View.Favorites); } if (ShowSearch) { views.Add("4", View.Search); } ((ExtentrixWIWebPartUserControl)control).Views = views; } Controls.Add(control); } watch.Stop(); Logger.Default.Info(LogLocation, string.Format("End load web part={0}", watch.Elapsed)); } else { _isTrial = null; control = Page.LoadControl(_ascxLicenseValidPath); Controls.Add(control); } } catch (ThreadAbortException) { //Do nothing } catch (Exception e) { Logger.Default.Error(LogLocation, "User - " + Page.Request.LogonUserIdentity.Name + " ; Error = " + e.Message, e); //control = Page.LoadControl(_ascxErrPath); control = Page.LoadControl(_ascxPath); Controls.Add(control); } }