示例#1
0
        public async Task <long> SyncMessages(IDictionary <string, SystemMessages> remote)
        {
            long           processed  = 0;
            SystemMessages msgs       = Messages["en"];
            SystemMessages remoteMsgs = remote["en"];
            SystemLabel    label;

            foreach (KeyValuePair <string, SystemLabel> msg in remoteMsgs.Messages)
            {
                processed++;
                if (msgs.Messages.ContainsKey(msg.Key))
                {
                    msgs.Messages.TryRemove(msg.Key, out label);
                }
                msgs.Add(msg.Key, msg.Value);
            }

            msgs       = Messages["es"];
            remoteMsgs = remote["es"];
            foreach (KeyValuePair <string, SystemLabel> msg in remoteMsgs.Messages)
            {
                processed++;
                if (msgs.Messages.ContainsKey(msg.Key))
                {
                    msgs.Messages.TryRemove(msg.Key, out label);
                }
                msgs.Add(msg.Key, msg.Value);
            }

            msgs       = Messages["pt-br"];
            remoteMsgs = remote["pt-br"];
            foreach (KeyValuePair <string, SystemLabel> msg in remoteMsgs.Messages)
            {
                processed++;
                if (msgs.Messages.ContainsKey(msg.Key))
                {
                    msgs.Messages.TryRemove(msg.Key, out label);
                }
                msgs.Add(msg.Key, msg.Value);
            }

            await SaveSystemMessages();

            return(processed);
        }
示例#2
0
        private SystemMessages CreateMSystemMessages(string lang, IMongoCollection <SystemMessages> msgCollection)
        {
            var msgs = new SystemMessages()
            {
                Language = lang
            };
            var                   culture     = new CultureInfo(lang);
            ResourceSet           resourceSet = IlevusResources.Manager.GetResourceSet(culture, true, true);
            IDictionaryEnumerator enumerator  = resourceSet.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var msg = new SystemLabel()
                {
                    Content  = enumerator.Value.ToString(),
                    Reviewed = true,
                    New      = false
                };
                msgs.Add(enumerator.Key.ToString(), msg);
            }
            msgCollection.InsertOne(msgs);
            return(msgs);
        }