public HttpResponseMessage EditCertificate(
            [FromBody] CertificateEditModel model, [FromUri] string sessionKey)
        {
            var responseMsg = this.PerformOperationAndHandleExceptions(() =>
            {
                this.ValidateCertificateName(model.Name);
                this.ValidateCertificateUrl(model.Url);

                var user        = this.GetUserBySessionKey(sessionKey);
                var certificate = user.Certificates.FirstOrDefault(c => c.Id == model.Id);
                if (certificate == null)
                {
                    throw new ArgumentException("The user does not have certificate with id=" + model.Id);
                }

                certificate.Name = model.Name;
                certificate.Url  = model.Url;

                this.db.Certificates.Update(certificate);
                this.db.SaveChanges();

                var returnData = new CertificateModel()
                {
                    Id   = certificate.Id,
                    Name = certificate.Name
                };

                var response = this.Request.CreateResponse(HttpStatusCode.Created, returnData);
                return(response);
            });

            return(responseMsg);
        }
 public ActionResult Create(CertificateModel certificateModel)
 {
     try
     {
         Certificate certificate = new Certificate
         {
             ID         = certificateModel.ID,
             No_Passout = certificateModel.No_Passout,
             ntcIssued  = certificateModel.ntcIssued,
             toIssued   = certificateModel.toIssued
         };
         if (ModelState.IsValid)
         {
             if (certificate.ID > 0)
             {
                 certificateRepository.UpdateCertificate(certificate);
             }
             else
             {
                 certificateRepository.InsertCertificate(certificate);
             }
         }
         else
         {
             return(View(certificateModel));
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View(certificateModel));
     }
 }
示例#3
0
        private void UploadFileToGoogleDrive(string studentName, string studentId, DateTime date, string ccEnName, string ccNumber, string ccCode, string email, string filePath, DoWorkEventArgs ev)
        {
            CertificateModel certificateModel = new CertificateModel();

            if (Upload)
            {
                if (backgroundWorker1.CancellationPending)
                {
                    ev.Cancel = true;
                }
                else
                {
                    string webViewLink = UploadFileToGoogleDrive(studentName, ccNumber, ccCode, filePath, service, studentId);

                    //string certiLink = $"https://drive.google.com/file/d/{webViewLink}/view?usp=sharing";

                    if (!certificateModel.CheckCertificateInDatabase(ccNumber))
                    {
                        certificateModel.AddNewUserCertificate(webViewLink, ccNumber, date, studentId, ccEnName, email, studentName);
                    }
                    else
                    {
                        certificateModel.UpdateUserCertificate(webViewLink, ccNumber, date, studentId, ccEnName, email, studentName);
                    }
                }
            }
        }
        public HttpResponseMessage AddCertificate(
            [FromBody] CertificateCreateModel model, [FromUri] string sessionKey)
        {
            var responseMsg = this.PerformOperationAndHandleExceptions(() =>
            {
                this.ValidateCertificateName(model.Name);
                this.ValidateCertificateUrl(model.Url);

                var user        = this.GetUserBySessionKey(sessionKey);
                var certificate = new Certificate()
                {
                    Name = model.Name,
                    Url  = model.Url
                };

                user.Certificates.Add(certificate);
                this.db.Users.Update(user);
                this.db.SaveChanges();

                var returnData = new CertificateModel()
                {
                    Id   = certificate.Id,
                    Name = certificate.Name
                };

                var response = this.Request.CreateResponse(HttpStatusCode.Created, returnData);
                return(response);
            });

            return(responseMsg);
        }
        public IActionResult Certificate([FromBody] CertificateModel model)
        {
            CertificateDTO dto = Mapping.Mapper.Map <CertificateModel, CertificateDTO>(model);

            _curriculumService.AddOrUpdateSectionBlock <CertificateDTO>(dto, model.FormMode, SectionNames.Certificate);

            return(Ok(new { id = model.CertificateId }));
        }
示例#6
0
        // This event handler is where the time-consuming work is done.
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            SelectPdf.HtmlToPdf converter = InitConverter();

            int count = 0;

            if (string.IsNullOrEmpty(folderStoragePath))
            {
                string exePath = Application.ExecutablePath;
                folderStoragePath = Path.Combine(exePath.Remove(exePath.LastIndexOf('\\')), "funix-certificate");
            }
            try
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    //TODO: (Ms.Hồng Anh required) File excel change the column Tên chứng chỉ (tiếng anh) and Chứng chỉ to single column Mã môn.
                    //check if row has checked in check box
                    if (!backgroundWorker1.CancellationPending && Convert.ToBoolean(row.Cells["checkBoxColumn"].Value))
                    {
                        //render this row to pdf
                        string studentName = row.Cells["Họ và tên"].Value.ToString();
                        string studentId   = row.Cells["Mã sinh viên"].Value.ToString();
                        string email       = row.Cells["Email"].Value.ToString();

                        DateTime date = Convert.ToDateTime(row.Cells["Ngày hoàn thành "].Value);

                        string ccVnName = row.Cells["Tên chứng chỉ"].Value.ToString().Trim();
                        if (ccVnName.StartsWith("Chứng chỉ "))
                        {
                            ccVnName = ccVnName.Replace("Chứng chỉ ", "").Trim();
                            ccVnName = char.ToUpper(ccVnName.First()) + ccVnName.Substring(1);
                        }

                        string ccEnName = row.Cells["Tên chứng chỉ (tiếng anh)"].Value.ToString();
                        string ccNumber = row.Cells["Số CC"].Value.ToString();
                        //string ccCode = "hihi";
                        string ccCode = new CertificateModel().GetCcCode(ccEnName);

                        GeneratePdf(studentName, studentId, date, ccVnName, ccEnName, ccNumber, folderStoragePath, ccCode, email, e, converter);
                        count++;

                        worker.ReportProgress(count);
                    }
                }
                MessageBox.Show("Generate successfull", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                backgroundWorker1.CancelAsync();
            }
            finally
            {
                Process.Start(folderStoragePath);
            }
        }
示例#7
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> UpdateAsync(CertificateModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.UpdateAsync(model);

                return(result > 0);
            }
        }
示例#8
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> AddAsync(CertificateModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.InsertAsync <string, CertificateModel>(model);

                return(!string.IsNullOrWhiteSpace(result));
            }
        }
示例#9
0
        public async Task <int> Put([FromForm] CertificateModel certificateModel)
        {
            if (ModelState.IsValid)
            {
                if (certificateModel.FileChange)
                {
                    File _file = await aztuAkademik.File.FirstOrDefaultAsync(x => x.Id == certificateModel.Certificate.FileId).ConfigureAwait(false);

                    if (!string.IsNullOrEmpty(_file.Name))
                    {
                        System.IO.File.Delete(_file.Name[1..]);
 public IActionResult Put(int id, [FromBody]CertificateModel obj)
 {
     if (!IsCurrentUserAdmin())
         return Forbid();
     var certificate = unitOfWork.CertificateRepository.GetById(id);
     certificate.Name = obj.Name;
     certificate.Level = obj.Level;
     certificate.Description = obj.Description;
     certificate.ValidThroughMonths = obj.ValidThroughMonths;
     unitOfWork.Commit();
     return new ObjectResult(certificate.CertificateId);
 }
示例#11
0
 public bool UpdateCertificate(CertificateModel model)
 {
     if (model.Id == null)
     {
         return(false);
     }
     if (_certificateRepository.Has(model.Id.Value))
     {
         Certificate entity = model.ToEntity();
         return(_certificateRepository.Update(entity));
     }
     return(false);
 }
示例#12
0
 public static TaxCertificate Map(CertificateModel source, string base64pdf)
 {
     return(new TaxCertificate()
     {
         ID = source.id ?? 0,
         SignedDate = source.signedDate,
         ExpirationDate = source.expirationDate,
         ExemptionNumber = source.exemptionNumber,
         ExposureZoneName = source.exposureZone.name,
         FileName = source.filename,
         Base64UrlEncodedPDF = base64pdf
     });
 }
示例#13
0
        public virtual ActionResult Modify(CertificateModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = model.CreateEntity(SaveType.Modify);
            var result = new Dictionary <string, object>();
            var rev    = this.SaveEntity(entity);
            var mess   = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
 public CertificateModel Get(int id)
 {
     var cert =  unitOfWork.CertificateRepository.GetById(id);
     
     var certModel = new CertificateModel
     {
         CertificateId = cert.CertificateId,
         Name = cert.Name,
         Level = cert.Level,
         Description = cert.Description,
         ValidThroughMonths = cert.ValidThroughMonths,
         DogIds = cert.DogCertificates.Select(x => x.DogId).ToList()
     };
     return certModel;
 }
 public IActionResult Post([FromBody]CertificateModel obj)
 {
     if (!IsCurrentUserAdmin())
         return Forbid();
     var cert = new Certificate
     {
         Name = obj.Name,
         Level = obj.Level,
         Description = obj.Description,
         ValidThroughMonths = obj.ValidThroughMonths
     };
     unitOfWork.CertificateRepository.Insert(cert);
     unitOfWork.Commit();
     return new ObjectResult(cert.CertificateId);
 }
示例#16
0
 public static Certificate ToEntity(this CertificateModel model)
 {
     if (model == null)
     {
         throw new NullReferenceException("CertificateModel is null");
     }
     return(new Certificate()
     {
         Id = model.Id.HasValue ? model.Id.Value : 0,
         Name = model.Name,
         Date = model.Date,
         Location = model.Location,
         ResumeId = model.ResumeId.HasValue ? model.ResumeId.Value :0
     });
 }
        public ActionResult Create(int id = 0)
        {
            Certificate certificate = new Certificate();

            if (id > 0)
            {
                certificate = certificateRepository.GetCertificateById(id);
            }
            CertificateModel certificateModel = new CertificateModel
            {
                ID         = certificate.ID,
                No_Passout = certificate.No_Passout,
                ntcIssued  = certificate.ntcIssued,
                toIssued   = certificate.toIssued
            };

            return(View(certificateModel));
        }
示例#18
0
        public virtual ActionResult Get(long id)
        {
            var entity = this.GetEntity <CertificateEntity>(id);

            if (entity == null)
            {
                return(null);
            }
            var model = new CertificateModel
            {
                Id       = entity.Id.ToString(),
                Sequence = entity.Sequence,
                IsShow   = entity.IsShow,
                FileName = entity.FullFileName
            };

            return(this.Jsonp(model));
        }
示例#19
0
        private void ProcessCertificate(CertificateModel certificate, bool force)
        {
            var acme           = certificate.Configs.OfType <AcmeConfig>().FirstOrDefault();
            var getCertificate = certificate.Configs.OfType <IGetCertificateConfig>().FirstOrDefault();

            if (acme != null && getCertificate != null && GetCertificate(getCertificate, out bool shouldRenew))
            {
                if (force)
                {
                    shouldRenew = true;
                }
                var success =
                    shouldRenew &&
                    acme.Renew(certificate.Configs.OfType <INotifyConfig>().ToList()) &&
                    SaveNewCertificate(acme.Controller.Model.Certificate, certificate.Configs.OfType <ISaveCertificateConfig>().ToList()) &&
                    NotifyNewCertificate(acme.Controller.Model.Certificate, certificate.Configs.OfType <INotifyConfig>().ToList());
            }
        }
示例#20
0
        public async Task <ActionResult> /*Task<ActionResult>*/ AddCertificate(CertificateModel addedCertificate)
        {
            if (!LoginHelper.IsAuthenticated())
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = this.Request.Url.AbsoluteUri }));
            }
            else if (!LoginHelper.IsCurrentUserAdmin())
            {
                return(RedirectToAction("Error", "Home", new { error = "Nie masz wystarczających uprawnień by dodać certyfikat." }));
            }

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", LoginHelper.GetToken());

            /* for put $ post:
             * httpmethod.put i httpmethod.post
             * message.Content = new StringContent(***object-json-serialized***,
             *                                  System.Text.Encoding.UTF8, "application/json");
             */

            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, client.BaseAddress + "certificates/");

            var certificateSerialized = JsonConvert.SerializeObject(addedCertificate);

            message.Content = new StringContent(certificateSerialized, System.Text.Encoding.UTF8, "application/json");

            HttpResponseMessage responseMessage = client.SendAsync(message).Result; // await client.SendAsync(message)

            if (responseMessage.IsSuccessStatusCode)                                //200 OK
            {
                //display info
                message.Dispose();
                return(RedirectToAction("Certificate", new { id = Int32.Parse(responseMessage.Content.ReadAsStringAsync().Result) }));
            }
            else    // msg why not ok
            {
                message.Dispose();
                ViewBag.Message = "Kod błędu: " + responseMessage.StatusCode;
                return(View("Error"));
            }
        }
 public List<CertificateModel> Get()
 {
     var certs = unitOfWork.CertificateRepository.GetAll().ToList();
     var certificateModels = new List<CertificateModel>();
     foreach(var cert in certs)
     {
         var certModel = new CertificateModel
         {
             CertificateId = cert.CertificateId,
             Name = cert.Name,
             Level = cert.Level,
             Description = cert.Description,
             ValidThroughMonths = cert.ValidThroughMonths,
             DogIds = cert.DogCertificates.Select(x => x.DogId).ToList()
         };
         certificateModels.Add(certModel);
     }
     return certificateModels;
 }
示例#22
0
        private void GeneratePdf(string studentName, string studentId, DateTime date, string ccVnName, string ccEnName, string ccNumber, string folderStoragePath, string ccCode, string email, DoWorkEventArgs ev, SelectPdf.HtmlToPdf converter)
        {
            CertificateModel certificateModel = new CertificateModel();
            string           filePath         = null;

            if (backgroundWorker1.CancellationPending)
            {
                ev.Cancel = true;
            }
            else
            {
                try
                {
                    string   finishedDate = date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    string[] parameters   = { studentName, ccVnName, ccEnName, ccNumber, finishedDate, Application.ExecutablePath.Remove(Application.ExecutablePath.LastIndexOf("\\")).Replace("\\", "/") };
                    //string filename = "E:/Funix/Template certificate/certificate template 1.pdf";

                    filePath = $"{folderStoragePath.Replace("\\", "/")}/{ccNumber}-{ccCode}-{studentName}.pdf";

                    string html = string.Format(contentHtml, parameters);
                    // define a rendering result object

                    PdfDocument doc = converter.ConvertHtmlString(html);
                    doc.Save(filePath);
                    doc.Close();

                    //HtmlToImage htmlToImage = new HtmlToImage();
                    //Image img = htmlToImage.ConvertHtmlString(html);

                    ////TODO: create new file first
                    //FileStream stream = File.Open("D:/Image/test.png", FileMode.Create);
                    //img.Save(stream, ImageFormat.Png);

                    UploadFileToGoogleDrive(studentName, studentId, date, ccEnName, ccNumber, ccCode, email, filePath, ev);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
示例#23
0
        public virtual ActionResult Add(CertificateModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = model.CreateEntity(SaveType.Add);
            var result = new Dictionary <string, object>();

            entity.Site = new SiteEntity {
                Id = SiteId
            };
            entity.Sequence = GetSequence();
            var rev  = this.SaveEntity(entity);
            var mess = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Id", entity.Id);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
示例#24
0
        public async Task <ActionResult> UpdateCertificate(CertificateModel updatedCertificate)    //? -> może być null
        {
            if (!LoginHelper.IsAuthenticated())
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = this.Request.Url.AbsoluteUri }));
            }
            else if (!LoginHelper.IsCurrentUserAdmin())
            {
                return(RedirectToAction("Error", "Home", new { error = "Nie masz wystarczających uprawnień by dodać certyfikat." }));
            }


            //client.BaseAddress = new Uri(url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", LoginHelper.GetToken());
            System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Put, client.BaseAddress + "certificates/" + updatedCertificate.CertificateId.ToString());
            var certificateSerialized  = JsonConvert.SerializeObject(updatedCertificate);

            message.Content = new StringContent(certificateSerialized, System.Text.Encoding.UTF8, "application/json"); //dog serialized id.ToString()
            HttpResponseMessage responseMessage = client.SendAsync(message).Result;

            if (responseMessage.IsSuccessStatusCode)    //200 OK
            {
                //wyswietlić informację


                message.Dispose();
                return(RedirectToAction("Certificate", new { id = Int32.Parse(responseMessage.Content.ReadAsStringAsync().Result) }));
            }
            else    // wiadomosc czego się nie udało
            {
                message.Dispose();
                ViewBag.Message = "Kod błędu: " + responseMessage.StatusCode;
                return(View("Error"));
            }
        }
示例#25
0
        private async Task <List <CertificateModel> > GetVerificationResponseAsync(string xmlString)
        {
            RestClient client = new RestClient(ApiUrl);

            client.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;    //Disable Certificate Check
            RestRequest uploadRequest = new RestRequest("", Method.POST);

            uploadRequest.AddParameter("xml", xmlString);
            IRestResponse uploadResponse = await client.ExecutePostTaskAsync(uploadRequest);

            if (uploadResponse.StatusCode.CompareTo(HttpStatusCode.OK) == 0)
            {
                JObject jObject = JObject.Parse(uploadResponse.Content);
                IsSignatureVerified = (bool)jObject["success"];
                List <CertificateModel> certList = new List <CertificateModel>();
                if (IsSignatureVerified == true)
                {
                    foreach (JToken signature in jObject["signatures"])
                    {
                        CertificateModel certModel = new CertificateModel();
                        certModel.CertificateValidFrom           = (DateTime)signature["certificateValidFrom"];
                        certModel.CertificateValidTo             = (DateTime)signature["certificateValidFrom"];
                        certModel.CertificateHash                = (string)signature["certificateHash"];
                        certModel.CertificateIssuer              = (string)signature["certificateIssuer"];
                        certModel.CertificateSubject             = (string)signature["certificateSubject"];
                        certModel.SigningTime                    = (DateTime)signature["signingTsaTime"];
                        certModel.tsaSignedTimestamp_Base64_UTF8 = (string)signature["tsaSignedTimestamp_Base64_UTF8"];
                        certList.Add(certModel);
                    }
                }
                return(certList);
            }
            else
            {
                return(null);
            }
            throw new NotImplementedException();
        }
示例#26
0
 public void CreateCertificate(CertificateModel model)
 {
     _certificateRepository.Add(model.ToEntity());
 }
示例#27
0
        public async Task <IActionResult> ModifyDoctorInfoAsync([FromBody] ModifyDoctorInfoRequestDto doctorDto)
        {
            var doctorModelGuid = UserID;
            var doctorBiz       = new DoctorBiz();
            var checkDoctor     = await doctorBiz.GetAsync(doctorModelGuid);

            if (checkDoctor == null)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!"));
            }

            var userModel = await new UserBiz().GetModelAsync(UserID);

            userModel.UserName       = doctorDto.UserName;
            userModel.IdentityNumber = doctorDto.IdentityNumber;
            userModel.Birthday       = doctorDto.Birthday;
            userModel.Gender         = doctorDto.Gender;

            var hospitalBiz  = new HospitalBiz();
            var officeBiz    = new OfficeBiz();
            var accessoryBiz = new AccessoryBiz();
            var doctorModel  = new DoctorModel();

            doctorModel = checkDoctor;

            //医生数据
            doctorModel.HospitalGuid       = doctorDto.HospitalGuid;
            doctorModel.OfficeGuid         = doctorDto.DocOffice;
            doctorModel.WorkCity           = doctorDto.City;
            doctorModel.PractisingHospital = doctorDto.PractisingHospital;
            doctorModel.Honor      = doctorDto.Honor;
            doctorModel.Background = doctorDto.Background;
            doctorModel.TitleGuid  = doctorDto.DocTitle;
            doctorModel.AdeptTags  = doctorDto.Adepts;
            doctorModel.Status     = StatusEnum.Submit.ToString();
            //doctorModel.SignatureGuid = doctorDto.SignatureGuid;
            doctorModel.CreatedBy       = UserID;
            doctorModel.OrgGuid         = "";
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.PortraitGuid    = doctorDto.PortraitGuid;
            doctorModel.LastUpdatedDate = DateTime.Now;

            //医院名称
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;

            //医生证书配置项 & 附件
            var lstCertificate = new List <CertificateModel>();
            var lstAccessory   = new List <AccessoryModel>();

            if (doctorDto.Certificates.Any())
            {
                foreach (var certificate in doctorDto.Certificates)
                {
                    var certificateModel = new CertificateModel
                    {
                        CertificateGuid = Guid.NewGuid().ToString("N"),
                        PictureGuid     = certificate.AccessoryGuid,
                        OwnerGuid       = doctorModel.DoctorGuid,
                        DicGuid         = certificate.DicGuid,
                        CreatedBy       = UserID,
                        OrgGuid         = "",
                        LastUpdatedBy   = UserID
                    };
                    lstCertificate.Add(certificateModel);
                    var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid);

                    if (accModel != null)
                    {
                        accModel.OwnerGuid       = certificateModel.CertificateGuid;
                        accModel.LastUpdatedDate = DateTime.Now;
                        lstAccessory.Add(accModel);
                    }
                }
            }
            var doctorCompositeBiz = new DoctorCompositeBiz();
            var result             = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, false);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生数据修改失败!"));
        }
示例#28
0
        public async Task <IActionResult> RegisterDoctor([FromBody] RegisterDoctorRequestDto doctorDto)
        {
            var doctorModelGuid = UserID;
            var doctorBiz       = new DoctorBiz();
            var checkModel      = await doctorBiz.GetAsync(doctorModelGuid, true, true);

            bool isAdd       = checkModel == null;;//当前为更新操作还是新增操作
            var  statusCheck = string.Equals(checkModel?.Status, StatusEnum.Submit.ToString(), StringComparison.OrdinalIgnoreCase) || string.Equals(checkModel?.Status, StatusEnum.Approved.ToString(), StringComparison.OrdinalIgnoreCase);

            if (checkModel != null && statusCheck && checkModel.Enable)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户已注册过医生!"));
            }

            var doctorCertificates = await new DictionaryBiz().GetListByParentGuidAsync(DictionaryType.DoctorDicConfig);

            foreach (var item in doctorCertificates)
            {
                if (doctorDto.Certificates.FirstOrDefault(a => a.DicGuid == item.DicGuid) == null)
                {
                    var eMsg = $"[{item.ConfigName}]没有上传";
                    return(Failed(ErrorCode.UserData, $"上传的医生证书项和系统配置的项不符,请核对,详情:{eMsg}"));
                }
            }

            var userModel = await new UserBiz().GetModelAsync(UserID);

            userModel.UserName       = doctorDto.UserName;
            userModel.IdentityNumber = doctorDto.IdentityNumber;
            userModel.Birthday       = doctorDto.Birthday;
            userModel.Gender         = doctorDto.Gender;
            var hospitalBiz  = new HospitalBiz();
            var officeBiz    = new OfficeBiz();
            var accessoryBiz = new AccessoryBiz();
            var doctorModel  = new DoctorModel();

            if (!isAdd)
            {
                doctorModel = checkModel;
            }
            //医生数据
            doctorModel.DoctorGuid         = doctorModelGuid;
            doctorModel.HospitalGuid       = doctorDto.HospitalGuid;
            doctorModel.OfficeGuid         = doctorDto.DocOffice;
            doctorModel.WorkCity           = doctorDto.City;
            doctorModel.PractisingHospital = doctorDto.PractisingHospital;
            doctorModel.Honor           = doctorDto.Honor;
            doctorModel.Background      = doctorDto.Background;
            doctorModel.TitleGuid       = doctorDto.DocTitle;
            doctorModel.AdeptTags       = Newtonsoft.Json.JsonConvert.SerializeObject(doctorDto.Adepts);
            doctorModel.Status          = StatusEnum.Submit.ToString();
            doctorModel.SignatureGuid   = doctorDto.SignatureGuid;
            doctorModel.CreatedBy       = UserID;
            doctorModel.OrgGuid         = "";
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.PortraitGuid    = doctorDto.PortraitGuid;
            doctorModel.LastUpdatedDate = DateTime.Now;
            doctorModel.Enable          = true;

            //医院名称
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;

            //医生证书配置项 & 附件
            var lstCertificate = new List <CertificateModel>();
            var lstAccessory   = new List <AccessoryModel>();

            if (doctorDto.Certificates.Any())
            {
                foreach (var certificate in doctorDto.Certificates)
                {
                    var certificateModel = new CertificateModel
                    {
                        CertificateGuid = Guid.NewGuid().ToString("N"),
                        PictureGuid     = certificate.AccessoryGuid,
                        OwnerGuid       = doctorModel.DoctorGuid,
                        DicGuid         = certificate.DicGuid,
                        CreatedBy       = UserID,
                        OrgGuid         = "",
                        LastUpdatedBy   = UserID
                    };
                    lstCertificate.Add(certificateModel);
                    var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid);

                    if (accModel != null)
                    {
                        accModel.OwnerGuid       = certificateModel.CertificateGuid;
                        accModel.LastUpdatedDate = DateTime.Now;
                        lstAccessory.Add(accModel);
                    }
                }
            }
            var doctorCompositeBiz = new DoctorCompositeBiz();
            var result             = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, isAdd);

            if (result)
            {
                new DoctorActionBiz().RegisterDoctor(this.UserID);
            }
            return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生注册数据插入不成功!"));
        }