Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Windows
pEp for Outlook
Commits
1510fb85
Commit
1510fb85
authored
Sep 30, 2021
by
Thomas
Browse files
Add ApplyTo identities and catch errors
parent
3bfe6a7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
DPE/Patch.cs
View file @
1510fb85
...
...
@@ -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
;
}
}
}
UI/ViewModels/PatchViewModel.cs
View file @
1510fb85
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment