Commit 1510fb85 authored by Thomas's avatar Thomas
Browse files

Add ApplyTo identities and catch errors

parent 3bfe6a7d
......@@ -7,7 +7,7 @@ namespace pEp.DPE
public class Patch
{
public static readonly string REG_FILE_SCHEME = "file:///microsoft.windows.registry";
public enum RejectReason
{
None,
......@@ -39,7 +39,16 @@ namespace pEp.DPE
/// <returns>The Patch object or null if an error occured.</returns>
public static Patch Deserialize(string json)
{
return json.Deserialize<Patch>();
try
{
return json.Deserialize<Patch>();
}
catch (Exception ex)
{
Log.Error("Deserialize: Error occured. " + ex);
}
return null;
}
}
}
......@@ -58,6 +58,11 @@ namespace pEp.UI.ViewModels
}
}
/// <summary>
/// Gets the identities this patch will be applied to.
/// </summary>
public ObservableCollection<PEPIdentity> ApplyTo => new ObservableCollection<PEPIdentity>(this.Dialog.Patch.ApplyTo);
/// <summary>
/// Gets or sets the background.
/// </summary>
......@@ -90,7 +95,14 @@ namespace pEp.UI.ViewModels
/// <summary>
/// Gets the creation date as string.
/// </summary>
public string CreationDateString => DateTime.FromFileTimeUtc(this.Dialog.Patch.CreationDate).ToLocalTime().ToString("F");
public string CreationDateString
{
get
{
long? fileTime = this.Dialog?.Patch?.CreationDate;
return (fileTime != null) ? DateTime.FromFileTimeUtc((long)fileTime).ToLocalTime().ToString("F") : null;
}
}
/// <summary>
/// The own identity that acts as sender of DPE calls.
......@@ -199,7 +211,7 @@ namespace pEp.UI.ViewModels
/// </summary>
public string RootPath
{
get => this.Dialog.Patch?.RootPath?.AbsoluteUri;
get => this.Dialog.Patch?.RootPath?.OriginalString;
set
{
this.Dialog.Patch.RootPath = new Uri(value);
......@@ -334,6 +346,14 @@ namespace pEp.UI.ViewModels
// Concatenate all diffs from the selected files
this.Dialog.Patch.Diff = this.UnifyDiffs();
// Add Apply identities
this.Dialog.Patch.ApplyTo.Clear();
foreach (PEPIdentity identity in this.ApplyTo)
{
this.Dialog.Patch.ApplyTo.Add(identity);
}
// Send patch to DPE and close if successful
if (await this.ExecutePatchTask(Globals.ThisAddIn.DistributedPolicyEngine.Suggest(this.Dialog.Patch, this.From)))
{
AdapterExtensions.ShowNotification("Patch successfully suggested", this.Dialog.Patch.CommitMessage);
......@@ -707,7 +727,7 @@ namespace pEp.UI.ViewModels
break;
}
}
/// <summary>
/// Supports this patch.
/// </summary>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment