| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -275,86 +275,46 @@ namespace Shentun.Peis | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        public static string Base64ToImageInAbsolutePath(string AbsolutePath, string fileName, string base64Str, string PatientRegisterId, string RegisterCheckId) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        public static string Base64ToImageUseAbsolutePath(string absolutePath, string fileName, string base64Str, string patientRegisterId, string registerCheckId) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var ret = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(absolutePath)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("absolutePath不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                base64Str = base64Str.Substring(base64Str.IndexOf(",") + 1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                string savePath = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                string hostPath = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                var bitmap = Base64StrToImage(base64Str); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (bitmap != null) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    string ImageSuffix = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (ImageFormat.Png.Guid == bitmap.RawFormat.Guid) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        ImageSuffix = ".png"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    else if (ImageFormat.Gif.Guid == bitmap.RawFormat.Guid) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        ImageSuffix = ".gif"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    else if (ImageFormat.Bmp.Guid == bitmap.RawFormat.Guid) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        ImageSuffix = ".bmp"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    else | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        ImageSuffix = ".jpg"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    string savaDirectory = $"{AbsolutePath}\\pacs\\{DateTime.Now.Year}\\{DateTime.Now.Month}\\{DateTime.Now.Day}\\{PatientRegisterId}\\{RegisterCheckId}"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    savePath = $"{savaDirectory}\\{fileName + ImageSuffix}"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    hostPath = $"/CheckPictureImg/pacs/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{PatientRegisterId}/{RegisterCheckId}/{fileName + ImageSuffix}"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (!Directory.Exists(savaDirectory)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        Directory.CreateDirectory(savaDirectory); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    //图片后缀格式
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    var suffix = savePath.Substring(savePath.LastIndexOf('.') + 1, savePath.Length - savePath.LastIndexOf('.') - 1).ToLower(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    var suffixName = suffix == "png" ? ImageFormat.Png : | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        suffix == "jpg" || suffix == "jpeg" ? ImageFormat.Jpeg : | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        suffix == "bmp" ? ImageFormat.Bmp : | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        suffix == "gif" ? ImageFormat.Gif : ImageFormat.Jpeg; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    //这里复制一份对图像进行保存,否则会出现“GDI+ 中发生一般性错误”的错误提示
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    var bmpNew = new Bitmap(bitmap); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    //  bmpNew.Save(_hostingEnvironment.ContentRootPath + savePath, suffixName);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    var s1 = Directory.GetCurrentDirectory(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    string saveurl = Path.Combine(s1, savePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(fileName)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("文件名不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    bmpNew.Save(saveurl, suffixName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    bmpNew.Dispose(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(base64Str)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("base64Str不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    bitmap.Dispose(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(patientRegisterId)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("PatientRegisterId不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ret = hostPath; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                else | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ret = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(registerCheckId)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("RegisterCheckId不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            catch (Exception ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            string savaDirectory = $"{absolutePath}\\pacs\\{DateTime.Now.Year}\\{DateTime.Now.Month}\\{DateTime.Now.Day}\\{patientRegisterId}\\{registerCheckId}"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!Directory.Exists(savaDirectory)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ret = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Directory.CreateDirectory(savaDirectory); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var savePath = $"{savaDirectory}\\{fileName}"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var fullFileName = Base64ToImage(base64Str, savePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var ImageSuffix = Path.GetExtension(fullFileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            var hostPath = $"/CheckPictureImg/pacs/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{patientRegisterId}/{registerCheckId}/{fileName + ImageSuffix}"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ret = hostPath; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return ret; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -474,7 +434,7 @@ namespace Shentun.Peis | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            byte[] arr = Convert.FromBase64String(base64Str); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            using (MemoryStream ms = new MemoryStream(arr)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Bitmap bmp = new Bitmap(ms); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ms.Close(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                bitmap = bmp; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -482,8 +442,19 @@ namespace Shentun.Peis | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return bitmap; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        public static void ConvertFromBase64(string base64String, string filePath) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        public static string Base64ToImage(string base64String, string filePath) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(filePath)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("文件名不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (string.IsNullOrWhiteSpace(base64String)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                throw new UserFriendlyException("base64Str不能为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            byte[] imageBytes = Convert.FromBase64String(base64String); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -508,7 +479,8 @@ namespace Shentun.Peis | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        ImageSuffix = ".jpg"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    image.Save(filePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    image.Save(filePath + ImageSuffix); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return filePath + ImageSuffix; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |