Skip to content
Permalink
Browse files

End of the day commit :)

  • Loading branch information
codingmag committed Sep 5, 2016
1 parent 1d88e57 commit b208b3bd11f4a54a386c4eb96b81b7c235f520e4
@@ -6,7 +6,7 @@

namespace SocialFeedCollector.Job
{
public class AppSettings
public class ApplicationSettings
{
public string Query { get; set; }

@@ -11,35 +11,48 @@ namespace SocialFeedCollector.Job
{
class Program
{
private static AppSettings appSettings;
private static ApplicationSettings appSettings;

public static ApplicationSettings AppSettings
{
get
{
if (appSettings == null)
{
appSettings = new ApplicationSettings();
GetValidateAppSettings();
}

return appSettings;
}
}

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

private static async Task MainAsync()
{
var realm = TokenHelper.GetRealmFromTargetUrl(appSettings.SiteUri);
var accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, appSettings.SiteUri.Authority, realm).AccessToken;
using (var clientContext = TokenHelper.GetClientContextWithAccessToken(appSettings.SiteUri.ToString(), accessToken))
var realm = TokenHelper.GetRealmFromTargetUrl(AppSettings.SiteUri);
var accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, AppSettings.SiteUri.Authority, realm).AccessToken;
using (var clientContext = TokenHelper.GetClientContextWithAccessToken(AppSettings.SiteUri.ToString(), accessToken))
{
// Check if the list to insert tweets exists
if (!ListExists(clientContext, appSettings.ListName))
if (!ListExists(clientContext, AppSettings.ListName))
{
throw new Exception(string.Format("The list with name {0} has not been found in the target SharePoint site {1}.", appSettings.ListName, appSettings.SiteUri.ToString());
throw new Exception(string.Format("The list with name {0} has not been found in the target SharePoint site {1}.", AppSettings.ListName, AppSettings.SiteUri.ToString()));
}

// Get tweets for the query
var tweets = await SearchTwitterAsync(appSettings.Query);
var tweets = await SearchTwitterAsync(AppSettings.Query);

// Add the tweets to SharePoint list
foreach (var tweet in tweets)
{
if (!ItemExists(clientContext, appSettings.ListName, tweet))
if (!ItemExists(clientContext, AppSettings.ListName, tweet))
{
AddItem(clientContext, appSettings.ListName, tweet);
AddItem(clientContext, AppSettings.ListName, tweet);
}
}
}
@@ -104,7 +104,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppSettings.cs" />
<Compile Include="ApplicationSettings.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SharePointContext.cs" />

This file was deleted.

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="eb3a40e0-a8c5-4751-9389-75c61533c25a" description="This feature activates the required list instances for the Social Feed Collector add-in." featureId="eb3a40e0-a8c5-4751-9389-75c61533c25a" imageUrl="" solutionId="00000000-0000-0000-0000-000000000000" title="SocialFeedCollector List Instances" version="" deploymentPath="$SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel">
<projectItems>
<projectItemReference itemId="3d78e7ce-9ed5-4d19-bb04-2711d4f036f4" />
<projectItemReference itemId="66a5ce5a-1c43-45ad-b5a9-dd4205ad5779" />
</projectItems>
</feature>
@@ -58,11 +58,11 @@
<None Include="Package\Package.Template.xml">
<DependentUpon>Package.package</DependentUpon>
</None>
<None Include="Features\Feature1\Feature1.feature">
<None Include="Features\ListInstancesFeature\ListInstancesFeature.feature">
<FeatureId>{eb3a40e0-a8c5-4751-9389-75c61533c25a}</FeatureId>
</None>
<None Include="Features\Feature1\Feature1.Template.xml">
<DependentUpon>Feature1.feature</DependentUpon>
<None Include="Features\ListInstancesFeature\ListInstancesFeature.Template.xml">
<DependentUpon>ListInstancesFeature.feature</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
@@ -48,7 +48,7 @@ public static async Task<List<SocialFeedItem>> SearchAsync(string query)
Source = FeedSource.Twitter,
Text = result.Text,
ThumbnailUrl = result.User.ProfileImageUrl,
UserName = result.User.ScreenNameResponse
Username = result.User.ScreenNameResponse
}).ToList();

return twitterFeed;

0 comments on commit b208b3b

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