Esempio n. 1
0
        public async Task <Guid> CreateOnOpen(string sort, Guid?id = null, bool isBackOffice = false)
        {
            Guid licenseId;

            try
            {
                if (id == null)
                {
                    licenseId = _prlLicenseService.GetLicenseGuid().Value;
                }
                else
                {
                    licenseId = _prlLicenseService.GetLicenseGuid(id).Value;
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            Guid applicationId;

            try
            {
                applicationId = await ProcessLicenseToApplication(licenseId, sort, isBackOffice);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            return(applicationId);
        }
Esempio n. 2
0
        public async Task <List <(string type, bool isActive)> > GetActiveLicenses()
        {
            var list = new List <(string, bool)>
            {
                _trlLicenseService.GetLicenseGuid() == null ? ("TRL", false) : ("TRL", true),
                _prlLicenseService.GetLicenseGuid() == null ? ("PRL", false) : ("PRL", true),
                _imlLicenseService.GetLicenseGuid() == null ? ("IML", false) : ("IML", true)
            };

            return(list);
        }
Esempio n. 3
0
        public override async Task <IActionResult> Index()
        {
            var licenseId = _service.GetLicenseGuid();
            var model     = (await _service._commonDataService.GetDtoAsync <PrlLicenseDetailDTO>(dto => dto.Id == licenseId.Value)).FirstOrDefault();

            if (model == null)
            {
                return(await Task.Run(() => NotFound()));
            }
            model.OrgName = !string.IsNullOrEmpty(model.EDRPOU) ? model.OrgDirector : model.Name;

            return(await(licenseId == null
                ? Task.FromResult <IActionResult>(View())
                : Task.FromResult <IActionResult>(View(nameof(Details), model))));
        }
Esempio n. 4
0
        public async Task <IActionResult> AppTypes(Guid?orgId)
        {
            if (orgId == null || orgId == Guid.Empty)
            {
                return(await Task.Run(() => View($"{nameof(AppTypes)}Error")));
            }

            PrlOrganizationExtShortDTO org;

            try
            {
                org = DataService.GetDto <PrlOrganizationExtShortDTO>(dto => dto.Id == orgId).Single();
            }
            catch (Exception e)
            {
                throw new Exception("Невірно вказан id організації", e);
            }

            ViewBag.OrgId   = orgId;
            ViewBag.OrgName = org.Name;
            ViewBag.Number  = org.edrpouOrInn;

            ViewBag.PrlLicense = _prlLicenseService.GetLicenseGuid(orgId);

            return(await Task.Run(() => View()));
        }
Esempio n. 5
0
        public async Task <Guid> SaveApplication(PrlAppDetailDTO editModel, bool isBackOffice)
        {
            Guid appId;
            var  userInfo = await _userInfoService?.GetCurrentUserInfoAsync();

            var isNew = false;

            if (editModel.Id == Guid.Empty)
            {
                isNew = true;
                var model = new PrlAppDetailDTO();
                _objectMapper.Map(editModel, model);
                if (model.OrgUnitId == Guid.Empty)
                {
                    model.OrgUnitId = new Guid(userInfo.OrganizationId());
                }
                if (isBackOffice)
                {
                    model.IsCreatedOnPortal  = false;
                    model.BackOfficeAppState = "Project";
                }
                else
                {
                    model.AppState          = "Project";
                    model.IsCreatedOnPortal = true;
                }
                model.AppType = "PRL";

                var organizationInfo = new OrganizationInfo();
                organizationInfo.OrganizationId = model.OrgUnitId == Guid.Empty ? new Guid(userInfo?.OrganizationId()) : model.OrgUnitId;
                organizationInfo.Type           = "PRL";
                if (string.IsNullOrEmpty(model.EDRPOU))
                {
                    if (isBackOffice == false)
                    {
                        organizationInfo.OrgDirector = userInfo.FullName();
                    }
                }
                else
                {
                    organizationInfo.OrgDirector = model.OrgDirector;
                }
                organizationInfo.Name                        = model.OrgName;
                organizationInfo.EMail                       = model.EMail;
                organizationInfo.LegalFormType               = model.LegalFormType;
                organizationInfo.OwnershipType               = model.OwnershipType;
                organizationInfo.PhoneNumber                 = model.PhoneNumber;
                organizationInfo.FaxNumber                   = model.FaxNumber;
                organizationInfo.NationalAccount             = model.NationalAccount;
                organizationInfo.InternationalAccount        = model.InternationalAccount;
                organizationInfo.NationalBankRequisites      = model.NationalBankRequisites;
                organizationInfo.InternationalBankRequisites = model.InternationalBankRequisites;
                organizationInfo.PassportSerial              = model.PassportSerial;
                organizationInfo.PassportNumber              = model.PassportNumber;
                organizationInfo.PassportDate                = model.PassportDate;
                organizationInfo.PassportIssueUnit           = model.PassportIssueUnit;
                organizationInfo.AddressId                   = model.AddressId;


                var license = _prlLicenseService.GetLicenseGuid(model.OrgUnitId);
                if (license == null)
                {
                    if (editModel.AppSort == "AdditionalInfoToLicense")
                    {
                        organizationInfo.IsPendingLicenseUpdate = true;
                    }
                    organizationInfo.IsActualInfo = true;
                    DataService.GetEntity <OrganizationInfo>(x =>
                                                             x.IsActualInfo && x.OrganizationId == model.OrgUnitId && x.Type == "PRL").ToList()
                    .ForEach(x => x.IsActualInfo = false);
                }

                DataService.Add(organizationInfo);
                DataService.SaveChanges();
                model.OrganizationInfoId = organizationInfo.Id;

                var organization = DataService.GetEntity <OrganizationExt>()
                                   .SingleOrDefault(x => x.Id == model.OrgUnitId);
                if (string.IsNullOrEmpty(model.EDRPOU))
                {
                    organization.INN = model.INN;
                }

                // Тут работал Макс
                // organization.EMail = model.EMail;
                appId = DataService.Add <PrlApplication>(model);

                await DataService.SaveChangesAsync();
            }
            else
            {
                if (isBackOffice)
                {
                    editModel.IsCreatedOnPortal  = false;
                    editModel.BackOfficeAppState = "Project";
                }
                else
                {
                    editModel.AppState          = "Project";
                    editModel.IsCreatedOnPortal = true;
                }
                var organizationInfo = DataService.GetEntity <OrganizationInfo>()
                                       .SingleOrDefault(x => x.Id == editModel.OrganizationInfoId);

                organizationInfo.LegalFormType               = editModel.LegalFormType;
                organizationInfo.OwnershipType               = editModel.OwnershipType;
                organizationInfo.PhoneNumber                 = editModel.PhoneNumber;
                organizationInfo.FaxNumber                   = editModel.FaxNumber;
                organizationInfo.NationalAccount             = editModel.NationalAccount;
                organizationInfo.InternationalAccount        = editModel.InternationalAccount;
                organizationInfo.NationalBankRequisites      = editModel.NationalBankRequisites;
                organizationInfo.InternationalBankRequisites = editModel.InternationalBankRequisites;
                organizationInfo.PassportSerial              = editModel.PassportSerial;
                organizationInfo.PassportNumber              = editModel.PassportNumber;
                organizationInfo.PassportDate                = editModel.PassportDate;
                organizationInfo.PassportIssueUnit           = editModel.PassportIssueUnit;
                organizationInfo.OrgDirector                 = editModel.OrgDirector;
                organizationInfo.AddressId                   = editModel.AddressId;
                organizationInfo.EMail = editModel.EMail;

                // Тут работал Макс
                // var organization = DataService.GetEntity<OrganizationExt>().SingleOrDefault(x => x.Id == editModel.OrgUnitId);
                // organization.EMail = editModel.EMail;

                appId = DataService.Add <PrlApplication>(editModel);
                await DataService.SaveChangesAsync();
            }

            if (editModel.AppSort == "AdditionalInfoToLicense" && isNew)
            {
                var license = (await _limsExchangeService
                               .GetLicenses("PRL", string.IsNullOrEmpty(editModel.EDRPOU) ? editModel.INN : editModel.EDRPOU)).FirstOrDefault();
                if (license == null)
                {
                    throw new Exception();
                }
                foreach (var branchLicense in license.Branches)
                {
                    var branch = new Branch
                    {
                        Id             = Guid.NewGuid(),
                        OrganizationId = editModel.OrgUnitId == Guid.Empty
                            ? new Guid(userInfo?.OrganizationId())
                            : editModel.OrgUnitId,
                        OldLimsId = branchLicense.Id,
                        Name      = branchLicense.Name
                    };
                    var branchId  = DataService.Add(branch, false);
                    var appBranch = new ApplicationBranch()
                    {
                        LimsDocumentId = appId,
                        BranchId       = branchId
                    };
                    DataService.Add(appBranch, false);
                    await DataService.SaveChangesAsync();
                }
                ;
            }

            return(appId);
        }
Esempio n. 6
0
        public async Task <string> MsgToPDFOrgFopLocationChange(Guid id)
        {
            var pdfMessage = new Message();
            var htmlFile   = new StringBuilder();

            BaseTemplate("Templates/Messages/PDFTemplate_OrgFopLocationChange.html", id, out htmlFile, out pdfMessage);

            if (pdfMessage.NewLocationId != Guid.Empty)
            {
                var subAddress = _dataService.GetDto <AtuSubjectAddressDTO>(p => p.Id == pdfMessage.NewLocationId).SingleOrDefault();

                if (subAddress != null)
                {
                    htmlFile.Replace("@@NewAddress@@", subAddress.Address);
                }
            }

            var listPath = Path.Combine(_path, "Templates/Messages/PDFTemplate_MsgList.html");
            var listFile = new StringBuilder();

            // TODO - добавить обработку других лицензий, когда они появятся
            if (pdfMessage.IsPrlLicense)
            {
                var idLic        = _prlLicenseService.GetLicenseGuid(pdfMessage.OrgUnitId);
                var licPRL       = _dataService.GetDto <LicenseRptMinDetailOrgFopLocation>(x => x.Id == idLic).FirstOrDefault();
                var listTemp     = new StringBuilder(File.ReadAllText(listPath));
                var changeString = "Ліцензія на діяльність від " + licPRL.LicenseDate.ToString();

                if (string.IsNullOrEmpty(licPRL.LicenseNumber))
                {
                    changeString += " б/н, ";
                }
                else
                {
                    changeString += "№" + licPRL.LicenseNumber.ToString() + ", ";
                }

                changeString += "наказ №" + licPRL.OrderNumber.ToString() + ", від " + licPRL.OrderDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("uk"));

                listTemp.Replace("@@ListItem@@", changeString);
                listTemp.Replace("@@OrgDir@@", "  (Адреса, вказана в ліцензії: " + licPRL.Address.ToString() + ")");
                listFile.Append(listTemp);
            }
            if (pdfMessage.IsImlLicense)
            {
                var idLic        = _imlLicenseService.GetLicenseGuid(pdfMessage.OrgUnitId);
                var licIML       = _dataService.GetDto <LicenseRptMinDetailOrgFopLocation>(x => x.Id == idLic).FirstOrDefault();
                var listTemp     = new StringBuilder(File.ReadAllText(listPath));
                var changeString = "Ліцензія на діяльність від " + licIML.LicenseDate.ToString();

                if (string.IsNullOrEmpty(licIML.LicenseNumber))
                {
                    changeString += " б/н, ";
                }
                else
                {
                    changeString += "№" + licIML.LicenseNumber.ToString() + ", ";
                }

                changeString += "наказ №" + licIML.OrderNumber.ToString() + ", від " + licIML.OrderDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("uk"));

                listTemp.Replace("@@ListItem@@", changeString);
                listTemp.Replace("@@OrgDir@@", "  (Адреса, вказана в ліцензії: " + licIML.Address.ToString() + ")");
                listFile.Append(listTemp);
            }

            htmlFile.Replace("@@LicenceList@@", listFile.ToString());

            return(htmlFile.ToString());
        }