Пример #1
0
        private async Task InsertPersonalityInsights(PersonalityInsightsRequest personalityInsightsReq,
                                                     string piUsername,
                                                     string piPassword,
                                                     string facebookUserId)
        {
            DataAccess.FacebookProfile userProfile       = null;
            WatsonCSClient             objWatsonCsClient = new WatsonCSClient(piUsername, piPassword);
            var personalityInsights = await objWatsonCsClient.GetProfile(personalityInsightsReq);

            using (DataAccess.MoodDetectorContext ctx = new DataAccess.MoodDetectorContext())
            {
                if (userProfile == null)
                {
                    userProfile = ctx.FacebookProfiles.Where(p => p.ProfileId == facebookUserId).FirstOrDefault();
                }
                DataAccess.FacebookPersonalityInsight daPI = new DataAccess.FacebookPersonalityInsight();
                daPI.ProcessedLanguage = personalityInsights.Response.processed_language;
                daPI.WordCount         = personalityInsights.Response.word_count;
                daPI.JsonRequest       = personalityInsights.JsonRequest;
                daPI.FacebookProfileId = userProfile.FacebookProfileId;
                ctx.FacebookPersonalityInsights.Add(daPI);
                ctx.SaveChanges();
                ProcessPersonality(personalityInsights.Response, ctx, daPI);
                ProcessNeeds(personalityInsights.Response, ctx, daPI);
                ProcessBehavior(personalityInsights.Response, ctx, daPI);
                ProcessValues(personalityInsights.Response, ctx, daPI);
                ProcessConsumptionPreferences(personalityInsights.Response, ctx, daPI);
                ctx.SaveChanges();
            }
            await Task.Yield();
        }
Пример #2
0
        public async Task PersonalityInsightsAuth()
        {
            WatsonCSClient
                watsonClient =
                new WatsonCSClient(PIUsername,
                                   PIPassword);
            var token = await watsonClient.GetTokenForPersonalityInsights();

            await Task.Yield();
        }