BusinessUnitBoxClientFunctions.cs
7.01 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.ExchangeCore.BusinessUnitBox;
namespace Sungero.ExchangeCore.Client
{
partial class BusinessUnitBoxFunctions
{
/// <summary>
/// Отобразить диалог поиска документов из сервисов обмена.
/// </summary>
public virtual void ShowExchangeDocumentsSearchDialog()
{
var dialog = Dialogs.CreateInputDialog(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.FindDocumentDialogTitle);
dialog.HelpCode = Constants.BusinessUnitBox.ExchangeDocumentsSearchHelpCode;
var hyperlink = dialog.AddString(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.FindDocumentDialogHyperlink, true);
var closeButton = dialog.Buttons.AddCustom(Sungero.Docflow.Resources.Dialog_Close);
var nextButton = dialog.Buttons.AddCustom(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.FindDocumentDialogNext);
var cancelButton = dialog.Buttons.AddCustom(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.FindDocumentDialogCancel);
closeButton.IsVisible = false;
var availableDocumentsLink = dialog.AddHyperlink(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.DocumentFullInfoDialogDocuments);
availableDocumentsLink.IsVisible = false;
var availableDocuments = new List<Docflow.IOfficialDocument>();
availableDocumentsLink.SetOnExecute(() =>
{
availableDocuments.ShowModal();
});
var documentInfosLink = dialog.AddHyperlink(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.DocumentFullInfoDialogDocumentInfos);
documentInfosLink.IsVisible = false;
var documentInfos = new List<Exchange.IExchangeDocumentInfo>();
documentInfosLink.SetOnExecute(() =>
{
documentInfos.ShowModal();
});
var messagesLink = dialog.AddHyperlink(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.DocumentFullInfoDialogMessages);
messagesLink.IsVisible = false;
var messages = new List<IMessageQueueItem>();
messagesLink.SetOnExecute(() =>
{
messages.ShowModal();
});
dialog.SetOnRefresh((arg) =>
{
availableDocumentsLink.IsVisible = availableDocuments.Any();
documentInfosLink.IsVisible = documentInfos.Any();
messagesLink.IsVisible = messages.Any();
});
dialog.SetOnButtonClick((arg) =>
{
if (arg.Button == closeButton)
{
arg.CloseAfterExecute = true;
return;
}
if (!arg.IsValid)
return;
arg.CloseAfterExecute = false;
if (string.IsNullOrWhiteSpace(hyperlink.Value))
arg.AddError(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.FindDocumentDialogInvalidHyperlink);
var messageIdParsed = string.Empty;
var documentIdParsed = string.Empty;
if (_obj.ExchangeService.ExchangeProvider == Sungero.ExchangeCore.ExchangeService.ExchangeProvider.Diadoc)
{
messageIdParsed = Functions.Module.GetParameterValueFromHyperlink(hyperlink.Value, Constants.BusinessUnitBox.DocumentHyperlinkParameterLetterId);
documentIdParsed = Functions.Module.GetParameterValueFromHyperlink(hyperlink.Value, Constants.BusinessUnitBox.DocumentHyperlinkParameterDocumentId);
}
else
{
documentIdParsed = Functions.Module.GetDocumentGuidFromHyperlink(hyperlink.Value);
messageIdParsed = documentIdParsed;
}
if (!Functions.Module.CheckGuid(messageIdParsed) || !Functions.Module.CheckGuid(documentIdParsed))
{
arg.AddError(Sungero.ExchangeCore.BusinessUnitBoxes.Resources.FindDocumentDialogInvalidHyperlink);
return;
}
var exchangePackagesInfo = Functions.BusinessUnitBox.Remote.GetExchangeDocumentsPackage(messageIdParsed, documentIdParsed);
var documentsCount = exchangePackagesInfo.Documents != null ? exchangePackagesInfo.Documents.Where(d => d.DocumentId != null).Count() : 0;
dialog.Text += BusinessUnitBoxes.Resources.DocumentFullInfoDialogAllDocumentsCountFormat(documentsCount);
if (exchangePackagesInfo.Documents != null && exchangePackagesInfo.Documents.Count > 0)
{
var forbiddenDocuments = exchangePackagesInfo.Documents.Where(d => d.Document != null && d.HasDocumentReadPermissions != true).Select(d => d.DocumentId).ToList();
if (forbiddenDocuments.Any())
{
var forbiddenDocumentsCount = forbiddenDocuments.Count();
dialog.Text += BusinessUnitBoxes.Resources.DocumentFullInfoDialogForbiddenDocumentsCountFormat(Environment.NewLine, forbiddenDocumentsCount);
}
availableDocuments = exchangePackagesInfo.Documents.Where(d => d.Document != null && d.HasDocumentReadPermissions == true).Select(d => d.Document).ToList();
documentInfos = exchangePackagesInfo.Documents.Where(d => d.DocumentInfo != null).Select(d => d.DocumentInfo).ToList();
}
if (exchangePackagesInfo.Messages != null)
messages = exchangePackagesInfo.Messages;
nextButton.IsVisible = false;
cancelButton.IsVisible = false;
closeButton.IsVisible = true;
hyperlink.IsVisible = false;
});
dialog.Show();
}
}
}