Пример #1
0
        protected void FillSearchControls()
        {
            sortOrders.Clear();
            exerciseTypes.Clear();
            searchGroups.Clear();
            ExerciseName = null;

            foreach (SearchSortOrder type in Enum.GetValues(typeof(SearchSortOrder)))
            {
                CheckListItem <SearchSortOrder> item = new CheckListItem <SearchSortOrder>(EnumLocalizer.Default.Translate(type), type);
                sortOrders.Add(item);
            }

            var strengthTrainingLocalizer = new EnumLocalizer(StrengthTrainingEntryStrings.ResourceManager);

            foreach (ExerciseSearchCriteriaGroup type in Enum.GetValues(typeof(ExerciseSearchCriteriaGroup)))
            {
                CheckListItem <ExerciseSearchCriteriaGroup> item = new CheckListItem <ExerciseSearchCriteriaGroup>(strengthTrainingLocalizer.Translate(type), type);
                if (type == ExerciseSearchCriteriaGroup.Other)
                {//by default search only in other user exercises
                    item.IsChecked = true;
                }
                SearchGroups.Add(item);
            }
            foreach (ExerciseType type in Enum.GetValues(typeof(ExerciseType)))
            {
                if (type != ExerciseType.NotSet)
                {
                    CheckListItem <ExerciseType> item = new CheckListItem <ExerciseType>(EnumLocalizer.Default.Translate(type), type);
                    exerciseTypes.Add(item);
                }
            }
        }
        private async Task Run()
        {
            var keywords = SearchGroups.Contains("|") ? string.Join(",", SearchGroups.Split('|')) : SearchGroups;
            var config   = new EventHubConfig();

            config.ConnectionString = EventHubConnectionString;
            config.EventHubName     = EventHubName;

            Tweet             = new Tweet();
            Tweet.keepRunning = true;
            var myEventHubObserver = new EventHubObserverWPF(config);

            var sendingPayload = Tweet.StreamStatuses(new TwitterConfig(OAuthToken, OAuthTokenSecret, OAuthCustomerKey, OAuthConsumerSecret,
                                                                        keywords, SearchGroups)).Select(tweet => Sentiment.ComputeScore(tweet, SearchGroups, RequireAll ? "all" : "any")).Select(tweet => new Payload {
                CreatedAt = tweet.CreatedAt, Topic = tweet.Topic, SentimentScore = tweet.SentimentScore, Author = tweet.UserName, Text = tweet.Text, SendExtended = SendExtendedInformation
            });

            if (ClearUnfoundSentiment)
            {
                sendingPayload = sendingPayload.Where(e => e.SentimentScore > -1);
            }
            sendingPayload = sendingPayload.Where(e => e.Topic != "No Match");
            SendingPayload = await Task <IDisposable> .Run(() =>
            {
                return(SendingPayload = sendingPayload.ToObservable().Subscribe(myEventHubObserver));
            });
        }
Пример #3
0
        private ActionResult DoSearch()
        {
            IdentifierNames  = displayOptions.Default;
            IdentifierLabels = IdentifierNames.ToDictionary(_ => _, path => GetIdentifierDefinitionByPath(path).Name);

            var identifierSearches = SearchGroups
                                     .SelectMany(_ => _.Fields)
                                     .Where(_ => !string.IsNullOrWhiteSpace(_.Value))
                                     .Select(_ => new IdentifierSearch {
                IdentifierName = _.FieldName, Value = _.Value, Operator = GetOperator(_)
            })
                                     .ToArray();

            if (string.IsNullOrEmpty(SubjectIdentifier) && !identifierSearches.Any())
            {
                ModelState.AddModelError("", "Please enter a search criteria");
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var studyIdentity     = Study.Id;
            var consentedSubjects =
                IncludeWithdrawnParticipants
                    ? Subjects.GetSubjectsWithLastWithdrawalDate(studyIdentity).Select(_ => _.studySubject)
                    : Subjects.GetConsentedSubjects(studyIdentity);

            Logger.LogDebug(
                "Found {count} consentedPeople - {consentedPeopleIds}",
                consentedSubjects.LongCount(),
                consentedSubjects);

            ShowPeople = true;
            var peopleDetails = identityRepository.GetPeopleWithIdentifiers(
                consentedSubjects.Select(_ => _.PersonId),
                IdentifierNames,
                user,
                identifierSearches,
                SubjectIdentifier);

            People =
                (from p in peopleDetails
                 join s in consentedSubjects on p.Key equals s.PersonId
                 select new PersonDetails {
                Subject = s, Identifiers = p.Value
            }
                ).ToImmutableList();

            return(Page());
        }