private static UserConfiguration BuildConfigurationFromQueryItem(Folder folder, IStorePropertyBag row, bool hasLoadedUserConfigurationData) { if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemClass))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass")); } if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemId))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id")); } if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.UserConfigurationType))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = UserConfigurationType."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("UserConfigurationType")); } string name = (string)row[InternalSchema.ItemClass]; if (!UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass)) { return(null); } UserConfigurationName configurationName = new UserConfigurationName(name, ConfigurationNameKind.ItemClass); if (hasLoadedUserConfigurationData) { object dictionaryObject = UserConfiguration.CheckDictionaryData(row.TryGetProperty(InternalSchema.UserConfigurationDictionary)); return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], dictionaryObject, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row)); } return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], null, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row)); }
public static bool IsValidName(string configurationName) { if (configurationName == null) { throw new ArgumentNullException("configurationName"); } return(UserConfigurationName.IsValidName(configurationName, ConfigurationNameKind.Name)); }
private static void AddToConfigurationCache(Folder folder, IList <IStorePropertyBag> items) { if (items == null || items.Count == 0) { return; } MailboxSession mailboxSession = folder.Session as MailboxSession; if (mailboxSession == null) { throw new NotSupportedException(); } UserConfigurationManager userConfigurationManager = mailboxSession.UserConfigurationManager; List <VersionedId> list = new List <VersionedId>(); new List <int>(); string a = null; for (int i = 0; i < items.Count; i++) { IStorePropertyBag storePropertyBag = items[i]; if (PropertyError.IsPropertyError(storePropertyBag.TryGetProperty(InternalSchema.ItemClass))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass")); } if (PropertyError.IsPropertyError(storePropertyBag.TryGetProperty(InternalSchema.ItemId))) { ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id."); throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id")); } string b = storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string; if (a == b) { list.Add((VersionedId)storePropertyBag[InternalSchema.ItemId]); items.RemoveAt(i); i--; } else { string name = (string)storePropertyBag[InternalSchema.ItemClass]; if (UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass)) { userConfigurationManager.UserConfigurationCache.Add(folder.Id.ObjectId, new UserConfigurationName(name, ConfigurationNameKind.ItemClass), ((VersionedId)storePropertyBag[InternalSchema.ItemId]).ObjectId); } } a = (storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string); } if (folder.Session.LogonType == LogonType.Owner) { userConfigurationManager.UserConfigurationCache.Save(); } AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.SoftDelete, list.ToArray()); UserConfiguration.CheckOperationResults(result, "DeleteDuplicates"); }