Beispiel #1
0
        public void InsertBefore(CultureInfo cultureAtInsertPoint, CultureInfo cultureToInsert)
        {
            if (!this.CultureWillFit(cultureToInsert))
            {
                throw new PreferredCulturesException(ServerStrings.TooManyCultures);
            }
            if (cultureAtInsertPoint == null || cultureToInsert == null)
            {
                throw new ArgumentNullException();
            }
            if (this.cultures.Contains(cultureToInsert))
            {
                if (LocaleMap.GetLcidFromCulture(cultureToInsert) == LocaleMap.GetLcidFromCulture(cultureAtInsertPoint))
                {
                    return;
                }
                this.Remove(cultureToInsert);
            }
            if (!this.cultures.Contains(cultureAtInsertPoint))
            {
                this.Add(cultureToInsert);
                return;
            }
            int index = this.cultures.IndexOf(cultureAtInsertPoint);

            this.cultures.Insert(index, cultureToInsert);
        }
 internal static bool TryGetDefaultFolderCulture(MailboxSession session, StoreObjectId inboxId, out CultureInfo defaultFolderCulture, out string inboxDisplayName)
 {
     defaultFolderCulture = null;
     inboxDisplayName     = null;
     if (session.LogonType == LogonType.Delegated)
     {
         return(false);
     }
     try
     {
         using (Folder folder = Folder.Bind(session, inboxId, new PropertyDefinition[]
         {
             FolderSchema.DefaultFoldersLocaleId
         }))
         {
             inboxDisplayName = folder.DisplayName;
             int?num = folder.TryGetProperty(FolderSchema.DefaultFoldersLocaleId) as int?;
             if (num != null)
             {
                 defaultFolderCulture = LocaleMap.GetCultureFromLcid(num.Value);
                 return(true);
             }
         }
     }
     catch (ObjectNotFoundException)
     {
         ExTraceGlobals.DefaultFoldersTracer.TraceError(0L, "DefaultFolderManager::TryGetDefaultFolderCulture. The Inbox is inaccessible.");
     }
     return(false);
 }
Beispiel #3
0
        private static CultureInfo GetMdnCulture(ICoreItem item)
        {
            int         num         = 0;
            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            if (item.Session != null)
            {
                cultureInfo = item.Session.InternalPreferedCulture;
            }
            CultureInfo result = cultureInfo;
            object      obj    = item.PropertyBag.TryGetProperty(ReportMessageSchema.MessageLocaleId);

            if (obj is int)
            {
                num = (int)obj;
            }
            try
            {
                if (num != 0)
                {
                    CultureInfo cultureInfo2 = LocaleMap.GetCultureFromLcid(num);
                    if (cultureInfo2.IsNeutralCulture)
                    {
                        cultureInfo2 = new CultureInfo(cultureInfo2.Name);
                    }
                    result = cultureInfo2;
                }
            }
            catch (ArgumentException)
            {
                result = cultureInfo;
            }
            return(result);
        }
Beispiel #4
0
            private void AddCultureMapping(CultureInfo culture, bool isResourcePresent)
            {
                Dictionary <int, bool> dictionary = new Dictionary <int, bool>(this.resourceAvailabilityMap);

                dictionary[LocaleMap.GetLcidFromCulture(culture)] = isResourcePresent;
                this.resourceAvailabilityMap = dictionary;
            }
Beispiel #5
0
 private static CultureInfo GetCultureEnglishUS()
 {
     if (ReplyForwardUtils.cultureEnglishUS == null)
     {
         ReplyForwardUtils.cultureEnglishUS = LocaleMap.GetCultureFromLcid(1033);
     }
     return(ReplyForwardUtils.cultureEnglishUS);
 }
        protected List <PeopleHeader> GetLocaleHeaderList(CultureInfo cultureInfo)
        {
            List <PeopleHeader> result = null;

            if (!this.localeHeaders.TryGetValue(LocaleMap.GetLcidFromCulture(cultureInfo), out result))
            {
                result = this.fallbackHeaders;
            }
            return(result);
        }
Beispiel #7
0
        internal static CultureInfo CalculateReplyForwardCulture(CultureInfo culture, Item newItem)
        {
            CultureInfo cultureInfo = null;

            if (culture != null)
            {
                cultureInfo = culture;
            }
            else if (newItem.Session != null)
            {
                cultureInfo = newItem.Session.InternalCulture;
            }
            if (cultureInfo != null && LocaleMap.GetLcidFromCulture(cultureInfo) == 4100)
            {
                return(ReplyForwardUtils.GetCultureEnglishUS());
            }
            return(cultureInfo);
        }
        public string GetHeader(string inputString, CultureInfo cultureInfo)
        {
            List <PeopleHeader> localeHeaderList = this.GetLocaleHeaderList(cultureInfo);

            for (int i = localeHeaderList.Count - 1; i >= 0; i--)
            {
                PeopleHeader peopleHeader = localeHeaderList[i];
                if (cultureInfo.CompareInfo.Compare(inputString, peopleHeader.StartChar, PeopleStringUtils.StringCompareOptions) >= 0)
                {
                    return(peopleHeader.DisplayName);
                }
            }
            string message = string.Format(CultureInfo.InvariantCulture, "List of headers should cover the entire unicode range. Input String: {0}, LCID: {1}, LocaleName: {2}", new object[]
            {
                inputString,
                LocaleMap.GetLcidFromCulture(cultureInfo),
                cultureInfo.Name
            });

            PeopleHeaderProvider.Tracer.TraceError(0L, message);
            return(PeopleHeaderProvider.FirstHeader.DisplayName);
        }
        private void StampDefaultFolderCulture()
        {
            CultureInfo   defaultFoldersCulture = this.session.SharedDataManager.DefaultFoldersCulture;
            StoreObjectId folderId;

            if (this.defaultFolders[5].TryGetFolderId(out folderId))
            {
                using (Folder folder = Folder.Bind(this.session, folderId, new PropertyDefinition[]
                {
                    FolderSchema.DefaultFoldersLocaleId
                }))
                {
                    folder.SetProperties(new StorePropertyDefinition[]
                    {
                        FolderSchema.DefaultFoldersLocaleId
                    }, new object[]
                    {
                        LocaleMap.GetLcidFromCulture(defaultFoldersCulture)
                    });
                    folder.Save();
                }
            }
        }
        private Dictionary <string, DefaultFolderManager.FolderData> ReadFolderData()
        {
            MapiFolder   mapiFolder   = null;
            StoreSession storeSession = this.Session;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                mapiFolder = this.session.Mailbox.MapiStore.GetNonIpmSubtreeFolder();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExCannotReadFolderData, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("DefaultFolderManager::ReadFolderData.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExCannotReadFolderData, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("DefaultFolderManager::ReadFolderData.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            Dictionary <string, DefaultFolderManager.FolderData> result;

            using (mapiFolder)
            {
                HierarchyTableFlags flags         = HierarchyTableFlags.ConvenientDepth;
                MapiTable           mapiTable     = null;
                StoreSession        storeSession2 = this.Session;
                bool   flag2 = false;
                byte[] inboxFolderEntryId;
                try
                {
                    if (storeSession2 != null)
                    {
                        storeSession2.BeginMapiCall();
                        storeSession2.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    mapiTable          = mapiFolder.GetHierarchyTable(flags);
                    inboxFolderEntryId = this.Session.Mailbox.MapiStore.GetInboxFolderEntryId();
                }
                catch (MapiPermanentException ex3)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExCannotReadFolderData, ex3, storeSession2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("DefaultFolderManager::ReadFolderData.", new object[0]),
                        ex3
                    });
                }
                catch (MapiRetryableException ex4)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExCannotReadFolderData, ex4, storeSession2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("DefaultFolderManager::ReadFolderData.", new object[0]),
                        ex4
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession2 != null)
                        {
                            storeSession2.EndMapiCall();
                            if (flag2)
                            {
                                storeSession2.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                using (mapiTable)
                {
                    PropTag[] columns = new PropTag[]
                    {
                        (PropTag)InternalSchema.EntryId.PropertyTag,
                        (PropTag)InternalSchema.DisplayName.PropertyTag,
                        (PropTag)InternalSchema.ContainerClass.PropertyTag,
                        (PropTag)InternalSchema.ParentEntryId.PropertyTag,
                        (PropTag)InternalSchema.MapiFolderType.PropertyTag,
                        (PropTag)InternalSchema.AdminFolderFlags.PropertyTag,
                        (PropTag)InternalSchema.IsHidden.PropertyTag,
                        (PropTag)InternalSchema.SystemFolderFlags.PropertyTag,
                        (PropTag)InternalSchema.ExtendedFolderFlagsInternal.PropertyTag,
                        (PropTag)InternalSchema.DefaultFoldersLocaleId.PropertyTag
                    };
                    PropValue[][] array         = null;
                    StoreSession  storeSession3 = this.Session;
                    bool          flag3         = false;
                    try
                    {
                        if (storeSession3 != null)
                        {
                            storeSession3.BeginMapiCall();
                            storeSession3.BeginServerHealthCall();
                            flag3 = true;
                        }
                        if (StorageGlobals.MapiTestHookBeforeCall != null)
                        {
                            StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                        }
                        mapiTable.SetColumns(columns);
                        array = mapiTable.QueryRows(StorageLimits.Instance.DefaultFolderDataCacheMaxRowCount);
                    }
                    catch (MapiPermanentException ex5)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.ExCannotReadFolderData, ex5, storeSession3, this, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("DefaultFolderManager::ReadFolderData.", new object[0]),
                            ex5
                        });
                    }
                    catch (MapiRetryableException ex6)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.ExCannotReadFolderData, ex6, storeSession3, this, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("DefaultFolderManager::ReadFolderData.", new object[0]),
                            ex6
                        });
                    }
                    finally
                    {
                        try
                        {
                            if (storeSession3 != null)
                            {
                                storeSession3.EndMapiCall();
                                if (flag3)
                                {
                                    storeSession3.EndServerHealthCall();
                                }
                            }
                        }
                        finally
                        {
                            if (StorageGlobals.MapiTestHookAfterCall != null)
                            {
                                StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                            }
                        }
                    }
                    if (array.Length == StorageLimits.Instance.DefaultFolderDataCacheMaxRowCount)
                    {
                        ExTraceGlobals.DefaultFoldersTracer.TraceDebug <int>((long)this.GetHashCode(), "DefaultFolderManager::ReadFolderData. There are too many folders under IpmSubtree. Some of default folders may have been ignored. Query Rows = {0}.", array.Length);
                    }
                    string      inboxDisplayName = null;
                    CultureInfo stampedCulture   = null;
                    Dictionary <string, DefaultFolderManager.FolderData> dictionary = new Dictionary <string, DefaultFolderManager.FolderData>();
                    foreach (PropValue[] array3 in array)
                    {
                        byte[]            array4              = array3[0].IsError() ? null : array3[0].GetBytes();
                        string            text                = array3[1].IsError() ? null : array3[1].GetString();
                        string            containerClass      = array3[2].IsError() ? null : array3[2].GetString();
                        byte[]            parentEntryId       = array3[3].IsError() ? null : array3[3].GetBytes();
                        FolderType?       arg                 = array3[4].IsError() ? null : new FolderType?((FolderType)array3[4].GetInt());
                        ELCFolderFlags?   elcFolderFlags      = array3[5].IsError() ? null : new ELCFolderFlags?((ELCFolderFlags)array3[5].GetInt());
                        bool              isHidden            = !array3[6].IsError() && array3[6].GetBoolean();
                        SystemFolderFlags?systemFolderFlags   = array3[7].IsError() ? null : new SystemFolderFlags?((SystemFolderFlags)array3[7].GetInt());
                        byte[]            extendedFolderFlags = array3[8].IsError() ? null : array3[8].GetBytes();
                        if (array4 != null && text != null && arg != null)
                        {
                            string key = Convert.ToBase64String(array4);
                            if (dictionary.ContainsKey(key))
                            {
                                ExTraceGlobals.DefaultFoldersTracer.TraceError <string, string, FolderType?>((long)this.GetHashCode(), "DefaultFolderManager::ReadFolderData. Store returns duplicate entries from hierarch query. Mailbox = {0}. displayName = {1}, folderType = {2}.", this.Session.DisplayName, text, arg);
                            }
                            else
                            {
                                dictionary.Add(key, new DefaultFolderManager.FolderData(text, arg.Value, containerClass, parentEntryId, elcFolderFlags, isHidden, systemFolderFlags, extendedFolderFlags));
                                if (array4.SequenceEqual(inboxFolderEntryId))
                                {
                                    int?num = new int?(array3[9].GetInt());
                                    if (num != null && num.Value >= 0)
                                    {
                                        stampedCulture = LocaleMap.GetCultureFromLcid(num.Value);
                                    }
                                }
                            }
                        }
                    }
                    this.session.SharedDataManager.DefaultFoldersCulture = this.GetBestCulture(stampedCulture, inboxDisplayName, this.session);
                    result = dictionary;
                }
            }
            return(result);
        }