Exemplo n.º 1
0
        ///// <summary>
        ///// Syncs groups. googleChanged and outlookChanged are needed because not always
        ///// when a google contact's groups have changed does it become dirty.
        ///// </summary>
        ///// <param name="match"></param>
        ///// <param name="googleChanged"></param>
        ///// <param name="outlookChanged"></param>
        //public void SaveContactGroups(ContactMatch match, out bool googleChanged, out bool outlookChanged)
        //{
        //    // get google groups
        //    Collection<GroupEntry> groups = Utilities.GetGoogleGroups(this, match.GoogleContact);

        //    // get outlook categories
        //    string[] cats = Utilities.GetOutlookGroups(match.OutlookContact);

        //    googleChanged = false;
        //    outlookChanged = false;

        //    if (groups.Count == 0 && cats.Length == 0)
        //        return;

        //    switch (SyncOption)
        //    {
        //        case SyncOption.MergeOutlookWins:
        //            //overwrite google contact
        //            OverwriteGoogleContactGroups(match.GoogleContact, groups, cats);
        //            googleChanged = true;
        //            break;
        //        case SyncOption.MergeGoogleWins:
        //            //overwrite outlook contact
        //            OverwriteOutlookContactGroups(match.OutlookContact, cats, groups);
        //            outlookChanged = true;
        //            break;
        //        case SyncOption.GoogleToOutlookOnly:
        //            //overwrite outlook contact
        //            OverwriteOutlookContactGroups(match.OutlookContact, cats, groups);
        //            outlookChanged = true;
        //            break;
        //        case SyncOption.OutlookToGoogleOnly:
        //            //overwrite google contact
        //            OverwriteGoogleContactGroups(match.GoogleContact, groups, cats);
        //            googleChanged = true;
        //            break;
        //        case SyncOption.MergePrompt:
        //            //TODO: we can not rely on previously chosen option as it may be different for each contact.
        //            if (CResolution == null)
        //            {
        //                //promp for sync option
        //                ConflictResolver r = new ConflictResolver();
        //                CResolution = r.Resolve(match.OutlookContact, match.GoogleContact);
        //            }
        //            switch (CResolution)
        //            {
        //                case ConflictResolution.Cancel:
        //                    break;
        //                case ConflictResolution.OutlookWins:
        //                    //overwrite google contact
        //                    OverwriteGoogleContactGroups(match.GoogleContact, groups, cats);
        //                    //TODO: we don't actually know if groups has changed. if all groups were the same it hasn't changed
        //                    googleChanged = true;
        //                    break;
        //                case ConflictResolution.GoogleWins:
        //                    //overwrite outlook contact
        //                    OverwriteOutlookContactGroups(match.OutlookContact, cats, groups);
        //                    //TODO: we don't actually know if groups has changed. if all groups were the same it hasn't changed
        //                    outlookChanged = true;
        //                    break;
        //                default:
        //                    break;
        //            }
        //            break;
        //    }
        //}

        public GroupEntry SaveGoogleGroup(GroupEntry group)
        {
            //check if this group was not yet inserted on google.
            if (group.Id.Uri == null)
            {
                //insert group.
                Uri feedUri = new Uri(GroupsQuery.CreateGroupsUri("default"));

                try
                {
                    GroupEntry createdEntry = _googleService.Insert(feedUri, group) as GroupEntry;
                    return(createdEntry);
                }
                catch (Exception ex)
                {
                    //TODO: save google group xml for diagnistics
                    throw;
                }
            }
            else
            {
                try
                {
                    //group already present in google. just update
                    GroupEntry updatedEntry = group.Update() as GroupEntry;
                    return(updatedEntry);
                }
                catch (Exception ex)
                {
                    //TODO: save google group xml for diagnistics
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult GetImageByName(GroupForUser group)
        {
            long languageId  = WebSettingsConfig.Instance.GetLanguageFromId();
            var  groupsQuery = new GroupsQuery(languageId);

            return(GetImage(group != null ? group.Name : null, n => groupsQuery.GetImage(n, GroupType.ByWord)));
        }
Exemplo n.º 3
0
 public IEnumerable <Group> Handle(GroupsQuery request)
 {
     using (var context = _contextFactory())
     {
         return(context.GetTable <Group>().ToList());
     }
 }
Exemplo n.º 4
0
        public void WriteGroups(XElement root)
        {
            Load();

            string allGroupsUrl = GetAllGroupsUrl();

            SitemapItemWriter.WriteUrlToResult(root, allGroupsUrl, 1);

            IGroupsQuery        groupsQuery   = new GroupsQuery(_languageId);
            List <GroupForUser> visibleGroups = groupsQuery.GetVisibleGroups(GroupType);

            foreach (GroupForUser visibleGroup in visibleGroups)
            {
                string name = visibleGroup.Name;
                string url  = GetUrlByName(name);
                SitemapItemWriter.WriteUrlToResult(root, url, 0.9m);

                url = GetSmartTrainerUrl(name);
                SitemapItemWriter.WriteUrlToResult(root, url, TRAINER_GROUP_PRIORITY, ChangeFrequency.YEARLY);

                url = GetManualTrainerUrl(name);
                SitemapItemWriter.WriteUrlToResult(root, url, INNER_GROUP_PRIORITY, ChangeFrequency.YEARLY);
                //записать содержимое группы
                WriteGroupContent(root, visibleGroup.Id, name);
            }
        }
Exemplo n.º 5
0
        public void Create(string file)
        {
            var csvReader = new CsvReader(file);
            //var sentences = IoCModule.Create<SentencesQuery>();
            var      languages = new LanguagesQuery(LanguageShortName.Unknown, LanguageShortName.Unknown);
            Language from      = languages.GetByShortName(_from);
            Language russian   = languages.GetByShortName(LanguageShortName.Ru);

            string[] firstLine = csvReader.ReadLine();
            if (firstLine == null || EnumerableValidator.IsEmpty(firstLine))
            {
                return;
            }

            string groupName = TextFormatter.FirstUpperCharAndTrim(firstLine[0]);

            if (string.IsNullOrEmpty(groupName) || groupName.Length < 2)
            {
                return;
            }
            var groupsQuery = new GroupsQuery(from.Id);

            string fileName = firstLine.Length > 1 && !string.IsNullOrWhiteSpace(firstLine[1])
                                  ? firstLine[1].Trim()
                                  : groupName;
            string imageFileName = Path.Combine(@"C:\Projects\StudyLanguages\Источники для групп\Источники картинок\",
                                                fileName + ".jpg");

            //создает или получает раннее созданную группу
            byte[]       image        = !string.IsNullOrEmpty(imageFileName) ? File.ReadAllBytes(imageFileName) : null;
            GroupForUser groupForUser = groupsQuery.GetOrCreate(GroupType, groupName, image);

            do
            {
                string[] line = csvReader.ReadLine();
                if (line == null)
                {
                    break;
                }
                if (line.Length < 2)
                {
                    continue;
                }
                image = line.Length > 2 && !string.IsNullOrEmpty(line[2]) ? File.ReadAllBytes(line[2]) : null;
                int?rating = null;
                int rat;
                if (line.Length > 3 && int.TryParse(line[3], out rat))
                {
                    rating = rat;
                }

                bool isSuccess = Create(groupForUser, line, from, russian, image, rating);
                Console.WriteLine("{0}: {1}", isSuccess ? "Сохранено" : "Не сохранено",
                                  line.Aggregate((e1, e2) => e1 + " -> " + e2));
            } while (true);
        }
Exemplo n.º 6
0
        protected List <GroupForUser> GetModel()
        {
            var languageId = WebSettingsConfig.Instance.GetLanguageFromId();

            IGroupsQuery        groupsQuery = new GroupsQuery(languageId);
            List <GroupForUser> groups      = groupsQuery.GetVisibleGroups(GroupType);
            var sorter = new GroupsSorter(HttpContext.Request.Cookies);

            sorter.Sort(groups);
            return(groups);
        }
Exemplo n.º 7
0
        static AtomEntryCollection GetGroups()
        {
            var query = new GroupsQuery(GroupsQuery.CreateGroupsUri("default"))
            {
                NumberToRetrieve = 1000
            };
            var feed   = service.Query(query);
            var groups = feed.Entries;

            return(groups);
        }
Exemplo n.º 8
0
        public IEnumerable <IContactTag> GetTags()
        {
            var query = new GroupsQuery("https://www.google.com/m8/feeds/groups/default/full");

            query.NumberToRetrieve = int.MaxValue;

            var feed   = _googleService.Query(query);
            var result = feed.Entries.OfType <GroupEntry>()
                         .Where(x => !x.Deleted && x.SystemGroup == null)
                         .Select(CreateTag).Where(x => x != null)
                         .ToArray();

            return(result);
        }
Exemplo n.º 9
0
        private GroupForUser GetGroupForUser(ActionExecutingContext filterContext)
        {
            var groupName = filterContext.RouteData.Values[RouteConfig.GROUP_PARAM_NAME] as string;

            if (string.IsNullOrWhiteSpace(groupName))
            {
                return(null);
            }

            var languageId  = WebSettingsConfig.Instance.GetLanguageFromId();
            var groupsQuery = new GroupsQuery(languageId);

            return(groupsQuery.GetVisibleGroupByName(_type, groupName));
        }
Exemplo n.º 10
0
        private static void findGroup(string groupname)
        {
            GroupsQuery query = new GroupsQuery(GroupsQuery.CreateGroupsUri("default"));

            query.StartDate = new DateTime(2008, 1, 1);
            Feed <Group> feed = cr.Get <Group>(query);

            foreach (Group group in feed.Entries)
            {
                if (group.Title == groupname)
                {
                    HRefMedlem = group.Id;
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Send authorized queries to a Request-based library
        /// </summary>
        /// <param name="service"></param>
        static void RunContactsSample(OAuth2Parameters parameters)
        {
            try
            {
                RequestSettings settings = new RequestSettings("Google contacts tutorial", parameters);
                ContactsRequest cr       = new ContactsRequest(settings);

                //ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
                //query.StartDate = new DateTime(2001, 1, 1);
                //Feed<Contact> feed = cr.Get<Contact>(query);
                //foreach (Contact contact in feed.Entries)
                //{
                //    Console.WriteLine(contact.Name.FullName);
                //    //Console.WriteLine("Updated on: " + contact.Updated.ToString());
                //}

                GroupsQuery query = new GroupsQuery(GroupsQuery.CreateGroupsUri("default"));
                query.StartDate = new DateTime(2001, 1, 1);
                Feed <Group> feed = cr.Get <Group>(query);

                foreach (Group group in feed.Entries)
                {
                    Console.WriteLine(group.Title);
                    Console.WriteLine("Updated on: " + group.Updated.ToString());
                }

                ////string applicationName = "Test-OAuth2";
                ////GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory("apps", applicationName, parameters);
                ////GroupsService service = new GroupsService(domain, applicationName);
                ////service.RequestFactory = requestFactory;
                ////GroupFeed feed = service.RetrieveAllGroups();
                ////foreach (GroupEntry group in feed.Entries)
                ////{
                ////    Console.WriteLine(group.GroupName);
                ////}

                //Feed<Contact> f = cr.GetContacts();
                //foreach (Contact c in f.Entries)
                //{
                //    Console.WriteLine(c.Name.FullName);
                //}
            }
            catch (Exception a)
            {
                Console.WriteLine("A Google Apps error occurred.");
                Console.WriteLine();
            }
        }
Exemplo n.º 12
0
        public void ConvertGroupSentences()
        {
            LoadLanguages();

            IGroupsQuery groupsQuery = new GroupsQuery(_userLanguages.To.Id);
            Dictionary <long, string> visibleGroups =
                groupsQuery.GetVisibleGroups(GroupType.BySentence).ToDictionary(
                    e => e.Id, e => e.Name);
            IGroupSentencesQuery groupSentencesQuery = new GroupSentencesQuery();

            foreach (var visibleGroup in visibleGroups)
            {
                long groupId = visibleGroup.Key;
                if (!visibleGroups.ContainsKey(groupId))
                {
                    continue;
                }

                string groupName = visibleGroups[groupId];
                string fileName  = string.Format(@"C:\Projects\StudyLanguages\Источники для групп\Group\{0}\Xml\{1}.xml",
                                                 _languageTo, groupName);

                if (File.Exists(fileName))
                {
                    Console.WriteLine("Группа \"{0}\" уже существует - пропустить", groupName);
                    continue;
                }

                List <SourceWithTranslation> sentences = groupSentencesQuery.GetSentencesByGroup(_userLanguages, groupId);

                Console.WriteLine("Начали обрабатывать группу фраз \"{0}\"", groupName);

                SaveConvertedWords(fileName, sentences);
            }

            Console.WriteLine(
                "Переконвертировали группы с фразами. Воспользовались дополнительными словарями {0} раз",
                _translator.CountExtraCalls);
        }
Exemplo n.º 13
0
        public void LoadGoogleGroups()
        {
            GroupsQuery query = new GroupsQuery(GroupsQuery.CreateGroupsUri("default"));

            query.NumberToRetrieve = 256;
            query.StartIndex       = 0;
            query.ShowDeleted      = false;

            GroupsFeed feed;

            feed          = _googleService.Query(query);
            _googleGroups = feed.Entries;
            while (feed.Entries.Count == query.NumberToRetrieve)
            {
                query.StartIndex = _googleGroups.Count;
                feed             = _googleService.Query(query);
                foreach (AtomEntry a in feed.Entries)
                {
                    _googleGroups.Add(a);
                }
            }
        }
Exemplo n.º 14
0
        public ActionResult Index(UserLanguages userLanguages)
        {
            const int COUNT = 5;

            if (UserLanguages.IsInvalid(userLanguages))
            {
                return(RedirectToAction("Unknown", "Errors"));
            }

            var  model      = new MainModel();
            long languageId = WebSettingsConfig.Instance.GetLanguageFromId();

            //слова по темам
            AddSectionIfNeed(SectionId.GroupByWords, model, () => {
                IGroupsQuery groupsQuery   = new GroupsQuery(languageId);
                List <GroupForUser> groups = groupsQuery.GetVisibleGroups(GroupType.ByWord, COUNT);
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Слова по темам",
                        Url = Url.Action("Index", RouteConfig.GROUPS_BY_WORDS_CONTROLLER, null, Request.Url.Scheme),
                        Description = "Перейти ко всем темам"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.GroupByWordsDescription),
                    MostPopularTitle = "5 наиболее популярных тем:",
                    Items = ConvertToItems(groups, e => e.Name),
                    TitleItemGetter =
                        item =>
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.GroupByWords, PageId.Index,
                                                                   TemplateId.ItemTipOnMainPage, item.Title),
                    UrlItemGetter =
                        item =>
                        @Url.Action("Index", RouteConfig.GROUP_WORD_CONTROLLER, new { group = item.Title + "/" },
                                    Request.Url.Scheme),
                    UrlImageItemGetter =
                        item =>
                        Url.Action("GetImageByName", RouteConfig.GROUP_WORD_CONTROLLER, new { group = item.Title },
                                   Request.Url.Scheme),
                    //Btn = BtnModel.CreateBuyAllMaterials(Url, "btn btn-danger btn-xs buy-btn-main")
                });
            });

            //почувствуй разницу
            AddSectionIfNeed(SectionId.FillDifference, model, () => {
                IComparisonsQuery comparisonsQuery   = new ComparisonsQuery(languageId);
                List <ComparisonForUser> comparisons = comparisonsQuery.GetVisibleWithoutRules(COUNT);
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Почувствуй разницу",
                        Url =
                            Url.Action("Index", RouteConfig.GROUPS_BY_COMPARISONS_CONTROLLER, null,
                                       Request.Url.Scheme),
                        Description = "Перейти ко всем правилам употребления"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.FillDifferenceDescription),
                    MostPopularTitle = "5 наиболее популярных тем сравнения:",
                    Items = ConvertToItems(comparisons, e => e.Title),
                    TitleItemGetter =
                        item =>
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.FillDifference, PageId.Index,
                                                                   TemplateId.ItemTipOnMainPage, item.Title),
                    UrlItemGetter =
                        item =>
                        Url.Action("Index", RouteConfig.COMPARISON_CONTROLLER, new { group = item.Title + "/" },
                                   Request.Url.Scheme)
                });
            });

            //минилекс слов
            AddSectionIfNeed(SectionId.PopularWord, model, () => {
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Минилекс слов",
                        Url =
                            Url.Action("Index", RouteConfig.POPULAR_WORDS_CONTROLLER, null, Request.Url.Scheme),
                        Description = "Перейти к минилексу слов Гуннемарка"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.PopularWordDescription)
                });
            });

            //визуальные словари
            AddSectionIfNeed(SectionId.VisualDictionary, model, () => {
                IRepresentationsQuery representationsQuery       = new RepresentationsQuery(languageId);
                List <RepresentationForUser> visibleDictionaries = representationsQuery.GetVisibleWithoutAreas(COUNT);
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Визуальные словари",
                        Url =
                            Url.Action("Index", RouteConfig.VISUAL_DICTIONARIES_CONTROLLER_NAME, null,
                                       Request.Url.Scheme),
                        Description = "Перейти ко всем визуальным словарям"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main,
                                                                   TemplateId.VisualDictionaryDescription),
                    MostPopularTitle = "5 наиболее популярных визуальных словарей:",
                    Items = ConvertToItems(visibleDictionaries, e => e.Title),
                    TitleItemGetter =
                        item =>
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.VisualDictionary, PageId.Index,
                                                                   TemplateId.ItemTipOnMainPage, item.Title),
                    UrlItemGetter =
                        item =>
                        Url.Action("Index", RouteConfig.VISUAL_DICTIONARY_CONTROLLER, new { group = item.Title + "/" },
                                   Request.Url.Scheme),
                    UrlImageItemGetter =
                        item =>
                        Url.Action("GetImageByName", RouteConfig.VISUAL_DICTIONARY_CONTROLLER, new { group = item.Title },
                                   Request.Url.Scheme),
                    //Btn = BtnModel.CreateBuyVisualDictionaries(Url, "btn btn-danger btn-xs buy-btn-main")
                });
            });

            AddSectionIfNeed(SectionId.GroupByPhrases, model, () => {
                //фразы по темам
                IGroupsQuery groupsQuery   = new GroupsQuery(languageId);
                List <GroupForUser> groups = groupsQuery.GetVisibleGroups(GroupType.BySentence, COUNT);
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Фразы по темам",
                        Url = Url.Action("Index", RouteConfig.GROUPS_BY_SENTENCES_CONTROLLER, null, Request.Url.Scheme),
                        Description = "Перейти ко всем темам"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.GroupByPhrasesDescription),
                    MostPopularTitle = "5 наиболее популярных тем:",
                    Items = ConvertToItems(groups, e => e.Name),
                    TitleItemGetter =
                        item =>
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.GroupByPhrases, PageId.Index,
                                                                   TemplateId.ItemTipOnMainPage, item.Title),
                    UrlItemGetter =
                        item =>
                        @Url.Action("Index", RouteConfig.GROUP_SENTENCE_CONTROLLER, new { group = item.Title + "/" },
                                    Request.Url.Scheme),
                    UrlImageItemGetter =
                        item =>
                        Url.Action("GetImageByName", RouteConfig.GROUP_SENTENCE_CONTROLLER, new { group = item.Title },
                                   Request.Url.Scheme),
                });
            });

            //стена знания
            AddSectionIfNeed(SectionId.MyKnowledge, model, () => new DescriptionSection {
                Title = new DescriptionTitle {
                    Title       = "Стена знаний",
                    Url         = Url.Action("Index", RouteConfig.USER_KNOWLEDGE_CONTROLLER, null, Request.Url.Scheme),
                    Description = "Перейти к стене с Вашими знаниями"
                },
                Description =
                    WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.MyKnowledgeDescription),
                Items = null,
            });

            //генератор знаний
            AddSectionIfNeed(SectionId.KnowledgeGenerator, model, () => new DescriptionSection {
                Title = new DescriptionTitle {
                    Title       = "Генератор знаний",
                    Url         = Url.Action("Index", RouteConfig.KNOWLEDGE_GENERATOR_CONTROLLER, null, Request.Url.Scheme),
                    Description = "Перейти к генератору знаний"
                },
                Description =
                    WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.KnowledgeGeneratorDescription),
                Items = null,
            });

            //видео
            AddSectionIfNeed(SectionId.Video, model, () => {
                IVideosQuery videosQuery   = new VideosQuery(languageId);
                List <VideoForUser> videos = videosQuery.GetVisible(VideoType.Clip, COUNT);
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Видеоролики",
                        Url = Url.Action("Index", RouteConfig.VIDEO_CONTROLLER, new { type = VideoType.Clip }, Request.Url.Scheme),
                        Description = "Перейти ко всем видеороликам"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.VideoDescription),
                    MostPopularTitle = "5 наиболее популярных видеороликов:",
                    Items = ConvertToItems(videos, e => e.Title),
                    TitleItemGetter =
                        item =>
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Video, PageId.Index,
                                                                   TemplateId.ItemTipOnMainPage, item.Title),
                    UrlItemGetter =
                        item =>
                        @Url.Action("Detail", RouteConfig.VIDEO_CONTROLLER, new { group = item.Title + "/" },
                                    Request.Url.Scheme),
                    UrlImageItemGetter =
                        item =>
                        Url.Action("GetImageByName", RouteConfig.VIDEO_CONTROLLER, new { group = item.Title },
                                   Request.Url.Scheme),
                });
            });

            //задания
            AddSectionIfNeed(SectionId.UserTasks, model, () => {
                return(new DescriptionSection {
                    Title = new DescriptionTitle {
                        Title = "Задания",
                        Url =
                            Url.Action("Index", RouteConfig.USER_TASKS_CONTROLLER, null, Request.Url.Scheme),
                        Description = "Перейти к заданиям пользователей"
                    },
                    Description =
                        WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.UserTasksDescription)
                });
            });

            //предложения
            AddSectionIfNeed(SectionId.Sentences, model, () => new DescriptionSection {
                Title = new DescriptionTitle {
                    Title       = "Предложения",
                    Url         = Url.Action("Index", RouteConfig.HOME_CONTROLLER, null, Request.Url.Scheme),
                    Description = "Перейти к предложениям"
                },
                Description =
                    WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.SentencesDescription),
                Items = null,
            });

            //аудирование
            AddSectionIfNeed(SectionId.Audio, model, () => new DescriptionSection {
                Title = new DescriptionTitle {
                    Title       = "Аудирование",
                    Url         = Url.Action("Index", RouteConfig.AUDIO_WORDS_CONTROLLER, null, Request.Url.Scheme),
                    Description = "Перейти к аудированию"
                },
                Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.AudioDescription),
                Items       = null,
            });

            //перевод слов
            AddSectionIfNeed(SectionId.WordTranslation, model, () => new DescriptionSection {
                Title = new DescriptionTitle {
                    Title       = "Перевод слов",
                    Url         = Url.Action("Index", RouteConfig.WORDS_TRANSLATION_CONTROLLER, null, Request.Url.Scheme),
                    Description = "Перейти к переводу слов"
                },
                Description =
                    WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.WordTranslationDescription),
                Items = null,
            });

            //перевод фразовых глаголов
            AddSectionIfNeed(SectionId.PhraseVerbTranslation, model, () => new DescriptionSection {
                Title = new DescriptionTitle {
                    Title       = "Перевод фразовых глаголов",
                    Url         = Url.Action("Index", RouteConfig.PHRASAL_VERBS_TRANLATION_CONTROLLER, null, Request.Url.Scheme),
                    Description = "Перейти к переводу фразовых глаголов"
                },
                Description =
                    WebSettingsConfig.Instance.GetTemplateText(SectionId.Main,
                                                               TemplateId.PhrasalVerbsTranslationDescription),
                Items = null,
            });

            return(View(model));
        }
Exemplo n.º 15
0
        /// <summary>
        ///  returns a feed of Groups for the given user
        /// </summary>
        /// <param name="user">the user for whom to retrieve the feed</param>
        /// <returns>a feed of Groups</returns>
        public Feed <Group> GetGroups(string user)
        {
            GroupsQuery q = PrepareQuery <GroupsQuery>(GroupsQuery.CreateGroupsUri(user));

            return(PrepareFeed <Group>(q));
        }
        /////////////////////////////////////////////////////////////////////////////


        /////////////////////////////////////////////////////////////////////
        /// <summary>runs an basic auth test against the groups feed test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void GroupsSystemTest()
        {
            Tracing.TraceMsg("Entering GroupsSystemTest");

            GroupsQuery     query   = new GroupsQuery(ContactsQuery.CreateGroupsUri(this.userName + "@googlemail.com"));
            ContactsService service = new ContactsService("unittests");

            if (this.userName != null)
            {
                service.Credentials = new GDataCredentials(this.userName, this.passWord);
            }

            GroupsFeed feed = service.Query(query);

            int i = 0;

            foreach (GroupEntry g in feed.Entries)
            {
                if (g.SystemGroup != null)
                {
                    i++;
                }
            }

            Assert.IsTrue(i == 4, "There should be 4 system groups in the groups feed");


            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("GroupsAuthTest"));

            GroupEntry newGroup = new GroupEntry();

            newGroup.Title.Text = "Private Data";

            GroupEntry insertedGroup = feed.Insert(newGroup);

            GroupEntry g2 = new GroupEntry();

            g2.Title.Text = "Another Private Group";
            GroupEntry insertedGroup2 = feed.Insert(g2);

            // now insert a new contact that belongs to that group
            ContactsQuery   q      = new ContactsQuery(ContactsQuery.CreateContactsUri(this.userName + "@googlemail.com"));
            ContactsFeed    cf     = service.Query(q);
            ContactEntry    entry  = ObjectModelHelper.CreateContactEntry(1);
            GroupMembership member = new GroupMembership();

            member.HRef = insertedGroup.Id.Uri.ToString();
            GroupMembership member2 = new GroupMembership();

            member2.HRef = insertedGroup2.Id.Uri.ToString();

            ContactEntry insertedEntry = cf.Insert(entry);

            // now change the group membership
            insertedEntry.GroupMembership.Add(member);
            insertedEntry.GroupMembership.Add(member2);
            ContactEntry currentEntry = insertedEntry.Update();

            Assert.IsTrue(currentEntry.GroupMembership.Count == 2, "The entry should be in 2 groups");

            currentEntry.GroupMembership.Clear();
            currentEntry = currentEntry.Update();
            // now we should have 2 new groups and one new entry with no groups anymore

            int oldCountGroups   = feed.Entries.Count;
            int oldCountContacts = cf.Entries.Count;

            currentEntry.Delete();

            insertedGroup.Delete();
            insertedGroup2.Delete();

            feed = service.Query(query);
            cf   = service.Query(q);

            Assert.AreEqual(oldCountContacts, cf.Entries.Count, "Contacts count should be the same");
            Assert.AreEqual(oldCountGroups, feed.Entries.Count, "Groups count should be the same");
        }
Exemplo n.º 17
0
        private List <GroupForUser> GetGroups(GroupType groupType)
        {
            var groupsQuery = new GroupsQuery(_languageId);

            return(groupsQuery.GetVisibleGroups(groupType));
        }
Exemplo n.º 18
0
 public IEnumerable <GroupModel> Run(GroupsQuery query)
 {
     return(this.forumGateway.GetGroups());
 }