Example #1
0
        public async Task <IActionResult> GetFiles(Guid entityId, string entityName)
        {
            var success  = true;
            var modelObj = new FilesSignViewModel();

            try
            {
                switch (entityName)
                {
                case "PrlApplication":
                    modelObj = await _prlAppService.GetFilesForVerification(entityId);

                    break;

                case "ImlApplication":
                    modelObj = await _imlApplicationService.GetFilesForVerification(entityId);

                    break;

                default:
                    Log.Error("Entity name isn't received");
                    success = false;
                    break;
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                success = false;
            }

            return(Json(new { success = success, model = modelObj }));
        }
Example #2
0
        public async Task <JsonResult> SaveSignedFiles(FilesSignViewModel model)
        {
            if (model.id == Guid.Empty)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка, спробуйте пізніше", returnUrl = Url.Action("Index", "Home", new { Area = "" }) }));
            }
            if (model.files.Count == 0)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка, спробуйте пізніше", returnUrl = Url.Action("Details", "PrlApp", new { Area = "APP" }) }));
            }

            try
            {
                await _prlApplicationService.SubmitApplication(Configuration, model);
            }
            catch (Exception)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка, спробуйте пізніше", returnUrl = Url.Action("Edit", "PrlApp", new { Area = "APP" }) }));
            }

            try
            {
                var app = _dataService.GetEntity <PrlApplication>(x => x.Id == model.id)?.FirstOrDefault();
                await _notificationService.PrlCreateNotificationAppSend(app.Id, app.AppSort, DateTime.Now.ToString("«dd» MMMM yyyy", CultureInfo.CreateSpecificCulture("uk")), app.OrgUnitId);
            }
            catch (Exception)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка з відправкою сповіщення на електронну пошту", returnUrl = Url.Action("Index", "Monitoring", new { Area = "MTR" }) }));
            }

            return(new JsonResult(new { success = true, returnUrl = Url.Action("Index", "Monitoring", new { Area = "MTR" }) }));
        }
Example #3
0
        public async Task <FilesSignViewModel> GetFilesForVerification(Guid appId)
        {
            var files = DataService.GetEntity <FileStore>(x => x.EntityId == appId && x.EntityName == "PrlApplication");

            if (!files.Any())
            {
                throw new Exception("Файли до заяви відсутні");
            }
            var systemFile = files.FirstOrDefault(x => x.Ock);

            if (systemFile == null)
            {
                throw new Exception("Файл підпису досьє відсутний");
            }

            var systemFileErrors = await VerificationEDocumentHex(systemFile.Id, appId);

            var fileModel = new FilesSignViewModel()
            {
                id = appId, files = new List <FilesViewModel>()
            };
            var streamSystemFile = await GetFile(systemFile.Id);

            fileModel.files.Add(new FilesViewModel
            {
                id           = Guid.Empty,
                idFileStore  = systemFile.Id,
                names        = systemFileErrors.names,
                file         = Convert.ToBase64String(streamSystemFile.ToArray()),
                isSystemFile = true,
                errors       = systemFileErrors.errors
            });
            files = files.Where(x => x.Id != systemFile.Id);
            if (!files.Any())
            {
                throw new Exception("Файл підпису заяви відсутний");
            }


            fileModel.files.AddRange(files.Select(x =>
            {
                var fileStream = GetFile(x.Id).Result;
                return(new FilesViewModel()
                {
                    id = Guid.Empty,
                    idFileStore = x.Id,
                    names = new List <string>()
                    {
                        x.OrigFileName
                    },
                    file = Convert.ToBase64String(fileStream.ToArray()),
                    isSystemFile = false
                });
            }));
            return(fileModel);
        }
Example #4
0
        public async Task SubmitApplication(IConfiguration config, FilesSignViewModel model)
        {
            try
            {
                foreach (var file in model.files)
                {
                    if (file.idFileStore != Guid.Empty)
                    {
                        var fileStore = DataService.GetEntity <FileStore>(x => x.Id == file.idFileStore).FirstOrDefault();
                        DataService.Remove(fileStore);
                        await DataService.SaveChangesAsync();

                        var fileStoreNew = new FileStoreDTO
                        {
                            FileType     = FileType.Unknown,
                            OrigFileName = file.name + ".p7s",
                            FileSize     = FileSignHelper.GetOriginalLengthInBytes(file.file),
                            Ock          = file.isSystemFile,
                            EntityId     = fileStore.EntityId,
                            EntityName   = fileStore.EntityName,
                            ContentType  = ".p7s",
                            Description  = "Підписаний файл лікарських засобів"
                        };
                        await FileSignHelper.SaveFile(config, file, fileStoreNew, DataService);
                    }
                    else
                    {
                        var fileStore = new FileStoreDTO
                        {
                            FileType     = FileType.Unknown,
                            OrigFileName = file.name + ".p7s",
                            FileSize     = FileSignHelper.GetOriginalLengthInBytes(file.file),
                            Ock          = file.isSystemFile,
                            EntityId     = model.id,
                            EntityName   = nameof(ImlApplication),
                            ContentType  = ".p7s",
                            Description  = "Підписаний PDF заяви"
                        };


                        await FileSignHelper.SaveFile(config, file, fileStore, DataService);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                throw;
            }
            var app = DataService.GetEntity <ImlApplication>(x => x.Id == model.id)?.FirstOrDefault();

            app.AppState           = "Submitted";
            app.BackOfficeAppState = "Submitted";
            app.IsCreatedOnPortal  = true;
            await DataService.SaveChangesAsync();
        }
        public async Task <JsonResult> SaveSignedMsgFiles(FilesSignViewModel model)
        {
            if (model.id == Guid.Empty)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка, спробуйте пізніше", returnUrl = Url.Action("Index", "Home", new { Area = "" }) }));
            }
            if (model.files.Count == 0)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка, спробуйте пізніше", returnUrl = Url.Action("Details", "MessageTypes", new { Area = "MSG", model.id }) }));
            }
            try
            {
                var tempPath = _configuration["FileStorePath"];
                await _messageService.SubmitMessage(model, tempPath);

                // await _messageService.SubmitApplication(Configuration, model);
            }
            catch (Exception)
            {
                return(new JsonResult(new { success = false, errorMessage = "Виникла помилка, спробуйте пізніше", returnUrl = Url.Action("Details", "MessageTypes", new { Area = "MSG", model.id }) }));
            }
            return(new JsonResult(new { success = true, returnUrl = Url.Action("Index", "Message", new { Area = "MSG" }) }));
        }
Example #6
0
        public async Task <FilesSignViewModel> GetFilesForSign(Guid id)
        {
            var appSort   = DataService.GetEntity <PrlApplication>(x => x.Id == id).Select(x => x.AppSort).FirstOrDefault();
            var fileModel = new FilesSignViewModel()
            {
                id = id, files = new List <FilesViewModel>()
            };

            fileModel.files.Add(await _applicationService.GetEDocumentJsonFile(id));
            var rep = new PdfFromHtmlOwnConverter(_converter);

            byte[] applicationFile;
            string filename = "";

            try
            {   //TODO check on sort(other pdf html sorts) TODOED!
                switch (appSort)
                {
                case "GetLicenseApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_02)_Заява_про_отримання_ліцензії_на_провадження_діяльності_з_виробництва_лікарських_засобів_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlCreateLicenseApp(id));

                    filename = $"(Додаток_02)_Заява_про_отримання_ліцензії_на_провадження_діяльності_з_виробництва_лікарських_засобів_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "AdditionalInfoToLicense":
                    applicationFile = await rep.CreatePDF($"Доповнення інформації по наявній ліцензії{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlCreateLicenseApp(id));

                    filename = $"Доповнення інформації по наявній ліцензії{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "IncreaseToPRLApplication":
                    applicationFile = await rep.CreatePDF($"Заява_про_розширення_провадження_виду_господарської_діяльності_(Розширення_до_виробництва_лікарських_засобів){DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlCreateLicenseApp(id));

                    filename = $"Доповнення інформації по наявній ліцензії{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "CancelLicenseApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_22)_Заява_про_анулювання_ліцензії_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlCancelLicenseApp(id));

                    filename = $"(Додаток_22)_Заява_про_анулювання_ліцензії_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "DecreasePRLApplication":
                    applicationFile = await rep.CreatePDF($"Заява_про_звуження_провадження_виду_господарської_діяльності_-_Звуження_виробництва_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlCancelLicenseApp(id));

                    filename = $"Заява_про_звуження_провадження_виду_господарської_діяльності_-_Звуження_виробництва_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "RemBranchApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_16)_Заява_про_внесення_змін_до_ЄДР_у_зв'язку_з_припиненням_діяльності_МПД_(закриття_МПД){DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlRemBranchApp(id));

                    filename = $"(Додаток_16)_Заява_про_внесення_змін_до_ЄДР_у_зв'язку_з_припиненням_діяльності_МПД_(закриття_МПД){DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "ChangeContrApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_18)_Заява_про_зміну_інформації_у_додатку_(зміна_контрактних_виробників_та_лабораторій)_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlChangeContrApp(id));

                    filename = $"(Додаток_18)_Заява_про_зміну_інформації_у_додатку_(зміна_контрактних_виробників_та_лабораторій)_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "ChangeAutPersonApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_18)_Заява_про_зміну_інформації_у_додатку_(зміна_уповноважених_осіб)_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlChangeAutPersonApp(id));

                    filename = $"(Додаток_18)_Заява_про_зміну_інформації_у_додатку_(зміна_уповноважених_осіб)_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "AddBranchInfoApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_12)_Заява_про_внесення_до_ЄДР_відомостей_про_МПД_(розширення_операцій)_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlAddBranchInfoApp(id));

                    filename = $"(Додаток_12)_Заява_про_внесення_до_ЄДР_відомостей_про_МПД_(розширення_операцій)_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "RemBranchInfoApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_16)_Заява_про_внесення_змін_до_ЄДР_у_зв'язку_з_припиненням_діяльності_МПД_(звуження_операцій)_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlRemBranchInfoApp(id));

                    filename = $"(Додаток_16)_Заява_про_внесення_змін_до_ЄДР_у_зв'язку_з_припиненням_діяльності_МПД_(звуження_операцій)_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "AddBranchApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_12)_Заява_про_внесення_до_ЄДР_відомостей_про_МПД_(додавання_МПД){DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlAddBranchApp(id));

                    filename = $"(Додаток_12)_Заява_про_внесення_до_ЄДР_відомостей_про_МПД_(додавання_МПД){DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                //case "RenewLicenseApplication":
                //    applicationFile = await rep.CreatePDF($"(Додаток_14)_Заява_на_переоформлення_ліцензії_{DateTime.Now.ToString("Hmmss")}.pdf", await _prlReportService.PrlRenewLicenseApp(id));
                //    filename = $"(Додаток_14)_Заява_на_переоформлення_ліцензії_{DateTime.Now.ToString("Hmmss")}.pdf";
                //    break;
                default:
                    applicationFile = null;
                    break;
                }

                fileModel.files.Add(new FilesViewModel()
                {
                    id          = Guid.Empty,
                    idFileStore = Guid.Empty,
                    name        = filename,
                    file        = Convert.ToBase64String(applicationFile)
                });
            }
            catch (Exception e)
            {
                Log.Error("Maksim error");
                throw e;
            }
            return(fileModel);
        }
Example #7
0
        public async Task <FilesSignViewModel> GetFilesForSign(Guid id)
        {
            var appSort   = DataService.GetEntity <ImlApplication>(x => x.Id == id).Select(x => x.AppSort).FirstOrDefault();
            var fileModel = new FilesSignViewModel()
            {
                id = id, files = new List <FilesViewModel>()
            };

            fileModel.files.Add(await _applicationService.GetEDocumentJsonFile(id));
            var rep = new PdfFromHtmlOwnConverter(_converter);

            byte[] applicationFile;
            string filename = "";

            var rpFileStore = DataService.GetEntity <FileStore>(x =>
                                                                x.EntityName == "ImlApplication" && x.EntityId == id && x.Description == "Medicines").FirstOrDefault();

            if (rpFileStore != null)
            {
                var fileRP = await GetFile(rpFileStore.Id);

                fileModel.files.Add(new FilesViewModel()
                {
                    id          = Guid.Empty,
                    idFileStore = rpFileStore.Id,
                    name        = "Підпис_лікарських_засобів.xlsx",
                    file        = Convert.ToBase64String(fileRP.ToArray())
                });
            }

            try
            {
                switch (appSort)
                {
                case "GetLicenseApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_02)_Заява_про_отримання_ліцензії_на_провадження_діяльності_з_виробництва_лікарських_засобів_{DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlCreateLicenseApp(id));

                    filename = $"(Додаток_02)_Заява_про_отримання_ліцензії_на_провадження_діяльності_з_виробництва_лікарських_засобів_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "IncreaseToIMLApplication":
                    applicationFile = await rep.CreatePDF($"Заява_про_розширення_провадження_виду_господарської_діяльності_(Розширення_до_імпорту_лікарських_засобів){DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlCreateLicenseApp(id));

                    filename = $"Заява_про_розширення_провадження_виду_господарської_діяльності_(Розширення_до_імпорту_лікарських_засобів){DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "CancelLicenseApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_22)_Заява_про_анулювання_ліцензії_{DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlCancelLicenseApp(id));

                    filename = $"(Додаток_22)_Заява_про_анулювання_ліцензії_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "DecreaseIMLApplication":
                    applicationFile = await rep.CreatePDF($"Заява_про_звуження_провадження_виду_господарської_діяльності_-_Звуження_імпорту_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlCancelLicenseApp(id));

                    filename = $"Заява_про_звуження_провадження_виду_господарської_діяльності_-_Звуження_імпорту_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "RemBranchApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_16)_Заява_про_внесення_змін_до_ЄДР_у_зв'язку_з_припиненням_діяльності_МПД_(закриття_МПД){DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlRemBranchApp(id));

                    filename = $"(Додаток_16)_Заява_про_внесення_змін_до_ЄДР_у_зв'язку_з_припиненням_діяльності_МПД_(закриття_МПД){DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "ChangeAutPersonApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_18)_Заява_про_зміну_інформації_у_додатку_(зміна_уповноважених_осіб)_{DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlChangeAutPersonApp(id));

                    filename = $"(Додаток_18)_Заява_про_зміну_інформації_у_додатку_(зміна_уповноважених_осіб)_{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "AddBranchApplication":
                    applicationFile = await rep.CreatePDF($"(Додаток_12)_Заява_про_внесення_до_ЄДР_відомостей_про_МПД_(додавання_МПД){DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlAddBranchApp(id));

                    filename = $"(Додаток_12)_Заява_про_внесення_до_ЄДР_відомостей_про_МПД_(додавання_МПД){DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "ChangeDrugList":
                    applicationFile = await rep.CreatePDF($"Заява_про_зміну_переліку_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlChangeMedicineListApp(id));

                    filename = $"Заява_про_зміну_переліку_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                case "ReplacementDrugList":
                    applicationFile = await rep.CreatePDF($"Заява_про_заміну_переліку_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf", await _imlReportService.ImlChangeMedicineListApp(id));

                    filename = $"Заява_про_заміну_переліку_лікарських_засобів{DateTime.Now.ToString("Hmmss")}.pdf";
                    break;

                default:
                    applicationFile = await rep.CreatePDF("applicationPDF.pdf", "<h1>Hi</h1>");

                    filename = "applicationPDF.pdf";
                    break;
                }

                fileModel.files.Add(new FilesViewModel()
                {
                    id          = Guid.Empty,
                    idFileStore = Guid.Empty,
                    name        = filename,
                    file        = Convert.ToBase64String(applicationFile)
                });
            }
            catch (Exception e)
            {
                Log.Error("Maksim error");
                throw e;
            }
            return(fileModel);
        }