예제 #1
0
        /// <summary>
        /// 保存病历
        /// </summary>
        /// <param name="history"></param>
        public static void SaveHistorys(CaseHistory history)
        {
            var dirName = $"{PatientPath}\\{history.HistoryNo}";

            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }
            if (history.imgInfos != null)
            {
                history.imgInfos.Where(w => !w.IsSaveToFile).ToList().ForEach(f => {
                    if (f.InfoType == 1)
                    {
                        var file        = new FileInfo(f.VideoPath);
                        string fileName = "General_A";
                        var newFilePath = $"{dirName}\\{fileName}{f.FileName}.avi";
                        File.Move(f.VideoPath, newFilePath);
                        f.VideoPath = newFilePath;
                    }
                    var imgPath    = $"{PatientPath}\\{history.HistoryNo}\\{f.FileName}.bmp";
                    f.ImgPath      = imgPath;
                    f.IsSaveToFile = true;
                    File.WriteAllText($"{PatientPath}\\{history.HistoryNo}\\{f.FileName}.ini", f.ToJson());
                    f.Img.Save(imgPath);
                });
            }
            File.WriteAllText($"{dirName}\\{history.HistoryNo}.ini", history.ToJson());

            ReadCurrentPatientHistorys();
        }
예제 #2
0
        /// <summary>
        /// 读取当前患者的病历
        /// </summary>
        public static void ReadCurrentPatientHistorys()
        {
            if (CurrentPatient.Historys == null)
            {
                CurrentPatient.Historys = new List <CaseHistory>();
            }
            if (Directory.Exists(PatientPath))
            {
                var dirs = Directory.GetDirectories(PatientPath);

                CurrentPatient.Historys.Clear();
                foreach (var dir in dirs)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(dir);
                    var           str     = File.ReadAllText(dir + $"\\{dirInfo.Name}.ini");
                    CaseHistory   history = str.ToObject <CaseHistory>();

                    var files = Directory.GetFiles(dir, "*.ini");
                    //int index = 0;

                    foreach (var file in files)
                    {
                        FileInfo finfo = new FileInfo(file);

                        if (finfo.Name != $"{dirInfo.Name}.ini")
                        {
                            str = File.ReadAllText(file);
                            var imgInfo = str.ToObject <ImgInfo>();
                            //imgInfo.Img = ReadImageFile(imgInfo.ImgPath); //Help.Base64Util.GetImageFromBase64(imgInfo.Base64);
                            //imgInfo.ID = index++;
                            if (history.imgInfos == null)
                            {
                                history.imgInfos = new List <ImgInfo>();
                            }
                            history.imgInfos.Add(imgInfo);
                        }
                    }
                    CurrentPatient.Historys.Add(history);
                }
            }
        }