예제 #1
0
            public MessageSendResult Handle(Command message)
            {
                using (var transaction = _niisWebContext.Database.BeginTransaction())
                {
                    try
                    {
                        var document = _messageSendService.CorrespondenceAdd(message.Argument);
                        if (document != null)
                        {
                            message.Result.DocumentNumber = document.DocumentNum;
                            message.Result.DocumentUID    = document.Barcode;
                            message.Result.DocumentDate   = document.DateCreate.DateTime;
                        }

                        var paymentDocument = _messageSendService.PaymentDocumentAdd(message.Argument, document.Id);
                        if (paymentDocument != null)
                        {
                            message.Result.PaymentDocumentNumber = paymentDocument.DocumentNum;
                            message.Result.PaymentDocumentUID    = paymentDocument.Barcode;
                            message.Result.PaymentDocumentDate   = paymentDocument.DateCreate.DateTime;
                        }
                        _niisWebContext.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        EntityFrameworkHelper.DetachAll(_niisWebContext);
                        transaction.Rollback();
                        throw new Exception("Смотри внутренний Exception", ex);
                    }
                }
                return(message.Result);
            }
예제 #2
0
            public RequisitionSendResult Handle(Command message)
            {
                using (var transaction = _niisContext.Database.BeginTransaction())
                {
                    try
                    {
                        var requestInfo = _requisitionSendService.RequisitionDocumentAdd(message.Argument);
                        if (message.Argument.BlockClassification != null)
                        {
                            _requisitionSendService.RequisitionMktuAdd(message.Argument.BlockClassification,
                                                                       requestInfo.requestId);
                        }

                        if (message.Argument.BlockEarlyReg != null)
                        {
                            _requisitionSendService.RequisitionEarlyRegAdd(message.Argument.BlockEarlyReg,
                                                                           requestInfo.requestId);
                        }

                        if (message.Argument.BlockColor != null)
                        {
                            _requisitionSendService.RequisitionColorAdd(message.Argument.BlockColor,
                                                                        requestInfo.requestId, message.Argument.PatentType.UID);
                        }

                        if (message.Argument.BlockCustomer != null)
                        {
                            _requisitionSendService.RequisitionBlockCustomerAdd(message.Argument.BlockCustomer,
                                                                                requestInfo.requestId);
                        }

                        if (message.Argument.BlockFile != null)
                        {
                            _requisitionSendService.RequisitionBlockFileAdd(message.Argument.BlockFile,
                                                                            requestInfo.requestId, message.Argument.SystemInfo.Sender);
                        }

                        var integrationRequisition = new IntegrationRequisition
                        {
                            ChainId             = message.Argument.SystemInfo.ChainId,
                            ProtectionDocTypeId = message.Argument.PatentType.UID,
                            Sender                    = message.Argument.SystemInfo.Sender,
                            StatusURL                 = _configuration.UrlServiceKazPatent,
                            RequestBarcode            = requestInfo.barcode,
                            RequestNumber             = requestInfo.incomingNum,
                            OnlineRequisitionStatusId = requestInfo.onlineStatusId,
                            Callback                  = "RequisitionSend"
                        };
                        _niisContext.IntegrationRequisitions.Add(integrationRequisition);
                        _niisContext.SaveChanges();
                        transaction.Commit();

                        message.Result.DocumentID        = requestInfo.barcode;
                        message.Result.DocumentNumber    = requestInfo.incomingNum;
                        message.Result.RequisitionStatus = requestInfo.onlineStatusId;
                    }
                    catch (Exception)
                    {
                        EntityFrameworkHelper.DetachAll(_niisContext);
                        transaction.Rollback();
                        throw;
                    }
                }

                return(message.Result);
            }