Skip to content

Commit

Permalink
License file merged [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
akankshagaur committed Jun 24, 2015
2 parents 5b561ab + 2ca96f3 commit 1a16346
Show file tree
Hide file tree
Showing 213 changed files with 7,200 additions and 6,435 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
<HintPath>..\packages\waf.3.0.0\lib\net45\WpfApplicationFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Zlib.Portable, Version=1.10.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Zlib.Portable.1.10.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll</HintPath>
<Reference Include="Zlib.Portable, Version=1.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Zlib.Portable.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using Google.Apis.Analytics.v3;
using Google.Apis.Analytics.v3.Data;

Expand All @@ -11,27 +7,30 @@ namespace CalendarSyncPlus.Analytics.Helper
public class AccountSummariesHelper
{
/// <summary>
/// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
/// Documentation: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list
/// Lists account summaries (lightweight tree comprised of
/// accounts/properties/profiles) to which the user has access.
/// Documentation:
/// https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list
/// </summary>
/// <param name="service">Valid authenticated Analytics Service</param>
/// <returns>List of Account Summaries resource - https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries</returns>
/// <returns>
/// List of <see cref="Account" /> Summaries resource -
/// https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries
/// </returns>
public static AccountSummaries AccountSummaryList(AnalyticsService service)
{

//List all of the activities in the specified collection for the current user.
// Documentation: https://developers.google.com/+/api/latest/activities/list

ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
list.MaxResults = 1000; // Maximum number of Account Summaries to return per request.
var list = service.Management.AccountSummaries.List();
list.MaxResults = 1000; // Maximum number of Account Summaries to return per request.

AccountSummaries feed = list.Execute();
List<AccountSummary> allRows = new List<AccountSummary>();
var feed = list.Execute();
var allRows = new List<AccountSummary>();

//// Loop through until we arrive at an empty page
while (feed.Items != null)
{

allRows.AddRange(feed.Items);

// We will know we are on the last page when the next page token is
Expand All @@ -46,7 +45,6 @@ public static AccountSummaries AccountSummaryList(AnalyticsService service)
list.StartIndex = feed.StartIndex + list.MaxResults;
// Execute and process the next page request
feed = list.Execute();

}

feed.Items = allRows;
Expand All @@ -57,7 +55,7 @@ public static AccountSummaries AccountSummaryList(AnalyticsService service)
public static string GetAccountId(AnalyticsService service)
{
//Get account summary and display them.
foreach (AccountSummary account in AccountSummaryList(service).Items)
foreach (var account in AccountSummaryList(service).Items)
{
// Account
//Console.WriteLine("Account: " + account.Name + "(" + account.Id + ")");
Expand Down Expand Up @@ -85,4 +83,4 @@ public static string GetAccountId(AnalyticsService service)
return null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("CalendarSyncPlus.Analytics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("9ac926eb-2258-4c7e-88e3-d5d4813e0328")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
using System.Net.Http;
using System.Threading.Tasks;
using System.Waf.Applications;
using CalendarSyncPlus.Analytics.Helper;
using CalendarSyncPlus.Analytics.Interfaces;
using CalendarSyncPlus.Authentication.Google;
using CalendarSyncPlus.Common.Log;
using CalendarSyncPlus.Domain.Models;
using CalendarSyncPlus.GoogleServices.Google;
using Google.Apis.Analytics.v3;
using Google.Apis.Analytics.v3.Data;
using Google.Apis.Requests;
Expand All @@ -19,52 +17,51 @@ namespace CalendarSyncPlus.Analytics
{
/// <summary>
/// </summary>
[Export(typeof(ISyncAnalyticsService))]
[Export(typeof (ISyncAnalyticsService))]
public class SyncAnalyticsService : ISyncAnalyticsService
{
public IAccountAuthenticationService AccountAuthenticationService { get; set; }

/// <summary>
///
/// </summary>
public ILog Logger { get; set; }

/// <summary>
///
/// </summary>
/// <param name="accountAuthenticationService"></param>
/// <param name="applicationLogger"></param>
[ImportingConstructor]
public SyncAnalyticsService(IAccountAuthenticationService accountAuthenticationService ,ApplicationLogger applicationLogger)
public SyncAnalyticsService(IAccountAuthenticationService accountAuthenticationService,
ApplicationLogger applicationLogger)
{
AccountAuthenticationService = accountAuthenticationService;
Logger = applicationLogger.GetLogger(this.GetType());
Logger = applicationLogger.GetLogger(GetType());
}

public IAccountAuthenticationService AccountAuthenticationService { get; set; }

/// <summary>
/// </summary>
public ILog Logger { get; set; }

/// <summary>
///
/// </summary>
/// <param name="syncMetric"></param>
/// <param name="accountName"></param>
/// <returns></returns>
/// <returns>
/// </returns>
public async Task<bool> UploadSyncData(SyncMetric syncMetric, string accountName)
{
try
{
AnalyticsService analyticsService = new AnalyticsService(new BaseClientService.Initializer()
var analyticsService = new AnalyticsService(new BaseClientService.Initializer
{
ApplicationName = ApplicationInfo.ProductName,
ApiKey = "AIzaSyBrpqcL6Nh1vVecfhIbxGVnyGHMZ8-aH6k"
});
BatchRequest batchRequest = new BatchRequest(analyticsService);
var metric = new CustomMetric()
var batchRequest = new BatchRequest(analyticsService);
var metric = new CustomMetric
{
Name = "SyncMetric",
Kind = "string"
};

var insertRequest = analyticsService.Management.CustomMetrics.Insert(metric, "", "");
batchRequest.Queue<CustomMetric>(insertRequest,InsertMetricCallback);
batchRequest.Queue<CustomMetric>(insertRequest, InsertMetricCallback);
await batchRequest.ExecuteAsync();
}
catch (Exception ex)
Expand All @@ -75,7 +72,8 @@ public async Task<bool> UploadSyncData(SyncMetric syncMetric, string accountName
return true;
}

private void InsertMetricCallback(CustomMetric content, RequestError error, int index, HttpResponseMessage message)
private void InsertMetricCallback(CustomMetric content, RequestError error, int index,
HttpResponseMessage message)
{
if (!message.IsSuccessStatusCode)
{
Expand Down
1 change: 1 addition & 0 deletions src/CalendarSyncPlus/CalendarSyncPlus.Analytics/app.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="Google.Apis" version="1.9.1" targetFramework="net45" />
<package id="Google.Apis.Analytics.v3" version="1.9.0.1160" targetFramework="net45" />
Expand All @@ -11,5 +12,5 @@
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="waf" version="3.0.0" targetFramework="net45" />
<package id="Zlib.Portable" version="1.10.0" targetFramework="net45" />
<package id="Zlib.Portable" version="1.11.0" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,36 @@
using CalendarSyncPlus.Application.ViewModels;
using CalendarSyncPlus.Authentication.Google;
using CalendarSyncPlus.Common;
using CalendarSyncPlus.Domain.Models;
using CalendarSyncPlus.GoogleServices.Google;
using CalendarSyncPlus.Services;
using CalendarSyncPlus.Services.Interfaces;

namespace CalendarSyncPlus.Application.Controllers
{
[Export(typeof(IApplicationController))]
[Export(typeof (IApplicationController))]
public class ApplicationController : IApplicationController
{
public ILocalizationService LocalizationService { get; set; }
private readonly AboutViewModel _aboutViewModel;
private readonly DelegateCommand _exitCommand;
private readonly IGuiInteractionService _guiInteractionService;
private readonly ILogController _logController;
private readonly HelpViewModel _helpViewModel;
private readonly ILogController _logController;
private readonly LogViewModel _logViewModel;
private readonly SettingsViewModel _settingsViewModel;
private readonly IShellController _shellController;
private readonly ShellService _shellService;
private readonly ShellViewModel _shellViewModel;
private readonly SystemTrayNotifierViewModel _systemTrayNotifierViewModel;
private bool _isApplicationExiting;
private LogViewModel _logViewModel;

[ImportingConstructor]
public ApplicationController(Lazy<ShellViewModel> shellViewModelLazy,
Lazy<SettingsViewModel> settingsViewModelLazy,
Lazy<AboutViewModel> aboutViewModelLazy, Lazy<HelpViewModel> helpViewModelLazy,Lazy<LogViewModel> logViewModelLazy,
Lazy<AboutViewModel> aboutViewModelLazy, Lazy<HelpViewModel> helpViewModelLazy,
Lazy<LogViewModel> logViewModelLazy,
Lazy<ShellService> shellServiceLazy, CompositionContainer compositionContainer,
Lazy<IAccountAuthenticationService> accountAuthenticationServiceLazy, IShellController shellController,
Lazy<SystemTrayNotifierViewModel> lazySystemTrayNotifierViewModel,
IGuiInteractionService guiInteractionService,ILogController logController)
IGuiInteractionService guiInteractionService, ILogController logController)
{
//ViewModels
_shellViewModel = shellViewModelLazy.Value;
Expand Down Expand Up @@ -87,43 +85,9 @@ public ApplicationController(Lazy<ShellViewModel> shellViewModelLazy,
}
}

public ILocalizationService LocalizationService { get; set; }
public IAccountAuthenticationService AccountAuthenticationService { get; set; }

#region IApplicationController Members

public void Initialize()
{
_shellViewModel.ExitCommand = _exitCommand;
_systemTrayNotifierViewModel.ExitCommand = _exitCommand;
//Initialize Other Controllers if Any
_shellController.Initialize();
_logController.Initialize();
PropertyChangedEventManager.AddHandler(_settingsViewModel, SettingsChangedHandler, "");
PropertyChangedEventManager.AddHandler(_shellViewModel, ShellViewUpdatedHandler, "");
}

public void Run(bool startMinimized)
{
_logController.Run(startMinimized);
//Perform Other assignments if required
_shellViewModel.Show(startMinimized);
_settingsViewModel.ApplyProxySettings();
}

public void Shutdown()
{
//Close All controllers if required
_logController.Shutdown();
_shellController.Shutdown();
_settingsViewModel.Shutdown();
PropertyChangedEventManager.RemoveHandler(_settingsViewModel, SettingsChangedHandler, "");
PropertyChangedEventManager.RemoveHandler(_shellViewModel, ShellViewUpdatedHandler, "");

//Save Settings if any
}

#endregion

private void ShellViewUpdatedHandler(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
Expand Down Expand Up @@ -155,7 +119,7 @@ private void SettingsChangedHandler(object sender, PropertyChangedEventArgs e)
{
_shellViewModel.IsSettingsVisible = false;
_shellViewModel.Settings = _settingsViewModel.Settings;
foreach (CalendarSyncProfile syncProfile in _settingsViewModel.Settings.SyncProfiles)
foreach (var syncProfile in _settingsViewModel.Settings.SyncProfiles)
{
if (syncProfile.IsSyncEnabled && syncProfile.SyncSettings.SyncFrequency != null)
{
Expand Down Expand Up @@ -187,5 +151,40 @@ private void ShellViewModelClosing(object sender, CancelEventArgs e)
_guiInteractionService.HideApplication();
e.Cancel = true;
}

#region IApplicationController Members

public void Initialize()
{
_shellViewModel.ExitCommand = _exitCommand;
_systemTrayNotifierViewModel.ExitCommand = _exitCommand;
//Initialize Other Controllers if Any
_shellController.Initialize();
_logController.Initialize();
PropertyChangedEventManager.AddHandler(_settingsViewModel, SettingsChangedHandler, "");
PropertyChangedEventManager.AddHandler(_shellViewModel, ShellViewUpdatedHandler, "");
}

public void Run(bool startMinimized)
{
_logController.Run(startMinimized);
//Perform Other assignments if required
_shellViewModel.Show(startMinimized);
_settingsViewModel.ApplyProxySettings();
}

public void Shutdown()
{
//Close All controllers if required
_logController.Shutdown();
_shellController.Shutdown();
_settingsViewModel.Shutdown();
PropertyChangedEventManager.RemoveHandler(_settingsViewModel, SettingsChangedHandler, "");
PropertyChangedEventManager.RemoveHandler(_shellViewModel, ShellViewUpdatedHandler, "");

//Save Settings if any
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ namespace CalendarSyncPlus.Application.Controllers
public interface IController
{
void Initialize();

void Run(bool startMinimized);

void Shutdown();
}
}
Loading

0 comments on commit 1a16346

Please sign in to comment.