private static RepresentationForUser GetRepresentationForUser(UserLanguages userLanguages, string group)
        {
            if (string.IsNullOrEmpty(group))
            {
                return(null);
            }
            RepresentationsQuery  representationsQuery  = GetRepresentationsQuery();
            RepresentationForUser representationForUser = representationsQuery.GetWithAreas(userLanguages, group);

            return(representationForUser);
        }
Esempio n. 2
0
        public void ConvertVisualDictionaries()
        {
            LoadLanguages();

            var representationsQuery = new RepresentationsQuery(_userLanguages.To.Id);
            Dictionary <long, string> visibleDictionaries =
                representationsQuery.GetVisibleWithoutAreas().ToDictionary(e => e.Id, e => e.Title);

            foreach (var visualDictionary in visibleDictionaries)
            {
                long id = visualDictionary.Key;
                if (!visibleDictionaries.ContainsKey(id))
                {
                    continue;
                }

                string title    = visibleDictionaries[id];
                string fileName =
                    string.Format(@"C:\Projects\StudyLanguages\Источники визуального словаря\{0}\Xml\{1}.xml",
                                  _languageTo, title);

                if (File.Exists(fileName))
                {
                    Console.WriteLine("Визуальный словарь \"{0}\" уже существует - пропустить", title);
                    continue;
                }

                Console.WriteLine("Начали обрабатывать визуальный словарь \"{0}\"", title);

                RepresentationForUser representation = representationsQuery.GetWithAreas(_userLanguages,
                                                                                         visualDictionary.Value);
                if (representation == null)
                {
                    Console.WriteLine(
                        "Не удалось получить данные из словаря \"{0}\" - пропустить. Нажмите enter для продолжения...",
                        title);
                    Console.ReadLine();
                    continue;
                }
                List <SourceWithTranslation> words =
                    representation.Areas.Select(e => {
                    var sourceWithTranslation = new SourceWithTranslation();
                    sourceWithTranslation.Set(e.WordTranslationId, e.Source, e.Translation);
                    return(sourceWithTranslation);
                }).ToList();

                SaveConvertedWords(fileName, words);
            }

            Console.WriteLine(
                "Переконвертировали визуальные словари. Воспользовались дополнительными словарями {0} раз",
                _translator.CountExtraCalls);
        }
Esempio n. 3
0
        internal RepresentationForUser GetVisualDictionary(string title)
        {
            var representationsQuery = new RepresentationsQuery(_languageId);

            return(representationsQuery.GetWithAreas(_userLanguages, title));
        }