コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public static bool ShowTrialExpiredDialog(IServices services, CommonDialogCreator trialExpiredDialogCreator)
        {
            bool flag = false;
            ILicensingDialogQuery getInstance = trialExpiredDialogCreator.GetInstance;

            if (LicensingDialogHelper.ShowDialogWithMainWindowDisabled(services, getInstance) && getInstance.IsLicensed)
            {
                flag = true;
            }
            return(flag);
        }
コード例 #3
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);
        }
コード例 #4
0
 private static string ErrorMessageFromResponse(ILicenseSubServiceResponse response)
 {
     if (response.Exception != null)
     {
         return(response.Exception.Message);
     }
     if ((int)response.ErrorCode != 0)
     {
         return(LicensingDialogHelper.ErrorMessageFromHResult(response.ErrorCode));
     }
     return(string.Empty);
 }
コード例 #5
0
        public static bool ShowActivationGraceExpiredDialog(IServices services, CommonDialogCreator activationGraceExpiredDialogCreator)
        {
            ILicensingDialogQuery getInstance = activationGraceExpiredDialogCreator.GetInstance;

            if (!LicensingDialogHelper.ShowDialogWithMainWindowDisabled(services, getInstance))
            {
                return(false);
            }
            ILicenseService service             = services.GetService <ILicenseService>();
            Guid            mostPermissiveSkuId = service.MostPermissiveSkuId;

            return(service.IsLicensed(mostPermissiveSkuId) || service.IsInGrace(mostPermissiveSkuId));
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
0
        public static LicenseDialogPopup DialogToDisplay(IServices services, int nagDays)
        {
            ILicenseService service             = services.GetService <ILicenseService>();
            Guid            mostPermissiveSkuId = service.MostPermissiveSkuId;

            if (LicensingDialogHelper.ShouldNag(service, mostPermissiveSkuId, nagDays))
            {
                return(LicenseDialogPopup.LicenseDialog);
            }
            if (service.IsLicensed(mostPermissiveSkuId) || service.IsInGrace(mostPermissiveSkuId))
            {
                return(LicenseDialogPopup.NoDialog);
            }
            if (!service.IsLicensed(mostPermissiveSkuId) && service.HasKey(mostPermissiveSkuId) && service.GetUnlicensedReason(mostPermissiveSkuId) == UnlicensedReason.GraceTimeExpired)
            {
                return(LicenseDialogPopup.ActivationGraceExpiredDialog);
            }
            if (service.RightNotGranted)
            {
                return(LicenseDialogPopup.TrialExpiredDialog);
            }
            return(service.ProductLicenseNotInstalled ? LicenseDialogPopup.ProductSkuNotInstalled : LicenseDialogPopup.LicensingError);
        }
コード例 #9
0
 protected override bool ProcessFallbackOption()
 {
     return(LicensingDialogHelper.ShowActivationDialog(this.Services, (CommonDialogCreator) new ActivationDialogCreator(this.Services, ActivationWizardAction.AttemptOnlineActivation)));
 }
コード例 #10
0
 public override void Execute()
 {
     LicensingDialogHelper.ShowActivationDialog(this.Services, (CommonDialogCreator) new ActivationDialogCreator(this.Services, ActivationWizardAction.AttemptOnlineActivation));
 }
コード例 #11
0
 public static bool EnsureProductIsLicensed(IServices services)
 {
     return(LicensingDialogHelper.EnsureProductIsLicensed(services, 30));
 }
コード例 #12
0
 public static LicenseDialogPopup DialogToDisplay(IServices services)
 {
     return(LicensingDialogHelper.DialogToDisplay(services, 30));
 }
コード例 #13
0
        public static bool ShowActivationDialog(IServices services, CommonDialogCreator activationDialogCreator)
        {
            ILicensingDialogQuery getInstance = activationDialogCreator.GetInstance;

            return(LicensingDialogHelper.ShowDialogWithMainWindowDisabled(services, getInstance));
        }
コード例 #14
0
 public override void Execute()
 {
     LicensingDialogHelper.ShowLicensingDialog(this.Services, (CommonDialogCreator) new LicensingDialogCreator(this.Services));
 }