WIP files
This commit is contained in:
@ -31,7 +31,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;DEV</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
|
||||
@ -162,6 +162,14 @@
|
||||
<HintPath>..\..\packages\Xamarin.Controls.SignaturePad.1.4.0\lib\MonoAndroid\SignaturePad.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SignaturePad.Forms, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xamarin.Controls.SignaturePad.Forms.1.4.0\lib\MonoAndroid\SignaturePad.Forms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SignaturePad.Forms.Droid, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xamarin.Controls.SignaturePad.Forms.1.4.0\lib\MonoAndroid\SignaturePad.Forms.Droid.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLite.Net">
|
||||
<HintPath>..\..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.service.chooser.chooser_target_service" android:value="fr.pschneider.bas.YavscChooserTargetService" />
|
||||
</activity>
|
||||
|
@ -19,9 +19,12 @@ namespace BookAStar
|
||||
using Model.UI;
|
||||
using Pages;
|
||||
using Plugin.Connectivity;
|
||||
using ViewModels;
|
||||
using Microsoft.AspNet.SignalR.Client;
|
||||
using Model.Social.Messaging;
|
||||
using ViewModels.Messaging;
|
||||
using ViewModels.UserProfile;
|
||||
using Pages.UserProfile;
|
||||
using ViewModels.EstimateAndBilling;
|
||||
|
||||
public partial class App : Application // superclass new in 1.3
|
||||
{
|
||||
@ -144,9 +147,9 @@ namespace BookAStar
|
||||
ViewFactory.Register<BookQueriesPage, BookQueriesViewModel>();
|
||||
ViewFactory.Register<EditBillingLinePage, BillingLineViewModel>();
|
||||
ViewFactory.Register<EditEstimatePage, EditEstimateViewModel>();
|
||||
ConfigManager = new XLabs.Settings.GenericConfigSettingsMgr(s =>
|
||||
ViewFactory.Register<UserFiles, DirectoryInfoViewModel>();
|
||||
ConfigManager = new GenericConfigSettingsMgr(s =>
|
||||
MainSettings.AppSettings.GetValueOrDefault<string>(s, MainSettings.SettingsDefault), null);
|
||||
|
||||
}
|
||||
|
||||
ExtendedMasterDetailPage masterDetail;
|
||||
@ -213,14 +216,20 @@ namespace BookAStar
|
||||
ToolbarItem tiHome = new ToolbarItem()
|
||||
{
|
||||
Text = "Accueil",
|
||||
Icon = "icon.png"
|
||||
Icon = "icon.png",
|
||||
Command = new Command(
|
||||
() => { NavigationService.NavigateTo<ChatPage>(); }
|
||||
)
|
||||
};
|
||||
|
||||
ToolbarItem tiPubChat= new ToolbarItem()
|
||||
{
|
||||
Text = "Chat",
|
||||
Icon = "chat_icon_s.png"
|
||||
Icon = "chat_icon_s.png",
|
||||
Command = new Command(
|
||||
() => { NavigationService.NavigateTo<ChatPage>(); }
|
||||
)
|
||||
};
|
||||
tiPubChat.Clicked += TiPubChat_Clicked;
|
||||
masterDetail.ToolbarItems.Add(tiHome);
|
||||
masterDetail.ToolbarItems.Add(tiSetts);
|
||||
masterDetail.ToolbarItems.Add(tiPubChat);
|
||||
@ -250,7 +259,7 @@ namespace BookAStar
|
||||
|
||||
private void TiPubChat_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
NavigationService.NavigateTo<ChatPage>();
|
||||
|
||||
}
|
||||
|
||||
public static INavigationService NavigationService { protected set; get; }
|
||||
|
@ -22,7 +22,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;DEV</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet />
|
||||
@ -48,13 +48,27 @@
|
||||
<Compile Include="Behaviors\PickerBehavior.cs" />
|
||||
<Compile Include="Behaviors\StarBehavior.cs" />
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="Converters\NotValueConverter.cs" />
|
||||
<Compile Include="Converters\SignalRConnectionStateToObject.cs" />
|
||||
<Compile Include="Data\LocalState.cs" />
|
||||
<Compile Include="Data\NonCrUD\RemoteFiles.cs" />
|
||||
<Compile Include="Model\FileSystem\UserDirectoryInfo.cs" />
|
||||
<Compile Include="Model\FileSystem\UserFileInfo.cs" />
|
||||
<Compile Include="Model\Settings\SignatureSettings.cs" />
|
||||
<Compile Include="Model\Social\Messaging\ChatStatus.cs" />
|
||||
<Compile Include="Model\Social\Messaging\PrivateMessage.cs" />
|
||||
<Compile Include="Model\UI\PageState.cs" />
|
||||
<Compile Include="Pages\UserProfile\UserFiles.xaml.cs">
|
||||
<DependentUpon>UserFiles.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings\ChatSettings.cs" />
|
||||
<Compile Include="ViewModels\EditingViewModel.cs" />
|
||||
<Compile Include="Pages\DocSigning.xaml.cs">
|
||||
<DependentUpon>DocSigning.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ViewModels\Signing\EstimateSignaturePad.cs" />
|
||||
<Compile Include="ViewModels\Signing\SignaturePadConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\UserProfile\DirectoryInfoViewModel.cs" />
|
||||
<Compile Include="Views\EnumPicker.cs" />
|
||||
<Compile Include="Converters\BooleanToObjectConverter.cs" />
|
||||
<Compile Include="Converters\EnumConverter.cs" />
|
||||
@ -82,23 +96,23 @@
|
||||
<Compile Include="Interfaces\IBookQueryData.cs" />
|
||||
<Compile Include="Interfaces\IBillingLine.cs" />
|
||||
<Compile Include="Interfaces\IEstimate.cs" />
|
||||
<Compile Include="Pages\BlogPage.cs" />
|
||||
<Compile Include="Pages\BookQueriesPage.xaml.cs">
|
||||
<Compile Include="Pages\BlogPages\BlogPage.cs" />
|
||||
<Compile Include="Pages\Estimate\BookQueriesPage.xaml.cs">
|
||||
<DependentUpon>BookQueriesPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\BookQueryPage.xaml.cs">
|
||||
<Compile Include="Pages\Estimate\BookQueryPage.xaml.cs">
|
||||
<DependentUpon>BookQueryPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\ChatPage.xaml.cs">
|
||||
<DependentUpon>ChatPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\EditBillingLinePage.xaml.cs">
|
||||
<Compile Include="Pages\Estimate\EditBillingLinePage.xaml.cs">
|
||||
<DependentUpon>EditBillingLinePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\DashboardPage.xaml.cs">
|
||||
<Compile Include="Pages\UserProfile\DashboardPage.xaml.cs">
|
||||
<DependentUpon>DashboardPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\EventDetail.xaml.cs">
|
||||
<Compile Include="Pages\Oooops\EventDetail.xaml.cs">
|
||||
<DependentUpon>EventDetail.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings\MainSettings.cs" />
|
||||
@ -143,30 +157,33 @@
|
||||
<Compile Include="Model\Auth\Tokens.cs" />
|
||||
<Compile Include="Model\Auth\User.cs" />
|
||||
<Compile Include="Model\Workflow\Estimate.cs" />
|
||||
<Compile Include="Pages\EditEstimatePage.xaml.cs">
|
||||
<Compile Include="Pages\Estimate\EditEstimatePage.xaml.cs">
|
||||
<DependentUpon>EditEstimatePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\HomePage.xaml.cs">
|
||||
<Compile Include="Pages\Oooops\HomePage.xaml.cs">
|
||||
<DependentUpon>HomePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\PinPage.cs" />
|
||||
<Compile Include="ViewModels\BookQueriesViewModel.cs" />
|
||||
<Compile Include="ViewModels\BookQueryViewModel.cs" />
|
||||
<Compile Include="ViewModels\BillingLineViewModel.cs" />
|
||||
<Compile Include="ViewModels\ChatViewModel.cs" />
|
||||
<Compile Include="ViewModels\DashboardViewModel.cs" />
|
||||
<Compile Include="ViewModels\EditEstimateViewModel.cs" />
|
||||
<Compile Include="ViewModels\UserLoginViewModel.cs" />
|
||||
<Compile Include="Pages\Oooops\PinPage.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\BookQueriesViewModel.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\BookQueryViewModel.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\BillingLineViewModel.cs" />
|
||||
<Compile Include="ViewModels\Messaging\ChatViewModel.cs" />
|
||||
<Compile Include="ViewModels\UserProfile\DashboardViewModel.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\EditEstimateViewModel.cs" />
|
||||
<Compile Include="ViewModels\UserProfile\UserLoginViewModel.cs" />
|
||||
<Compile Include="ViewModels\ViewModelBase.cs" />
|
||||
<Compile Include="Views\MarkdownView.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Pages\SearchPage.xaml.cs">
|
||||
<Compile Include="Pages\Oooops\SearchPage.xaml.cs">
|
||||
<DependentUpon>SearchPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\AccountChooserPage.xaml.cs">
|
||||
<Compile Include="Pages\UserProfile\AccountChooserPage.xaml.cs">
|
||||
<DependentUpon>AccountChooserPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\Tag.cs" />
|
||||
<Compile Include="Views\MDSigningView.xaml.cs">
|
||||
<DependentUpon>MDSigningView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\RatingView.xaml.cs">
|
||||
<DependentUpon>RatingView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -188,15 +205,15 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\EventDetail.xaml">
|
||||
<EmbeddedResource Include="Pages\Oooops\EventDetail.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Pages\SearchPage.xaml">
|
||||
<EmbeddedResource Include="Pages\Oooops\SearchPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Pages\AccountChooserPage.xaml">
|
||||
<EmbeddedResource Include="Pages\UserProfile\AccountChooserPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
@ -239,6 +256,10 @@
|
||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SignaturePad.Forms, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xamarin.Controls.SignaturePad.Forms.1.4.0\lib\portable-net45+win+wp8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SignaturePad.Forms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLite.Net, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\SQLite.Net-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -301,7 +322,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\BookQueryPage.xaml">
|
||||
<EmbeddedResource Include="Pages\Estimate\BookQueryPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
@ -313,25 +334,25 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\EditEstimatePage.xaml">
|
||||
<EmbeddedResource Include="Pages\Estimate\EditEstimatePage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\BookQueriesPage.xaml">
|
||||
<EmbeddedResource Include="Pages\Estimate\BookQueriesPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\EditBillingLinePage.xaml">
|
||||
<EmbeddedResource Include="Pages\Estimate\EditBillingLinePage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\DashboardPage.xaml">
|
||||
<EmbeddedResource Include="Pages\UserProfile\DashboardPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
@ -345,7 +366,7 @@
|
||||
<EmbeddedResource Include="Images\Users\icon_user_settings.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\HomePage.xaml">
|
||||
<EmbeddedResource Include="Pages\Oooops\HomePage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
@ -383,6 +404,24 @@
|
||||
<EmbeddedResource Include="Images\Chat\disconnected.png" />
|
||||
<EmbeddedResource Include="Images\Chat\reconnecting.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\DocSigning.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Views\MDSigningView.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Pages\UserProfile\UserFiles.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
@ -14,7 +14,7 @@ namespace BookAStar
|
||||
#region Uri
|
||||
|
||||
#if DEV
|
||||
public const string YavscHomeUrl = "https://dev.pschneider.fr";
|
||||
public const string YavscHomeUrl = "http://dev.pschneider.fr";
|
||||
#else
|
||||
#if YAVSC
|
||||
public const string YavscHomeUrl = "https://yavsc.pschneider.fr";
|
||||
|
19
BookAStar/BookAStar/Converters/NotValueConverter.cs
Normal file
19
BookAStar/BookAStar/Converters/NotValueConverter.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
public class NotValueConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return object.Equals(value, false);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return object.Equals(value, false);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,8 +4,9 @@
|
||||
using Model.Blog;
|
||||
using Model.Workflow;
|
||||
using Model.UI;
|
||||
using ViewModels;
|
||||
using Model.Social.Messaging;
|
||||
using Model.FileSystem;
|
||||
using ViewModels.EstimateAndBilling;
|
||||
|
||||
public class DataManager
|
||||
{
|
||||
@ -13,8 +14,11 @@
|
||||
public RemoteEntityRO<BookQueryData, long> BookQueries { get; set; }
|
||||
public RemoteEntity<Estimate, long> Estimates { get; set; }
|
||||
public RemoteEntity<Blog, long> Blogspot { get; set; }
|
||||
internal RemoteEntity<UserDirectoryInfo, string> RemoteFiles { get; set; }
|
||||
|
||||
public LocalEntity<ClientProviderInfo,string> Contacts { get; set; }
|
||||
internal LocalEntity<PageState, int> AppState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// They have no remote exisence ...
|
||||
/// </summary>
|
||||
@ -38,11 +42,13 @@
|
||||
BookQueries = new RemoteEntityRO<BookQueryData, long>("bookquery", q => q.Id);
|
||||
Estimates = new RemoteEntity<Estimate, long>("estimate", x => x.Id);
|
||||
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);
|
||||
EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description);
|
||||
PrivateMessages = new LocalEntity<ChatMessage, int>(m=> m.GetHashCode());
|
||||
RemoteFiles = new RemoteEntity<UserDirectoryInfo, string> ("fs", d => d.SubPath);
|
||||
|
||||
PrivateMessages.Load();
|
||||
BookQueries.Load();
|
||||
@ -52,6 +58,7 @@
|
||||
AppState.Load();
|
||||
EstimationCache.Load();
|
||||
EstimateLinesTemplates.Load();
|
||||
RemoteFiles.Load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
BookAStar/BookAStar/Data/NonCrUD/RemoteFiles.cs
Normal file
50
BookAStar/BookAStar/Data/NonCrUD/RemoteFiles.cs
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace BookAStar.Data.NonCrUD
|
||||
{
|
||||
using Helpers;
|
||||
using Model.FileSystem;
|
||||
|
||||
public class RemoteFiles : RemoteEntity<UserDirectoryInfo, FileAddress>
|
||||
{
|
||||
public RemoteFiles() : base("fs", d => d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override async void Execute(object parameter)
|
||||
{
|
||||
BeforeExecute();
|
||||
using (var client = UserHelpers.CreateClient())
|
||||
{
|
||||
// Get the whole data
|
||||
try
|
||||
{
|
||||
var subpath = parameter as string;
|
||||
string path = ControllerUri.AbsolutePath + ((subpath != null) ? "/" + subpath : null);
|
||||
using (var response = await client.GetAsync(ControllerUri))
|
||||
{
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var di = JsonConvert.DeserializeObject<UserDirectoryInfo>(content);
|
||||
this.Merge(di);
|
||||
}
|
||||
else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
|
||||
throw new Exception("Bad request");
|
||||
else
|
||||
throw new Exception("Remote call failed");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Remote call failed", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -14,11 +14,12 @@ namespace BookAStar.Data
|
||||
|
||||
public class RemoteEntity<V, K> : LocalEntity<V, K>, ICommand where K : IEquatable<K>
|
||||
{
|
||||
private string _controller;
|
||||
public string ControllerName { protected set; get; }
|
||||
public event EventHandler CanExecuteChanged;
|
||||
public bool IsExecuting { get; private set; }
|
||||
|
||||
private Uri controllerUri;
|
||||
public Uri ControllerUri { get; protected set; }
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return !IsExecuting && (MainSettings.CurrentUser != null);
|
||||
@ -28,11 +29,11 @@ namespace BookAStar.Data
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(controllerName))
|
||||
throw new InvalidOperationException();
|
||||
_controller = controllerName;
|
||||
controllerUri = new Uri(Constants.YavscApiUrl + "/" + _controller);
|
||||
ControllerName = controllerName;
|
||||
ControllerUri = new Uri(Constants.YavscApiUrl + "/" + ControllerName);
|
||||
}
|
||||
|
||||
private void BeforeExecute()
|
||||
protected void BeforeExecute()
|
||||
{
|
||||
if (IsExecuting)
|
||||
throw new InvalidOperationException("Already executing");
|
||||
@ -45,7 +46,7 @@ namespace BookAStar.Data
|
||||
/// Refresh the collection
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
public async void Execute(object parameter)
|
||||
public virtual async void Execute(object parameter)
|
||||
{
|
||||
BeforeExecute();
|
||||
using (HttpClient client = UserHelpers.CreateClient())
|
||||
@ -53,7 +54,7 @@ namespace BookAStar.Data
|
||||
// Get the whole data
|
||||
try
|
||||
{
|
||||
using (var response = await client.GetAsync(controllerUri))
|
||||
using (var response = await client.GetAsync(ControllerUri))
|
||||
{
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
@ -77,26 +78,27 @@ namespace BookAStar.Data
|
||||
AfterExecuting();
|
||||
}
|
||||
|
||||
private void AfterExecuting()
|
||||
protected void AfterExecuting()
|
||||
{
|
||||
IsExecuting = false;
|
||||
if (CanExecuteChanged != null)
|
||||
CanExecuteChanged.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
public async Task<V> Get(K key)
|
||||
public virtual async Task<V> Get(K key)
|
||||
{
|
||||
var item = LocalGet(key);
|
||||
if (item == null) item = await RemoteGet(key);
|
||||
CurrentItem = item;
|
||||
return CurrentItem;
|
||||
}
|
||||
private Uri GetUri(K key)
|
||||
|
||||
protected Uri GetUri(K key)
|
||||
{
|
||||
return new Uri(controllerUri.AbsoluteUri + "/" + key.ToString());
|
||||
return new Uri(ControllerUri.AbsoluteUri + "/" + key.ToString());
|
||||
}
|
||||
|
||||
public async Task<V> RemoteGet(K key)
|
||||
public virtual async Task<V> RemoteGet(K key)
|
||||
{
|
||||
V item = default(V);
|
||||
BeforeExecute();
|
||||
@ -121,7 +123,7 @@ namespace BookAStar.Data
|
||||
return item;
|
||||
}
|
||||
|
||||
public async void Create(V item)
|
||||
public virtual async void Create(V item)
|
||||
{
|
||||
BeforeExecute();
|
||||
|
||||
@ -131,13 +133,13 @@ namespace BookAStar.Data
|
||||
HttpContent content = new StringContent(
|
||||
stringContent, Encoding.UTF8, "application/json"
|
||||
);
|
||||
using (var response = await client.PostAsync(controllerUri, content))
|
||||
using (var response = await client.PostAsync(ControllerUri, content))
|
||||
{
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
// TODO throw custom exception, and catch to inform user
|
||||
var errcontent = await response.Content.ReadAsStringAsync();
|
||||
Debug.WriteLine($"Create failed posting {stringContent} @ {controllerUri.AbsoluteUri}: {errcontent}");
|
||||
Debug.WriteLine($"Create failed posting {stringContent} @ {ControllerUri.AbsoluteUri}: {errcontent}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -152,7 +154,7 @@ namespace BookAStar.Data
|
||||
CurrentItem = item;
|
||||
AfterExecuting();
|
||||
}
|
||||
public async void Update(V item)
|
||||
public virtual async void Update(V item)
|
||||
{
|
||||
BeforeExecute();
|
||||
|
||||
@ -188,7 +190,7 @@ namespace BookAStar.Data
|
||||
AfterExecuting();
|
||||
}
|
||||
|
||||
public async void Delete(K key)
|
||||
public virtual async void Delete(K key)
|
||||
{
|
||||
BeforeExecute();
|
||||
var uri = GetUri(key);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
@ -7,8 +8,12 @@ using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Helpers
|
||||
{
|
||||
using Data.NonCrUD;
|
||||
using Model.FileSystem;
|
||||
|
||||
public static class UserHelpers
|
||||
{
|
||||
|
||||
public static ImageSource Avatar(string avatarPath)
|
||||
{
|
||||
var result = avatarPath == null ?
|
||||
|
35
BookAStar/BookAStar/Model/FileSystem/UserDirectoryInfo.cs
Normal file
35
BookAStar/BookAStar/Model/FileSystem/UserDirectoryInfo.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BookAStar.Model.FileSystem
|
||||
{
|
||||
public class FileAddress : IEquatable<FileAddress>
|
||||
{
|
||||
public string SubPath { get; set; }
|
||||
public string UserName { get; set; }
|
||||
|
||||
public bool Equals(FileAddress other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
if (other.UserName != UserName) return false;
|
||||
if (other.SubPath != SubPath) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class UserDirectoryInfo : FileAddress
|
||||
{
|
||||
public UserFileInfo[] Files
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string[] SubDirectories
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
19
BookAStar/BookAStar/Model/FileSystem/UserFileInfo.cs
Normal file
19
BookAStar/BookAStar/Model/FileSystem/UserFileInfo.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BookAStar.Model.FileSystem
|
||||
{
|
||||
public class UserFileInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public long Size { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
}
|
||||
}
|
35
BookAStar/BookAStar/Pages/UserProfile/UserFiles.xaml
Normal file
35
BookAStar/BookAStar/Pages/UserProfile/UserFiles.xaml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="BookAStar.Pages.UserProfile.UserFiles">
|
||||
<Label Text="{Binding SubPath}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<ListView x:Name="dirlist" ItemsSource="{Binding SubDirectories}"
|
||||
RefreshCommand="{Binding RefreshCommand}" >
|
||||
<ListView.ItemTemplate >
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<ViewCell.View>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="{Binding Name}" />
|
||||
<Label Text="{Binding Size}" />
|
||||
<Label Text="{Binding CreationTime, StringFormat='créé {0:dddd d MMMM à HH:mm}'}" />
|
||||
<Label Text="{Binding LastModified, StringFormat='modifié {0:dddd d MMMM à HH:mm}'}" />
|
||||
</StackLayout>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<ListView x:Name="filelist" ItemsSource="{Binding FileInfo}"
|
||||
RefreshCommand="{Binding RefreshCommand}">
|
||||
<ListView.ItemTemplate >
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<ViewCell.View>
|
||||
<Label Text="{Binding .}" />
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ContentPage>
|
34
BookAStar/BookAStar/Pages/UserProfile/UserFiles.xaml.cs
Normal file
34
BookAStar/BookAStar/Pages/UserProfile/UserFiles.xaml.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Pages.UserProfile
|
||||
{
|
||||
using ViewModels.UserProfile;
|
||||
using Data;
|
||||
public partial class UserFiles : ContentPage
|
||||
{
|
||||
protected DirectoryInfoViewModel model;
|
||||
|
||||
public UserFiles()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var currentDir = DataManager.Current.RemoteFiles.CurrentItem;
|
||||
|
||||
BindingContext = new DirectoryInfoViewModel(currentDir)
|
||||
{
|
||||
RefreshCommand = new Command(() =>
|
||||
{
|
||||
DataManager.Current.RemoteFiles.Execute(null);
|
||||
|
||||
this.dirlist.EndRefresh();
|
||||
this.filelist.EndRefresh();
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
base.OnBindingContextChanged();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using XLabs.Forms.Mvvm;
|
||||
|
||||
namespace BookAStar.ViewModels.UserProfile
|
||||
{
|
||||
using Model.FileSystem;
|
||||
|
||||
public class DirectoryInfoViewModel : ViewModel
|
||||
{
|
||||
public ObservableString SubPath { get; set; }
|
||||
public ObservableCollection<string> SubDirectories { get; set; }
|
||||
public ObservableCollection<UserFileInfo> FileInfo { get; set; }
|
||||
public ICommand RefreshCommand { get; set; }
|
||||
public DirectoryInfoViewModel (UserDirectoryInfo model=null)
|
||||
{
|
||||
Data.DataManager.Current.RemoteFiles.CollectionChanged += RemoteFiles_CollectionChanged;
|
||||
|
||||
if (model == null)
|
||||
model = Data.DataManager.Current.RemoteFiles.CurrentItem;
|
||||
SubDirectories = new ObservableCollection<string> (model.SubDirectories);
|
||||
SubPath = new ObservableString (model.SubPath);
|
||||
FileInfo = new ObservableCollection<Model.FileSystem.UserFileInfo> (model.Files);
|
||||
}
|
||||
|
||||
private void RemoteFiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user