CustomNamingPeople: fix

This commit is contained in:
pavelbannov 2020-11-02 13:35:08 +03:00
parent 10d21caf30
commit b0b4f91eac

View File

@ -163,9 +163,18 @@ namespace ASC.Web.Core.Users
public class CustomNamingPeople
{
private static object Locked;
private static bool loaded = false;
private static readonly List<PeopleNamesItem> items = new List<PeopleNamesItem>();
private SettingsManager SettingsManager { get; }
static CustomNamingPeople()
{
Locked = new object();
loaded = false;
items = new List<PeopleNamesItem>();
}
public CustomNamingPeople(SettingsManager settingsManager)
{
@ -183,9 +192,6 @@ namespace ASC.Web.Core.Users
}
}
public PeopleNamesSettings PeopleNamesSettings { get; }
private SettingsManager SettingsManager { get; }
public string Substitute<T>(string resourceKey) where T : class
{
var text = (string)typeof(T).GetProperty(resourceKey, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null, null);
@ -257,28 +263,36 @@ namespace ASC.Web.Core.Users
return;
}
loaded = true;
var doc = new XmlDocument();
doc.LoadXml(NamingPeopleResource.PeopleNames);
items.Clear();
foreach (XmlNode node in doc.SelectNodes("/root/item"))
lock (Locked)
{
var item = new PeopleNamesItem
if (loaded)
{
Id = node.SelectSingleNode("id").InnerText,
SchemaName = node.SelectSingleNode("names/schemaname").InnerText,
GroupHeadCaption = node.SelectSingleNode("names/grouphead").InnerText,
GroupCaption = node.SelectSingleNode("names/group").InnerText,
GroupsCaption = node.SelectSingleNode("names/groups").InnerText,
UserCaption = node.SelectSingleNode("names/user").InnerText,
UsersCaption = node.SelectSingleNode("names/users").InnerText,
UserPostCaption = node.SelectSingleNode("names/userpost").InnerText,
RegDateCaption = node.SelectSingleNode("names/regdate").InnerText,
GuestCaption = node.SelectSingleNode("names/guest").InnerText,
GuestsCaption = node.SelectSingleNode("names/guests").InnerText,
};
items.Add(item);
return;
}
loaded = true;
var doc = new XmlDocument();
doc.LoadXml(NamingPeopleResource.PeopleNames);
items.Clear();
foreach (XmlNode node in doc.SelectNodes("/root/item"))
{
var item = new PeopleNamesItem
{
Id = node.SelectSingleNode("id").InnerText,
SchemaName = node.SelectSingleNode("names/schemaname").InnerText,
GroupHeadCaption = node.SelectSingleNode("names/grouphead").InnerText,
GroupCaption = node.SelectSingleNode("names/group").InnerText,
GroupsCaption = node.SelectSingleNode("names/groups").InnerText,
UserCaption = node.SelectSingleNode("names/user").InnerText,
UsersCaption = node.SelectSingleNode("names/users").InnerText,
UserPostCaption = node.SelectSingleNode("names/userpost").InnerText,
RegDateCaption = node.SelectSingleNode("names/regdate").InnerText,
GuestCaption = node.SelectSingleNode("names/guest").InnerText,
GuestsCaption = node.SelectSingleNode("names/guests").InnerText,
};
items.Add(item);
}
}
}