Ejemplo n.º 1
0
        public IActionResult SignPdf(string sourceId, int sourceType)
        {
            if (String.IsNullOrEmpty(sourceId) || sourceType < 1)
            {
                SetErrorMessage("Документът не е намерен.");

                return(this.RedirectToAction("Index", "Home"));
            }

            Uri url = new Uri(Url.Action("Index", "Home"), UriKind.Relative);

            var model = new SignPdfInfo()
            {
                SourceId        = sourceId,
                SourceType      = sourceType,
                DestinationType = sourceType,
                Location        = "Sofia",
                Reason          = "Test",
                SuccessUrl      = url,
                CancelUrl       = url,
                ErrorUrl        = url
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public IActionResult SendForSign(int id)
        {
            var saved = service.Select(new CaseDeactivationFilterVM {
                Id = id
            }).FirstOrDefault();

            if (saved.DeclaredDate != null)
            {
                return(RedirectToAction(nameof(View), new { id }));
            }
            Uri urlSuccess = new Uri(Url.Action("Signed", "CaseDeactivation", new { id = id }), UriKind.Relative);
            Uri url        = new Uri(Url.Action("View", "CaseDeactivation", new { id = id }), UriKind.Relative);

            var model = new SignPdfInfo()
            {
                SourceId        = id.ToString(),
                SourceType      = SourceTypeSelectVM.CaseDeactivate,
                DestinationType = SourceTypeSelectVM.CaseDeactivate,
                Location        = userContext.CourtName,
                Reason          = "Подписване на протокол за анулиране",
                SuccessUrl      = urlSuccess,
                CancelUrl       = url,
                ErrorUrl        = url,
                SignerName      = saved.DeactivateUserName,
                SignerUic       = saved.DeactivateUserUIC
            };

            return(View("_SignPdf", model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> SendForSign(long id, long taskId)
        {
            Uri urlSuccess = new Uri(Url.Action(nameof(SignedOk), new { taskId }), UriKind.Relative);
            Uri url        = new Uri(Url.Action("Edit", new { id = id }), UriKind.Relative);

            var model = new SignPdfInfo()
            {
                SourceId        = id.ToString(),
                SourceType      = SourceTypeSelectVM.DocumentResolutionPdf,
                DestinationType = SourceTypeSelectVM.DocumentResolutionPdf,
                Location        = userContext.CourtName,
                Reason          = "Подписване на разпореждане",
                SuccessUrl      = urlSuccess,
                CancelUrl       = url,
                ErrorUrl        = url
            };

            var docResolution = drService.GetById <DocumentResolution>(id);

            var registerResult = drService.Register(docResolution);

            if (!registerResult.Result)
            {
                SetErrorMessage(registerResult.ErrorMessage);
                return(RedirectToAction("Edit", new { id = id }));
            }
            else
            {
                if (registerResult.SaveMethod == "register")
                {
                    var actModel = drService.Select(0, id).FirstOrDefault();

                    string actHTML = await GetActHTML(actModel);
                    await PrepareActFile(actModel, actHTML);

                    return(RedirectToAction(nameof(SendForSign), new { id, taskId }));
                }
            }

            var lu = taskService.GetLawUnitByTaskId(taskId);

            if (lu != null)
            {
                model.SignerName = lu.FullName;
                model.SignerUic  = lu.Uic;
            }

            return(View("_SignPdf", model));
        }
Ejemplo n.º 4
0
        public async Task <IViewComponentResult> InvokeAsync(SignPdfInfo info, string viewName = "")
        {
            SignPdfViewModel model = new SignPdfViewModel()
            {
                SuccessUrl = info.SuccessUrl.ToString(),
                ErrorUrl   = info.ErrorUrl.ToString(),
                CancelUrl  = info.CancelUrl.ToString(),
                SourceId   = info.SourceId,
                SourceType = info.DestinationType,
                SignerName = info.SignerName,
                SignerUic  = info.SignerUic
            };

            try
            {
                var pdf = await cdn.MongoCdn_Download(new CdnFileSelect()
                {
                    FileId = info.FileId, SourceId = info.SourceId, SourceType = info.SourceType
                });

                using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(pdf.FileContentBase64)))
                {
                    var(hash, tempPdfId) = await cdn.SignTools.GetPdfHash(ms, info.Reason, info.Location);

                    model.PdfUrl    = Url.Action("GetFile", "PDF", new { pdfContentId = pdf.FileId });
                    model.PdfId     = tempPdfId;
                    model.PdfHash   = hash;
                    model.FileName  = pdf.FileName;
                    model.FileTitle = pdf.FileTitle;
                }
            }
            catch (ArgumentException aex)
            {
                logger.LogError(aex, "SignPdf Error");
                string message = "Невалиден файл за подписване";

                return(await Task.FromResult <IViewComponentResult>(View("Error", message)));
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "SignPdf Error");

                return(await Task.FromResult <IViewComponentResult>(View("Error", ex.Message)));
            }

            return(await Task.FromResult <IViewComponentResult>(View(viewName, model)));
        }