protected void HandleFailedDomain(string operationName, EhfDomainItem domain, DomainResponseInfo response, ref int transientFailureCount, ref int permanentFailureCount)
        {
            if (response.Status == ResponseStatus.TransientFailure)
            {
                transientFailureCount++;
            }
            else
            {
                permanentFailureCount++;
            }
            string       responseTargetValuesString = EhfProvisioningService.GetResponseTargetValuesString(response);
            EdgeSyncDiag diagSession   = base.DiagSession;
            string       messageFormat = "Failed to {0}: FaultId={1}; FaultType={2}; FaultDetail={3}; Target={4}; TargetValues=({5}); DN=({6}); Name={7}; AD-GUID=({8}); EHF-GUID=({9}); EHF-Company-ID={10}";

            object[] array = new object[11];
            array[0] = operationName;
            array[1] = response.Fault.Id;
            array[2] = response.Status;
            array[3] = (response.Fault.Detail ?? "null");
            array[4] = response.Target;
            array[5] = responseTargetValuesString;
            array[6] = domain.DistinguishedName;
            array[7] = domain.Name;
            array[8] = domain.GetDomainGuid();
            object[] array2     = array;
            int      num        = 9;
            Guid?    domainGuid = response.DomainGuid;

            array2[num] = ((domainGuid != null) ? domainGuid.GetValueOrDefault() : "null");
            array[10]   = domain.Domain.CompanyId;
            domain.AddSyncError(diagSession.LogAndTraceError(messageFormat, array));
        }
        private void InvokeEhfDeleteDomains()
        {
            if (this.domainsToDelete == null || this.domainsToDelete.Count == 0)
            {
                return;
            }
            DomainResponseInfoSet responseSet = null;

            base.InvokeProvisioningService("Delete Domain", delegate
            {
                responseSet = this.ProvisioningService.DeleteDomains(this.domainsToDelete);
            }, this.domainsToDelete.Count);
            int transientFailureCount = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i];
                EhfDomainItem      ehfDomainItem      = this.domainsToDelete[i];
                if (domainResponseInfo.Status == ResponseStatus.Success)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully deleted EHF domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        domainResponseInfo.DomainGuid.Value,
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainDoesNotExist)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that does not exist; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that belongs to a different company under this reseller; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.AccessDenied)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that belongs to a different company outside of this reseller; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else
                {
                    this.HandleFailedDomain("Delete Domain", ehfDomainItem, domainResponseInfo, ref transientFailureCount, ref permanentFailureCount);
                }
                if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    throw new InvalidOperationException("EventLogAndTryStoreSyncErrors() returned false for a deleted object");
                }
            }
            base.HandlePerEntryFailureCounts("Delete Domain", this.domainsToDelete.Count, transientFailureCount, permanentFailureCount, false);
            this.domainsToDelete.Clear();
        }
        protected virtual void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate)
        {
            int num = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i];
                EhfDomainItem      ehfDomainItem      = domainsTriedToCreate[i];
                bool flag = false;
                if (domainResponseInfo.Status == ResponseStatus.Success)
                {
                    flag = true;
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.Domain.Name,
                        domainResponseInfo.DomainGuid.Value,
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany)
                {
                    Guid domainGuid = ehfDomainItem.GetDomainGuid();
                    if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid))
                    {
                        flag = true;
                        base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[]
                        {
                            ehfDomainItem.DistinguishedName,
                            ehfDomainItem.Domain.Name,
                            domainGuid,
                            ehfDomainItem.Domain.CompanyId
                        });
                    }
                    else if (!this.handledAllDeletedDomains)
                    {
                        base.AddItemToLazyList <EhfDomainItem>(ehfDomainItem, ref this.domainsToCreateLast);
                        EdgeSyncDiag         diagSession = base.DiagSession;
                        EdgeSyncLoggingLevel level       = EdgeSyncLoggingLevel.Low;
                        string   messageFormat           = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>";
                        object[] array = new object[5];
                        array[0] = ehfDomainItem.DistinguishedName;
                        array[1] = ehfDomainItem.Name;
                        array[2] = domainGuid;
                        object[] array2      = array;
                        int      num2        = 3;
                        Guid?    domainGuid2 = domainResponseInfo.DomainGuid;
                        array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null");
                        array[4]     = ehfDomainItem.Domain.CompanyId;
                        diagSession.LogAndTraceInfo(level, messageFormat, array);
                    }
                    else
                    {
                        this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount);
                    }
                }
                else
                {
                    this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount);
                }
                if (flag && ehfDomainItem.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure)
                {
                    num++;
                }
                if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    num++;
                }
            }
            base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false);
        }