コード例 #1
0
        internal PolicyDistributionErrorDetails CreatePolicyDistributionError(Workload singleWorkload, UnifiedPolicyStorageBase storage, UnifiedPolicySettingStatus status)
        {
            bool flag = false;
            UnifiedPolicyErrorCode errorCode = UnifiedPolicyErrorCode.Unknown;
            string   empty                 = string.Empty;
            DateTime lastErrorTime         = DateTime.UtcNow;
            string   additionalDiagnostics = string.Empty;

            if (status == null)
            {
                if (storage is ScopeStorage)
                {
                    flag                  = true;
                    errorCode             = UnifiedPolicyErrorCode.PolicySyncTimeout;
                    empty                 = string.Empty;
                    lastErrorTime         = DateTime.UtcNow;
                    additionalDiagnostics = (this.includeDiagnosticInfo ? Strings.DiagnoseMissingStatusForScope(storage.WhenChangedUTC.Value) : string.Empty);
                }
                else if (storage.WhenChangedUTC != null)
                {
                    DateTime dateTime = storage.WhenChangedUTC.Value.Add(PolicySettingStatusHelpers.policySyncTimeoutInterval);
                    if (dateTime < DateTime.UtcNow)
                    {
                        flag                  = true;
                        errorCode             = UnifiedPolicyErrorCode.PolicySyncTimeout;
                        empty                 = string.Empty;
                        lastErrorTime         = dateTime;
                        additionalDiagnostics = (this.includeDiagnosticInfo ? Strings.DiagnosePendingStatusTimeout(storage.WhenChangedUTC.Value, PolicySettingStatusHelpers.policySyncTimeoutInterval) : string.Empty);
                    }
                }
            }
            else if (status.ErrorCode != 0)
            {
                flag                  = true;
                errorCode             = (UnifiedPolicyErrorCode)status.ErrorCode;
                empty                 = string.Empty;
                lastErrorTime         = status.WhenProcessedUTC;
                additionalDiagnostics = (this.includeDiagnosticInfo ? status.AdditionalDiagnostics : string.Empty);
            }
            if (flag)
            {
                return(new PolicyDistributionErrorDetails(this.GetStorageObjectName(storage), storage.Guid, PolicySettingStatusHelpers.GetConfigurationObjectTypeFromString(storage.GetType().Name), singleWorkload, errorCode, empty, lastErrorTime, additionalDiagnostics));
            }
            return(null);
        }
コード例 #2
0
 internal ChangeNotificationData(Guid id, Guid parentId, ConfigurationObjectType objectType, ChangeType changeType, Workload workload, PolicyVersion version, UnifiedPolicyErrorCode errorCode = UnifiedPolicyErrorCode.Unknown, string errorMessage = "")
 {
     this.Id           = id;
     this.ParentId     = parentId;
     this.ObjectType   = objectType;
     this.ChangeType   = changeType;
     this.Workload     = workload;
     this.Version      = version;
     this.ErrorCode    = errorCode;
     this.ErrorMessage = errorMessage;
     this.ShouldNotify = true;
     this.UseFullSync  = false;
 }
コード例 #3
0
 public PolicyDistributionErrorDetails(string endpoint, Guid objectId, ConfigurationObjectType objectType, Workload workload, UnifiedPolicyErrorCode errorCode, string errorMessage, DateTime lastErrorTime, string additionalDiagnostics)
 {
     this.Endpoint              = endpoint;
     this.ObjectId              = objectId;
     this.ObjectType            = objectType;
     this.Workload              = workload;
     this.ResultCode            = errorCode;
     this.ResultMessage         = errorMessage;
     this.LastResultTime        = new DateTime?(lastErrorTime);
     this.AdditionalDiagnostics = additionalDiagnostics;
     this.Severity              = PolicyDistributionResultSeverity.Error;
     if (string.IsNullOrEmpty(this.ResultMessage))
     {
         string resultMessage;
         if (!PolicyDistributionErrorDetails.errorCodeToStringMap.TryGetValue(this.ResultCode, out resultMessage))
         {
             resultMessage = Strings.UnknownErrorMsg;
         }
         this.ResultMessage = resultMessage;
     }
 }