Merge branch 'vnext' of github.com:pazof/yavsc into vnext

vnext
Paul Schneider 8 years ago
commit afaae51c27
50 changed files with 4108 additions and 82 deletions

4
.gitignore vendored

@ -3,6 +3,7 @@
appsettings.*.json
.idea/
.vscode/
.vs/
YavscWeb.userprefs
bin/
obj/
@ -17,4 +18,7 @@ kestrel*.log
scaffold.cmds
DataProtection-Keys
RSA-Params.json
Components/
packages/

@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookAStar.iOS", "BookAStar\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookAStar", "BookAStar\BookAStar\BookAStar.csproj", "{A0815650-0A0A-47B0-8826-771F0E1AD137}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Yavsc.Server.Api", "Yavsc.Api\Yavsc.Server.Api.xproj", "{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yavsc.Client", "Yavsc.Client\Yavsc.Client.csproj", "{67F9D3A8-F71E-4428-913F-C37AE82CDB24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -189,6 +193,102 @@ Global
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Release|x64.Build.0 = Release|Any CPU
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Release|x86.ActiveCfg = Release|Any CPU
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Release|x86.Build.0 = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|ARM.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|iPhone.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|x64.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|x64.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|x86.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.AppStore|x86.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|ARM.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|iPhone.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|x64.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|x64.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|x86.ActiveCfg = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Debug|x86.Build.0 = Debug|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|Any CPU.Build.0 = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|ARM.ActiveCfg = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|ARM.Build.0 = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|iPhone.ActiveCfg = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|iPhone.Build.0 = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|x64.ActiveCfg = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|x64.Build.0 = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|x86.ActiveCfg = Release|Any CPU
{5C3248AC-CAE0-4324-8A70-08F2DCA9FB08}.Release|x86.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|ARM.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|x64.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|Any CPU.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|ARM.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|ARM.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|iPhone.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|x64.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|x64.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|x86.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.AppStore|x86.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|ARM.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|ARM.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|iPhone.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x64.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x64.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x86.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x86.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|Any CPU.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|ARM.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|ARM.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|iPhone.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|iPhone.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x64.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x64.Build.0 = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x86.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -185,17 +185,21 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\Settings.cs" />
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
<Compile Include="Helpers\YavscHelpers.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="OAuth2\YaOAuth2Authenticator.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\GcmListenerService.cs" />
<Compile Include="Services\GcmRegistrationIntentService.cs" />
<Compile Include="Services\MyGcmIntentService.cs" />
<Compile Include="Services\MyInstanceIdListener.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Resources\AboutResources.txt" />
<AndroidAsset Include="Assets\AboutAssets.txt" />
@ -212,6 +216,10 @@
<AndroidResource Include="Resources\values\styles.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Yavsc.Client\Yavsc.Client.csproj">
<Project>{67F9D3A8-F71E-4428-913F-C37AE82CDB24}</Project>
<Name>Yavsc.Client</Name>
</ProjectReference>
<ProjectReference Include="..\BookAStar\BookAStar.csproj">
<Project>{A0815650-0A0A-47B0-8826-771F0E1AD137}</Project>
<Name>BookAStar</Name>
@ -224,7 +232,7 @@
</XamarinComponentReference>
<XamarinComponentReference Include="GeolocatorPlugin">
<Visible>False</Visible>
<Version>1.0.0</Version>
<Version>1.0.3</Version>
</XamarinComponentReference>
<XamarinComponentReference Include="json.net">
<Visible>False</Visible>

@ -0,0 +1,103 @@
//
// PostJson.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Net;
using System.IO;
using System.Json;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System;
namespace Yavsc.Helpers
{
/// <summary>
/// Simple json post method.
/// </summary>
public class SimpleJsonPostMethod : IDisposable
{
private HttpWebRequest request=null;
/// <summary>
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.
/// </summary>
/// <param name="pathToMethod">Path to method.</param>
public SimpleJsonPostMethod (string pathToMethod, string authorizationHeader = null)
{
request = (HttpWebRequest) WebRequest.Create (
BasePath + pathToMethod);
request.Method = "POST";
request.Accept = "application/json";
request.ContentType = "application/json";
request.SendChunked = true;
request.TransferEncoding = "UTF-8";
if (authorizationHeader!=null)
request.Headers.Add($"Authorization: Bearer {authorizationHeader}");
}
public static string BasePath { get; private set; } = "http://dev.pschneider.fr/api/";
public void Dispose()
{
request.Abort();
}
/// <summary>
/// Invoke the specified query.
/// </summary>
/// <param name="query">Query.</param>
public TAnswer Invoke<TAnswer>(object query)
{
using (Stream streamQuery = request.GetRequestStream()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) {
writer.Write (JsonConvert.SerializeObject(query));
}}
TAnswer ans = default (TAnswer);
using (WebResponse response = request.GetResponse ()) {
using (Stream responseStream = response.GetResponseStream ()) {
using (StreamReader rdr = new StreamReader (responseStream)) {
ans = (TAnswer) JsonConvert.DeserializeObject<TAnswer> (rdr.ReadToEnd ());
}
}
response.Close();
}
return ans;
}
public async Task<JsonValue> InvokeJson(object query)
{
JsonValue jsonDoc=null;
using (Stream streamQuery = request.GetRequestStream()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) {
writer.Write (JsonConvert.SerializeObject(query));
}}
using (WebResponse response = request.GetResponse ()) {
using (Stream stream = response.GetResponseStream ()) {
if (stream.Length>0)
jsonDoc = await Task.Run (() => JsonObject.Load (stream));
}
response.Close();
}
return jsonDoc;
}
}
}

@ -20,6 +20,8 @@ using System.Net.Http;
using System.Text;
using BookAStar.Model.Auth.Account;
using BookAStar.Droid.OAuth;
using Yavsc.Helpers;
using Yavsc.Models.Identity;
namespace BookAStar.Droid
{
@ -256,22 +258,59 @@ namespace BookAStar.Droid
{
throw new NotImplementedException("Auth_Error");
}
public GoogleCloudMobileDeclaration GetDeviceInfo()
public class GCMDeclaration : IGCMDeclaration
{
public string DeviceId
{ get; set; }
public string GCMRegistrationId
{ get; set; }
public string Model
{ get; set; }
public string Platform
{ get; set; }
public string Version
{ get; set; }
}
public IGCMDeclaration GetDeviceInfo()
{
var devinfo = DeviceInfo.Plugin.CrossDeviceInfo.Current;
return new GoogleCloudMobileDeclaration
return new GCMDeclaration
{
DeviceId = devinfo.Id,
GCMRegistrationId = MainSettings.GoogleRegId,
Model = devinfo.Model,
Platform = devinfo.Platform.ToString(),
Version = devinfo.Version,
GCMRegistrationId = MainSettings.GoogleRegId,
DeviceOwnerId = MainSettings.CurrentUser?.Id
Version = devinfo.Version
};
}
public TAnswer InvokeApi<TAnswer>(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(method,
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
return m.Invoke<TAnswer>(arg);
}
}
public object InvokeApi(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(method,
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
return m.InvokeJson(arg);
}
}
}
}

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace BookAStar.Droid.Services
{
using Android.App;
using Android.Content;
using Android.OS;
using Android.Gms.Gcm;
using Android.Util;
namespace ClientApp
{
[Service(Exported = false), IntentFilter(new[] { "com.google.android.c2dm.intent.RECEIVE" })]
public class MyGcmListenerService : GcmListenerService
{
public override void OnMessageReceived(string from, Bundle data)
{
var message = data.GetString("message");
Log.Debug("MyGcmListenerService", "From: " + from);
Log.Debug("MyGcmListenerService", "Message: " + message);
SendNotification(message);
}
void SendNotification(string message)
{
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop);
var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.icon)
.SetContentTitle("GCM Message")
.SetContentText(message)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent);
var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
notificationManager.Notify(0, notificationBuilder.Build());
}
}
}
}

@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

@ -8,11 +8,12 @@ using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Yavsc.Helpers;
/*
Glyphish icons from
http://www.glyphish.com/
http://www.glyphish.com/
under
http://creativecommons.org/licenses/by/3.0/us/
http://creativecommons.org/licenses/by/3.0/us/
support them by buying the full set / Retina versions
*/
@ -82,35 +83,12 @@ namespace BookAStar
else deviceInfoPage.Focus();
}
public async void RegisterThisDevice()
public async Task PostDeviceInfo()
{
HttpClient client = new HttpClient();
// var request = new HttpRequestMessage(HttpMethod.Post, MainSettings.MobileRegistrationUrl);
// request.Headers.Authorization
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken);
/* client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")
);*/
var info =PlateformSpecificInstance.GetDeviceInfo();
/* var serSettings = new JsonSerializerSettings(); serSettings.Formatting = Formatting.None; serSettings.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;*/
client.MaxResponseContentBufferSize = 256000;
using ( client)
{
var json = Newtonsoft.Json.JsonConvert.SerializeObject(info);
/*
var dataString = JsonConvert.SerializeObject(info,serSettings); */
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(MainSettings.MobileRegistrationUrl, content);
if (response.IsSuccessStatusCode)
Debug.WriteLine(@"Device info successfully saved.");
}
var res = PlateformSpecificInstance.InvokeApi(
"gcm/register", PlateformSpecificInstance.GetDeviceInfo());
}
}
}

@ -48,13 +48,11 @@
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Model\Auth\MobileAppDeclaration.cs" />
<Compile Include="Model\Auth\passwrecovery.cs" />
<Compile Include="Model\Auth\Tokens.cs" />
<Compile Include="Model\Auth\User.cs" />
<Compile Include="Model\Blog\Blog.cs" />
<Compile Include="Model\Blog\BlogTag.cs" />
<Compile Include="Model\Manager.cs" />
<Compile Include="Model\Auth\MobileAppDeclaration.cs" />
<Compile Include="Model\Auth\passwrecovery.cs" />
<Compile Include="Model\Social\Calendar\OpenDay.cs" />
<Compile Include="Model\Social\Calendar\Period.cs" />
<Compile Include="Model\Social\Calendar\Periodicity.cs" />
@ -83,6 +81,8 @@
<Compile Include="Model\Social\Messaging\PositionAndKeyphrase.cs" />
<Compile Include="Model\Social\Messaging\SearchQuery.cs" />
<Compile Include="Model\Social\Messaging\YaEvent.cs" />
<Compile Include="Model\Auth\Tokens.cs" />
<Compile Include="Model\Auth\User.cs" />
<Compile Include="PinPage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SearchPage.xaml.cs">
@ -126,16 +126,14 @@
<Folder Include="Model\Workflow\" />
</ItemGroup>
<ItemGroup>
<Reference Include="Json.NET.Web, Version=1.0.49.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Json.NET.Web">
<HintPath>..\..\packages\Json.NET.Web.1.0.49\lib\portable45-net45+win8+wpa81\Json.NET.Web.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Android">
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v6.0\Mono.Android.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Plugin.Settings, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Settings.dll</HintPath>
@ -162,6 +160,12 @@
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Yavsc.Client\Yavsc.Client.csproj">
<Project>{67F9D3A8-F71E-4428-913F-C37AE82CDB24}</Project>
<Name>Yavsc.Client</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.2.3.0.107\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.0.107\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

@ -5,12 +5,13 @@ using System.Linq;
using System.Text;
using Xamarin.Forms;
using Yavsc.Models.Identity;
namespace BookAStar
{
public class DeviceInfoPage : ContentPage
{
public DeviceInfoPage(GoogleCloudMobileDeclaration infos)
public DeviceInfoPage(IGCMDeclaration infos)
{
Content = new StackLayout
{

@ -6,7 +6,7 @@ using Plugin.Settings.Abstractions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar
@ -69,14 +69,19 @@ namespace BookAStar
}
}
public static string GoogleRegId
public static string GoogleRegId
{
set {
set {
var oldregid = GoogleRegId;
AppSettings.AddOrUpdateValue<string>(GoogleRegIdKey, value);
// TODO If it changed, and there's an identified user,
// Inform the server of it.
if (oldregid != value) App.CurrentApp.RegisterThisDevice();
if (oldregid != value)
{
Task.Run( async () => {
await App.CurrentApp.PostDeviceInfo();
});
}
}
get { return AppSettings.GetValueOrDefault<string>(GoogleRegIdKey); }
}
@ -126,7 +131,9 @@ namespace BookAStar
{
if (olduserid != value.Id)
{
App.CurrentApp.RegisterThisDevice();
Task.Run(async () => {
await App.CurrentApp.PostDeviceInfo();
});
}
}
}

@ -1,4 +1,5 @@
using BookAStar.Model.Auth.Account;
using Yavsc.Models.Identity;
namespace BookAStar
{
@ -16,10 +17,11 @@ namespace BookAStar
void RevokeAccount(string userName);
GoogleCloudMobileDeclaration GetDeviceInfo();
IGCMDeclaration GetDeviceInfo();
// void RegisterThisDevice();
TAnswer InvokeApi<TAnswer>(string method, object arg);
object InvokeApi(string method, object arg);
}
}

@ -1,12 +1,36 @@
using System;
using Yavsc.Models;
using Yavsc.Models.Identity;
namespace BookAStar.Model.Auth.Account
{
public class GoogleCloudMobileDeclaration
public class GoogleCloudMobileDeclaration : IGoogleCloudMobileDeclaration
{
public string GCMRegistrationId { get; set; }
public string DeviceId { get; set; }
public string Model { get; set; }
public string Platform { get; set; }
public string Version { get; set; }
public IApplicationUser DeviceOwner
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public string DeviceOwnerId
{
get;
set;
}
}
}

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © Paul Albert Schneider 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: NeutralResourcesLanguage("fr")]
// Version information for an assembly consists of the following four values:
//

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>2f4ae1ac-5311-483b-ab03-f8bfdf998f29</ProjectGuid>
<RootNamespace>MessageSender</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>console1</ActiveDebugProfile>
</PropertyGroup>
</Project>

@ -0,0 +1,51 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace MessageSender
{
public class Program
{
public const string API_KEY = "AIzaSyDwPlu2ky9AoPwDvThoXxJwqiPq-Tc8p8k";
public const string MESSAGE = "Hello, Xamarin!";
static void Main(string[] args)
{
var jGcmData = new JObject();
var jData = new JObject();
jData.Add("message", MESSAGE);
jGcmData.Add("to", "/topics/global");
jGcmData.Add("data", jData);
var url = new Uri("https://gcm-http.googleapis.com/gcm/send");
try
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.TryAddWithoutValidation(
"Authorization", "key=" + API_KEY);
Task.WaitAll(client.PostAsync(url,
new StringContent(jGcmData.ToString(), Encoding.Default, "application/json"))
.ContinueWith(response =>
{
Console.WriteLine(response);
Console.WriteLine("Message sent: check the client device notification tray.");
}));
}
}
catch (Exception e)
{
Console.WriteLine("Unable to send GCM message:");
Console.Error.WriteLine(e.StackTrace);
}
}
}
}

@ -0,0 +1,19 @@
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: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MessageSender")]
[assembly: AssemblyTrademark("")]
// 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("2f4ae1ac-5311-483b-ab03-f8bfdf998f29")]

@ -0,0 +1,5 @@
{
"profiles": {
"console1": {}
}
}

@ -0,0 +1,21 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "build",
"version": "1.0.0-rc2-3002702"
},
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"dnx451": {"compilationOptions": {"emitEntryPoint": true}},
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}

@ -0,0 +1,92 @@
{
"locked": false,
"version": 2,
"targets": {
"DNX,Version=v4.5.1": {
"Microsoft.NETCore.App/1.0.0-rc2-3002702": {
"type": "package"
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
}
},
"DNX,Version=v4.5.1/win7-x86": {
"Microsoft.NETCore.App/1.0.0-rc2-3002702": {
"type": "package"
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
}
},
"DNX,Version=v4.5.1/win7-x64": {
"Microsoft.NETCore.App/1.0.0-rc2-3002702": {
"type": "package"
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
}
}
},
"libraries": {
"Microsoft.NETCore.App/1.0.0-rc2-3002702": {
"type": "package",
"sha512": "G+wsg7zwathgjAOZ2w0XbHU0MD4GEHIpi/JsvBGmbACW+/Dsx2YoXai7LLItfe5ZVidqBXXQCz8NxCKbKqr8Ww==",
"files": [
"dotnet_library_license.txt",
"Microsoft.NETCore.App.1.0.0-rc2-3002702.nupkg",
"Microsoft.NETCore.App.1.0.0-rc2-3002702.nupkg.sha512",
"Microsoft.NETCore.App.nuspec",
"ThirdPartyNotices.txt"
]
},
"Newtonsoft.Json/9.0.1": {
"type": "package",
"sha512": "U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw==",
"files": [
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netstandard1.0/Newtonsoft.Json.dll",
"lib/netstandard1.0/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.9.0.1.nupkg",
"Newtonsoft.Json.9.0.1.nupkg.sha512",
"Newtonsoft.Json.nuspec",
"tools/install.ps1"
]
}
},
"projectFileDependencyGroups": {
"": [
"Microsoft.NETCore.App >= 1.0.0-rc2-3002702",
"Newtonsoft.Json >= 9.0.1"
],
"DNX,Version=v4.5.1": []
}
}

@ -5,12 +5,12 @@ namespace Yavsc.Models
{
public partial class AccountBalance {
public partial class AccountBalance: IAccountBalance {
[Key]
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual ApplicationUser Owner { get; set; }
public virtual IApplicationUser Owner { get; set; }
[Required,Display(Name="Credits in €")]
public decimal Credits { get; set; }

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public partial class Blog
public partial class Blog: IBlog
{
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
@ -19,7 +19,7 @@ namespace Yavsc.Models
[Required]
public string AuthorId { get; set; }
[ForeignKey("AuthorId")]
public ApplicationUser Author { set; get; }
public IApplicationUser Author { set; get; }
public bool visible { get; set; }
}
}

@ -8,25 +8,25 @@ using Yavsc.Models.Identity;
namespace Yavsc.Models
{
public class ApplicationUser : IdentityUser
public class ApplicationUser : IdentityUser, IApplicationUser
{
[Display(Name="AccountBalance")]
public virtual AccountBalance AccountBalance { get; set; }
public virtual IAccountBalance AccountBalance { get; set; }
[InverseProperty("Author")]
public virtual List<Blog> Posts { get; set; }
public virtual IList<IBlog> Posts { get; set; }
[InverseProperty("Owner")]
public virtual List<Contact> Book { get; set; }
public virtual IList<IContact> Book { get; set; }
[InverseProperty("DeviceOwner")]
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
public virtual IList<IGoogleCloudMobileDeclaration> Devices { get; set; }
[InverseProperty("Owner")]
public virtual List<Circle> Circles { get; set; }
public virtual Location PostalAddress { get; set; }
public virtual IList<ICircle> Circles { get; set; }
public virtual ILocation PostalAddress { get; set; }
public string DedicatedGoogleCalendar { get; set; }

@ -19,9 +19,7 @@ namespace Yavsc.Models.Identity
public string Version { get; set; }
public string DeviceOwnerId { get; set; }
[JsonIgnore]
[ForeignKeyAttribute("DeviceOwnerId")]
[JsonIgnore,ForeignKey("DeviceOwnerId")]
public virtual ApplicationUser DeviceOwner { get; set; }
}

@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public partial class Circle {
public partial class Circle: ICircle {
[Key, DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
@ -13,9 +13,9 @@ namespace Yavsc.Models
public string OwnerId { get; set; }
[ForeignKey("OwnerId")]
public virtual ApplicationUser Owner { get; set; }
public virtual IApplicationUser Owner { get; set; }
[InverseProperty("Circle")]
public virtual List<CircleMember> Members { get; set; }
public virtual IList<ICircleMember> Members { get; set; }
}
}

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public class Contact
public class Contact: IContact
{
[Required()]
public string UserId { get; set; }
@ -13,6 +13,6 @@ namespace Yavsc.Models
public string OwnerId { get; set; }
[ForeignKeyAttribute("OwnerId")]
public virtual ApplicationUser Owner { get; set; }
public virtual IApplicationUser Owner { get; set; }
}
}

@ -7,7 +7,7 @@ namespace Yavsc
/// <summary>
/// Position.
/// </summary>
public class Position
public class Position: IPosition
{
/// <summary>
/// The longitude.
@ -27,7 +27,7 @@ namespace Yavsc
}
public class Location : Position {
public class Location : Position, ILocation {
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[Required(),

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>5c3248ac-cae0-4324-8a70-08f2dca9fb08</ProjectGuid>
<RootNamespace>Yavsc.Api</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Démarrer</ActiveDebugProfile>
</PropertyGroup>
</Project>

@ -17,13 +17,15 @@
"EntityFramework.Core": "7.0.0-rc1-*",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-*",
"EntityFramework.Relational": "7.0.0-rc1-*",
"EntityFramework7.Npgsql": "3.1.0-*",
"EntityFramework7.Npgsql.Design": "3.1.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
"Newtonsoft.Json": "9.0.1",
"System.Json": "4.0.20126.16343"
},
"frameworks": {
"net451": {}
"net451": {
"dependencies": {
"Yavsc.Client": "1.0.0-*"
}
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,128 @@
//
// PostJson.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Net;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System;
using System.Diagnostics;
namespace Yavsc.Helpers
{
/// <summary>
/// Simple json post method.
/// </summary>
public class NotSoSimpleJsonPostMethod : IDisposable
{
private HttpWebRequest request = null;
/// <summary>
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.
/// </summary>
/// <param name="pathToMethod">Path to method.</param>
public NotSoSimpleJsonPostMethod(string pathToMethod, string authorizationHeader = null)
{
request = (HttpWebRequest)WebRequest.Create(pathToMethod);
request.Method = "POST";
request.Accept = "application/json";
request.ContentType = "application/json";
// request.SendChunked = true;
// request.TransferEncoding = "UTF-8";
request.Headers = new WebHeaderCollection();
if (authorizationHeader != null)
request.Headers["Authorization"] = "Bearer " + authorizationHeader;
}
public void Dispose()
{
request.Abort();
}
/// <summary>
/// Invoke the specified query.
/// </summary>
/// <param name="query">Query.</param>
public async Task<TAnswer> Invoke<TAnswer>(object query)
{
using (Stream streamQuery = await request.GetRequestStreamAsync())
{
using (StreamWriter writer = new StreamWriter(streamQuery))
{
writer.Write(JsonConvert.SerializeObject(query));
}
}
TAnswer ans = default(TAnswer);
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader rdr = new StreamReader(responseStream))
{
ans = (TAnswer)JsonConvert.DeserializeObject<TAnswer>(rdr.ReadToEnd());
}
}
}
return ans;
}
public async Task<object> InvokeAnonymous(object query)
{
object result = null;
using (Stream streamQuery = await request.GetRequestStreamAsync())
{
using (StreamWriter writer = new StreamWriter(streamQuery))
{
var json = JsonConvert.SerializeObject(query);
writer.Write(json);
}
}
try
{
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream stream = response.GetResponseStream())
{
if (stream.Length > 0)
{
using (var sr = new StreamReader(stream))
{
var json = await sr.ReadToEndAsync();
result = JsonConvert.DeserializeObject(json);
}
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message.ToString());
}
return result;
}
}
}

@ -0,0 +1,10 @@
namespace Yavsc.Models
{
public interface IAccountBalance
{
long ContactCredits { get; set; }
decimal Credits { get; set; }
IApplicationUser Owner { get; set; }
string UserId { get; set; }
}
}

@ -0,0 +1,16 @@
using System.Collections.Generic;
using Yavsc.Models.Identity;
namespace Yavsc.Models
{
public interface IApplicationUser
{
IAccountBalance AccountBalance { get; set; }
IList<IContact> Book { get; set; }
IList<ICircle> Circles { get; set; }
string DedicatedGoogleCalendar { get; set; }
IList<IGoogleCloudMobileDeclaration> Devices { get; set; }
ILocation PostalAddress { get; set; }
IList<IBlog> Posts { get; set; }
}
}

@ -0,0 +1,18 @@
using System;
namespace Yavsc.Models
{
public interface IBlog
{
IApplicationUser Author { get; set; }
string AuthorId { get; set; }
string bcontent { get; set; }
long Id { get; set; }
DateTime modified { get; set; }
string photo { get; set; }
DateTime posted { get; set; }
int rate { get; set; }
string title { get; set; }
bool visible { get; set; }
}
}

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Yavsc.Models
{
public interface ICircle
{
long Id { get; set; }
IList<ICircleMember> Members { get; set; }
string Name { get; set; }
IApplicationUser Owner { get; set; }
string OwnerId { get; set; }
}
}

@ -0,0 +1,9 @@
namespace Yavsc.Models
{
public interface ICircleMember
{
ICircle Circle { get; set; }
long Id { get; set; }
IApplicationUser Member { get; set; }
}
}

@ -0,0 +1,9 @@
namespace Yavsc.Models
{
public interface IContact
{
IApplicationUser Owner { get; set; }
string OwnerId { get; set; }
string UserId { get; set; }
}
}

@ -0,0 +1,18 @@
namespace Yavsc.Models.Identity
{
public interface IGCMDeclaration
{
string DeviceId { get; set; }
string GCMRegistrationId { get; set; }
string Model { get; set; }
string Platform { get; set; }
string Version { get; set; }
}
public interface IGoogleCloudMobileDeclaration: IGCMDeclaration
{
IApplicationUser DeviceOwner { get; set; }
string DeviceOwnerId { get; set; }
}
}

@ -0,0 +1,8 @@
namespace Yavsc
{
public interface ILocation
{
string Address { get; set; }
long Id { get; set; }
}
}

@ -0,0 +1,8 @@
namespace Yavsc
{
public interface IPosition
{
double Latitude { get; set; }
double Longitude { get; set; }
}
}

@ -0,0 +1,30 @@
using System.Resources;
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("Yavsc.Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Yavsc.Client")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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")]

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{67F9D3A8-F71E-4428-913F-C37AE82CDB24}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Yavsc.Client</RootNamespace>
<AssemblyName>Yavsc.Client</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
<Compile Include="IAccountBalance.cs" />
<Compile Include="IApplicationUser.cs" />
<Compile Include="IBlog.cs" />
<Compile Include="ICircle.cs" />
<Compile Include="ICircleMember.cs" />
<Compile Include="IContact.cs" />
<Compile Include="IGoogleCloudMobileDeclaration.cs" />
<Compile Include="ILocation.cs" />
<Compile Include="IPosition.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="Json.NET.Web, Version=1.0.49.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.NET.Web.1.0.49\lib\portable45-net45+win8+wpa81\Json.NET.Web.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Json.NET.Web" version="1.0.49" targetFramework="portable45-net45+win8+wpa81" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="portable45-net45+win8+wpa81" />
</packages>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>79e701ba-fd0a-409c-8fb8-54b55329ecba</ProjectGuid>
<RootNamespace>Yavsc</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

@ -1,8 +1,12 @@
{
"projects": [ "Yavsc", "Yavsc.Api" ],
"projects": [
"Yavsc",
"Yavsc.Api",
"wrap"
],
"sdk": {
"version": "1.0.0-rc1-update2",
"runtime": "mono",
"architecture": "x64"
}
}
}

@ -0,0 +1,12 @@
{
"version": "1.0.0-*",
"frameworks": {
"net45+win+wpa81+MonoAndroid10+Xamarin.iOS10+MonoTouch10": {
"wrappedProject": "../../Yavsc.Client/Yavsc.Client.csproj",
"bin": {
"assembly": "../../Yavsc.Client/obj/{configuration}/Yavsc.Client.dll",
"pdb": "../../Yavsc.Client/obj/{configuration}/Yavsc.Client.pdb"
}
}
}
}

@ -0,0 +1,10 @@
{
"version": "1.0.0-*",
"frameworks": {
"net45+win+wpa81+MonoAndroid10+Xamarin.iOS10+MonoTouch10": {
"bin": {
"assembly": "../../../../../../../Program Files (x86)/Reference Assemblies/Microsoft/Framework/MonoAndroid/v1.0/mscorlib.dll"
}
}
}
}
Loading…