protected void ProcessLicenseServiceResponse(IEnterKeyResponse response)
        {
            ILicenseService        service1 = this.Services.GetService <ILicenseService>();
            IMessageDisplayService service2 = this.Services.GetService <IMessageDisplayService>();

            this.IsLicensed = response.IsEnabled;
            if ((int)response.ErrorCode != -1073418160)
            {
                LicensingDialogHelper.ShowErrorMessageFromResponse((ILicenseSubServiceResponse)response, service2);
            }
            if (!response.IsEnabled)
            {
                if (service1.HasKey(response.KeySku) && service1.GetUnlicensedReason(response.KeySku) == UnlicensedReason.GraceTimeExpired)
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Owner   = (Window)this,
                        Message = StringTable.LicensingYouNeedToActivate,
                        Button  = MessageBoxButton.OK,
                        Image   = MessageBoxImage.Exclamation
                    };
                    int num = (int)service2.ShowMessage(args);
                }
                else
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Owner   = (Window)this,
                        Message = StringTable.LicensingInvalidKeyMessage,
                        Button  = MessageBoxButton.OK,
                        Image   = MessageBoxImage.Hand
                    };
                    int num = (int)service2.ShowMessage(args);
                }
            }
            else if (this.ShouldActivate && service1.SkusFromFeature(ExpressionFeatureMapper.ActivationLicense).Contains(response.KeySku) && !response.IsActivated)
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Owner   = (Window)this,
                    Message = StringTable.LicensingEnterKeySucceededAndActivationFailed,
                    Image   = MessageBoxImage.Exclamation
                };
                int num = (int)service2.ShowMessage(args);
                LicensingDialogHelper.ShowActivationDialog(this.Services, (CommonDialogCreator) new ActivationDialogCreator(this.Services, ActivationWizardAction.ChooseActivationType));
            }
            else
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Owner   = (Window)this,
                    Message = StringTable.LicensingValidMessage
                };
                int num = (int)service2.ShowMessage(args);
            }
        }
Beispiel #2
0
        public static bool EnsureProductIsLicensed(IServices services, int nagAtDays)
        {
            services.GetService <ILicenseService>().WaitForValidLicenseInformation();
            IMessageDisplayService service = services.GetService <IMessageDisplayService>();
            bool flag;

            switch (LicensingDialogHelper.DialogToDisplay(services, nagAtDays))
            {
            case LicenseDialogPopup.NoDialog:
                flag = true;
                break;

            case LicenseDialogPopup.LicenseDialog:
                flag = LicensingDialogHelper.ShowLicensingDialog(services, (CommonDialogCreator) new LicensingDialogCreator(services));
                break;

            case LicenseDialogPopup.TrialExpiredDialog:
                flag = LicensingDialogHelper.ShowTrialExpiredDialog(services, (CommonDialogCreator) new TrialExpiredDialogCreator(services));
                break;

            case LicenseDialogPopup.ActivationGraceExpiredDialog:
                flag = LicensingDialogHelper.ShowActivationGraceExpiredDialog(services, (CommonDialogCreator) new ActivationGraceExpiredDialogCreator(services));
                break;

            case LicenseDialogPopup.ProductSkuNotInstalled:
                MessageBoxArgs args1 = new MessageBoxArgs()
                {
                    Message = StringTable.LicensingProductSkuLicenseNotInstalledMessage,
                    Button  = MessageBoxButton.OK,
                    Image   = MessageBoxImage.Hand
                };
                if (service != null)
                {
                    int num1 = (int)service.ShowMessage(args1);
                }
                flag = false;
                break;

            default:
                MessageBoxArgs args2 = new MessageBoxArgs()
                {
                    Message = StringTable.LicensingInitializationFailureMessage,
                    Button  = MessageBoxButton.OK,
                    Image   = MessageBoxImage.Hand
                };
                if (service != null)
                {
                    int num2 = (int)service.ShowMessage(args2);
                }
                flag = false;
                break;
            }
            return(flag);
        }
Beispiel #3
0
        internal static void ShowErrorMessageFromResponse(ILicenseSubServiceResponse response, IMessageDisplayService messageDisplayService)
        {
            string str = LicensingDialogHelper.ErrorMessageFromResponse(response);

            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = str,
                Button  = MessageBoxButton.OK,
                Image   = MessageBoxImage.Hand
            };
            int num = (int)messageDisplayService.ShowMessage(args);
        }
Beispiel #4
0
        public static bool ShowLicensingDialog(IServices services, CommonDialogCreator licensingDialogCreator)
        {
            bool                  flag                = false;
            ILicenseService       service1            = services.GetService <ILicenseService>();
            ILicensingDialogQuery getInstance         = licensingDialogCreator.GetInstance;
            Guid                  mostPermissiveSkuId = service1.MostPermissiveSkuId;

            if (mostPermissiveSkuId != Guid.Empty)
            {
                if (service1.IsInGrace(mostPermissiveSkuId))
                {
                    getInstance.IsPermanentLicense = false;
                    getInstance.GraceDaysRemaining = (uint)Math.Floor((double)service1.GetRemainingGraceMinutes(mostPermissiveSkuId) / 1440.0);
                }
                else
                {
                    getInstance.IsStudioPermanentLicense = service1.FeaturesFromSku(service1.MostPermissiveSkuId).Contains(ExpressionFeatureMapper.StudioLicense);
                    getInstance.IsPermanentLicense       = !getInstance.IsStudioPermanentLicense && !service1.FeaturesFromSku(service1.MostPermissiveSkuId).Contains(ExpressionFeatureMapper.TrialLicense);
                }
                if (LicensingDialogHelper.ShowDialogWithMainWindowDisabled(services, getInstance) && getInstance.IsLicensed)
                {
                    flag = true;
                }
            }
            else
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message = StringTable.LicensingTrialKeyInstallationFailureMessage,
                    Button  = MessageBoxButton.OK,
                    Image   = MessageBoxImage.Hand
                };
                IMessageDisplayService service2 = services.GetService <IMessageDisplayService>();
                if (service2 != null)
                {
                    int num = (int)service2.ShowMessage(args);
                }
            }
            return(flag);
        }