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

This commit is contained in:
2017-02-06 15:22:14 +01:00
17 changed files with 192 additions and 154 deletions

View File

@ -16,6 +16,8 @@
// along with yavsc. If not, see <http://www.gnu.org/licenses/>.
//
using System;
namespace Yavsc.Models.Identity
{
public interface IGCMDeclaration
@ -25,7 +27,7 @@ namespace Yavsc.Models.Identity
string Model { get; set; }
string Platform { get; set; }
string Version { get; set; }
DateTime LatestActivityUpdate { get; set; }
}
public interface IGoogleCloudMobileDeclaration: IGCMDeclaration

View File

@ -47,12 +47,15 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="IAccountBalance.cs" />
<Compile Include="IActivity.cs" />
<Compile Include="IApplicationUser.cs" />
<Compile Include="IBaseTrackedEntity.cs" />
<Compile Include="IBlog.cs" />
<Compile Include="ICircle.cs" />
<Compile Include="ICircleMember.cs" />
<Compile Include="ICommandForm.cs" />
<Compile Include="IContact.cs" />
<Compile Include="ICoWorking.cs" />
<Compile Include="IGoogleCloudMobileDeclaration.cs" />
<Compile Include="ILocation.cs" />
<Compile Include="IPosition.cs" />

View File

@ -32,7 +32,6 @@ using XLabs.Platform.Services.Email;
using XLabs.Platform.Services.Media;
using XLabs.Serialization;
using XLabs.Serialization.JsonNET;
using Yavsc.Helpers;
using Yavsc.Models.Identity;
namespace ZicMoove.Droid
@ -327,8 +326,8 @@ namespace ZicMoove.Droid
{
var auth = new YaOAuth2Authenticator(
clientId: Constants.APIKey,
clientSecret: "blouh",
scope: "profile",
clientSecret: Constants.APISecret,
scope: Constants.Scope,
authorizeUrl: new Uri(Constants.AuthorizeUrl),
redirectUrl: new Uri(Constants.RedirectUrl),
accessTokenUrl: new Uri(Constants.AccessTokenUrl));
@ -401,43 +400,7 @@ namespace ZicMoove.Droid
public IGCMDeclaration GetDeviceInfo()
{
var devinfo = CrossDeviceInfo.Current;
return new GCMRegIdDeclaration
{
DeviceId = devinfo.Id,
GCMRegistrationId = MainSettings.GoogleRegId,
Model = devinfo.Model,
Platform = devinfo.Platform.ToString(),
Version = devinfo.Version
};
}
[Obsolete("Use RemoteEntity to manage entities from API")]
public TAnswer InvokeApi<TAnswer>(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(
method, "Bearer " +
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
return m.Invoke<TAnswer>(arg);
}
}
public object InvokeApi(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(
method, "Bearer " +
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
return m.InvokeJson(arg);
}
}
public T Resolve<T>()
{

View File

@ -64,7 +64,7 @@ namespace ZicMoove.Droid
}
#endif
var senderid = MainSettings.GoogleSenderId;
var senderid = Constants.GoogleSenderId;
var token = instanceID.GetToken ( senderid,
GoogleCloudMessaging.InstanceIdScope, null);

View File

@ -112,8 +112,7 @@ namespace ZicMoove.Droid
void SubscribeGCM ()
{
Context context = this.ApplicationContext;
string senders = MainSettings.GoogleSenderId;
// Resources.GetString(GoogleSenderId);
string senders = Constants.GoogleSenderId;
Intent intent = new Intent ("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage ("com.google.android.gsf");
intent.PutExtra ("app", PendingIntent.GetBroadcast (context, 0, new Intent (), 0));

View File

@ -352,7 +352,6 @@
<ItemGroup>
<Compile Include="Accounts\YavscAccountAuthenticator.cs" />
<Compile Include="Helpers\Settings.cs" />
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
<Compile Include="Helpers\YavscHelpers.cs" />
<Compile Include="Html.cs" />
<Compile Include="Interfaces\IGCMessageHandler.cs" />

View File

@ -32,6 +32,10 @@ namespace ZicMoove
using System.Collections.Generic;
using Model.Social;
using Settings;
using Helpers;
using Model.Auth;
using Plugin.DeviceInfo;
using Yavsc.Models.Identity;
public partial class App : Application // superclass new in 1.3
{
@ -67,12 +71,10 @@ namespace ZicMoove
app.Startup += OnStartup;
app.Suspended += OnSuspended;
MainSettings.UserChanged += MainSettings_UserChanged;
CrossConnectivity.Current.ConnectivityChanged += (conSender, args) =>
{ App.IsConnected = args.IsConnected; };
SetupHubConnection();
MainSettings_UserChanged(this, null);
StartConnexion();
StartConnexion();
}
// omg
@ -334,22 +336,7 @@ namespace ZicMoove
public static INavigationService NavigationService { protected set; get; }
public static bool isConnected;
public static bool IsConnected { get { return isConnected; }
private set
{
if (isConnected != value)
{
isConnected = value;
if (isConnected)
{
// TODO Start all cloud related stuff
StartConnexion();
}
}
}
}
public static bool IsConnected { get { return CrossConnectivity.Current.IsConnected; } }
private static HubConnection chatHubConnection = null;
public static HubConnection ChatHubConnection
{
@ -453,11 +440,57 @@ namespace ZicMoove
public static void PostDeviceInfo()
{
var info = PlatformSpecificInstance.GetDeviceInfo();
var info = GetDeviceInfo();
if (!string.IsNullOrWhiteSpace(info.GCMRegistrationId))
PlatformSpecificInstance.InvokeApi("gcm/register", info);
{
if (MainSettings.CurrentUser != null)
{
InvokeApi("gcm/register", info);
DataManager.Instance.Activities.Execute(null);
}
}
}
public static IGCMDeclaration GetDeviceInfo()
{
var devinfo = CrossDeviceInfo.Current;
return new GCMRegIdDeclaration
{
DeviceId = devinfo.Id,
GCMRegistrationId = MainSettings.GoogleRegId,
Model = devinfo.Model,
Platform = devinfo.Platform.ToString(),
Version = devinfo.Version,
LatestActivityUpdate = DataManager.Instance.Activities.Aggregate(
(a,b)=> a.DateModified > b.DateModified ? a : b
).DateModified
};
}
[Obsolete("Use RemoteEntity to manage entities from API")]
public async Task<TAnswer> InvokeApi<TAnswer>(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(
method, "Bearer " +
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
return await m.Invoke<TAnswer>(arg);
}
}
public static object InvokeApi(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(
method, "Bearer " +
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
return m.InvokeJson(arg);
}
}
public static void ShowBookQuery (BookQuery query)
{
var page = new BookQueryPage

View File

@ -11,7 +11,6 @@ namespace ZicMoove
{
public static readonly string AuthorizeUrl = YavscHomeUrl + "/authorize";
public static readonly string RedirectUrl = YavscHomeUrl + "/oauth/success";
public static readonly string AccessTokenUrl = YavscHomeUrl + "/token";
public static readonly string YavscApiUrl = YavscHomeUrl + "/api";

View File

@ -15,6 +15,7 @@
{
// TODO estimatetemplate rating service product tag
public RemoteEntityRO<BookQuery, long> BookQueries { get; set; }
public RemoteEntityRO<Activity, string> Activities { get; set; }
public ChatUserCollection ChatUsers { get; set; }
public EstimateEntity Estimates { get; set; }
public RemoteEntity<Blog, long> Blogspot { get; set; }
@ -47,7 +48,6 @@
BookQueries = new RemoteEntityRO<BookQuery, long>("bookquery", q => q.Id);
Estimates = new EstimateEntity();
Blogspot = new RemoteEntity<Blog, long>("blog", x=>x.Id);
Contacts = new LocalEntity<ClientProviderInfo, string>(c => c.UserId);
AppState = new LocalEntity<PageState, int>(s => s.Position);
EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id);
@ -56,6 +56,7 @@
RemoteFiles = new RemoteFilesEntity ();
BlackList = new RemoteEntity<BlackListed, long>("blacklist",u => u.Id);
ChatUsers = new ChatUserCollection();
Activities = new RemoteEntityRO<Activity,string>("activity",a=>a.Code);
PrivateMessages.Load();
BookQueries.Load();
Estimates.Load();
@ -67,6 +68,7 @@
RemoteFiles.Load();
BlackList.Load();
ChatUsers.Load();
Activities.Load();
}
}
}

View File

@ -27,7 +27,7 @@ using System;
using System.Diagnostics;
using ZicMoove;
namespace Yavsc.Helpers
namespace ZicMoove.Helpers
{
/// <summary>
/// Simple json post method.
@ -46,10 +46,9 @@ namespace Yavsc.Helpers
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: {authorizationHeader}");
if (authorizationHeader != null)
request.Headers["Authorization"] = authorizationHeader;
}
public static string BasePath { get; private set; } = Constants.YavscApiUrl;
@ -63,21 +62,20 @@ namespace Yavsc.Helpers
/// Invoke the specified query.
/// </summary>
/// <param name="query">Query.</param>
public TAnswer Invoke<TAnswer>(object query)
public async Task<TAnswer> Invoke<TAnswer>(object query)
{
using (Stream streamQuery = request.GetRequestStream()) {
using (Stream streamQuery = await request.GetRequestStreamAsync()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) {
writer.Write (JsonConvert.SerializeObject(query));
}}
TAnswer ans = default (TAnswer);
using (WebResponse response = request.GetResponse ()) {
using (WebResponse response = await request.GetResponseAsync ()) {
using (Stream responseStream = response.GetResponseStream ()) {
using (StreamReader rdr = new StreamReader (responseStream)) {
ans = (TAnswer) JsonConvert.DeserializeObject<TAnswer> (rdr.ReadToEnd ());
}
}
response.Close();
}
return ans;
}
@ -88,31 +86,30 @@ namespace Yavsc.Helpers
try
{
using (Stream streamQuery = request.GetRequestStream())
using (Stream streamQuery = await request.GetRequestStreamAsync())
{
using (StreamWriter writer = new StreamWriter(streamQuery))
{
writer.Write(JsonConvert.SerializeObject(query));
}
}
using (WebResponse response = request.GetResponse())
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream stream = response.GetResponseStream())
{
if (stream.Length > 0)
jsonDoc = await Task.Run(() => JsonObject.Load(stream));
}
response.Close();
}
}
catch (WebException ex)
{
// TODO err logging
Debug.Print($"Web request failed: {request.ToString()}\n" + ex.ToString());
Debug.WriteLine($"Web request failed: {request.ToString()}\n" + ex.ToString());
}
catch (Exception ex)
{
Debug.Print($"Web request failed: {request.ToString()}\n" + ex.ToString());
Debug.WriteLine($"Web request failed: {request.ToString()}\n" + ex.ToString());
}
return jsonDoc;

View File

@ -17,12 +17,6 @@ namespace ZicMoove.Interfaces
void AddAccount();
void RevokeAccount(string userName);
IGCMDeclaration GetDeviceInfo();
TAnswer InvokeApi<TAnswer>(string method, object arg);
object InvokeApi(string method, object arg);
}
}

View File

@ -15,6 +15,9 @@ namespace ZicMoove.Model.Auth
public string GCMRegistrationId
{ get; set; }
public DateTime LatestActivityUpdate
{ get; set; }
public string Model
{ get; set; }

View File

@ -1,63 +0,0 @@
using ZicMoove.Model.Social;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
namespace ZicMoove
{
[Obsolete("Use Helpers.DataManager")]
public static class Manager
{
static Manager ()
{
}
public static ICommand RefreshBookQueries;
// TODO WIP TEST rop this
private static Location[] _places = new Location[] {
new Location { Latitude = 48.8626458, Longitude = 2.2065559, Address = "2 bd Aristide Briand - Suresnes" },
new Location{ Latitude =48.8632757, Longitude =2.2023099, Address ="Théatre Jean Villard - Suresnes" },
new Location{ Latitude =48.8647120, Longitude =2.2054588,Address = "Place de la Paix - Suresnes" },
new Location{ Latitude =48.8640133, Longitude =2.2056573, Address ="Restaurant" },
new Location{ Latitude =48.8634839, Longitude =2.2064137,Address = "Square" },
new Location{ Latitude =48.8653649, Longitude =2.2014945,Address = "Stade de foot" },
};
// TODO WIP TEST rop this
private static ObservableCollection<LocalizedEvent> _your_events = new ObservableCollection<LocalizedEvent> {
new LocalizedEvent {
Title = "Yavsc Party",
Description = "Lancement en fanfare de la version 1.0 de ZicMoove, l'appli des fétards",
ProviderId = "paul",
ProviderName = "Yavsc Fondation",
EventWebPage = "http://lua.pschneider.fr/",
Location = _places[0]
},
new LocalizedEvent {
Title = "Evenement de test",
Description = "Blah bli lo qui est errare, ma no. Blou test allo 3!",
ProviderId = "provid3",
ProviderName = "Prov Entreprise 3",
EventWebPage = "http://lua.pschneider.fr/events/test3",
Location = _places[1]
},
new LocalizedEvent {
Title = "DjFx feat XamCoder, en Concert gratuit",
Description = "Hip Hop à Suresnes",
ProviderId = "brahim",
ProviderName = "Totem Production",
EventWebPage = "http://lua.pschneider.fr/events/totem",
Location = _places[2]
}
};
// TODO WIP TEST rop this
public static ObservableCollection<LocalizedEvent> Events {
get {
return _your_events;
}
}
}
}

View File

@ -0,0 +1,65 @@
using System;
using YavscLib;
namespace ZicMoove.Model.Workflow
{
public class Activity : IActivity
{
public string Code
{
get; set;
}
public DateTime DateCreated
{
get; set;
}
public DateTime DateModified
{
get; set;
}
public string ModeratorGroupName
{
get; set;
}
public string Name
{
get; set;
}
public string ParentCode
{
get; set;
}
public string Photo
{
get; set;
}
public int Rate
{
get; set;
}
public string SettingsClassName
{
get; set;
}
public string UserCreated
{
get; set;
}
public string UserModified
{
get; set;
}
public CommandForm[] Forms { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YavscLib;
namespace ZicMoove.Model.Workflow
{
public class CommandForm : ICommandForm
{
public string Action
{
get; set;
}
public string ActivityCode
{
get; set;
}
public long Id
{
get; set;
}
public string Title
{
get; set;
}
}
}

View File

@ -43,7 +43,6 @@ namespace ZicMoove.Settings
string.Empty;
private static readonly bool PushNotificationsDefault = false;
public static readonly string GoogleSenderId = "325408689282";
private const string MusicalKey = "musical_prefs";
private const string EnvironKey = "environ_prefs";

View File

@ -67,6 +67,7 @@
<Compile Include="Data\ApiCallFailedException.cs" />
<Compile Include="Data\EstimateEntity.cs" />
<Compile Include="Data\NonCrUD\RemoteFiles.cs" />
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
<Compile Include="Model\Access\BlackListed.cs" />
<Compile Include="Model\Auth\GCRegIdDeclaration.cs" />
<Compile Include="Model\Booking\MusicalPreference.cs" />
@ -77,6 +78,8 @@
<Compile Include="Model\Social\Chat\ChatStatus.cs" />
<Compile Include="Model\Social\Chat\ChatMessage.cs" />
<Compile Include="Model\Social\LocationType.cs" />
<Compile Include="Model\Workflow\Activity.cs" />
<Compile Include="Model\Workflow\CommandForm.cs" />
<Compile Include="Pages\ClientPages\SearchPage.xaml.cs">
<DependentUpon>SearchPage.xaml</DependentUpon>
</Compile>
@ -180,7 +183,6 @@
<Compile Include="Model\Booking\BookQuery.cs" />
<Compile Include="Model\Market\BaseProduct.cs" />
<Compile Include="Pages\EstimatePages\BillingLine.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" />
@ -300,6 +302,12 @@
<Reference Include="Plugin.Connectivity.Abstractions">
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\MonoAndroid10\Plugin.Connectivity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Plugin.DeviceInfo">
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.DeviceInfo.dll</HintPath>
</Reference>
<Reference Include="Plugin.DeviceInfo.Abstractions">
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.DeviceInfo.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Plugin.Geolocator">
<HintPath>..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Geolocator.dll</HintPath>
</Reference>
@ -328,6 +336,9 @@
<HintPath>..\..\packages\SQLite.Net-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Json">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Extensions, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net45+win8+wpa81\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>