コード例 #1
0
        protected override void PerformRunCommand(string[] args)
        {
            var boxId = args.Length > 0 ? args[0] : null;

            if (boxId == null)
            {
                OutputHelpers.ShowBoxes(ConsoleContext);
                return;
            }
            ConsoleContext.CurrentBoxId = InputHelpers.AutocompleteBoxId(ConsoleContext, boxId);
            System.Console.WriteLine("Текущий ящик: " + ConsoleContext.CurrentBoxId);
            ConsoleContext.Events = null;
        }
コード例 #2
0
        protected override void PerformRunCommand(string[] args)
        {
            var newMsg = NewMessage.ReadFromConsole();
            var msg    = new MessageToPost
            {
                FromBoxId = ConsoleContext.CurrentBoxId,
                ToBoxId   = InputHelpers.AutocompleteBoxId(ConsoleContext, newMsg.ToBoxId),
            };

            msg.DocumentAttachments.AddRange(newMsg.DocumentsToPost
                                             .Select(e =>
            {
                var document = new DocumentAttachment
                {
                    TypeNamedId   = e.TypeNamedId,
                    Function      = e.Function,
                    Version       = e.Version,
                    SignedContent = new SignedContent
                    {
                        Content   = e.Content,
                        Signature = ConsoleContext.Crypt.Sign(e.Content, ConsoleContext.CurrentCert.RawData)
                    },
                    Comment = e.Comment,
                    NeedRecipientSignature = e.NeedRecipientSignature,
                };

                foreach (var m in e.Metadata)
                {
                    document.AddMetadataItem(new MetadataItem
                    {
                        Key   = m.Key,
                        Value = m.Value
                    });
                }

                return(document);
            }));
            var messagePosted = ConsoleContext.DiadocApi.PostMessage(ConsoleContext.CurrentToken, msg, Guid.NewGuid().ToString("N"));

            System.Console.WriteLine("Было отправлено следующее письмо:");
            messagePosted.WriteToConsole();
        }
コード例 #3
0
 protected override void PerformRunCommand(string[] args)
 {
     var newMsg = NewMessage.ReadFromConsole();
     var msg = new MessageToPost
     {
         FromBoxId = ConsoleContext.CurrentBoxId,
         ToBoxId = InputHelpers.AutocompleteBoxId(ConsoleContext, newMsg.ToBoxId),
     };
     msg.NonformalizedDocuments.AddRange(newMsg.Attachments
         .Where(e => e.AttachmentType == AttachmentType.Nonformalized)
         .Select(e => new NonformalizedAttachment
         {
             FileName = e.FileName,
             SignedContent = new SignedContent
             {
                 Content = e.Content,
                 Signature = ConsoleContext.SignByAttorney ? null : ConsoleContext.Crypt.Sign(e.Content, ConsoleContext.CurrentCert.RawData),
                 SignByAttorney = ConsoleContext.SignByAttorney
             },
             Comment = e.Comment,
             NeedRecipientSignature = e.NeedRecipientSignature,
         }));
     msg.Invoices.AddRange(newMsg.Attachments
         .Where(e => e.AttachmentType == AttachmentType.Invoice)
         .Select(e => new XmlDocumentAttachment
         {
             SignedContent = new SignedContent
             {
                 Content = e.Content,
                 Signature = ConsoleContext.SignByAttorney ? null : ConsoleContext.Crypt.Sign(e.Content, ConsoleContext.CurrentCert.RawData),
                 SignByAttorney = ConsoleContext.SignByAttorney,
             },
             Comment = e.Comment,
         }));
     var messagePosted = ConsoleContext.DiadocApi.PostMessage(ConsoleContext.CurrentToken, msg);
     System.Console.WriteLine("Было отправлено следующее письмо:");
     messagePosted.WriteToConsole();
 }