Skip to content

Commit

Permalink
Merge pull request #612 from zharkovstas/template-refusal
Browse files Browse the repository at this point in the history
Add template refusals
  • Loading branch information
zharkovstas committed Dec 24, 2019
2 parents ee72d91 + 9dee44d commit a1a9fd7
Show file tree
Hide file tree
Showing 19 changed files with 399 additions and 12 deletions.
File renamed without changes.
8 changes: 8 additions & 0 deletions proto/Docflow/DocumentInfoV3.proto
Expand Up @@ -78,6 +78,7 @@ message DocumentTemplateInfo
required DocumentParticipants LetterParticipants = 1;
repeated string TransformedToLetterIds = 2;
repeated TemplateTransformationInfo TemplateTransformationInfos = 3;
optional TemplateRefusalInfo TemplateRefusalInfo = 4;
}

message TemplateTransformationInfo
Expand All @@ -86,3 +87,10 @@ message TemplateTransformationInfo
optional DocumentId TransformedToDocumentId = 2;
optional string AuthorUserId = 3;
}

message TemplateRefusalInfo
{
required string BoxId = 1;
optional string AuthorUserId = 2;
optional string Comment = 3;
}
17 changes: 17 additions & 0 deletions proto/Events/DiadocMessage-GetApi.proto
Expand Up @@ -113,6 +113,7 @@ message Entity {
repeated string Labels = 25;
optional string Version = 26;
optional TemplateTransformationInfo TemplateTransformationInfo = 27;
optional TemplateRefusalInfo TemplateRefusalInfo = 28;
}

message EntityPatch {
Expand All @@ -138,6 +139,21 @@ message TemplateTransformationInfo
optional string Author = 2;
}

message TemplateRefusalInfo
{
required TemplateRefusalType Type = 1 [default = UnknownTemplateRefusalType];
required string BoxId = 2;
optional string Author = 3;
optional string Comment = 4;
}

enum TemplateRefusalType {
UnknownTemplateRefusalType = 0;
Refusal = 1;
Withdrawal = 2;
}


enum EntityType {
UnknownEntityType = 0; // Reserved type to report to legacy clients for newly introduced entity types
Attachment = 1;
Expand Down Expand Up @@ -200,5 +216,6 @@ enum AttachmentType {
Edition = 71;
DeletionRestoration = 72;
TemplateTransformation = 73;
TemplateRefusal = 74;
//Неизвестные типы должны обрабатываться как Title
}
11 changes: 11 additions & 0 deletions proto/Events/DiadocMessage-PostApi.proto
Expand Up @@ -545,6 +545,17 @@ message TemplateDocumentAttachment {
optional string EditingSettingId = 9;
optional bool NeedRecipientSignature = 10 [default = false];
optional PredefinedRecipientTitle PredefinedRecipientTitle = 11;
optional bool RefusalDisabled = 12 [default = false];
}

message TemplatePatchToPost {
repeated TemplateRefusalAttachment Refusals = 1;
}

message TemplateRefusalAttachment {
required string DocumentId = 1;
optional string Comment = 2;
repeated string Labels = 3;
}

message PredefinedRecipientTitle {
Expand Down
4 changes: 2 additions & 2 deletions proto/Invoicing/ExtendedSigner.proto
Expand Up @@ -55,7 +55,7 @@ enum SignerStatus {
SellerEmployee = 1; // Работник организации продавца товаров (работ, услуг, имущественных прав);
InformationCreatorEmployee = 2; // Работник организации - составителя информации продавца;
OtherOrganizationEmployee = 3; // Работник иной уполномоченной организации;
AuthorizedPerson= 4; // Уполномоченное физическое лицо (в том числе индивидуальный предприниматель);
AuthorizedPerson = 4; // Уполномоченное физическое лицо (в том числе индивидуальный предприниматель);
BuyerEmployee = 5; // Работник организации - покупателя (для документов в формате приказа №820);
InformationCreatorBuyerEmployee = 6; // Работник организации - составителя файла обмена информации покупателя, если составитель файла обмена информации покупателя не является покупателем (для документов в формате приказа №820)
}
Expand All @@ -66,7 +66,7 @@ enum DocumentTitleType {
UtdBuyer = 1; // Данные для титула покупателя УПД
UcdSeller = 2; // Данные для титула продавца УКД
UcdBuyer = 3; // Данные для титула покупателя УКД
TovTorg551Seller = 4; // Данные для титула продавца формата приказа 551
TovTorg551Seller = 4; // Данные для титула продавца формата приказа 551
TovTorg551Buyer = 5; // Данные для титула покупателя формата приказа 551
AccCert552Seller = 6; // Данные для титула исполнителя формата приказа 552
AccCert552Buyer = 7; // Данные для титула заказчика формата приказа 552
Expand Down
3 changes: 2 additions & 1 deletion src/Com/AttachmentType.cs
Expand Up @@ -62,6 +62,7 @@ public enum AttachmentType
Cancellation = 69,
Edition = 71,
DeletionRestoration = 72,
TemplateTransformation = 73
TemplateTransformation = 73,
TemplateRefusal = 74
}
}
19 changes: 19 additions & 0 deletions src/Com/DocflowsV3.cs
Expand Up @@ -411,6 +411,7 @@ public interface IDocumentTemplateInfo
{
DocumentParticipants LetterParticipants { get; }
ReadonlyList TransformedToLetterIdsList { get; }
TemplateRefusalInfo TemplateRefusalInfo { get; }
}

[ComVisible(true)]
Expand All @@ -427,6 +428,24 @@ public ReadonlyList TransformedToLetterIdsList
}
}

[ComVisible(true)]
[Guid("75C71C29-AC5C-43A4-A820-5841C71F3532")]
public interface ITemplateRefusalInfo
{
string BoxId { get; }
string AuthorUserId { get; }
string Comment { get; }
}

[ComVisible(true)]
[ProgId("Diadoc.Api.Docflow.TemplateRefusalInfo")]
[Guid("D1763A94-4981-4AFE-9AC1-845D11196169")]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(ITemplateRefusalInfo))]
public partial class TemplateRefusalInfo : SafeComObject, ITemplateRefusalInfo
{
}

[ComVisible(true)]
[Guid("F87CC29D-FF93-488C-83B0-AB8F148409F9")]
public interface IDocflowV3
Expand Down
16 changes: 16 additions & 0 deletions src/Com/TemplateRefusalType.cs
@@ -0,0 +1,16 @@
using System.Runtime.InteropServices;
using System.Xml.Serialization;

namespace Diadoc.Api.Com
{
[ComVisible(true)]
[Guid("67ED41D3-8E2C-4BF5-9FEA-FB0DBF97AB9E")]
//NOTE: Это хотели, чтобы можно было использовать XML-сериализацию для классов
[XmlType(TypeName = "TemplateRefusalType", Namespace = "https://diadoc-api.kontur.ru")]
public enum TemplateRefusalType
{
UnknownTemplateRefusalType = 0,
Refusal = 1,
Withdrawal = 2
}
}
6 changes: 6 additions & 0 deletions src/ComDiadocApi.cs
Expand Up @@ -459,6 +459,7 @@ public interface IComDiadocApi

Template PostTemplate(string authToken, [MarshalAs(UnmanagedType.IDispatch)] object template);
Template PostTemplate(string authToken, [MarshalAs(UnmanagedType.IDispatch)] object template, string operationId);
MessagePatch PostTemplatePatch(string authToken, string boxId, string templateId, [MarshalAs(UnmanagedType.IDispatch)] object patch, string operationId);
Message TransformTemplateToMessage(string authToken, [MarshalAs(UnmanagedType.IDispatch)] object templateTransformation);
Message TransformTemplateToMessage(string authToken, [MarshalAs(UnmanagedType.IDispatch)] object templateTransformation, string operationId);

Expand Down Expand Up @@ -714,6 +715,11 @@ public Template PostTemplate(string authToken, object template, string operation
return diadoc.PostTemplate(authToken, (TemplateToPost) template, operationId);
}

public MessagePatch PostTemplatePatch(string authToken, string boxId, string templateId, object patch, string operationId)
{
return diadoc.PostTemplatePatch(authToken, boxId, templateId, (TemplatePatchToPost) patch, operationId);
}

public Message TransformTemplateToMessage(string authToken, object templateTransformation)
{
return diadoc.TransformTemplateToMessage(authToken, (TemplateTransformationToPost) templateTransformation);
Expand Down
9 changes: 9 additions & 0 deletions src/DiadocApi.Async.cs
Expand Up @@ -223,6 +223,15 @@ public Task<MessagePatch> PostMessagePatchAsync(string authToken, MessagePatchTo
return diadocHttpApi.PostMessagePatchAsync(authToken, patch, operationId);
}

public Task<MessagePatch> PostTemplatePatchAsync(string authToken, string boxId, string templateId, TemplatePatchToPost patch, string operationId = null)
{
if (authToken == null) throw new ArgumentNullException("authToken");
if (boxId == null) throw new ArgumentNullException("boxId");
if (templateId == null) throw new ArgumentNullException("templateId");
if (patch == null) throw new ArgumentNullException("patch");
return diadocHttpApi.PostTemplatePatchAsync(authToken, boxId, templateId, patch, operationId);
}

public Task PostRoamingNotificationAsync(string authToken, RoamingNotificationToPost notification)
{
if (authToken == null) throw new ArgumentNullException("authToken");
Expand Down
9 changes: 9 additions & 0 deletions src/DiadocApi.cs
Expand Up @@ -281,6 +281,15 @@ public MessagePatch PostMessagePatch(string authToken, MessagePatchToPost patch,
return diadocHttpApi.PostMessagePatch(authToken, patch, operationId);
}

public MessagePatch PostTemplatePatch(string authToken, string boxId, string templateId, TemplatePatchToPost patch, string operationId = null)
{
if (authToken == null) throw new ArgumentNullException("authToken");
if (boxId == null) throw new ArgumentNullException("boxId");
if (templateId == null) throw new ArgumentNullException("templateId");
if (patch == null) throw new ArgumentNullException("patch");
return diadocHttpApi.PostTemplatePatch(authToken, boxId, templateId, patch, operationId);
}

public void PostRoamingNotification(string authToken, RoamingNotificationToPost notification)
{
if (authToken == null) throw new ArgumentNullException("authToken");
Expand Down
36 changes: 29 additions & 7 deletions src/DiadocHttpApi.Events.cs
Expand Up @@ -11,10 +11,11 @@ public BoxEventList GetNewEvents(string authToken, string boxId, string afterEve
var qsb = new PathAndQueryBuilder("/V6/GetNewEvents");
qsb.AddParameter("includeDrafts");
qsb.AddParameter("boxId", boxId);
if (!string.IsNullOrEmpty(afterEventId))
if (!string.IsNullOrEmpty(afterEventId))
qsb.AddParameter("afterEventId", afterEventId);
return PerformHttpRequest<BoxEventList>(authToken, "GET", qsb.BuildPathAndQuery());
}

public BoxEvent GetEvent(string authToken, string boxId, string eventId)
{
var queryString = string.Format("/V2/GetEvent?eventId={0}&boxId={1}", eventId, boxId);
Expand All @@ -32,7 +33,13 @@ public Message GetMessage(string authToken, string boxId, string messageId, bool
return PerformHttpRequest<Message>(authToken, "GET", qsb.BuildPathAndQuery());
}

public Message GetMessage(string authToken, string boxId, string messageId, string entityId, bool withOriginalSignature = false, bool injectEntityContent = false)
public Message GetMessage(
string authToken,
string boxId,
string messageId,
string entityId,
bool withOriginalSignature = false,
bool injectEntityContent = false)
{
var qsb = new PathAndQueryBuilder("/V5/GetMessage");
qsb.AddParameter("boxId", boxId);
Expand Down Expand Up @@ -82,8 +89,23 @@ public Message TransformTemplateToMessage(string authToken, TemplateTransformati

public MessagePatch PostMessagePatch(string authToken, MessagePatchToPost patch, string operationId = null)
{
var queryString = string.Format("/V3/PostMessagePatch?operationId={0}", operationId);
return PerformHttpRequest<MessagePatchToPost, MessagePatch>(authToken, queryString, patch);
var qsb = new PathAndQueryBuilder("/V3/PostMessagePatch");
qsb.AddParameter("operationId", operationId);
return PerformHttpRequest<MessagePatchToPost, MessagePatch>(authToken, qsb.BuildPathAndQuery(), patch);
}

public MessagePatch PostTemplatePatch(
string authToken,
string boxId,
string templateId,
TemplatePatchToPost patch,
string operationId = null)
{
var qsb = new PathAndQueryBuilder("/PostTemplatePatch");
qsb.AddParameter("boxId", boxId);
qsb.AddParameter("templateId", templateId);
qsb.AddParameter("operationId", operationId);
return PerformHttpRequest<TemplatePatchToPost, MessagePatch>(authToken, qsb.BuildPathAndQuery(), patch);
}

public void PostRoamingNotification(string authToken, RoamingNotificationToPost notification)
Expand All @@ -96,11 +118,11 @@ public PrepareDocumentsToSignResponse PrepareDocumentsToSign(string authToken, P
var queryString = "/PrepareDocumentsToSign" + (excludeContent ? "?excludeContent" : "");
return PerformHttpRequest<PrepareDocumentsToSignRequest, PrepareDocumentsToSignResponse>(authToken, queryString, request);
}

public BoxEvent GetLastEvent(string authToken, string boxId)
{
var queryString = BuildQueryStringWithBoxId("GetLastEvent", boxId);
return PerformHttpRequest<BoxEvent>(authToken,"GET", queryString, allowedStatusCodes: HttpStatusCode.NoContent);
return PerformHttpRequest<BoxEvent>(authToken, "GET", queryString, allowedStatusCodes: HttpStatusCode.NoContent);
}
}
}
}
14 changes: 14 additions & 0 deletions src/DiadocHttpApi.EventsAsync.cs
Expand Up @@ -100,6 +100,20 @@ public Task<MessagePatch> PostMessagePatchAsync(string authToken, MessagePatchTo
return PerformHttpRequestAsync<MessagePatchToPost, MessagePatch>(authToken, qsb.BuildPathAndQuery(), patch);
}

public Task<MessagePatch> PostTemplatePatchAsync(
string authToken,
string boxId,
string templateId,
TemplatePatchToPost patch,
string operationId = null)
{
var qsb = new PathAndQueryBuilder("/PostTemplatePatch");
qsb.AddParameter("boxId", boxId);
qsb.AddParameter("templateId", templateId);
qsb.AddParameter("operationId", operationId);
return PerformHttpRequestAsync<TemplatePatchToPost, MessagePatch>(authToken, qsb.BuildPathAndQuery(), patch);
}

public Task PostRoamingNotificationAsync(string authToken, RoamingNotificationToPost notification)
{
return PerformHttpRequestAsync(authToken, "POST", "/PostRoamingNotification", Serialize(notification));
Expand Down
2 changes: 2 additions & 0 deletions src/IDiadocApi.cs
Expand Up @@ -70,6 +70,7 @@ public interface IDiadocApi
Template PostTemplate(string authToken, TemplateToPost template, string operationId = null);
Message TransformTemplateToMessage(string authToken, TemplateTransformationToPost templateTransformation, string operationId = null);
MessagePatch PostMessagePatch(string authToken, MessagePatchToPost patch, string operationId = null);
MessagePatch PostTemplatePatch(string authToken, string boxId, string templateId, TemplatePatchToPost patch, string operationId = null);
void PostRoamingNotification(string authToken, RoamingNotificationToPost notification);
void Delete(string authToken, string boxId, string messageId, string documentId);
void Restore(string authToken, string boxId, string messageId, string documentId);
Expand Down Expand Up @@ -267,6 +268,7 @@ public interface IDiadocApi
Task<Message> TransformTemplateToMessageAsync(string authToken, TemplateTransformationToPost templateTransformation, string operationId
= null);
Task<MessagePatch> PostMessagePatchAsync(string authToken, MessagePatchToPost patch, string operationId = null);
Task<MessagePatch> PostTemplatePatchAsync(string authToken, string boxId, string templateId, TemplatePatchToPost patch, string operationId = null);
Task PostRoamingNotificationAsync(string authToken, RoamingNotificationToPost notification);
Task DeleteAsync(string authToken, string boxId, string messageId, string documentId);
Task RestoreAsync(string authToken, string boxId, string messageId, string documentId);
Expand Down
Expand Up @@ -7,7 +7,7 @@
// </auto-generated>
//------------------------------------------------------------------------------

// Generated from: CustomPrintFormDetectionResult.proto
// Generated from: CustomPrintFormDetection.proto
// Note: requires additional types generated from: DocumentId.proto
namespace Diadoc.Api.Proto
{
Expand Down
44 changes: 44 additions & 0 deletions src/Proto/Docflow/DocumentInfoV3.proto.cs
Expand Up @@ -380,6 +380,15 @@ public Diadoc.Api.Proto.Docflow.DocumentParticipants LetterParticipants
get { return _TemplateTransformationInfos; }
}


private Diadoc.Api.Proto.Docflow.TemplateRefusalInfo _TemplateRefusalInfo = null;
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"TemplateRefusalInfo", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public Diadoc.Api.Proto.Docflow.TemplateRefusalInfo TemplateRefusalInfo
{
get { return _TemplateRefusalInfo; }
set { _TemplateRefusalInfo = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
Expand Down Expand Up @@ -420,4 +429,39 @@ public string AuthorUserId
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}

[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TemplateRefusalInfo")]
public partial class TemplateRefusalInfo : global::ProtoBuf.IExtensible
{
public TemplateRefusalInfo() {}

private string _BoxId;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"BoxId", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string BoxId
{
get { return _BoxId; }
set { _BoxId = value; }
}

private string _AuthorUserId = "";
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"AuthorUserId", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string AuthorUserId
{
get { return _AuthorUserId; }
set { _AuthorUserId = value; }
}

private string _Comment = "";
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"Comment", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string Comment
{
get { return _Comment; }
set { _Comment = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}

}

0 comments on commit a1a9fd7

Please sign in to comment.