|
|
|
|
@ -36,6 +36,10 @@ namespace ZicMoove
|
|
|
|
|
using Model.Auth;
|
|
|
|
|
using Plugin.DeviceInfo;
|
|
|
|
|
using Yavsc.Models.Identity;
|
|
|
|
|
using System.Json;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
public partial class App : Application // superclass new in 1.3
|
|
|
|
|
{
|
|
|
|
|
@ -231,15 +235,20 @@ namespace ZicMoove
|
|
|
|
|
BindingContext = bookQueries
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
homePage = new HomePage() {
|
|
|
|
|
homePage = new HomePage()
|
|
|
|
|
{
|
|
|
|
|
Title = "Accueil",
|
|
|
|
|
Icon = "icon.png" };
|
|
|
|
|
Icon = "icon.png"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
homePage.BindingContext = new HomeViewModel {
|
|
|
|
|
homePage.BindingContext = new HomeViewModel
|
|
|
|
|
{
|
|
|
|
|
BookQueries = bookQueries,
|
|
|
|
|
UserProfile = userprofile };
|
|
|
|
|
UserProfile = userprofile
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
userProfilePage = new UserProfilePage {
|
|
|
|
|
userProfilePage = new UserProfilePage
|
|
|
|
|
{
|
|
|
|
|
Title = "Profile utilisateur",
|
|
|
|
|
Icon = "ic_corp_icon.png",
|
|
|
|
|
BindingContext = userprofile
|
|
|
|
|
@ -286,7 +295,8 @@ namespace ZicMoove
|
|
|
|
|
Text = "Accueil",
|
|
|
|
|
Icon = "icon.png",
|
|
|
|
|
Command = new Command(
|
|
|
|
|
() => {
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
ShowPage(homePage);
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
@ -373,7 +383,8 @@ namespace ZicMoove
|
|
|
|
|
chatHubConnection.Error += ChatHubConnection_Error;
|
|
|
|
|
|
|
|
|
|
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
|
|
|
|
|
chatHubProxy.On<string, string>("addPV", (n, m) => {
|
|
|
|
|
chatHubProxy.On<string, string>("addPV", (n, m) =>
|
|
|
|
|
{
|
|
|
|
|
var msg = new ChatMessage
|
|
|
|
|
{
|
|
|
|
|
Message = m,
|
|
|
|
|
@ -431,24 +442,52 @@ namespace ZicMoove
|
|
|
|
|
return chatHubProxy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static Task<bool> HasSomeCloud {
|
|
|
|
|
public static Task<bool> HasSomeCloud
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return CrossConnectivity.Current.IsReachable(Constants.YavscHomeUrl, Constants.CloudTimeout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void PostDeviceInfo()
|
|
|
|
|
public static async Task PostDeviceInfo()
|
|
|
|
|
{
|
|
|
|
|
var info = GetDeviceInfo();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(info.GCMRegistrationId))
|
|
|
|
|
{
|
|
|
|
|
if (MainSettings.CurrentUser != null)
|
|
|
|
|
{
|
|
|
|
|
InvokeApi("gcm/register", info);
|
|
|
|
|
using (var client = UserHelpers.CreateJsonClient())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var stringContent = JsonConvert.SerializeObject(info);
|
|
|
|
|
HttpContent content = new StringContent(
|
|
|
|
|
stringContent, Encoding.UTF8, "application/json"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
using (var response = await client.PostAsync(Constants.MobileRegistrationUrl, content))
|
|
|
|
|
{
|
|
|
|
|
if (response.IsSuccessStatusCode)
|
|
|
|
|
{
|
|
|
|
|
var rcontent = await response.Content.ReadAsStringAsync();
|
|
|
|
|
var jvalue = JsonValue.Parse(rcontent);
|
|
|
|
|
if (jvalue != null)
|
|
|
|
|
if (jvalue.ContainsKey("UpdateActivities"))
|
|
|
|
|
if ((bool)jvalue["UpdateActivities"])
|
|
|
|
|
{
|
|
|
|
|
DataManager.Instance.Activities.Execute(null);
|
|
|
|
|
DataManager.Instance.Activities.SaveEntity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
// TODO err reporting
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static IGCMDeclaration GetDeviceInfo()
|
|
|
|
|
@ -470,30 +509,7 @@ namespace ZicMoove
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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
|
|
|
|
|
|