Exemplo n.º 1
0
        public static UseLicenseRpcResult[] AcquireUseLicenses(RmsClientManagerContext clientContext, XmlNode[] rightsAccountCertificate, XmlNode[] issuanceLicense, LicenseeIdentity[] licenseeIdentities)
        {
            if (clientContext == null)
            {
                throw new ArgumentNullException("clientContext");
            }
            if (rightsAccountCertificate == null)
            {
                throw new ArgumentNullException("rightsAccountCertificate");
            }
            if (issuanceLicense == null || issuanceLicense.Length < 1)
            {
                throw new ArgumentNullException("issuanceLicense");
            }
            if (licenseeIdentities == null || licenseeIdentities.Length < 1)
            {
                throw new ArgumentNullException("licenseeIdentities");
            }
            RpcClientWrapper.InitializeIfNeeded();
            string randomRpcTargetServerName = RpcClientWrapper.instance.GetRandomRpcTargetServerName();

            byte[] data = null;
            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Entry, clientContext, string.Format("OfflineRmsRpcClient.AcquireUseLicenses against RPC server {0}", randomRpcTargetServerName));
            try
            {
                using (OfflineRmsRpcClient offlineRmsRpcClient = new OfflineRmsRpcClient(randomRpcTargetServerName))
                {
                    data = offlineRmsRpcClient.AcquireUseLicenses(1, new AcquireUseLicensesRpcParameters(clientContext, rightsAccountCertificate, issuanceLicense, licenseeIdentities).Serialize());
                }
            }
            catch (RpcException ex)
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.AcquireUseLicenses against RPC server {0} failed with RPC Exception {1}", randomRpcTargetServerName, ServerManagerLog.GetExceptionLogString(ex, ServerManagerLog.ExceptionLogOption.IncludeStack | ServerManagerLog.ExceptionLogOption.IncludeInnerException)));
                throw new RightsManagementServerException(ServerStrings.RpcClientException("AcquireUseLicenses", randomRpcTargetServerName), ex, false);
            }
            AcquireUseLicensesRpcResults acquireUseLicensesRpcResults = new AcquireUseLicensesRpcResults(data);

            if (acquireUseLicensesRpcResults.OverallRpcResult.Status == OverallRpcStatus.Success)
            {
                return(acquireUseLicensesRpcResults.UseLicenseRpcResults);
            }
            string serializedString = ErrorResult.GetSerializedString(acquireUseLicensesRpcResults.OverallRpcResult.ErrorResults);

            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.AcquireUseLicenses against RPC server {0} failed with WellKnownErrorCode {1}, and with Exception {2}", randomRpcTargetServerName, acquireUseLicensesRpcResults.OverallRpcResult.WellKnownErrorCode, serializedString));
            throw new RightsManagementServerException(ServerStrings.FailedToRpcAcquireUseLicenses(clientContext.OrgId.ToString(), serializedString, randomRpcTargetServerName), acquireUseLicensesRpcResults.OverallRpcResult.WellKnownErrorCode, acquireUseLicensesRpcResults.OverallRpcResult.Status == OverallRpcStatus.PermanentFailure);
        }
Exemplo n.º 2
0
        public override byte[] AcquireUseLicenses(int version, byte[] inputParameterBytes)
        {
            AcquireUseLicensesRpcParameters acquireUseLicensesRpcParameters = null;

            byte[] result;
            try
            {
                acquireUseLicensesRpcParameters = new AcquireUseLicensesRpcParameters(inputParameterBytes);
                UseLicenseResult[]           originalResults = ServerManager.AcquireUseLicenses(acquireUseLicensesRpcParameters.ClientManagerContext, acquireUseLicensesRpcParameters.RightsAccountCertificate, acquireUseLicensesRpcParameters.IssuanceLicense, acquireUseLicensesRpcParameters.LicenseeIdentities);
                AcquireUseLicensesRpcResults acquireUseLicensesRpcResults = new AcquireUseLicensesRpcResults(new OverallRpcResult(null), originalResults);
                result = acquireUseLicensesRpcResults.Serialize();
            }
            catch (Exception ex)
            {
                if (!(ex is RightsManagementServerException))
                {
                    ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcServerWrapper, ServerManagerLog.EventType.Error, (acquireUseLicensesRpcParameters != null) ? acquireUseLicensesRpcParameters.ClientManagerContext : null, string.Format("ServerManager.AcquireTenantLicenses has thrown unhandled exception {0}", ServerManagerLog.GetExceptionLogString(ex, ServerManagerLog.ExceptionLogOption.IncludeStack | ServerManagerLog.ExceptionLogOption.IncludeInnerException)));
                    ExWatson.SendReportAndCrashOnAnotherThread(ex);
                }
                AcquireUseLicensesRpcResults acquireUseLicensesRpcResults2 = new AcquireUseLicensesRpcResults(new OverallRpcResult(ex), Array <UseLicenseResult> .Empty);
                result = acquireUseLicensesRpcResults2.Serialize();
            }
            return(result);
        }