コード例 #1
0
        private void uninstallCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var castedToken = (PackageElementProviderInstalledPackageItemEntityToken)this.EntityToken;

            InstalledPackageInformation installedAddOnInformation =
                (from info in PackageManager.GetInstalledPackages()
                 where info.Id == castedToken.PackageId
                 select info).FirstOrDefault();

            if (installedAddOnInformation != null)
            {
                if (installedAddOnInformation.IsLocalInstalled)
                {
                    this.ExecuteWorklow(this.EntityToken, typeof(UninstallLocalPackageWorkflow));
                }
                else
                {
                    this.ExecuteWorklow(this.EntityToken, typeof(UninstallRemotePackageWorkflow));
                }
            }
            else
            {
                this.ShowMessage(
                    DialogType.Message,
                    "${Composite.Plugins.PackageElementProvider, ViewInstalledInformation.ShowError.MessageTitle}",
                    "${Composite.Plugins.PackageElementProvider, ViewInstalledInformation.ShowError.MessageMessage}");
            }
        }
コード例 #2
0
        private void step5CodeActivity_RefreshTree_ExecuteCode(object sender, EventArgs e)
        {
            if (this.GetBinding <bool>("ReloadConsoleOnCompletion"))
            {
                ConsoleMessageQueueFacade.Enqueue(new RebootConsoleMessageQueueItem(), null);
            }

            if (this.GetBinding <bool>("FlushOnCompletion"))
            {
                GlobalEventSystemFacade.FlushTheSystem();
            }

            SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();

            specificTreeRefresher.PostRefreshMesseges(new PackageElementProviderRootEntityToken());

            if (this.GetBinding <bool>("ReloadConsoleOnCompletion") == false)
            {
                PackageElementProviderAvailablePackagesItemEntityToken castedEntityToken = (PackageElementProviderAvailablePackagesItemEntityToken)this.EntityToken;

                InstalledPackageInformation installedPackage = PackageManager.GetInstalledPackages().FirstOrDefault(f => f.Id == castedEntityToken.PackageId);

                var installedPackageEntityToken = new PackageElementProviderInstalledPackageItemEntityToken(
                    installedPackage.Id,
                    installedPackage.GroupName,
                    installedPackage.IsLocalInstalled,
                    installedPackage.CanBeUninstalled);

                ExecuteWorklow(installedPackageEntityToken, WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.ViewInstalledPackageInfoWorkflow"));
            }
        }
コード例 #3
0
        /// <summary>
        /// </summary>
        /// <param name="packageId"></param>
        /// <param name="groupName"></param>
        /// <returns></returns>
        public virtual PackageElementProviderInstalledPackageItemEntityToken GetInstalledPackageEntityToken(Guid packageId, string groupName)
        {
            PackageElementProviderAvailablePackagesItemEntityToken castedEntityToken = new PackageElementProviderAvailablePackagesItemEntityToken(packageId.ToString(), groupName);
            InstalledPackageInformation installedPackage = PackageManager.GetInstalledPackages().FirstOrDefault(f => f.Id == castedEntityToken.PackageId);
            PackageElementProviderInstalledPackageItemEntityToken installedPackageEntityToken = new PackageElementProviderInstalledPackageItemEntityToken(
                installedPackage.Id,
                installedPackage.GroupName,
                installedPackage.IsLocalInstalled,
                installedPackage.CanBeUninstalled);

            return(installedPackageEntityToken);
        }
コード例 #4
0
        private void viewStateCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e)
        {
            var  castedToken = (PackageElementProviderInstalledPackageItemEntityToken)this.EntityToken;
            Guid packageId   = castedToken.PackageId;

            if (castedToken.CanBeUninstalled)
            {
                this.SetCustomToolbarDefinition(new FormDefinitionFileMarkupProvider(CustomToolbarDefinitionPath));
            }

            if (this.BindingExist(BindingNames.InstalledPackageInformation))
            {
                return;
            }

            InstalledPackageInformation installedAddOnInformation =
                PackageManager.GetInstalledPackages().Single(info => info.Id == packageId);

            string   name             = installedAddOnInformation.Name;
            string   documentTitle    = GetDocumentTitle(name);
            DateTime installationDate = installedAddOnInformation.InstallDate.ToLocalTime();

            this.Bindings = new Dictionary <string, object>
            {
                { BindingNames.DocumentTitle, documentTitle },
                { BindingNames.InstalledPackageInformation, installedAddOnInformation },
                { BindingNames.InstallDate, installationDate.ToString() }
            };

            PackageDescription packageDescription = null;

            try
            {
                var allPackages = PackageServerFacade.GetAllPackageDescriptions(InstallationInformationFacade.InstallationId, UserSettings.CultureInfo);

                packageDescription = allPackages.FirstOrDefault(p => p.Id == packageId);
            }
            catch
            {
            }

            if (!string.IsNullOrEmpty(packageDescription?.ReadMoreUrl))
            {
                this.Bindings[BindingNames.ReadMoreUrl] = packageDescription.ReadMoreUrl;
            }

            var licenses      = GetRelatedLicenses(packageId, packageDescription);
            var actualLicense = licenses.OrderBy(l => l.HasExpired).ThenByDescending(l => l.IsSubscription).FirstOrDefault();

            if (actualLicense != null)
            {
                Bindings[BindingNames.LicenseExpirationDate] = actualLicense.ExpirationDate.ToLocalTime().ToString();
            }

            bool isTrial = actualLicense != null && actualLicense.IsTrial;

            this.Bindings[BindingNames.IsTrial] = isTrial;


            bool showPurchaseButton = false;

            if (isTrial && !string.IsNullOrWhiteSpace(actualLicense.PurchaseUrl))
            {
                string url = actualLicense.PurchaseUrl;
                this.Bindings[BindingNames.TrialPurchaseUrl] = url;

                showPurchaseButton = true;
            }
            this.Bindings[BindingNames.ShowPurchaseThisButton] = showPurchaseButton;

            bool isSubscription = actualLicense != null && actualLicense.IsSubscription;

            this.Bindings[BindingNames.IsSubscription] = isSubscription;
            if (isSubscription)
            {
                Bindings[BindingNames.SubscriptionName] = actualLicense.Name;
            }
        }
コード例 #5
0
        private void viewStateCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e)
        {
            var castedToken = (PackageElementProviderInstalledPackageItemEntityToken)this.EntityToken;

            if (!this.BindingExist("InstalledPackageInformation"))
            {
                InstalledPackageInformation installedAddOnInformation =
                    (from info in PackageManager.GetInstalledPackages()
                     where info.Id == castedToken.PackageId
                     select info).Single();

                string name          = installedAddOnInformation.Name;
                string documentTitle = (name.Contains('.') && !name.EndsWith(".") ?
                                        string.Format("{0} ({1})", name.Substring(name.LastIndexOf('.') + 1), name.Substring(0, name.LastIndexOf('.'))) :
                                        name);

                this.Bindings.Add("DocumentTitle", documentTitle);
                this.Bindings.Add("InstalledPackageInformation", installedAddOnInformation);
                this.Bindings.Add("InstallDate", installedAddOnInformation.InstallDate.ToLocalTime().ToString());

                PackageLicenseDefinition licenseInfo = PackageLicenseHelper.GetLicenseDefinition(installedAddOnInformation.Id);
                bool isTrial = (licenseInfo != null && !licenseInfo.Permanent);
                this.Bindings.Add("IsTrial", isTrial);

                this.Bindings.Add("ShowPurchaseThisButton", isTrial && !string.IsNullOrWhiteSpace(licenseInfo.PurchaseUrl));

                PackageDescription packageDescription = null;
                try
                {
                    Guid packageId = new Guid(castedToken.Id);

                    var allPackages = PackageServerFacade.GetAllPackageDescriptions(InstallationInformationFacade.InstallationId,
                                                                                    UserSettings.CultureInfo);

                    packageDescription = allPackages.FirstOrDefault(p => p.Id == packageId);
                }
                catch
                {
                }

                if (packageDescription != null && !string.IsNullOrEmpty(packageDescription.ReadMoreUrl))
                {
                    this.Bindings.Add("ReadMoreUrl", packageDescription.ReadMoreUrl);
                }

                if (isTrial)
                {
                    this.Bindings.Add("TrialExpire", licenseInfo.Expires.ToLocalTime().ToString());
                    if (!string.IsNullOrWhiteSpace(licenseInfo.PurchaseUrl))
                    {
                        //string url = string.Format("{0}{1}installationId={2}", licenseInfo.PurchaseUrl, (licenseInfo.PurchaseUrl.Contains('?') ? "&" : "?"), Composite.Core.Configuration.InstallationInformationFacade.InstallationId);
                        string url = licenseInfo.PurchaseUrl;
                        this.Bindings.Add("TrialPurchaseUrl", url);
                    }
                }
            }

            if (castedToken.CanBeUninstalled)
            {
                this.SetCustomToolbarDefinition(new FormDefinitionFileMarkupProvider(@"\Administrative\PackageElementProviderViewInstalledPackageInformationToolbar.xml"));
            }
        }