Beispiel #1
0
        internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string propertyName) where T : SizeOverPredicate, new()
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("greaterThanOrEqual") || !predicateCondition.Property.Name.Equals(propertyName) || predicateCondition.Value.RawValues.Count != 1)
            {
                return(null);
            }
            ulong num;

            if (!ulong.TryParse(predicateCondition.Value.RawValues[0], out num))
            {
                return(null);
            }
            T t = Activator.CreateInstance <T>();

            if (num == 0UL)
            {
                t.Size = ByteQuantifiedSize.FromKB(0UL);
            }
            else
            {
                t.Size = ByteQuantifiedSize.FromBytes(num);
            }
            return(t);
        }
Beispiel #2
0
 public MailboxFolderConfiguration() : base(new MapiFolderConfigurationPropertyBag())
 {
     this.DeletedItemsInFolder = 0;
     this.DeletedItemsInFolderAndSubfolders = 0;
     this.ItemsInFolder = 0;
     this.ItemsInFolderAndSubfolders = 0;
     this.FolderAndSubfolderSize     = ByteQuantifiedSize.FromBytes(0UL);
     this.FolderSize = ByteQuantifiedSize.FromBytes(0UL);
     this.Date       = DateTime.MinValue;
     this.NewestDeletedItemReceivedDate     = null;
     this.NewestItemReceivedDate            = null;
     this.OldestDeletedItemReceivedDate     = null;
     this.OldestItemReceivedDate            = null;
     this.NewestDeletedItemLastModifiedDate = null;
     this.NewestItemLastModifiedDate        = null;
     this.OldestDeletedItemLastModifiedDate = null;
     this.OldestItemLastModifiedDate        = null;
     this.FolderId                     = null;
     this.FolderPath                   = null;
     this.FolderType                   = null;
     this.Name                         = null;
     this.ManagedFolder                = null;
     this.DeletePolicy                 = null;
     this.ArchivePolicy                = null;
     this.TopSubjectCount              = 0;
     this.TopSubjectSize               = ByteQuantifiedSize.FromBytes(0UL);
     this.TopClientInfoForSubject      = string.Empty;
     this.TopClientInfoCountForSubject = 0;
     this.TopSubjectPath               = string.Empty;
     this.TopSubject                   = string.Empty;
     this.TopSubjectReceivedTime       = null;
     this.TopSubjectFrom               = string.Empty;
     this.TopSubjectClass              = string.Empty;
     this.SearchFolders                = null;
 }
Beispiel #3
0
 protected override void LoadCustomSettings()
 {
     base.DirectoryPath    = this.logConfig.Value.LoggingFolder;
     base.MaxDirectorySize = ByteQuantifiedSize.FromBytes((ulong)this.logConfig.Value.MaxLogDirSize);
     base.MaxFileSize      = ByteQuantifiedSize.FromBytes((ulong)this.logConfig.Value.MaxLogFileSize);
     base.MaxAge           = this.logConfig.Value.MaxLogAge;
 }
Beispiel #4
0
 private void FillDatabaseSize(ExRpcAdmin rpcAdmin, Database database)
 {
     try
     {
         FaultInjectionUtils.FaultInjectionTracer.TraceTest(3395693885U);
         ulong bytesValue;
         ulong bytesValue2;
         rpcAdmin.GetDatabaseSize(database.Guid, out bytesValue, out bytesValue2);
         database.DatabaseSize             = new ByteQuantifiedSize?(ByteQuantifiedSize.FromBytes(bytesValue));
         database.AvailableNewMailboxSpace = new ByteQuantifiedSize?(ByteQuantifiedSize.FromBytes(bytesValue2));
     }
     catch (MapiExceptionNoSupport)
     {
     }
     catch (MapiPermanentException ex)
     {
         TaskLogger.Trace(string.Format(CultureInfo.InvariantCulture, "GetDatabase.FillDatabaseSize(Database '{0}') raises exception: {1}", new object[]
         {
             database.Identity.ToString(),
             ex.Message
         }), new object[0]);
         this.WriteWarning(Strings.ErrorFailedToGetDatabaseSize(database.Identity.ToString()));
     }
     catch (MapiRetryableException ex2)
     {
         TaskLogger.Trace(string.Format(CultureInfo.InvariantCulture, "GetDatabase.FillDatabaseSize(Database '{0}') raises exception: {1}", new object[]
         {
             database.Identity.ToString(),
             ex2.Message
         }), new object[0]);
         this.WriteWarning(Strings.ErrorFailedToGetDatabaseSize(database.Identity.ToString()));
     }
 }
Beispiel #5
0
        public void ProcessDatabase()
        {
            if (!this.settings.AutomaticDatabaseDrainEnabled)
            {
                return;
            }
            if (this.database == null)
            {
                return;
            }
            ByteQuantifiedSize currentPhysicalSize = this.database.GetSize().CurrentPhysicalSize;
            double             num = 1.0 + (double)this.settings.AutomaticDrainStartFileSizePercent / 100.0;
            ulong bytesValue       = (ulong)(this.database.MaximumSize.ToBytes() * num);

            if (currentPhysicalSize >= ByteQuantifiedSize.FromBytes(bytesValue))
            {
                this.logger.LogInformation("Database {0} has {1} EDB file size, and the maximum allowed size is {2} with a {3}% tolerance. Starting drain process.", new object[]
                {
                    this.database.Identity,
                    currentPhysicalSize,
                    this.database.MaximumSize,
                    this.settings.AutomaticDrainStartFileSizePercent
                });
                this.drainControl.BeginDrainDatabase(this.database);
            }
        }
Beispiel #6
0
        public DatabaseSizeInfo GetDatabaseSize(DirectoryDatabase database)
        {
            DatabaseSizeInfo result;

            using (ExRpcAdmin exRpcAdminForDatabase = this.GetExRpcAdminForDatabase(database))
            {
                ulong bytesValue;
                ulong bytesValue2;
                exRpcAdminForDatabase.GetDatabaseSize(database.Guid, out bytesValue, out bytesValue2);
                ByteQuantifiedSize byteQuantifiedSize  = ByteQuantifiedSize.FromBytes(bytesValue);
                ByteQuantifiedSize byteQuantifiedSize2 = ByteQuantifiedSize.FromBytes(bytesValue2);
                if (byteQuantifiedSize2 > byteQuantifiedSize)
                {
                    this.logger.LogWarning("Database {0} has more free space ({1}) than its total size ({2}), assuming sparse EDB file with no free pages.", new object[]
                    {
                        database.Name,
                        byteQuantifiedSize2,
                        byteQuantifiedSize
                    });
                    byteQuantifiedSize2 = ByteQuantifiedSize.Zero;
                }
                result = new DatabaseSizeInfo
                {
                    AvailableWhitespace = byteQuantifiedSize2,
                    CurrentPhysicalSize = byteQuantifiedSize
                };
            }
            return(result);
        }
Beispiel #7
0
 public static object ExtractUnlimitedByteQuantifiedSizeFromPages(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(Unlimited <ByteQuantifiedSize>) == propertyDefinition.Type)
     {
         object obj = null;
         if (MapiPropValueConvertor.TryCastValueToExtract(value, typeof(int), out obj))
         {
             long num = (long)((int)obj);
             if (0L > num)
             {
                 return(Unlimited <ByteQuantifiedSize> .UnlimitedValue);
             }
             return(new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromBytes(checked ((ulong)num * 32UL * 1024UL))));
         }
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
 }
        internal static byte[] PackAndValidateCompressedRulePackage(byte[] uncompressedSerializedRulePackageData, ValidationContext validationContext)
        {
            byte[] array;
            if (!ClassificationDefinitionUtils.TryCompressXmlBytes(uncompressedSerializedRulePackageData, out array))
            {
                throw new ClassificationRuleCollectionStorageException();
            }
            ByteQuantifiedSize value = (ByteQuantifiedSize)DataClassificationConfigSchema.MaxRulePackageSize.DefaultValue;

            if (validationContext != null && validationContext.DcValidationConfig != null)
            {
                value = validationContext.DcValidationConfig.MaxRulePackageSize;
            }
            ByteQuantifiedSize value2 = ByteQuantifiedSize.FromBytes((ulong)((long)array.Length));

            if (value2 > value)
            {
                throw new ClassificationRuleCollectionPayloadSizeExceededLimitException(value2.ToKB(), value.ToKB());
            }
            return(array);
        }
        public static string FromMB(this string size)
        {
            if (string.IsNullOrWhiteSpace(size))
            {
                throw new ArgumentNullException("size");
            }
            string result;

            try
            {
                result = ByteQuantifiedSize.FromBytes(checked ((ulong)Math.Round(unchecked (Convert.ToDouble(size) * 1048576.0), 0))).ToString();
            }
            catch (FormatException)
            {
                throw new ArgumentException("String '" + size + "' is not of the expected number format.");
            }
            catch (OverflowException)
            {
                throw new ArgumentException("String '" + size + "' is outside the allowable numeric range.");
            }
            return(result);
        }
		public override IEnumerable<LoadEntity> GetEntities(LoadContainer targetContainer)
		{
			IAllocationConstraint allocationConstraint = targetContainer.Constraint ?? new AnyLoadConstraint();
			List<LoadEntity> list = new List<LoadEntity>(base.SourceEntities);
			List<LoadEntity> list2 = new List<LoadEntity>();
			ByteQuantifiedSize value = ByteQuantifiedSize.FromBytes(0UL);
			Random random = new Random();
			while (list.Count > 0 && value < this.totalSize)
			{
				int index = random.Next(list.Count);
				LoadEntity loadEntity = list[index];
				if (allocationConstraint.Accept(loadEntity))
				{
					ByteQuantifiedSize byteQuantifiedSize = value + loadEntity.ConsumedLoad.GetSizeMetric(PhysicalSize.Instance);
					if (byteQuantifiedSize < this.totalSize)
					{
						list2.Add(loadEntity);
						value = byteQuantifiedSize;
					}
				}
				list.RemoveAt(index);
			}
			return list2;
		}
Beispiel #11
0
        public IEnumerable <T> FindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) where T : IConfigurable, new()
        {
            base.CheckDisposed();
            if (!typeof(PublicFolderStatistics).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()))
            {
                throw new NotSupportedException("FindPaged: " + typeof(T).FullName);
            }
            IEnumerable <PublicFolder> publicFolders = this.publicFolderDataProvider.FindPaged <PublicFolder>(filter, rootId, deepSearch, sortBy, pageSize);

            foreach (PublicFolder publicFolder in publicFolders)
            {
                PublicFolderSession contentSession = null;
                if (this.mailboxGuid == Guid.Empty)
                {
                    contentSession = this.PublicFolderDataProvider.PublicFolderSessionCache.GetPublicFolderSession(publicFolder.InternalFolderIdentity.ObjectId);
                }
                else
                {
                    contentSession = this.PublicFolderDataProvider.PublicFolderSessionCache.GetPublicFolderSession(this.mailboxGuid);
                }
                using (Folder contentFolder = Folder.Bind(contentSession, publicFolder.InternalFolderIdentity, PublicFolderStatisticsDataProvider.contentFolderProperties))
                {
                    PublicFolderStatistics publicFolderStatistics = new PublicFolderStatistics();
                    publicFolderStatistics.LoadDataFromXso(contentSession.MailboxPrincipal.ObjectId, contentFolder);
                    uint          ownerCount          = 0U;
                    uint          contactCount        = 0U;
                    PermissionSet folderPermissionSet = contentFolder.GetPermissionSet();
                    foreach (Permission permission in folderPermissionSet)
                    {
                        if (permission.IsFolderContact)
                        {
                            contactCount += 1U;
                        }
                        if (permission.IsFolderOwner)
                        {
                            ownerCount += 1U;
                        }
                    }
                    publicFolderStatistics.OwnerCount   = ownerCount;
                    publicFolderStatistics.ContactCount = contactCount;
                    StoreObjectId dumpsterId = PublicFolderCOWSession.GetRecoverableItemsDeletionsFolderId((CoreFolder)contentFolder.CoreObject);
                    checked
                    {
                        if (dumpsterId != null)
                        {
                            try
                            {
                                using (CoreFolder coreFolder = CoreFolder.Bind(contentSession, dumpsterId, PublicFolderStatisticsDataProvider.dumpsterProperties))
                                {
                                    publicFolderStatistics.DeletedItemCount     = (uint)((int)coreFolder.PropertyBag[FolderSchema.ItemCount]);
                                    publicFolderStatistics.TotalDeletedItemSize = ByteQuantifiedSize.FromBytes((ulong)((long)coreFolder.PropertyBag[FolderSchema.ExtendedSize]));
                                }
                            }
                            catch (ObjectNotFoundException)
                            {
                            }
                        }
                        yield return((T)((object)publicFolderStatistics));
                    }
                }
            }
            yield break;
        }
        private MailboxFolderConfiguration GetFolderInformation(int folderIndex, List <object[]> allFolderRows, MailboxSession mailboxSession, IConfigurationSession adConfigSession)
        {
            MailboxFolderConfiguration mailboxFolderConfiguration = null;

            object[] array = allFolderRows[folderIndex];
            if (GetMailboxFolderStatistics.PropertyExists(array[1]) && GetMailboxFolderStatistics.PropertyExists(array[15]))
            {
                mailboxFolderConfiguration = new MailboxFolderConfiguration();
                string folderPath = (string)array[15];
                mailboxFolderConfiguration.FolderPath = folderPath;
                mailboxFolderConfiguration.SetIdentity(new MailboxFolderId(this.Identity.ToString(), mailboxFolderConfiguration.FolderPath));
                mailboxFolderConfiguration.Date = (DateTime)((ExDateTime)array[10]);
                if (GetMailboxFolderStatistics.PropertyExists(array[0]))
                {
                    mailboxFolderConfiguration.Name = (string)array[0];
                }
                else
                {
                    this.WriteWarning(Strings.UnableToRetrieveFolderName(mailboxFolderConfiguration.FolderPath));
                }
                StoreObjectId objectId = ((VersionedId)array[1]).ObjectId;
                mailboxFolderConfiguration.FolderId = objectId.ToBase64String();
                long num = 0L;
                if (GetMailboxFolderStatistics.PropertyExists(array[6]))
                {
                    num = (long)array[6];
                }
                mailboxFolderConfiguration.FolderSize = ByteQuantifiedSize.FromBytes(checked ((ulong)num));
                if (GetMailboxFolderStatistics.PropertyExists(array[4]))
                {
                    mailboxFolderConfiguration.ItemsInFolder = (int)array[4];
                    mailboxFolderConfiguration.ItemsInFolderAndSubfolders = mailboxFolderConfiguration.ItemsInFolder;
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[5]))
                {
                    mailboxFolderConfiguration.ItemsInFolder += (int)array[5];
                    mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array[5];
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[11]))
                {
                    mailboxFolderConfiguration.DeletedItemsInFolder = (int)array[11];
                    mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders = mailboxFolderConfiguration.DeletedItemsInFolder;
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[12]))
                {
                    mailboxFolderConfiguration.DeletedItemsInFolder += (int)array[12];
                    mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += mailboxFolderConfiguration.DeletedItemsInFolder;
                }
                int num2 = -1;
                if (GetMailboxFolderStatistics.PropertyExists(array[3]))
                {
                    num2 = (int)array[3];
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[2]) && (bool)array[2])
                {
                    bool flag  = false;
                    bool flag2 = false;
                    for (int i = folderIndex + 1; i < allFolderRows.Count; i++)
                    {
                        object[] array2 = allFolderRows[i];
                        if (GetMailboxFolderStatistics.PropertyExists(array2[15]) && GetMailboxFolderStatistics.PropertyExists(array2[3]))
                        {
                            int num3 = (int)array2[3];
                            if (num3 <= num2)
                            {
                                break;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[6]))
                            {
                                long num4 = (long)array2[6];
                                if (num4 > 0L)
                                {
                                    num += num4;
                                }
                            }
                            else
                            {
                                flag2 = true;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[4]))
                            {
                                mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array2[4];
                            }
                            else
                            {
                                flag = true;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[5]))
                            {
                                mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array2[5];
                            }
                            else
                            {
                                flag = true;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[11]))
                            {
                                mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += (int)array2[11];
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[12]))
                            {
                                mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += (int)array2[12];
                            }
                        }
                    }
                    if (flag)
                    {
                        this.WriteWarning(Strings.TotalFolderCount(mailboxFolderConfiguration.FolderPath));
                    }
                    if (flag2)
                    {
                        this.WriteWarning(Strings.TotalFolderSize(mailboxFolderConfiguration.FolderPath));
                    }
                }
                mailboxFolderConfiguration.FolderAndSubfolderSize = ByteQuantifiedSize.FromBytes(checked ((ulong)num));
                if (GetMailboxFolderStatistics.PropertyExists(array[7]))
                {
                    bool flag3 = ((int)array[7] & 1) != 0;
                    mailboxFolderConfiguration.FolderType = (flag3 ? ElcFolderType.ManagedCustomFolder.ToString() : null);
                }
                if (mailboxFolderConfiguration.FolderType == null)
                {
                    VersionedId       folderId          = (VersionedId)array[1];
                    DefaultFolderType defaultFolderType = mailboxSession.IsDefaultFolderType(folderId);
                    if (defaultFolderType == DefaultFolderType.None)
                    {
                        if (GetMailboxFolderStatistics.PropertyExists(array[9]))
                        {
                            StoreObjectId folderId2 = (StoreObjectId)array[9];
                            defaultFolderType = mailboxSession.IsDefaultFolderType(folderId2);
                        }
                        switch (defaultFolderType)
                        {
                        case DefaultFolderType.AdminAuditLogs:
                        case DefaultFolderType.Audits:
                            mailboxFolderConfiguration.FolderType = defaultFolderType.ToString();
                            break;

                        default:
                            mailboxFolderConfiguration.FolderType = Strings.UserCreatedFolder;
                            break;
                        }
                    }
                    else
                    {
                        mailboxFolderConfiguration.FolderType = defaultFolderType.ToString();
                    }
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[8]))
                {
                    Guid             guid          = new Guid((string)array[8]);
                    ADObjectId       valueToSearch = new ADObjectId(guid.ToByteArray());
                    List <ELCFolder> list          = ELCTaskHelper.FindELCFolder(adConfigSession, valueToSearch, FindByType.FolderAdObjectId);
                    if (list == null || list.Count != 1)
                    {
                        this.WriteWarning(Strings.UnableToRetrieveManagedFolder);
                    }
                    else
                    {
                        mailboxFolderConfiguration.ManagedFolder = new ELCFolderIdParameter(list[0].Id);
                    }
                }
                IConfigurationSession configurationSession = null;
                if (GetMailboxFolderStatistics.PropertyExists(array[13]))
                {
                    byte[] array3 = (byte[])array[13];
                    if (array3 != null)
                    {
                        Guid tagGuid = new Guid(array3);
                        configurationSession = this.CreateConfigurationSession(mailboxSession);
                        List <RetentionPolicyTag> list2 = ELCTaskHelper.FindRetentionPolicyTag(configurationSession, tagGuid);
                        if (list2 == null || list2.Count != 1)
                        {
                            this.WriteWarning(Strings.UnableToRetrieveDeletePolicyTag);
                        }
                        else
                        {
                            mailboxFolderConfiguration.DeletePolicy = new RetentionPolicyTagIdParameter(list2[0].Id);
                        }
                    }
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[14]))
                {
                    byte[] array4 = (byte[])array[14];
                    if (array4 != null)
                    {
                        Guid tagGuid2 = new Guid(array4);
                        if (configurationSession == null)
                        {
                            configurationSession = this.CreateConfigurationSession(mailboxSession);
                        }
                        List <RetentionPolicyTag> list3 = ELCTaskHelper.FindRetentionPolicyTag(configurationSession, tagGuid2);
                        if (list3 == null || list3.Count != 1)
                        {
                            this.WriteWarning(Strings.UnableToRetrieveArchivePolicyTag);
                        }
                        else
                        {
                            mailboxFolderConfiguration.ArchivePolicy = new RetentionPolicyTagIdParameter(list3[0].Id);
                        }
                    }
                }
            }
            return(mailboxFolderConfiguration);
        }
Beispiel #13
0
 internal Band ToBand()
 {
     return(new Band(this.BandProfile, ByteQuantifiedSize.FromBytes(this.MinSize), ByteQuantifiedSize.FromBytes(this.MaxSize), this.WeightFactor, this.IncludeOnlyPhysicalMailboxes, PersistedBandDefinition.FromPersistableLogonAge(this.MinLastLogonAgeTicks), PersistedBandDefinition.FromPersistableLogonAge(this.MaxLastLogonAgeTicks)));
 }
 public DirectorySize(string dirName, ulong size)
 {
     this.Name = dirName;
     this.Size = ByteQuantifiedSize.FromBytes(size);
 }
Beispiel #15
0
        private static string RunComponentCommand(string componentName, DiagnosableParameters componentParameters)
        {
            XDocument xdocument = new XDocument();
            XElement  xelement  = new XElement("Diagnostics");

            xdocument.Add(xelement);
            if (string.Equals(componentName, "ProcessLocator", StringComparison.OrdinalIgnoreCase))
            {
                XElement xelement2 = new XElement("ProcessLocator");
                xelement.Add(xelement2);
                List <KeyValuePair <Guid, string> > registeredProcessGuids = ProcessAccessRpcServer.GetRegisteredProcessGuids();
                int num = 0;
                if (string.Equals(componentParameters.Argument, "debug", StringComparison.OrdinalIgnoreCase))
                {
                    using (List <KeyValuePair <Guid, string> > .Enumerator enumerator = registeredProcessGuids.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            KeyValuePair <Guid, string> pair = enumerator.Current;
                            ProcessAccessManager.AddAsXmlElement(xelement2, pair);
                            num++;
                        }
                        goto IL_117;
                    }
                }
                HashSet <string> hashSet = new HashSet <string>(registeredProcessGuids.Count);
                foreach (KeyValuePair <Guid, string> pair2 in registeredProcessGuids)
                {
                    if (pair2.Key != ProcessAccessRpcServer.ProcessLocatorGuid && !hashSet.Contains(pair2.Value))
                    {
                        ProcessAccessManager.AddAsXmlElement(xelement2, pair2);
                        num++;
                        hashSet.Add(pair2.Value);
                    }
                }
IL_117:
                xelement2.AddFirst(new XElement("count", num));
            }
            else
            {
                using (Process currentProcess = Process.GetCurrentProcess())
                {
                    DateTime dateTime = currentProcess.StartTime.ToUniversalTime();
                    DateTime utcNow   = DateTime.UtcNow;
                    XElement content  = new XElement("ProcessInfo", new object[]
                    {
                        new XElement("id", currentProcess.Id),
                        new XElement("serverName", Environment.MachineName),
                        new XElement("startTime", dateTime),
                        new XElement("currentTime", utcNow),
                        new XElement("lifetime", (utcNow - dateTime).ToString()),
                        new XElement("threadCount", currentProcess.Threads.Count),
                        new XElement("handleCount", currentProcess.HandleCount),
                        new XElement("workingSet", ByteQuantifiedSize.FromBytes((ulong)currentProcess.WorkingSet64))
                    });
                    xelement.Add(content);
                }
                bool flag  = string.IsNullOrEmpty(componentName);
                bool flag2 = componentName == "?";
                if (!flag2 && !flag && !ProcessAccessManager.diagnosableComponents.ContainsKey(componentName))
                {
                    XElement content2 = new XElement(componentName, new XElement("message", string.Format("Component \"{0}\" is not supported by this process.", componentName)));
                    xelement.Add(content2);
                    flag2 = true;
                }
                XElement xelement3 = new XElement("Components");
                xelement.Add(xelement3);
                lock (ProcessAccessManager.RpcServerLockObject)
                {
                    if (flag)
                    {
                        using (IEnumerator <KeyValuePair <string, IDiagnosable> > enumerator3 = ProcessAccessManager.diagnosableComponents.GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                KeyValuePair <string, IDiagnosable> keyValuePair = enumerator3.Current;
                                xelement3.Add(keyValuePair.Value.GetDiagnosticInfo(componentParameters));
                            }
                            goto IL_3C2;
                        }
                    }
                    if (flag2)
                    {
                        using (IEnumerator <KeyValuePair <string, IDiagnosable> > enumerator4 = ProcessAccessManager.diagnosableComponents.GetEnumerator())
                        {
                            while (enumerator4.MoveNext())
                            {
                                KeyValuePair <string, IDiagnosable> keyValuePair2 = enumerator4.Current;
                                xelement3.Add(new XElement("Component", keyValuePair2.Key));
                            }
                            goto IL_3C2;
                        }
                    }
                    IDiagnosable diagnosable    = ProcessAccessManager.diagnosableComponents[componentName];
                    XElement     diagnosticInfo = diagnosable.GetDiagnosticInfo(componentParameters);
                    xelement3.Add(diagnosticInfo);
                    IL_3C2 :;
                }
            }
            string result;

            try
            {
                using (StringWriter stringWriter = new StringWriter())
                {
                    using (XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter))
                    {
                        xmlTextWriter.Formatting = Formatting.None;
                        xdocument.Save(xmlTextWriter);
                    }
                    result = stringWriter.ToString();
                }
            }
            catch (XmlException ex)
            {
                foreach (XElement xelement4 in xdocument.Descendants())
                {
                    ex.Data[xelement4.Name] = xelement4.Value;
                }
                throw;
            }
            return(result);
        }
Beispiel #16
0
 protected virtual ByteQuantifiedSize CreateByteQuantifiedSizeFromValue(ulong value)
 {
     return(ByteQuantifiedSize.FromBytes(value));
 }
        internal static void GetEntryFromStatus(RpcDatabaseCopyStatus2 copyStatus, DatabaseCopyStatusEntry entry)
        {
            CopyStatusEnum copyStatus2 = copyStatus.CopyStatus;
            CopyStatus     copyStatus3 = GetMailboxDatabaseCopyStatus.TranslateRpcStatusToTaskStatus(copyStatus2);

            entry.Status = copyStatus3;
            entry.m_statusRetrievedTime      = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.StatusRetrievedTime);
            entry.m_lastStatusTransitionTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastStatusTransitionTime);
            entry.InstanceStartTime          = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.InstanceStartTime);
            entry.m_errorMessage             = copyStatus.ErrorMessage;
            entry.m_errorEventId             = ((copyStatus.ErrorEventId != 0U) ? new uint?(copyStatus.ErrorEventId) : null);
            entry.m_extendedErrorInfo        = copyStatus.ExtendedErrorInfo;
            if (copyStatus3 == CopyStatus.Suspended || copyStatus3 == CopyStatus.FailedAndSuspended || copyStatus3 == CopyStatus.Seeding)
            {
                entry.m_suspendMessage = copyStatus.SuspendComment;
            }
            entry.m_singlePageRestore  = copyStatus.SinglePageRestoreNumber;
            entry.m_mailboxServer      = copyStatus.MailboxServer;
            entry.m_activeDatabaseCopy = copyStatus.ActiveDatabaseCopy;
            entry.m_actionInitiator    = copyStatus.ActionInitiator;
            entry.ActiveCopy           = copyStatus.IsActiveCopy();
            if (copyStatus.ActivationPreference > 0)
            {
                entry.ActivationPreference = new int?(copyStatus.ActivationPreference);
            }
            entry.IsLastCopyAvailabilityChecksPassed   = new bool?(copyStatus.IsLastCopyAvailabilityChecksPassed);
            entry.IsLastCopyRedundancyChecksPassed     = new bool?(copyStatus.IsLastCopyRedundancyChecksPassed);
            entry.LastCopyAvailabilityChecksPassedTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopyAvailabilityChecksPassedTime);
            entry.LastCopyRedundancyChecksPassedTime   = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopyRedundancyChecksPassedTime);
            entry.DiskFreeSpacePercent                 = copyStatus.DiskFreeSpacePercent;
            entry.DiskFreeSpace                        = ByteQuantifiedSize.FromBytes(copyStatus.DiskFreeSpaceBytes);
            entry.DiskTotalSpace                       = ByteQuantifiedSize.FromBytes(copyStatus.DiskTotalSpaceBytes);
            entry.ExchangeVolumeMountPoint             = copyStatus.ExchangeVolumeMountPoint;
            entry.DatabaseVolumeMountPoint             = copyStatus.DatabaseVolumeMountPoint;
            entry.DatabaseVolumeName                   = copyStatus.DatabaseVolumeName;
            entry.DatabasePathIsOnMountedFolder        = new bool?(copyStatus.DatabasePathIsOnMountedFolder);
            entry.LogVolumeMountPoint                  = copyStatus.LogVolumeMountPoint;
            entry.LogVolumeName                        = copyStatus.LogVolumeName;
            entry.LogPathIsOnMountedFolder             = new bool?(copyStatus.LogPathIsOnMountedFolder);
            entry.LastDatabaseVolumeName               = copyStatus.LastDatabaseVolumeName;
            entry.LastDatabaseVolumeNameTransitionTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastDatabaseVolumeNameTransitionTime);
            entry.VolumeInfoError                      = copyStatus.VolumeInfoLastError;
            entry.m_activationSuspended                = copyStatus.ActivationSuspended;
            if (copyStatus.ActivationSuspended)
            {
                entry.m_suspendMessage = copyStatus.SuspendComment;
            }
            entry.m_latestAvailableLogTime           = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LatestAvailableLogTime);
            entry.m_latestCopyNotificationTime       = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopyNotifiedLogTime);
            entry.m_latestCopyTime                   = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopiedLogTime);
            entry.m_latestInspectorTime              = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastInspectedLogTime);
            entry.m_latestReplayTime                 = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastReplayedLogTime);
            entry.m_latestLogGenerationNumber        = copyStatus.LastLogGenerated;
            entry.m_copyNotificationGenerationNumber = copyStatus.LastLogCopyNotified;
            entry.m_copyGenerationNumber             = copyStatus.LastLogCopied;
            entry.m_inspectorGenerationNumber        = copyStatus.LastLogInspected;
            entry.m_replayGenerationNumber           = copyStatus.LastLogReplayed;
            entry.m_contentIndexState                = copyStatus.ContentIndexStatus;
            entry.m_contentIndexErrorMessage         = copyStatus.ContentIndexErrorMessage;
            entry.m_contentIndexErrorCode            = copyStatus.ContentIndexErrorCode;
            entry.m_contentIndexVersion              = copyStatus.ContentIndexVersion;
            entry.m_contentIndexBacklog              = copyStatus.ContentIndexBacklog;
            entry.m_contentIndexRetryQueueSize       = copyStatus.ContentIndexRetryQueueSize;
            entry.m_contentIndexMailboxesToCrawl     = copyStatus.ContentIndexMailboxesToCrawl;
            entry.m_contentIndexSeedingPercent       = copyStatus.ContentIndexSeedingPercent;
            entry.m_contentIndexSeedingSource        = copyStatus.ContentIndexSeedingSource;
            entry.m_logCopyQueueIncreasing           = new bool?(copyStatus.CopyQueueNotKeepingUp);
            entry.m_logReplayQueueIncreasing         = new bool?(copyStatus.ReplayQueueNotKeepingUp);
            entry.m_replaySuspended                  = new bool?(copyStatus.ReplaySuspended);
            entry.ResumeBlocked = new bool?(copyStatus.ResumeBlocked);
            entry.ReseedBlocked = new bool?(copyStatus.ReseedBlocked);
            if (copyStatus.WorkerProcessId != 0)
            {
                entry.m_workerProcessId = new int?(copyStatus.WorkerProcessId);
            }
            entry.LastLogInfoIsStale               = copyStatus.LastLogInfoIsStale;
            entry.LastLogInfoFromCopierTime        = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastLogInfoFromCopierTime);
            entry.LastLogInfoFromClusterTime       = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastLogInfoFromClusterTime);
            entry.LastLogInfoFromClusterGen        = copyStatus.LastLogInfoFromClusterGen;
            entry.LowestLogPresent                 = copyStatus.LowestLogPresent;
            entry.m_logsReplayedSinceInstanceStart = new long?(copyStatus.LogsReplayedSinceInstanceStart);
            entry.m_logsCopiedSinceInstanceStart   = new long?(copyStatus.LogsCopiedSinceInstanceStart);
            entry.ReplicationIsInBlockMode         = copyStatus.ReplicationIsInBlockMode;
            entry.ActivationDisabledAndMoveNow     = copyStatus.ActivationDisabledAndMoveNow;
            entry.AutoActivationPolicy             = (DatabaseCopyAutoActivationPolicyType)copyStatus.AutoActivationPolicy;
            int num = copyStatus.MinimumSupportedDatabaseSchemaVersion;

            if (num > 0)
            {
                entry.MinimumSupportedDatabaseSchemaVersion = string.Format("{0}.{1}", num >> 16, num & 65535);
            }
            num = copyStatus.MaximumSupportedDatabaseSchemaVersion;
            if (num > 0)
            {
                entry.MaximumSupportedDatabaseSchemaVersion = string.Format("{0}.{1}", num >> 16, num & 65535);
            }
            num = copyStatus.RequestedDatabaseSchemaVersion;
            if (num > 0)
            {
                entry.RequestedDatabaseSchemaVersion = string.Format("{0}.{1}", num >> 16, num & 65535);
            }
            GetMailboxDatabaseCopyStatus.UpdateReplayLagStatus(entry, copyStatus);
            GetMailboxDatabaseCopyStatus.UpdateDatabaseSeedStatus(entry, copyStatus);
            GetMailboxDatabaseCopyStatus.UpdateBackupInfo(entry, copyStatus);
            GetMailboxDatabaseCopyStatus.UpdateDumpsterRequests(entry, copyStatus);
            if (copyStatus.OutgoingConnections != null)
            {
                entry.m_outgoingConnections = (ConnectionStatus[])Serialization.BytesToObject(copyStatus.OutgoingConnections);
            }
            if (copyStatus.IncomingLogCopyingNetwork != null)
            {
                entry.m_incomingLogCopyingNetwork = (ConnectionStatus)Serialization.BytesToObject(copyStatus.IncomingLogCopyingNetwork);
            }
            if (copyStatus.SeedingNetwork != null)
            {
                entry.m_seedingNetwork = (ConnectionStatus)Serialization.BytesToObject(copyStatus.SeedingNetwork);
            }
            entry.MaxLogToReplay = copyStatus.MaxLogToReplay;
        }