private void step2StateStepcodeActivity_Initialize_ExecuteCode(object sender, EventArgs e) { try { if (this.BindingExist("EulaText") == false) { PackageDescription packageDescription = GetPackageDescription(); string eulaText = PackageSystemServices.GetEulaText(packageDescription); this.Bindings.Add("EulaText", eulaText); } if (this.BindingExist("EulaAccepted") == false) { this.Bindings.Add("EulaAccepted", false); } } catch (Exception ex) { this.UpdateBinding("Errors", new List <List <string> > { new List <string> { ex.Message, "" } }); } }
private IEnumerable <Element> GetInstalledPackagesElements(Predicate <InstalledPackageInformation> filter) { IEnumerable <InstalledPackageInformation> installedPackageInformations = from info in PackageManager.GetInstalledPackages() where filter(info) orderby info.Name select info; var serverPackagesPreviewUrls = PackageSystemServices.GetAllAvailablePackages() .Where(p => !string.IsNullOrEmpty(p.ConsoleBrowserUrl)) .GroupBy(p => p.Id) .ToDictionary(group => group.Key, group => group.First().ConsoleBrowserUrl); foreach (var installedPackageInformation in installedPackageInformations) { var element = new Element(_context.CreateElementHandle(new PackageElementProviderInstalledPackageItemEntityToken( installedPackageInformation.Id, installedPackageInformation.GroupName, installedPackageInformation.IsLocalInstalled, installedPackageInformation.CanBeUninstalled))); if (serverPackagesPreviewUrls.TryGetValue(installedPackageInformation.Id, out var previewUrl)) { element.PropertyBag.Add("BrowserUrl", previewUrl); element.PropertyBag.Add("BrowserToolingOn", "false"); } element.VisualData = new ElementVisualizedData { Label = installedPackageInformation.Name, ToolTip = installedPackageInformation.Name, HasChildren = false, Icon = GetIconForPackageItem(installedPackageInformation.Id), }; element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.ViewInstalledPackageInfoWorkflow"), ActionPermissions))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewInstalledInformationLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewInstalledInformationToolTip"), Icon = ViewInstalledInformationIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); yield return(element); } }
private IEnumerable <Element> GetInstalledPackageGroupFolderChildren(string groupName, SearchToken seachToken) { IEnumerable <InstalledPackageInformation> installedPackageInformations = from info in PackageManager.GetInstalledPackages() where info.GroupName == groupName && info.IsLocalInstalled == false orderby info.Name select info; var allServerPackages = PackageSystemServices.GetAllAvailablePackages(); foreach (InstalledPackageInformation installedPackageInformation in installedPackageInformations) { Element element = new Element(_context.CreateElementHandle(new PackageElementProviderInstalledPackageItemEntityToken( installedPackageInformation.Id, installedPackageInformation.GroupName, installedPackageInformation.IsLocalInstalled, installedPackageInformation.CanBeUninstalled))); PackageDescription serverPackageDescription = allServerPackages.Where(f => f.Id == installedPackageInformation.Id).FirstOrDefault(); if (serverPackageDescription != null && !string.IsNullOrEmpty(serverPackageDescription.ConsoleBrowserUrl)) { element.PropertyBag.Add("BrowserUrl", serverPackageDescription.ConsoleBrowserUrl); element.PropertyBag.Add("BrowserToolingOn", "false"); } element.VisualData = new ElementVisualizedData { Label = installedPackageInformation.Name, ToolTip = installedPackageInformation.Name, HasChildren = false, Icon = GetIconForPackageItem(installedPackageInformation.Id), }; element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.ViewInstalledPackageInfoWorkflow"), ActionPermissions))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewInstalledInformationLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewInstalledInformationToolTip"), Icon = ViewInstalledInformationIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); yield return(element); } }
private void viewStateCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e) { this.SetCustomToolbarDefinition(new FormDefinitionFileMarkupProvider(CustomToolbarFormPath)); if (this.BindingExist(BindingNames.PackageDescription)) { return; } var castedToken = (PackageElementProviderAvailablePackagesItemEntityToken)this.EntityToken; PackageDescription packageDescription = (from description in PackageSystemServices.GetFilteredAllAvailablePackages() where description.Id.ToString() == castedToken.Id select description).SingleOrDefault(); if (packageDescription == null) { return; } string packageSourceName = PackageSystemServices.GetPackageSourceNameByPackageId(packageDescription.Id, InstallationInformationFacade.InstallationId, UserSettings.CultureInfo); var purchasableSubscriptions = packageDescription.AvailableInSubscriptions.Where(f => f.Purchasable).ToList(); bool showTrialInformation = false; var licenses = GetSubscriptionLicenses(packageDescription.AvailableInSubscriptions); var validLicense = licenses.Where(l => !l.Expired) .OrderByDescending(l => l.ExpirationDate) .FirstOrDefault(); this.Bindings = new Dictionary <string, object> { { BindingNames.PackageDescription, packageDescription }, { BindingNames.DocumentTitle, GetDocumentTitle(packageDescription) }, { BindingNames.AddOnServerSource, packageSourceName }, { BindingNames.HasOwnPrice, packageDescription.PriceAmmount > 0 }, { BindingNames.PriceText, $"{packageDescription.PriceAmmount} {packageDescription.PriceCurrency}" }, { BindingNames.IsInPurchasableSubscriptions, purchasableSubscriptions.Any() }, { BindingNames.PurchasableSubscriptions, string.Join(", \n", purchasableSubscriptions.Select(f => f.Name)) }, { BindingNames.ShowTrialInfo, packageDescription.IsTrial&& validLicense == null }, { BindingNames.ShowSubscriptionLicense, validLicense != null }, { BindingNames.SubscriptionName, validLicense?.Name }, { BindingNames.LicenseExpirationDate, validLicense?.ExpirationDate.ToLocalTime().ToString() } }; }
private PackageDescription GetPackageDescription() { PackageElementProviderAvailablePackagesItemEntityToken castedEntityToken = (PackageElementProviderAvailablePackagesItemEntityToken)this.EntityToken; PackageDescription packageDescription = (from description in PackageSystemServices.GetFilteredAllAvailablePackages() where description.Id == castedEntityToken.PackageId select description).SingleOrDefault(); if (packageDescription == null) { this.UpdateBinding("ServerError", true); } return(packageDescription); }
private void viewStateCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e) { if (this.BindingExist("PackageDescription") == false) { PackageElementProviderAvailablePackagesItemEntityToken castedToken = (PackageElementProviderAvailablePackagesItemEntityToken)this.EntityToken; PackageDescription packageDescription = (from description in PackageSystemServices.GetFilteredAllAvailablePackages() where description.Id.ToString() == castedToken.Id select description).SingleOrDefault(); this.Bindings.Add("PackageDescription", packageDescription); if (packageDescription != null) { // Valid package names: // "Composite.Community.Versioning" // "Composite C1 3.0" string name = packageDescription.Name.Trim(); string documentTitle = name; if (name.Contains(".") && !name.EndsWith(".")) { string packageName = name.Substring(name.LastIndexOf('.') + 1); string packageNamespace = name.Substring(0, name.LastIndexOf('.')); int temp; if (!int.TryParse(packageName, out temp)) { documentTitle = "{0} ({1})".FormatWith(packageName, packageNamespace); } } this.Bindings.Add("DocumentTitle", documentTitle); this.Bindings.Add("AddOnServerSource", PackageSystemServices.GetPackageSourceNameByPackageId(packageDescription.Id, InstallationInformationFacade.InstallationId, UserSettings.CultureInfo)); this.Bindings.Add("HasOwnPrice", packageDescription.PriceAmmount > 0); this.Bindings.Add("PriceText", string.Format("{0} {1}", packageDescription.PriceAmmount, packageDescription.PriceCurrency)); this.Bindings.Add("IsInPurchasableSubscriptions", packageDescription.AvailableInSubscriptions.Any(f => f.Purchasable)); this.Bindings.Add("PurchasableSubscriptions", string.Join(", \n", packageDescription.AvailableInSubscriptions.Where(f => f.Purchasable).Select(f => f.Name))); } } this.SetCustomToolbarDefinition(new FormDefinitionFileMarkupProvider(@"\Administrative\PackageElementProviderViewAvailablePackageInformationToolbar.xml")); }
private void step3CodeActivity_DownloadAndValidate_ExecuteCode(object sender, EventArgs e) { try { PackageDescription packageDescription = GetPackageDescription(); string packageServerSource = PackageSystemServices.GetPackageSourceNameByPackageId(packageDescription.Id, InstallationInformationFacade.InstallationId, UserSettings.CultureInfo); System.IO.Stream installFileStream = PackageServerFacade.GetInstallFileStream(packageDescription.PackageFileDownloadUrl); PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(installFileStream, false, packageServerSource); this.Bindings.Add("PackageManagerInstallProcess", packageManagerInstallProcess); this.Bindings.Add("FlushOnCompletion", packageManagerInstallProcess.FlushOnCompletion); this.Bindings.Add("ReloadConsoleOnCompletion", packageManagerInstallProcess.ReloadConsoleOnCompletion); if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0) { this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(packageManagerInstallProcess.PreInstallValidationResult)); } else { List <PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate(); if (validationResult.Count > 0) { this.UpdateBinding("LayoutLabel", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallRemotePackage.ShowWarning.LayoutLabel")); this.UpdateBinding("TableCaption", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallRemotePackage.ShowWarning.InfoTableCaption")); this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(validationResult)); } else { this.UpdateBinding("Uninstallable", packageManagerInstallProcess.CanBeUninstalled == false); } } } catch (Exception ex) { this.UpdateBinding("Errors", new List <List <string> > { new List <string> { ex.Message, "" } }); } }
private IEnumerable <Element> GetAvailablePackageGroupFolderChildren(string groupName, SearchToken seachToken) { IEnumerable <PackageDescription> packageDescriptions = (from description in PackageSystemServices.GetFilteredAllAvailablePackages() where description.GroupName == groupName orderby description.Name select description); foreach (PackageDescription packageDescription in packageDescriptions) { ResourceHandle packageIcon = (packageDescription.PriceAmmount > 0 ? AvailableCommercialPackageItemIcon : AvailablePackageItemIcon); Element element = new Element(_context.CreateElementHandle(new PackageElementProviderAvailablePackagesItemEntityToken( packageDescription.Id.ToString(), packageDescription.GroupName))); element.VisualData = new ElementVisualizedData { Label = packageDescription.Name, ToolTip = packageDescription.Name, HasChildren = false, Icon = packageIcon, }; element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.ViewAvailablePackageInfoWorkflowWorkflow"), ActionPermissions))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewAvailableInformationLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewAvailableInformationToolTip"), Icon = ViewInstalledInformationIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); yield return(element); } }
private void installAddOnCodeActivity_Execute_ExecuteCode(object sender, EventArgs e) { var castedToken = (PackageElementProviderAvailablePackagesItemEntityToken)this.EntityToken; PackageDescription packageDescription = (from description in PackageSystemServices.GetFilteredAllAvailablePackages() where description.Id.ToString() == castedToken.Id select description).FirstOrDefault(); if (packageDescription != null) { #pragma warning disable 436 this.ExecuteWorklow(this.EntityToken, typeof(InstallRemotePackageWorkflow)); #pragma warning restore 436 } else { this.ShowMessage(DialogType.Message, Texts.ViewAvailableInformation_ShowError_MessageTitle, Texts.ViewAvailableInformation_ShowError_MessageMessage); } }
private IEnumerable <Element> GetAvailablePackagesFolderChildren(SearchToken seachToken) { IEnumerable <string> groupNames = (from description in PackageSystemServices.GetFilteredAllAvailablePackages() select description.GroupName).Distinct(); foreach (string groupName in groupNames.OrderBy(f => f)) { Element element = new Element(_context.CreateElementHandle(new PackageElementProviderAvailablePackagesGroupFolderEntityToken(groupName))); element.VisualData = new ElementVisualizedData { Label = groupName, ToolTip = groupName, HasChildren = true, Icon = AvailablePackagesGroupClosedIcon, OpenedIcon = AvailablePackagesGroupOpenedIcon }; yield return(element); } }
public IEnumerable <SiteUpdateInformation> GetUpdateSummaries(Guid installationId) { var basePath = PathUtil.Resolve(_location); var folder = Path.Combine(basePath, installationId.ToString()); var list = new List <SiteUpdateInformation>(); if (!Directory.Exists(folder)) { return(list); } var files = C1Directory.GetFiles(folder, "*.zip"); foreach (var f in files) { try { var fi = new C1FileInfo(f); var packageInformation = PackageSystemServices.GetPackageInformationFromZipfile(f); var changelog = ZipFileHelper.GetContentFromFile(f, "changelog.txt"); list.Add(new SiteUpdateInformation { Id = packageInformation.Id, InstallationId = installationId, FileName = fi.Name, Name = packageInformation.Name, Version = packageInformation.Version, ReleasedDate = fi.CreationTime, ChangeLog = changelog }); } catch { } } return(list); }
private void step4CodeActivity_Install_ExecuteCode(object sender, EventArgs e) { PackageDescription packageDescription = GetPackageDescription(); PackageManagerInstallProcess packageManagerInstallProcess = this.GetBinding <PackageManagerInstallProcess>("PackageManagerInstallProcess"); bool installOk = false; string packageServerUrl = null; Exception exception = null; try { packageServerUrl = PackageSystemServices.GetPackageSourceNameByPackageId(packageDescription.Id, InstallationInformationFacade.InstallationId, UserSettings.CultureInfo); List <PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install(); if (installResult.Count > 0) { this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(installResult)); } else { installOk = true; } } catch (Exception ex) { exception = ex; this.UpdateBinding("Errors", new List <List <string> > { new List <string> { ex.Message, "" } }); } try { if (installOk) { PackageServerFacade.RegisterPackageInstallationCompletion(packageServerUrl, InstallationInformationFacade.InstallationId, packageDescription.Id, UserSettings.Username, UserSettings.UserIPAddress.ToString()); } else { StringBuilder sb = new StringBuilder(); if (exception != null) { sb.Append(exception.ToString()); } else { List <List <string> > errors = this.GetBinding <List <List <string> > >("Errors"); foreach (List <string> list in errors) { sb.AppendLine(list[0]); } } PackageServerFacade.RegisterPackageInstallationFailure(packageServerUrl, InstallationInformationFacade.InstallationId, packageDescription.Id, UserSettings.Username, UserSettings.UserIPAddress.ToString(), sb.ToString()); } } catch (Exception ex) { LoggingService.LogWarning("InstallRemotePackageWorkflow", ex); } }