Пример #1
0
        /// <summary>
        /// Принятие материала
        /// </summary>
        /// <param name="argument">метаданные материала</param>
        /// <returns>Материал</returns>
        public Document CorrespondenceAdd(MessageSendArgument argument)
        {
            var document = DocumentAdd(argument);

            _egovPayHelper.CreatePay(argument.Pay);
            return(document);
        }
Пример #2
0
        public MessageSendResult MessageSend(MessageSendArgument argument)
        {
            var result  = new MessageSendResult();
            var command = new MessageSend.Command {
                Argument = argument, Result = result
            };

            _mediator.Send(command).Wait();
            return(result);
        }
Пример #3
0
        public void Execute(MessageSendArgument data)
        {
            agent.StartStress(data);

            ConsoleWriter.Write("Stress test successfully started ...", Color.GreenYellow);

            ConsoleWriter.WriteLine();

            ConsolePosition.MainMenuLastPosition = new Point(Console.CursorLeft, Console.CursorTop);
        }
Пример #4
0
        public Task StartStress(MessageSendArgument argument)
        {
            if (!RegisteredMethodsInternal.ContainsKey(argument.Method))
            {
                throw new ArgumentException("Please register a method first");
            }

            var function = RegisteredMethodsInternal[argument.Method];

            return(worker.RunStress(argument.Method, argument.TimeBetweenSends, argument.Timeout, function));
        }
Пример #5
0
        public static MessageSendArgument ConvertToStressArgument(this List <ConsoleFlowResult> data)
        {
            var messageSendArgument = new MessageSendArgument();

            if (data[0].Output is ConsoleOptionsPageResult)
            {
                messageSendArgument.Method = ((ConsoleOptionsPageResult)data[0].Output).SelectedText;
            }

            var textParameters = data[1].Output as List <string>;

            messageSendArgument.TimeBetweenSends = Convert.ToInt32(textParameters[0]);
            messageSendArgument.Timeout          = Convert.ToInt32(textParameters[1]);

            return(messageSendArgument);
        }
Пример #6
0
        public string GetValidationErrors(MessageSendArgument argument)
        {
            var errors = new List <string>();

            if (argument.DocumentType == null)
            {
                errors.Add("Тип документа не может быть пустым");
            }
            else
            {
                if (argument.DocumentType.UID <= 0)
                {
                    errors.Add("Некорректный тип документа");
                }
            }

            if (_validationHelper.FileIsEmpty(argument.File, argument))
            {
                errors.Add("Не добавлен файл!");
            }

            if (!_validationHelper.FileNameIsCorrect(argument.File, argument))
            {
                errors.Add("Не корректное имя файла!");
            }
            else
            {
                if (!_validationHelper.CheckFileExtension(new[] { ".pdf" }, argument.File, argument))
                {
                    errors.Add("Файл должен быть в формате \".pdf\"");
                }
            }
            if (errors.Count == 0)
            {
                return(null);
            }
            return(string.Join(Environment.NewLine, errors.ToArray()));
        }
Пример #7
0
        /// <summary>
        /// Создание документа
        /// </summary>
        /// <param name="argument">Метаданные документа</param>
        /// <param name="isPayment">Наличие платежа</param>
        /// <param name="documentId">Id родительского документа</param>
        /// <returns>Материал</returns>
        private Document DocumentAdd(MessageSendArgument argument, bool isPayment = false, int documentId = 0)
        {
            var customer = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(
                Mapper.Map <DicCustomer>(argument, el => el.Items[nameof(DicCustomer.TypeId)] = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerType), argument.CustomerType.UID).Id));

            var typeId = isPayment
                ? PaymentDocumentTypeId
                : argument.DocumentType.UID;

            var document = new Document(_dictionaryHelper.GetDocumentType(typeId).type)
            {
                TypeId        = _dictionaryHelper.GetDictionaryIdByExternalId(nameof(DicDocumentType), typeId),
                AddresseeId   = customer.Id,
                DateCreate    = DateTimeOffset.Now,
                StatusId      = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.InWork),
                ReceiveTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicReceiveType), DicReceiveTypeCodes.ElectronicFeed)
            };

            _documentHelper.CreateDocument(document);

            int?requestBarcode = null;

            if (int.TryParse(argument.OwnerDocumentUId, out var result))
            {
                requestBarcode = result;
            }
            var requestId = GetRequestId(requestBarcode);

            if (requestId.HasValue)
            {
                _niisContext.RequestsDocuments.Add(new RequestDocument
                {
                    DocumentId = document.Id,
                    RequestId  = requestId.Value
                });
                _niisContext.SaveChanges();
            }

            if (isPayment && documentId != 0)
            {
                var parentDocument = _niisContext.Documents.FirstOrDefault(d => d.Id == documentId);
                parentDocument.IsHasPaymentDocument = true;
                _niisContext.DocumentLinks.Add(new DocumentLink
                {
                    ParentDocumentId = documentId,
                    ChildDocumentId  = document.Id
                });
                _niisContext.SaveChanges();

                _attachFileHelper.AttachFile(new AttachedFileModel
                {
                    File   = argument.PaymentFile.Content,
                    Length = argument.PaymentFile.Content.Length,
                    IsMain = true,
                    Name   = argument.PaymentFile.Name
                },
                                             document);
            }
            else
            {
                _attachFileHelper.AttachFile(new AttachedFileModel
                {
                    File   = argument.File.Content,
                    Length = argument.File.Content.Length,
                    IsMain = true,
                    Name   = argument.File.Name
                },
                                             document);
            }

            return(document);
        }
Пример #8
0
 /// <summary>
 /// Принятие материала
 /// </summary>
 /// <param name="argument">метаданные материала</param>
 /// <param name="documentId">Id родительского документа</param>
 /// <returns>Материал</returns>
 public Document PaymentDocumentAdd(MessageSendArgument argument, int documentId = 0)
 {
     return(HasFileAndNotPayment(argument)
         ? DocumentAdd(argument, true, documentId)
         : null);
 }
Пример #9
0
 /// <summary>
 /// Проверяет наличие платежного материала и что документ не платежный документ
 /// </summary>
 /// <param name="argument"></param>
 /// <returns></returns>
 public bool HasFileAndNotPayment(MessageSendArgument argument)
 {
     return(argument.PaymentFile.Content != null && argument.DocumentType.UID != PaymentDocumentTypeId);
 }