Beispiel #1
0
 public static void LogAcquirePrelicenseResult(RmsClientManagerContext context, LicenseResponse[] responses)
 {
     if (!RmsClientManagerLog.rmsLogEnabled)
     {
         return;
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (responses == null || responses.Length == 0)
     {
         RmsClientManagerLog.LogEvent(RmsClientManagerLog.RmsClientManagerFeature.Prelicense, RmsClientManagerLog.RmsClientManagerEvent.Success, context.TransactionId, RmsClientManagerLog.PrelicenseNoResult, context.ContextStringForm);
         return;
     }
     foreach (LicenseResponse licenseResponse in responses)
     {
         if (licenseResponse.Exception != null)
         {
             RmsClientManagerLog.LogException(RmsClientManagerLog.RmsClientManagerFeature.Prelicense, context, licenseResponse.Exception);
         }
         else
         {
             RmsClientManagerLog.LogEvent(RmsClientManagerLog.RmsClientManagerFeature.Prelicense, RmsClientManagerLog.RmsClientManagerEvent.Success, context.TransactionId, licenseResponse.UsageRights.ToString(), context.ContextStringForm);
         }
     }
 }
Beispiel #2
0
        public static ExternalRMSServerInfo EndAcquireServerInfo(IAsyncResult asyncResult)
        {
            RmsServerInfoManager.ThrowIfNotInitialized();
            ArgumentValidator.ThrowIfNull("asyncResult", asyncResult);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = asyncResult as AcquireServerInfoAsyncResult;

            if (acquireServerInfoAsyncResult == null)
            {
                throw new InvalidOperationException("asyncResult cannot be null and has to be type of AcquireServerInfoAsyncResult");
            }
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.EndAcquireServerInfo);
            if (!acquireServerInfoAsyncResult.IsCompleted)
            {
                acquireServerInfoAsyncResult.InternalWaitForCompletion();
            }
            Exception ex = acquireServerInfoAsyncResult.Result as Exception;

            if (ex != null)
            {
                RmsServerInfoManager.Tracer.TraceError <Uri, Exception>(0L, "EndAcquireServerInfo hit an exception; and as a result of it, '{0}' will be marked as negative entry in cache. Exception - {1}", acquireServerInfoAsyncResult.LicenseUri, ex);
                RightsManagementException ex2 = ex as RightsManagementException;
                if (ex2 == null || ex2.IsPermanent)
                {
                    RmsServerInfoManager.AddNegativeServerInfo(acquireServerInfoAsyncResult.LicenseUri);
                }
                RmsClientManagerLog.LogException(RmsClientManagerLog.RmsClientManagerFeature.ServerInfo, acquireServerInfoAsyncResult.Context, ex);
                throw ex;
            }
            ExternalRMSServerInfo externalRMSServerInfo;

            if (!RmsServerInfoManager.serverInfoMap.TryGet(acquireServerInfoAsyncResult.LicenseUri, out externalRMSServerInfo))
            {
                RmsClientManagerLog.LogAcquireServerInfoResult(acquireServerInfoAsyncResult.Context, null);
                RmsServerInfoManager.Tracer.TraceError(0L, "Could not find the server info in the cache");
                return(null);
            }
            RmsClientManagerLog.LogAcquireServerInfoResult(acquireServerInfoAsyncResult.Context, externalRMSServerInfo);
            if (externalRMSServerInfo.IsNegativeEntry)
            {
                RmsServerInfoManager.Tracer.TraceError(0L, "RmsServerInfoManager found requested server info in cache; but it is a negative entry!");
                return(null);
            }
            return(externalRMSServerInfo);
        }