Skip to content
Permalink
Browse files

Edn of day commit

  • Loading branch information
codingmag committed Sep 28, 2016
1 parent 57eaea2 commit 67bf08f1822252dfa5a392610324dfb1ea0a599b
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocialFeedCollector.Job", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocialMediaAdapters", "SocialMediaAdapters\SocialMediaAdapters.csproj", "{A00B5F39-5D8A-4267-94C6-186F318F3158}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocialFeedCollector.ListInstances", "SocialFeedCollector.ListInstances\SocialFeedCollector.ListInstances.csproj", "{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -23,12 +21,6 @@ Global
{A00B5F39-5D8A-4267-94C6-186F318F3158}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A00B5F39-5D8A-4267-94C6-186F318F3158}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A00B5F39-5D8A-4267-94C6-186F318F3158}.Release|Any CPU.Build.0 = Release|Any CPU
{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}.Release|Any CPU.Build.0 = Release|Any CPU
{9CEF44FD-476B-4BE7-B338-295CD56DAA0C}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -3,7 +3,7 @@
<appSettings>
<add key="SharePointClientId" value="33206122-2f2d-42e1-b966-aa5c31072ec5"/>
<add key="SharePointClientSecret" value="QPkA5fZEkA88NmTyXwjmYtOQwajciziktWge3vC3R1k="/>
<add key="SharePointSiteUrl" value="https://codeholio.sharepoint.com/sites/sampledevsite/social365"/>
<add key="SharePointSiteUrl" value="https://codeholio.sharepoint.com/sites/sampledevsite"/>
<add key="SharePointListName" value="SocialFeeds"/>
<add key="SocialMediaQuery" value="brexit"/>
<add key="TwitterConsumerKey" value="k0lKFT9Z3IdCT1emt2DG8V60u" />
@@ -32,7 +32,8 @@ public static ApplicationSettings AppSettings

static void Main(string[] args)
{
Task.Run(async () => { MainAsync(); }).Wait();
var mainTask = MainAsync();
mainTask.Wait();
}

private static async Task MainAsync()
@@ -116,8 +117,8 @@ private static void GetValidateAppSettings()

private static void AddItem(ClientContext context, string listTitle, SocialFeedItem socialFeedItem)
{
var web = context.Web;
var list = web.GetList(listTitle);
var list = context.Web.Lists.GetByTitle(listTitle);
context.ExecuteQuery();
var listItemInfo = new ListItemCreationInformation();
var listItem = list.AddItem(listItemInfo);
listItem["Title"] = socialFeedItem.Username;
@@ -141,8 +142,10 @@ private static void AddItem(ClientContext context, string listTitle, SocialFeedI
private static async Task<List<SocialFeedItem>> SearchTwitterAsync(string query)
{
TwitterAdapter.ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"].ToString();
TwitterAdapter.ConsumerSecret = System.Web.HttpContext.Current.Application["TwitterConsumerSecret"].ToString();
TwitterAdapter.ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"].ToString();

var results = await TwitterAdapter.SearchAsync(query);

return results;
}

@@ -156,8 +159,7 @@ private static bool ListExists(ClientContext context, string listTitle)

private static bool ItemExists(ClientContext context, string listTitle, SocialFeedItem socialFeedItem)
{
var web = context.Web;
var list = web.GetList(listTitle);
var list = context.Web.Lists.GetByTitle(listTitle);
var listItemCamlQuery = new CamlQuery()
{
ViewXml = string.Format(@"<View>
@@ -168,25 +170,40 @@ private static bool ItemExists(ClientContext context, string listTitle, SocialFe
<FieldRef Name='Title' />
<Value Type='Text'>{0}</Value>
</Eq>
<Eq>
<FieldRef Name='Text' />
<Value Type='Text'>{1}</Value>
</Eq>
<Eq>
<FieldRef Name='Source' />
<Value Type='Text'>{2}</Value>
</Eq>
<And>
<Eq>
<FieldRef Name='Text' />
<Value Type='Text'>{1}</Value>
</Eq>
<Eq>
<FieldRef Name='Source' />
<Value Type='Choice'>{2}</Value>
</Eq>
</And>
</And>
</Where>
</Query>
</View>",
socialFeedItem.Username,
socialFeedItem.Text,
socialFeedItem.Source)
"test",
"test",
"Twitter")
//socialFeedItem.Username,
//socialFeedItem.Text,
//socialFeedItem.Source)
};
var listItems = list.GetItems(listItemCamlQuery);
context.Load(listItems, items => items.Include(item => item.Id));
context.ExecuteQuery();
return listItems.Count > 0;
//context.Load(listItems, items => items.Include(item => item.Id));
context.Load(listItems);
try
{
context.ExecuteQuery();
}
catch(Exception)
{
return false;
}

return true;
}
}
}
@@ -31,7 +31,7 @@ public static async Task<List<SocialFeedItem>> SearchAsync(string query)
};

await auth.AuthorizeAsync();

var twitterCtx = new TwitterContext(auth);

var searchResults =

0 comments on commit 67bf08f

Please sign in to comment.
You can’t perform that action at this time.