ModuleClientFunctions.cs
18.1 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Sungero.Company;
using Sungero.Content;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Docflow;
using Sungero.Domain.Shared;
using Sungero.Metadata.Services;
using Sungero.Reporting.Client;
using Sungero.Reporting.Shared;
using Sungero.Workflow;
namespace Sungero.RecordManagement.Client
{
public class ModuleFunctions
{
/// <summary>
/// Показать настройки текущего пользователя.
/// </summary>
public static void ShowCurrentPersonalSettings()
{
var personalSettings = Docflow.PublicFunctions.PersonalSetting.GetPersonalSettings(null);
if (personalSettings != null)
personalSettings.Show();
else
Dialogs.ShowMessage(Resources.FailedGetSettings, MessageType.Error);
}
/// <summary>
/// Перегрузка открытия отчет "Контроль исполнения поручений" из виджета за указанный месяц.
/// </summary>
/// <param name="currentPeriod">Дата.</param>
/// <param name="performerParam">Исполнитель, указанный в параметрах виджета.</param>
public static void ShowActionItemsExecutionReport(DateTime currentPeriod, Enumeration performerParam)
{
// Текущий период.
var periodBegin = currentPeriod.BeginningOfMonth();
var periodEnd = currentPeriod.EndOfMonth();
var report = RecordManagement.Reports.GetActionItemsExecutionReport();
report.BeginDate = periodBegin;
report.EndDate = periodEnd.EndOfDay();
report.ClientEndDate = periodEnd;
if (performerParam == RecordManagement.Widgets.ActionItemCompletionGraph.Performer.Author)
report.Author = Company.Employees.Current;
report.Open();
}
/// <summary>
/// Диалог с запросом параметров для отчетов по журналам регистрации.
/// </summary>
/// <param name="reportName">Наименование отчета.</param>
/// <param name="direction">Направление документопотока журнала.</param>
/// <param name="documentRegisterValue">Журнал.</param>
/// <param name="helpCode">Код справки.</param>
/// <returns>Возвращает структуру формата - запустить отчет, дата начала, дата окончания, журнал.</returns>
public static Structures.Module.DocumentRegisterReportParametrs ShowDocumentRegisterReportDialog(string reportName, Enumeration direction,
IDocumentRegister documentRegisterValue,
string helpCode)
{
var personalSettings = Docflow.PublicFunctions.PersonalSetting.GetPersonalSettings(Employees.Current);
var dialog = Dialogs.CreateInputDialog(reportName);
dialog.HelpCode = helpCode;
var settingsBeginDate = Docflow.PublicFunctions.PersonalSetting.GetStartDate(personalSettings);
var beginDate = dialog.AddDate(Resources.StartDate, true, settingsBeginDate ?? Calendar.UserToday);
var settingsEndDate = Docflow.PublicFunctions.PersonalSetting.GetEndDate(personalSettings);
var endDate = dialog.AddDate(Resources.EndDate, true, settingsEndDate ?? Calendar.UserToday);
INavigationDialogValue<IDocumentRegister> documentRegister = null;
if (documentRegisterValue == null)
{
var documentRegisters = Functions.Module.Remote.GetFilteredDocumentRegistersForReport(direction);
IDocumentRegister defaultDocumentRegister = null;
if (personalSettings != null)
{
if (direction == Docflow.DocumentRegister.DocumentFlow.Incoming)
defaultDocumentRegister = personalSettings.IncomingDocRegister;
else if (direction == Docflow.DocumentRegister.DocumentFlow.Outgoing)
defaultDocumentRegister = personalSettings.OutgoingDocRegister;
else
defaultDocumentRegister = personalSettings.InnerDocRegister;
}
if (documentRegisters.Count == 1)
documentRegister = dialog.AddSelect(Docflow.Resources.DocumentRegister, true, documentRegisters.FirstOrDefault()).From(documentRegisters);
else
documentRegister = dialog.AddSelect(Docflow.Resources.DocumentRegister, true, defaultDocumentRegister).From(documentRegisters);
}
dialog.SetOnButtonClick((args) =>
{
Docflow.PublicFunctions.Module.CheckReportDialogPeriod(args, beginDate, endDate);
});
dialog.Buttons.AddOkCancel();
dialog.Buttons.Default = DialogButtons.Ok;
if (dialog.Show() == DialogButtons.Ok)
{
if (documentRegisterValue == null)
documentRegisterValue = documentRegister.Value;
return Structures.Module.DocumentRegisterReportParametrs.Create(true, beginDate.Value, endDate.Value, documentRegisterValue);
}
else
{
documentRegisterValue = null;
return Structures.Module.DocumentRegisterReportParametrs.Create(false, null, null, null);
}
}
/// <summary>
/// Показать диалог подтверждения выполнения без создания поручений.
/// </summary>
/// <param name="assignment">Задание, которое выполняется.</param>
/// <param name="document">Документ.</param>
/// <param name="e">Аргументы.</param>
/// <returns>True, если диалог был, иначе false.</returns>
public static bool ShowConfirmationDialogCreationActionItem(IAssignment assignment, IOfficialDocument document, Sungero.Workflow.Client.ExecuteResultActionArgs e)
{
var reviewTask = DocumentReviewTasks.As(assignment.Task);
var hasSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.InProcess, reviewTask.Addressee);
if (hasSubActionItem)
return false;
var dialogText = ReviewResolutionAssignments.Is(assignment) ?
Docflow.Resources.ExecuteWithoutCreatingActionItemFromAddressee : Docflow.Resources.ExecuteWithoutCreatingActionItem;
var dialog = Dialogs.CreateTaskDialog(dialogText, MessageType.Question);
dialog.Buttons.AddYes();
dialog.Buttons.Default = DialogButtons.Yes;
var createActionItemButton = dialog.Buttons.AddCustom(Docflow.Resources.CreateActionItem);
dialog.Buttons.AddNo();
var result = dialog.Show();
if (result == DialogButtons.Yes)
return true;
if (result == DialogButtons.Cancel || result == DialogButtons.No)
e.Cancel();
assignment.Save();
var assignedBy = reviewTask.Addressee;
var resolution = ReviewResolutionAssignments.Is(assignment) ? ReviewResolutionAssignments.As(assignment).ResolutionText : assignment.ActiveText;
var actionItem = ActionItemExecutionTasks.As(Functions.Module.Remote.CreateActionItemExecutionWithResolution(document, assignment.Id, resolution, assignedBy));
if (actionItem != null)
{
actionItem.IsDraftResolution = false;
actionItem.WaitForParentAssignment = true;
actionItem.ShowModal();
}
hasSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.InProcess, reviewTask.Addressee);
if (hasSubActionItem)
return true;
var hasDraftSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.Draft, reviewTask.Addressee);
e.AddError(hasDraftSubActionItem ? Docflow.Resources.AllCreatedActionItemsShouldBeStarted : Docflow.Resources.CreatedActionItemExecutionNeeded);
e.Cancel();
return true;
}
/// <summary>
/// Показать диалог подтверждения прекращения подчиненных поручений.
/// </summary>
/// <param name="assignment">Ведущее поручение.</param>
/// <returns>True, если запрос был подтвержден.
/// False, если была нажата отмена.</returns>
[Public, Obsolete("Используйте метод ShowAbortSubActionItemsConfirmationDialog")]
public virtual bool ShowAbortConfirmationDialog(IActionItemExecutionAssignment assignment)
{
return this.ShowAbortSubActionItemsConfirmationDialog(assignment, null);
}
/// <summary>
/// Показать диалог подтверждения прекращения подчиненных поручений.
/// </summary>
/// <param name="assignment">Ведущее поручение.</param>
/// <param name="notCompletedExecutionSubTasks">Список невыполненных подчиненных поручений.</param>
/// <returns>True, если запрос был подтвержден.
/// False, если была нажата отмена.</returns>
[Public]
public virtual bool ShowAbortSubActionItemsConfirmationDialog(IActionItemExecutionAssignment assignment, List<IActionItemExecutionTask> notCompletedExecutionSubTasks)
{
if (assignment == null)
return false;
var dialog = Dialogs.CreateTaskDialog(ActionItemExecutionTasks.Resources.StopAdditionalActionItemExecutions,
MessageType.Question);
Action showNotCompletedExecutionSubTasksHandler = () =>
{
notCompletedExecutionSubTasks.ShowModal();
};
var showNotCompletedExecutionSubTasks = dialog.AddHyperlink(ActionItemExecutionTasks.Resources.NotCompletedExecutionSubTasksHyperlinkTitle);
showNotCompletedExecutionSubTasks.SetOnExecute(showNotCompletedExecutionSubTasksHandler);
showNotCompletedExecutionSubTasks.IsVisible = notCompletedExecutionSubTasks.Any();
var notAbort = dialog.Buttons.AddCustom(ActionItemExecutionAssignments.Resources.NotAbort);
dialog.Buttons.Default = notAbort;
var abort = dialog.Buttons.AddCustom(ActionItemExecutionAssignments.Resources.Abort);
dialog.Buttons.AddCancel();
var dialogResult = dialog.Show();
if (dialogResult == notAbort)
return true;
if (dialogResult == abort)
{
assignment.NeedAbortChildActionItems = true;
return true;
}
if (dialogResult == DialogButtons.Cancel)
return false;
return false;
}
/// <summary>
/// Показать диалог подтверждения выполнения ведущего поручения.
/// </summary>
/// <param name="supervisorAssignment">Задание на приемку в рамках подчиненного поручения.</param>
/// <param name="parentAssignment">Ведущее поручение.</param>
/// <returns>True, если запрос был подтвержден.
/// False, если была нажата отмена.</returns>
public virtual bool ShowCompleteParentActionItemConfirmationDialog(IActionItemSupervisorAssignment supervisorAssignment, IActionItemExecutionAssignment parentAssignment)
{
var resources = Sungero.RecordManagement.ActionItemSupervisorAssignments.Resources;
var dialog = Dialogs.CreateTaskDialog(resources.CompleteParentAssignmentDialogTitle, MessageType.Question);
Action showParentAssignmentHandler = () =>
{
parentAssignment.ShowModal();
};
var showParentAssignment = dialog.AddHyperlink(resources.ShowParentAssignmentHyperlinkTitle);
showParentAssignment.SetOnExecute(showParentAssignmentHandler);
showParentAssignment.IsVisible = parentAssignment != null;
var complete = dialog.Buttons.AddCustom(resources.CompleteParentAssignmentDialogCompleteButtonTitle);
var notComplete = dialog.Buttons.AddCustom(resources.CompleteParentAssignmentDialogNotCompleteButtonTitle);
var open = dialog.Buttons.AddCustom(resources.CompleteParentAssignmentDialogOpenButtonTitle);
dialog.Buttons.AddCancel();
dialog.Buttons.Default = complete;
var dialogResult = dialog.Show();
var task = ActionItemExecutionTasks.As(supervisorAssignment.Task);
if (dialogResult == complete)
{
// Проверить наличие подчиненных поручений.
var otherNotCompletedActionItemExecutionSubTasks = Functions.ActionItemExecutionTask.Remote.GetOtherNotCompletedActionItemExecutionSubTasks(task);
if (otherNotCompletedActionItemExecutionSubTasks.Any())
if (!Functions.Module.ShowAbortSubActionItemsConfirmationDialog(parentAssignment, otherNotCompletedActionItemExecutionSubTasks))
return false;
// Сохранить ведущее задание, чтобы установился признак необходимости прекращения подчиненных поручений.
parentAssignment.Save();
// Выполнить ведущее задание на исполнение асинхронно.
Functions.Module.Remote.CompleteParentActionItemExecutionAssignmentAsync(task.Id, parentAssignment.Id, parentAssignment.TaskStartId);
return true;
}
if (dialogResult == notComplete)
return true;
if (dialogResult == open)
{
Functions.ActionItemExecutionTask.Remote.SynchronizeResultGroup(task);
parentAssignment.Show();
return true;
}
if (dialogResult == DialogButtons.Cancel)
return false;
return false;
}
/// <summary>
/// Показать диалог подтверждения выполнения.
/// </summary>
/// <param name="text">Текст.</param>
/// <param name="description">Дополнительный текст.</param>
/// <param name="title">Заголовок.</param>
/// <param name="parentActionItemExecutionAssignment">Ведущее поручение.</param>
/// <returns>True, если запрос был подтвержден.</returns>
public virtual bool ShowConfirmationDialog(string text, string description, string title,
RecordManagement.IActionItemExecutionAssignment parentActionItemExecutionAssignment)
{
var dialog = Dialogs.CreateTaskDialog(text, description, MessageType.Question, title);
dialog.Buttons.AddYesNo();
Action showParentAssignmentHandler = () =>
{
parentActionItemExecutionAssignment.ShowModal();
};
var showParentAssignment = dialog.AddHyperlink(RecordManagement.ActionItemExecutionTasks.Resources.ShowParentAssignment);
showParentAssignment.SetOnExecute(showParentAssignmentHandler);
showParentAssignment.IsVisible = parentActionItemExecutionAssignment != null;
var dialogResult = dialog.Show();
if (dialogResult == DialogButtons.Yes)
return true;
if (dialogResult == DialogButtons.No)
return false;
return false;
}
/// <summary>
/// Паблик обертка для получения отчета.
/// </summary>
/// <returns>Отчет.</returns>
[Public]
public Sungero.Reporting.IReport GetOutgoingDocumentsReport()
{
return Reports.GetOutgoingDocumentsReport();
}
/// <summary>
/// Паблик обертка для получения отчета.
/// </summary>
/// <returns>Отчет.</returns>
[Public]
public Sungero.Reporting.IReport GetInternalDocumentsReport()
{
return Reports.GetInternalDocumentsReport();
}
/// <summary>
/// Паблик обертка для получения отчета.
/// </summary>
/// <returns>Отчет.</returns>
[Public]
public Sungero.Reporting.IReport GetIncomingDocumentsReport()
{
return Reports.GetIncomingDocumentsReport();
}
/// <summary>
/// Паблик обертка для получения отчета.
/// </summary>
/// <returns>Отчет.</returns>
[Public]
public Sungero.Reporting.IReport GetIncomingDocumentsProcessingReport()
{
return Reports.GetIncomingDocumentsProcessingReport();
}
/// <summary>
/// Паблик обертка для получения отчета.
/// </summary>
/// <returns>Отчет.</returns>
[Public]
public Sungero.Reporting.IReport GetDocumentReturnReport()
{
return Reports.GetDocumentReturnReport();
}
/// <summary>
/// Получить отчет "Контроль ознакомления".
/// </summary>
/// <param name="task">Задача.</param>
/// <returns>Отчет.</returns>
[Public]
public virtual Sungero.Reporting.IReport GetAcquaintanceReport(IAcquaintanceTask task)
{
var report = Reports.GetAcquaintanceReport();
report.Task = task;
return report;
}
/// <summary>
/// Получить отчет "Бланк ознакомления".
/// </summary>
/// <param name="task">Задача.</param>
/// <returns>Отчет.</returns>
[Public]
public virtual Sungero.Reporting.IReport GetAcquaintanceFormReport(IAcquaintanceTask task)
{
var report = Reports.GetAcquaintanceFormReport();
report.Task = task;
return report;
}
/// <summary>
/// Получить отчет "Контроль ознакомления".
/// </summary>
/// <param name="document">Документ.</param>
/// <returns>Отчет.</returns>
[Public]
public virtual Sungero.Reporting.IReport GetAcquaintanceReport(IOfficialDocument document)
{
var report = Reports.GetAcquaintanceReport();
report.Document = document;
return report;
}
}
}