SyncDataActions.cs
2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.Storage.SyncData;
namespace DirRX.Storage.Client
{
partial class SyncDataCollectionActions
{
public virtual bool CanConfirmSelected(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return true;
}
public virtual void ConfirmSelected(Sungero.Domain.Client.ExecuteActionArgs e)
{
var selectedIds = _objs.Select(x => x.Id).ToList();
var notConfirmed = PublicFunctions.Module.Remote.GetNotConfirmedSyncData().Where(x => selectedIds.Contains(x.Id)).ToList();
var cnt = notConfirmed.Count;
if (cnt > 0)
{
var accepted = Calendar.Now;
var responsible = Users.Current;
foreach (var item in notConfirmed)
{
item.Accepted = accepted;
item.Responsible = responsible;
item.Save();
var assyncHandler = AsyncHandlers.SynchronizeExternalEntities.Create();
assyncHandler.eventLogId = item.Id;
assyncHandler.ExecuteAsync();
}
Dialogs.NotifyMessage(string.Format("{0} пакетов отправлено в обработку", cnt));
}
}
public virtual bool CanDeleteSelected(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return true;
}
public virtual void DeleteSelected(Sungero.Domain.Client.ExecuteActionArgs e)
{
Functions.Module.Remote.DeleteSyncData(_objs.Select(x => x.Id).ToList());
}
}
internal static class SyncDataStaticActions
{
public static bool CanConfirmAll(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return true;
}
public static void ConfirmAll(Sungero.Domain.Client.ExecuteActionArgs e)
{
var notConfirmed = PublicFunctions.Module.Remote.GetNotConfirmedSyncData().ToList();
var cnt = notConfirmed.Count;
if (cnt > 0)
{
var accepted = Calendar.Now;
var responsible = Users.Current;
foreach (var item in notConfirmed)
{
item.Accepted = accepted;
item.Responsible = responsible;
item.Save();
var assyncHandler = AsyncHandlers.SynchronizeExternalEntities.Create();
assyncHandler.eventLogId = item.Id;
assyncHandler.ExecuteAsync();
}
Dialogs.NotifyMessage(string.Format("{0} пакетов отправлено в обработку", cnt));
}
}
}
}