diff --git a/App.config b/App.config new file mode 100644 index 0000000..563ead2 --- /dev/null +++ b/App.config @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExamRecord.cs b/ExamRecord.cs new file mode 100644 index 0000000..5475f03 --- /dev/null +++ b/ExamRecord.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class ExamRecord + { + public string examId { get; set; } + public string pname { get; set; } + public string gender { get; set; } + public string birthday { get; set; } + public string deviceType { get; set; } + public string deviceName { get; set; } + public string seDc { get; set; } + public string examDate { get; set; } + public string examItemCode { get; set; } + public string examItemName { get; set; } + public string reportstatus { get; set; } + public string applicationDate { get; set; } + public string orgId { get; set; } + public string orgName { get; set; } + public string regId { get; set; } + } +} diff --git a/ExamRecords.cs b/ExamRecords.cs new file mode 100644 index 0000000..751b138 --- /dev/null +++ b/ExamRecords.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class ExamRecords + { + public List Records { get; set; } + } +} diff --git a/FlyHisEcgdataModel.cs b/FlyHisEcgdataModel.cs new file mode 100644 index 0000000..fff77e6 --- /dev/null +++ b/FlyHisEcgdataModel.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + public class FlyHisEcgDataModel + { + public int total { get; set; } + public List rows { get; set; } + } + + public class patientInfo + { + public string jianchaid { get; set; } + public string jianchabh { get; set; } + public string name { get; set; } + public string sfz { get; set; } + public string birthdate { get; set; } + public int age { get; set; } + public string sex { get; set; } + public string yiyuanname { get; set; } + public string yiyuanid { get; set; } + public string yiyuancode { get; set; } + public string kaifangsj { get; set; } + public string departmentCode { get; set; } + public string departmentName { get; set; } + public string resDoctorName { get; set; } + public string resDoctorCode { get; set; } + public string nation { get; set; } + public string patientCode { get; set; } + public string visitType { get; set; } + public List projects { get; set; } + public int code { get; set; } + public string msg { get; set; } + } + + public class projectsInfo + { + public string jianchamingcheng { get; set; } + public string nhbm { get; set; } + public string category { get; set;} + } +} diff --git a/FlyHisTokenMsg.cs b/FlyHisTokenMsg.cs new file mode 100644 index 0000000..c3512f2 --- /dev/null +++ b/FlyHisTokenMsg.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + + //福乐云HIS的token信息结构 + public class FlyHisTokenMsgModel + { + public int code { get; set; } + public dataInfo data { get; set; } + } + + public class dataInfo + { + public string access_token { get; set; } + public string expires_in { get; set; } + } + +} diff --git a/FtpHelper.cs b/FtpHelper.cs new file mode 100644 index 0000000..f62cb8f --- /dev/null +++ b/FtpHelper.cs @@ -0,0 +1,267 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + public class FtpHelper + { + //基本设置 + //private static string ftppath = @"ftp://" + "10.13.1.36" + "/"; + private static string ftppath = ConfigurationManager.AppSettings["ftppath"]; + private static string username = ConfigurationManager.AppSettings["username"]; + private static string password = ConfigurationManager.AppSettings["password"]; + + //获取FTP上面的文件夹和文件 + public static string[] GetFolderAndFileList(string s) + { + string[] getfolderandfilelist; + FtpWebRequest request; + StringBuilder sb = new StringBuilder(); + try + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftppath)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.ListDirectory; + request.UseBinary = true; + WebResponse response = request.GetResponse(); + StreamReader reader = new StreamReader(response.GetResponseStream()); + string line = reader.ReadLine(); + while (line != null) + { + sb.Append(line); + sb.Append("\n"); + Console.WriteLine(line); + line = reader.ReadLine(); + } + sb.Remove(sb.ToString().LastIndexOf('\n'), 1); + reader.Close(); + response.Close(); + return sb.ToString().Split('\n'); + } + catch (Exception ex) + { + Console.WriteLine("获取FTP上面的文件夹和文件:" + ex.Message); + getfolderandfilelist = null; + return getfolderandfilelist; + } + } + + //获取FTP上面的文件大小 + public static int GetFileSize(string fileName) + { + FtpWebRequest request; + try + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftppath + fileName)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.GetFileSize; + int n = (int)request.GetResponse().ContentLength; + return n; + } + catch (Exception ex) + { + Console.WriteLine("获取FTP上面的文件大小:" + ex.Message); + return -1; + } + } + + //FTP上传文件 + public static string FileUpLoad(string filePath, string objPath = "") + { + try + { + string url = ftppath; + if (objPath != "") + url += objPath + "/"; + try + { + FtpWebRequest request = null; + try + { + FileInfo fi = new FileInfo(filePath); + using (FileStream fs = fi.OpenRead()) + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(url + fi.Name)); + request.Credentials = new NetworkCredential(username, password); + request.KeepAlive = false; + request.Method = WebRequestMethods.Ftp.UploadFile; + request.UseBinary = true; + using (Stream stream = request.GetRequestStream()) + { + int bufferLength = 5120; + byte[] buffer = new byte[bufferLength]; + int i; + while ((i = fs.Read(buffer, 0, bufferLength)) > 0) + { + stream.Write(buffer, 0, i); + } + return "上传成功"; + } + } + } + catch (Exception ex) + { + return ex.ToString(); + } + finally + { + + } + } + catch (Exception ex) + { + return ex.ToString(); + } + finally + { + + } + } + catch (Exception ex) + { + return ex.ToString(); + } + } + + + //FTP上传文件 + public static string FileUpLoad(string filePath, string objPath ,string ftpFileName) + { + try + { + string url = ftppath; + if (objPath != "") + url += objPath + "/"; + FtpWebRequest request = null; + + FileInfo fi = new FileInfo(filePath); + using (FileStream fs = fi.OpenRead()) + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(url + ftpFileName)); + request.Credentials = new NetworkCredential(username, password); + request.KeepAlive = false; + request.Method = WebRequestMethods.Ftp.UploadFile; + request.UseBinary = true; + request.UsePassive = true;//被动传输模式 设置 + + using (Stream stream = request.GetRequestStream()) + { + int bufferLength = 5120; + byte[] buffer = new byte[bufferLength]; + int i; + while ((i = fs.Read(buffer, 0, bufferLength)) > 0) + { + stream.Write(buffer, 0, i); + } + return "上传成功"; + } + } + + } + catch (Exception ex) + { + return ex.ToString(); + } + } + + + //FTP下载文件 + public static void FileDownLoad(string fileName) + { + FtpWebRequest request; + try + { + string downloadPath = @"D:"; + FileStream fs = new FileStream(downloadPath + "\\" + fileName, FileMode.Create); + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftppath + fileName)); + request.Method = WebRequestMethods.Ftp.DownloadFile; + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.UsePassive = false; + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + Stream stream = response.GetResponseStream(); + int bufferLength = 5120; + int i; + byte[] buffer = new byte[bufferLength]; + i = stream.Read(buffer, 0, bufferLength); + while (i > 0) + { + fs.Write(buffer, 0, i); + i = stream.Read(buffer, 0, bufferLength); + } + stream.Close(); + fs.Close(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP下载文件:" + ex.Message); + } + } + + //FTP删除文件 + public static void FileDelete(string fileName) + { + try + { + string uri = ftppath + fileName; + FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.KeepAlive = false; + request.Method = WebRequestMethods.Ftp.DeleteFile; + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP删除文件:" + ex.Message); + } + } + + //FTP新建目录,上一级须先存在 + public static void MakeDir(string dirName) + { + try + { + string uri = ftppath + dirName; + FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.MakeDirectory; + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP新建目录:" + ex.Message); + } + } + + //FTP删除目录,上一级须先存在 + public static void DelDir(string dirName) + { + try + { + string uri = ftppath + dirName; + FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); + reqFTP.Credentials = new NetworkCredential(username, password); + reqFTP.Method = WebRequestMethods.Ftp.RemoveDirectory; + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP删除目录:" + ex.Message); + } + } + } +} diff --git a/HisInfo.cs b/HisInfo.cs new file mode 100644 index 0000000..b6ec202 --- /dev/null +++ b/HisInfo.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + public class HisInfo + { + public string jianchaid { get; set; } + public string jianchabh { get; set; } + public string name { get; set; } + public string sfz { get; set; } + public string birthdate { get; set; } + public int age { get; set; } + public string sex { get; set; } + public string yiyuanname { get; set; } + + public string yiyuancode { get; set; } + + public string yiyuanid { get; set; } + public string kaifangsj { get; set; } + public string departmentCode { get; set; } + public string departmentName { get; set; } + public string resDoctorName { get; set; } + public string resDoctorCode { get; set; } + public string nation { get; set; } + public string patientCode { get; set; } + public string visitType { get; set; } + + public string jianchamingcheng { get; set; } + public string nhbm { get; set; } + public string category { get; set; } + } +} diff --git a/Imaganddcm.cs b/Imaganddcm.cs new file mode 100644 index 0000000..63d7581 --- /dev/null +++ b/Imaganddcm.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Drawing.Imaging; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Dicom; +using Dicom.Imaging; +using Dicom.IO.Buffer; +using System.IO; +using System.Collections; + + +namespace videoGather +{ + public class Imaganddcm + { + + /// + /// 存放转换后的dcm文件名称 + /// + public static ArrayList Array=new ArrayList(); + + /// + /// 转换为Dicom格式 + /// + /// 患者ID + /// 影像唯一号 + /// 访问号 + /// 患者姓名 + /// jpg图像 + /// dicom输出路径 + /// + public static bool ConvertToDicomImages(string patId, string pisId, string textId, string patName, Bitmap inputImagePath, string outputDicomPath) + { + + // 读取图像 + + // 创建DICOM数据集 + var dicomDataset = new DicomDataset + { + { DicomTag.PatientID, patId }, + { DicomTag.PatientName, patName }, + { DicomTag.StudyInstanceUID, pisId },//StudyUid + { DicomTag.SeriesInstanceUID, DicomUIDGenerator.GenerateDerivedFromUUID().UID }, + { DicomTag.SOPInstanceUID, DicomUIDGenerator.GenerateDerivedFromUUID().UID }, + { DicomTag.AccessionNumber,textId },//访问号 + { DicomTag.SOPClassUID, DicomUID.SecondaryCaptureImageStorage }, + { DicomTag.PhotometricInterpretation, "RGB" }, + { DicomTag.Rows, (ushort)inputImagePath.Height }, + { DicomTag.Columns, (ushort)inputImagePath.Width }, + { DicomTag.SamplesPerPixel, (ushort)3 }, + { DicomTag.BitsAllocated, (ushort)8 }, + { DicomTag.BitsStored, (ushort)8 }, + { DicomTag.HighBit, (ushort)7 } + + + + + }; + + // 创建像素数据 + var pixelData = DicomPixelData.Create(dicomDataset, true); + byte[] imageData = GetImageData(inputImagePath); + pixelData.AddFrame(new MemoryByteBuffer(imageData)); + + // 创建 DICOM 文件 + var dicomFile = new DicomFile(dicomDataset); + string guid= Guid.NewGuid().ToString("D"); + // 保存 DICOM 文件 + dicomFile.Save(outputDicomPath+"\\"+ guid+".dcm"); + Array.Add(outputDicomPath + "\\" + guid + ".dcm"); + return File.Exists(outputDicomPath+ "\\" + guid + ".dcm"); + + } + + private static byte[] GetImageData(Bitmap image) + { + // 将图像数据转换为DICOM格式 + + BitmapData bitmapData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); + int actualDataWidth = image.Width * 3; + int byteCount = actualDataWidth * image.Height; + byte[] pixels = new byte[byteCount]; + IntPtr ptr = bitmapData.Scan0; + for (int y = 0; y < image.Height; y++) + { + // Copy the data from the bitmap into the array + System.Runtime.InteropServices.Marshal.Copy(ptr + (y * bitmapData.Stride), pixels, y * actualDataWidth, actualDataWidth); + } + image.UnlockBits(bitmapData); + + // Swap the Red and Blue channels to convert from RGB to BGR + for (int i = 0; i < byteCount; i += 3) + { + byte temp = pixels[i]; + pixels[i] = pixels[i + 2]; + pixels[i + 2] = temp; + } + + return pixels; + } + + + public static bool ImportImage(string patId, string pisId, string textId, string patName, Bitmap inputImagePath, string outputDicomPath) + { + + //bitmap = GetValidImage(bitmap); + + + byte[] pixels = GetPixels(inputImagePath); + MemoryByteBuffer buffer = new MemoryByteBuffer(pixels); + DicomDataset dataset = new DicomDataset(); + //FillDataset(dataset); + dataset.Add(DicomTag.PhotometricInterpretation, PhotometricInterpretation.Rgb.Value); + dataset.Add(DicomTag.Rows, (ushort)inputImagePath.Height); + dataset.Add(DicomTag.Columns, (ushort)inputImagePath.Width); + dataset.Add(DicomTag.BitsAllocated, (ushort)8); + dataset.Add(DicomTag.SOPClassUID, DicomUIDGenerator.GenerateDerivedFromUUID().UID); + dataset.Add(DicomTag.SOPInstanceUID, DicomUIDGenerator.GenerateDerivedFromUUID().UID); + dataset.Add(DicomTag.PatientID, patId); + dataset.Add(DicomTag.PatientName, patName); + dataset.Add(DicomTag.StudyInstanceUID, pisId); + DicomPixelData pixelData = DicomPixelData.Create(dataset, true); + pixelData.BitsStored = 8; + //pixelData.BitsAllocated = 8; + pixelData.SamplesPerPixel = 3; + pixelData.HighBit = 7; + pixelData.PixelRepresentation = 0; + pixelData.PlanarConfiguration = 0; + pixelData.AddFrame(buffer); + + DicomFile dicomfile = new DicomFile(dataset); + string guid = Guid.NewGuid().ToString("D"); + Array.Add(outputDicomPath + "\\" + guid + ".dcm"); + dicomfile.Save(outputDicomPath + "\\" + guid + ".dcm"); + return File.Exists(outputDicomPath + "\\" + guid + ".dcm"); + } + public static byte[] GetPixels(Bitmap bitmap) + { + byte[] bytes = new byte[bitmap.Width * bitmap.Height * 3]; + int wide = bitmap.Width; + int i = 0; + int height = bitmap.Height; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < wide; x++) + { + var srcColor = bitmap.GetPixel(x, y); + //bytes[i] = (byte)(srcColor.R * .299 + srcColor.G * .587 + srcColor.B * .114); + bytes[i] = srcColor.R; + i++; + bytes[i] = srcColor.G; + i++; + bytes[i] = srcColor.B; + i++; + } + } + return bytes; + } + } +} diff --git a/ImageInfo.cs b/ImageInfo.cs new file mode 100644 index 0000000..af7fa9b --- /dev/null +++ b/ImageInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class image + { + public string ImageNumber { get; set; } + public string ObjectFile { get; set; } + public string UrlPrefix { get; set; } + } +} diff --git a/InfoForm.Designer.cs b/InfoForm.Designer.cs new file mode 100644 index 0000000..7d786cb --- /dev/null +++ b/InfoForm.Designer.cs @@ -0,0 +1,388 @@ +namespace videoGather +{ + partial class InfoForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.textjianchaid = new System.Windows.Forms.TextBox(); + this.txt_jianchabh = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.txtname = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.textsfz = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.datebirthdate = new System.Windows.Forms.DateTimePicker(); + this.textage = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.comboBoxsex = new System.Windows.Forms.ComboBox(); + this.label8 = new System.Windows.Forms.Label(); + this.datekaifangsj = new System.Windows.Forms.DateTimePicker(); + this.label9 = new System.Windows.Forms.Label(); + this.textexamItemName = new System.Windows.Forms.TextBox(); + this.textexamItemcode = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(306, 625); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 43); + this.button1.TabIndex = 0; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.ForeColor = System.Drawing.Color.Red; + this.label1.Location = new System.Drawing.Point(5, 28); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(63, 21); + this.label1.TabIndex = 1; + this.label1.Text = "患者ID:"; + // + // textjianchaid + // + this.textjianchaid.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textjianchaid.Location = new System.Drawing.Point(70, 26); + this.textjianchaid.Name = "textjianchaid"; + this.textjianchaid.Size = new System.Drawing.Size(161, 29); + this.textjianchaid.TabIndex = 2; + // + // txt_jianchabh + // + this.txt_jianchabh.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txt_jianchabh.Location = new System.Drawing.Point(371, 28); + this.txt_jianchabh.Name = "txt_jianchabh"; + this.txt_jianchabh.Size = new System.Drawing.Size(192, 29); + this.txt_jianchabh.TabIndex = 4; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.ForeColor = System.Drawing.Color.Red; + this.label2.Location = new System.Drawing.Point(294, 31); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(78, 21); + this.label2.TabIndex = 3; + this.label2.Text = "检查编号:"; + // + // txtname + // + this.txtname.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtname.ForeColor = System.Drawing.SystemColors.WindowText; + this.txtname.Location = new System.Drawing.Point(75, 83); + this.txtname.Name = "txtname"; + this.txtname.Size = new System.Drawing.Size(161, 29); + this.txtname.TabIndex = 6; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.ForeColor = System.Drawing.Color.Red; + this.label3.Location = new System.Drawing.Point(-1, 86); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(78, 21); + this.label3.TabIndex = 5; + this.label3.Text = "患者姓名:"; + // + // textsfz + // + this.textsfz.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textsfz.Location = new System.Drawing.Point(603, 83); + this.textsfz.Name = "textsfz"; + this.textsfz.Size = new System.Drawing.Size(169, 29); + this.textsfz.TabIndex = 8; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(535, 86); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(62, 21); + this.label4.TabIndex = 7; + this.label4.Text = "身份证:"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(254, 86); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(78, 21); + this.label5.TabIndex = 9; + this.label5.Text = "出生日期:"; + // + // datebirthdate + // + this.datebirthdate.CustomFormat = "yyyy-MM-dd"; + this.datebirthdate.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.datebirthdate.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.datebirthdate.Location = new System.Drawing.Point(335, 83); + this.datebirthdate.Name = "datebirthdate"; + this.datebirthdate.Size = new System.Drawing.Size(192, 26); + this.datebirthdate.TabIndex = 10; + // + // textage + // + this.textage.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textage.Location = new System.Drawing.Point(717, 28); + this.textage.Name = "textage"; + this.textage.Size = new System.Drawing.Size(55, 29); + this.textage.TabIndex = 12; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(665, 33); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(46, 21); + this.label6.TabIndex = 11; + this.label6.Text = "年龄:"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(23, 138); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(46, 21); + this.label7.TabIndex = 13; + this.label7.Text = "性别:"; + // + // comboBoxsex + // + this.comboBoxsex.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.comboBoxsex.FormattingEnabled = true; + this.comboBoxsex.Items.AddRange(new object[] { + "男", + "女"}); + this.comboBoxsex.Location = new System.Drawing.Point(75, 136); + this.comboBoxsex.Name = "comboBoxsex"; + this.comboBoxsex.Size = new System.Drawing.Size(161, 28); + this.comboBoxsex.TabIndex = 15; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.ForeColor = System.Drawing.Color.DarkRed; + this.label8.Location = new System.Drawing.Point(251, 143); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(78, 21); + this.label8.TabIndex = 16; + this.label8.Text = "开方时间:"; + // + // datekaifangsj + // + this.datekaifangsj.CustomFormat = "yyyy-MM-dd HH:mm:ss"; + this.datekaifangsj.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.datekaifangsj.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.datekaifangsj.Location = new System.Drawing.Point(335, 139); + this.datekaifangsj.Name = "datekaifangsj"; + this.datekaifangsj.Size = new System.Drawing.Size(192, 26); + this.datekaifangsj.TabIndex = 17; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label9.ForeColor = System.Drawing.Color.Red; + this.label9.Location = new System.Drawing.Point(527, 142); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(78, 21); + this.label9.TabIndex = 18; + this.label9.Text = "检查名称:"; + // + // textexamItemName + // + this.textexamItemName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textexamItemName.ForeColor = System.Drawing.SystemColors.WindowText; + this.textexamItemName.Location = new System.Drawing.Point(603, 139); + this.textexamItemName.Name = "textexamItemName"; + this.textexamItemName.Size = new System.Drawing.Size(169, 29); + this.textexamItemName.TabIndex = 19; + // + // textexamItemcode + // + this.textexamItemcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textexamItemcode.Location = new System.Drawing.Point(75, 197); + this.textexamItemcode.Name = "textexamItemcode"; + this.textexamItemcode.Size = new System.Drawing.Size(161, 29); + this.textexamItemcode.TabIndex = 21; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.ForeColor = System.Drawing.Color.Red; + this.label10.Location = new System.Drawing.Point(-1, 200); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(78, 21); + this.label10.TabIndex = 20; + this.label10.Text = "项目编码:"; + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(400, 625); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 43); + this.button2.TabIndex = 22; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button3.Location = new System.Drawing.Point(567, 28); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(59, 32); + this.button3.TabIndex = 23; + this.button3.Text = "生成"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button4 + // + this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button4.Location = new System.Drawing.Point(242, 197); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(59, 32); + this.button4.TabIndex = 24; + this.button4.Text = "生成"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // button5 + // + this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button5.Location = new System.Drawing.Point(232, 25); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(59, 32); + this.button5.TabIndex = 25; + this.button5.Text = "生成"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // InfoForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 680); + this.Controls.Add(this.button5); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.textexamItemcode); + this.Controls.Add(this.label10); + this.Controls.Add(this.textexamItemName); + this.Controls.Add(this.label9); + this.Controls.Add(this.datekaifangsj); + this.Controls.Add(this.label8); + this.Controls.Add(this.comboBoxsex); + this.Controls.Add(this.label7); + this.Controls.Add(this.textage); + this.Controls.Add(this.label6); + this.Controls.Add(this.datebirthdate); + this.Controls.Add(this.label5); + this.Controls.Add(this.textsfz); + this.Controls.Add(this.label4); + this.Controls.Add(this.txtname); + this.Controls.Add(this.label3); + this.Controls.Add(this.txt_jianchabh); + this.Controls.Add(this.label2); + this.Controls.Add(this.textjianchaid); + this.Controls.Add(this.label1); + this.Controls.Add(this.button1); + this.MaximizeBox = false; + this.Name = "InfoForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "新增患者"; + this.Load += new System.EventHandler(this.InfoForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textjianchaid; + private System.Windows.Forms.TextBox txt_jianchabh; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtname; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox textsfz; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.DateTimePicker datebirthdate; + private System.Windows.Forms.TextBox textage; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.ComboBox comboBoxsex; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.DateTimePicker datekaifangsj; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox textexamItemName; + private System.Windows.Forms.TextBox textexamItemcode; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + } +} \ No newline at end of file diff --git a/InfoForm.cs b/InfoForm.cs new file mode 100644 index 0000000..502aedc --- /dev/null +++ b/InfoForm.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace videoGather +{ + public partial class InfoForm : Form + { + public InfoForm() + { + InitializeComponent(); + } + public HisInfo info; + /// + /// 新增 + /// + /// + /// + private void button1_Click(object sender, EventArgs e) + { + if (!inspect()) + { + return; + } + info = new HisInfo(); + info.jianchaid = textjianchaid.Text.Trim(); + info.name = txtname.Text.Trim(); + info.jianchabh = txt_jianchabh.Text.Trim(); + info.sfz = textsfz.Text.Trim(); + info.birthdate = datebirthdate.Value.ToString("yyyy-MM-dd"); + info.age = string.IsNullOrEmpty(textage.Text.Trim())?0:int.Parse(textage.Text.Trim()); + info.sex = comboBoxsex.Text; + info.yiyuanname = ConfigurationManager.AppSettings["yymc"]; + info.yiyuancode = ConfigurationManager.AppSettings["yycode"]; + info.kaifangsj = datekaifangsj.Value.ToString("yyyy-MM-dd HH:mm:ss"); + info.jianchamingcheng = textexamItemName.Text; + info.nhbm = textexamItemcode.Text; + this.DialogResult = DialogResult.OK; + } + /// + /// 初始化 + /// + /// + /// + private void InfoForm_Load(object sender, EventArgs e) + { + datekaifangsj.Value = DateTime.Now; + } + + private void button2_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + } + + /// + /// 生成项目编码 + /// + /// + /// + private void button4_Click(object sender, EventArgs e) + { + Guid guid = Guid.NewGuid(); + string guidString = guid.ToString("N"); // 没有分隔符 + textexamItemcode.Text = "US" + guidString; + } + /// + /// 生成检查编号 + /// + /// + /// + private void button3_Click(object sender, EventArgs e) + { + Guid guid = Guid.NewGuid(); + string guidString = guid.ToString("N"); // 没有分隔符 + txt_jianchabh.Text = guidString; + } + + + /// + /// 验证必填 + /// + private bool inspect() + { + bool bol=true; + if (string.IsNullOrEmpty(textjianchaid.Text.Trim()) || + string.IsNullOrEmpty(txt_jianchabh.Text.Trim()) || + string.IsNullOrEmpty(txtname.Text.Trim()) || + string.IsNullOrEmpty(textexamItemName.Text.Trim()) || + string.IsNullOrEmpty(textexamItemcode.Text.Trim())) + { + + MessageBox.Show("必填字段不能为空"); + return false; + } + return bol; + } + /// + /// 生成患者ID + /// + /// + /// + private void button5_Click(object sender, EventArgs e) + { + string time= DateTime.Now.ToString("yyyyMMddHHmmss"); + textjianchaid.Text = "M"+time; + } + } +} diff --git a/InfoForm.resx b/InfoForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/InfoForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MsgInfo.cs b/MsgInfo.cs new file mode 100644 index 0000000..8429fda --- /dev/null +++ b/MsgInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class MsgInfo + { + public string code { get; set; } + public string data { get; set; } + public string msg { get; set; } + } +} diff --git a/Patient.cs b/Patient.cs new file mode 100644 index 0000000..4324e22 --- /dev/null +++ b/Patient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class Patient + { + public string PatientID { get; set; } + public string PatientNam { get; set; } + public string PatientBir { get; set; } + public string PatientSex { get; set; } + public string OrgId { get; set; } + public string OrgName { get; set; } + public string StudyDate { get; set; } + public List Studies { get; set; } + } +} diff --git a/ProcessForm.Designer.cs b/ProcessForm.Designer.cs new file mode 100644 index 0000000..41655f9 --- /dev/null +++ b/ProcessForm.Designer.cs @@ -0,0 +1,62 @@ +namespace videoGather +{ + partial class ProcessForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.SuspendLayout(); + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(12, 23); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(362, 23); + this.progressBar1.TabIndex = 0; + // + // ProcessForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(386, 69); + this.Controls.Add(this.progressBar1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProcessForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "正在上传"; + this.TopMost = true; + this.Load += new System.EventHandler(this.ProcessForm_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ProgressBar progressBar1; + } +} \ No newline at end of file diff --git a/ProcessForm.cs b/ProcessForm.cs new file mode 100644 index 0000000..8f3f593 --- /dev/null +++ b/ProcessForm.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace videoGather +{ + public partial class ProcessForm : Form + { + private BackgroundWorker backgroundWorker1; + public ProcessForm(BackgroundWorker backgroundWorker1) + { + InitializeComponent(); + this.backgroundWorker1 = backgroundWorker1; + this.backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); + this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted); + + } + + private void ProcessForm_Load(object sender, EventArgs e) + { + + } + + void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + this.Close();//执行完之后,直接关闭页面 + } + void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + this.progressBar1.Value = e.ProgressPercentage; + } + private void button1_Click(object sender, EventArgs e) + { + this.backgroundWorker1.CancelAsync(); + this.Close(); + } + } +} diff --git a/ProcessForm.resx b/ProcessForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ProcessForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..52e3e12 --- /dev/null +++ b/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using videoGather; + +namespace videoGather +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new video()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..089a41d --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("视频采集")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AForge拍照及录像")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("2990c129-31d9-4aa3-b10d-d2773f140ff4")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c0193d8 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace videoGather.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("videoGather.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..330e6f1 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace videoGather.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SaveFile.cs b/SaveFile.cs new file mode 100644 index 0000000..a1e2c53 --- /dev/null +++ b/SaveFile.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class SaveFile + { + + + public string folderPath { get; set; } + + public string imagebase { get; set; } + + public string fileName { get; set; } + + public string extension { get; set; } + + public string orgId { get; set; } + } +} diff --git a/Series.cs b/Series.cs new file mode 100644 index 0000000..e28f989 --- /dev/null +++ b/Series.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class Series + { + public string SeriesNumb { get; set; } + public string SeriesDesc { get; set; } + public string Modality { get; set; } + public List image { get; set; } + } +} diff --git a/StudyInfo.cs b/StudyInfo.cs new file mode 100644 index 0000000..3163403 --- /dev/null +++ b/StudyInfo.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class Study + { + public string StudyDescr { get; set; } + public string StudyID { get; set; } + public string StudyModal { get; set; } + public List Series { get; set; } + } +} diff --git a/insimagescreenshotVO.cs b/insimagescreenshotVO.cs new file mode 100644 index 0000000..78c955a --- /dev/null +++ b/insimagescreenshotVO.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class insimagescreenshotVO + { + public string id { get; set; } + + public string imagebase { get; set; } + + public string imgType { get; set; } + + public string imgDescription { get; set; } + + public string orgId { get; set; } + + } +} diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..9409584 --- /dev/null +++ b/packages.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/video.Designer.cs b/video.Designer.cs new file mode 100644 index 0000000..ec2a460 --- /dev/null +++ b/video.Designer.cs @@ -0,0 +1,633 @@ + +namespace videoGather +{ + partial class video + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(video)); + this.cb_CameraSelect = new System.Windows.Forms.ComboBox(); + this.btn_Capture = new System.Windows.Forms.Button(); + this.btn_Close = new System.Windows.Forms.Button(); + this.gb_ButtonBox = new System.Windows.Forms.GroupBox(); + this.button6 = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.btn_Connect = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.button4 = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.lab_Time = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.btn_EndVideo = new System.Windows.Forms.Button(); + this.btn_PauseVideo = new System.Windows.Forms.Button(); + this.btn_StartVideo = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button5 = new System.Windows.Forms.Button(); + this.txt_h = new System.Windows.Forms.TextBox(); + this.lab_h = new System.Windows.Forms.Label(); + this.txt_w = new System.Windows.Forms.TextBox(); + this.lab_w = new System.Windows.Forms.Label(); + this.txt_y = new System.Windows.Forms.TextBox(); + this.lab_y = new System.Windows.Forms.Label(); + this.txt_x = new System.Windows.Forms.TextBox(); + this.lab_x = new System.Windows.Forms.Label(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.button3 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.dGVPatient = new System.Windows.Forms.DataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.sex = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.age = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.jianchamingcheng = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.kaifangsi = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.gb_CameraPanel = new System.Windows.Forms.GroupBox(); + this.vsp_Panel = new AForge.Controls.VideoSourcePlayer(); + this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); + this.gb_ButtonBox.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dGVPatient)).BeginInit(); + this.gb_CameraPanel.SuspendLayout(); + this.SuspendLayout(); + // + // cb_CameraSelect + // + this.cb_CameraSelect.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.cb_CameraSelect.FormattingEnabled = true; + this.cb_CameraSelect.Location = new System.Drawing.Point(24, 140); + this.cb_CameraSelect.Margin = new System.Windows.Forms.Padding(2); + this.cb_CameraSelect.Name = "cb_CameraSelect"; + this.cb_CameraSelect.Size = new System.Drawing.Size(150, 24); + this.cb_CameraSelect.TabIndex = 12; + // + // btn_Capture + // + this.btn_Capture.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_Capture.Location = new System.Drawing.Point(19, 104); + this.btn_Capture.Margin = new System.Windows.Forms.Padding(2); + this.btn_Capture.Name = "btn_Capture"; + this.btn_Capture.Size = new System.Drawing.Size(98, 31); + this.btn_Capture.TabIndex = 4; + this.btn_Capture.Text = "截图(F9)"; + this.btn_Capture.UseVisualStyleBackColor = true; + this.btn_Capture.Click += new System.EventHandler(this.btn_Capture_Click); + // + // btn_Close + // + this.btn_Close.Location = new System.Drawing.Point(255, 138); + this.btn_Close.Margin = new System.Windows.Forms.Padding(2); + this.btn_Close.Name = "btn_Close"; + this.btn_Close.Size = new System.Drawing.Size(52, 28); + this.btn_Close.TabIndex = 15; + this.btn_Close.Text = "关闭源"; + this.btn_Close.UseVisualStyleBackColor = true; + this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); + // + // gb_ButtonBox + // + this.gb_ButtonBox.Controls.Add(this.button6); + this.gb_ButtonBox.Controls.Add(this.label3); + this.gb_ButtonBox.Controls.Add(this.btn_Connect); + this.gb_ButtonBox.Controls.Add(this.button1); + this.gb_ButtonBox.Controls.Add(this.label1); + this.gb_ButtonBox.Controls.Add(this.button4); + this.gb_ButtonBox.Controls.Add(this.label6); + this.gb_ButtonBox.Controls.Add(this.btn_Close); + this.gb_ButtonBox.Controls.Add(this.lab_Time); + this.gb_ButtonBox.Controls.Add(this.label2); + this.gb_ButtonBox.Controls.Add(this.btn_EndVideo); + this.gb_ButtonBox.Controls.Add(this.btn_PauseVideo); + this.gb_ButtonBox.Controls.Add(this.btn_StartVideo); + this.gb_ButtonBox.Controls.Add(this.btn_Capture); + this.gb_ButtonBox.Controls.Add(this.cb_CameraSelect); + this.gb_ButtonBox.Dock = System.Windows.Forms.DockStyle.Top; + this.gb_ButtonBox.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.gb_ButtonBox.Location = new System.Drawing.Point(3, 157); + this.gb_ButtonBox.Margin = new System.Windows.Forms.Padding(2); + this.gb_ButtonBox.Name = "gb_ButtonBox"; + this.gb_ButtonBox.Padding = new System.Windows.Forms.Padding(2); + this.gb_ButtonBox.Size = new System.Drawing.Size(556, 204); + this.gb_ButtonBox.TabIndex = 16; + this.gb_ButtonBox.TabStop = false; + this.gb_ButtonBox.Text = "功能区"; + this.gb_ButtonBox.Enter += new System.EventHandler(this.gb_ButtonBox_Enter); + // + // button6 + // + this.button6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button6.Location = new System.Drawing.Point(400, 173); + this.button6.Margin = new System.Windows.Forms.Padding(2); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(127, 31); + this.button6.TabIndex = 30; + this.button6.Text = "添加患者"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button6_Click); + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.ForeColor = System.Drawing.Color.Red; + this.label3.Location = new System.Drawing.Point(2, 182); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(109, 16); + this.label3.TabIndex = 29; + this.label3.Text = "双击选择患者"; + // + // btn_Connect + // + this.btn_Connect.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_Connect.Location = new System.Drawing.Point(199, 138); + this.btn_Connect.Margin = new System.Windows.Forms.Padding(2); + this.btn_Connect.Name = "btn_Connect"; + this.btn_Connect.Size = new System.Drawing.Size(52, 27); + this.btn_Connect.TabIndex = 17; + this.btn_Connect.Text = "连接"; + this.btn_Connect.UseVisualStyleBackColor = true; + this.btn_Connect.Click += new System.EventHandler(this.btn_Connect_Click); + // + // button1 + // + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(400, 139); + this.button1.Margin = new System.Windows.Forms.Padding(2); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(127, 31); + this.button1.TabIndex = 28; + this.button1.Text = "刷新患者(HIS)"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click_1); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(226, 111); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(15, 16); + this.label1.TabIndex = 26; + this.label1.Text = "0"; + // + // button4 + // + this.button4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button4.Location = new System.Drawing.Point(400, 23); + this.button4.Margin = new System.Windows.Forms.Padding(2); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(127, 112); + this.button4.TabIndex = 16; + this.button4.Text = "患者数据上传"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(129, 111); + this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(87, 16); + this.label6.TabIndex = 27; + this.label6.Text = "截图数量:"; + // + // lab_Time + // + this.lab_Time.AutoSize = true; + this.lab_Time.Location = new System.Drawing.Point(116, 74); + this.lab_Time.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lab_Time.Name = "lab_Time"; + this.lab_Time.Size = new System.Drawing.Size(87, 16); + this.lab_Time.TabIndex = 13; + this.lab_Time.Text = "00:00:00"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(25, 74); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(87, 16); + this.label2.TabIndex = 12; + this.label2.Text = "录制时间:"; + // + // btn_EndVideo + // + this.btn_EndVideo.Location = new System.Drawing.Point(255, 23); + this.btn_EndVideo.Margin = new System.Windows.Forms.Padding(2); + this.btn_EndVideo.Name = "btn_EndVideo"; + this.btn_EndVideo.Size = new System.Drawing.Size(112, 32); + this.btn_EndVideo.TabIndex = 11; + this.btn_EndVideo.Text = "停止录像(F8)"; + this.btn_EndVideo.UseVisualStyleBackColor = true; + this.btn_EndVideo.Click += new System.EventHandler(this.btn_EndVideo_Click); + // + // btn_PauseVideo + // + this.btn_PauseVideo.Location = new System.Drawing.Point(132, 23); + this.btn_PauseVideo.Margin = new System.Windows.Forms.Padding(2); + this.btn_PauseVideo.Name = "btn_PauseVideo"; + this.btn_PauseVideo.Size = new System.Drawing.Size(119, 32); + this.btn_PauseVideo.TabIndex = 10; + this.btn_PauseVideo.Text = "暂停录像(F7)"; + this.btn_PauseVideo.UseVisualStyleBackColor = true; + this.btn_PauseVideo.Click += new System.EventHandler(this.btn_PauseVideo_Click); + // + // btn_StartVideo + // + this.btn_StartVideo.Location = new System.Drawing.Point(15, 23); + this.btn_StartVideo.Margin = new System.Windows.Forms.Padding(2); + this.btn_StartVideo.Name = "btn_StartVideo"; + this.btn_StartVideo.Size = new System.Drawing.Size(113, 32); + this.btn_StartVideo.TabIndex = 9; + this.btn_StartVideo.Text = "开始录像(F6)"; + this.btn_StartVideo.UseVisualStyleBackColor = true; + this.btn_StartVideo.Click += new System.EventHandler(this.btn_StartVideo_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.button5); + this.groupBox2.Controls.Add(this.txt_h); + this.groupBox2.Controls.Add(this.lab_h); + this.groupBox2.Controls.Add(this.txt_w); + this.groupBox2.Controls.Add(this.lab_w); + this.groupBox2.Controls.Add(this.txt_y); + this.groupBox2.Controls.Add(this.lab_y); + this.groupBox2.Controls.Add(this.txt_x); + this.groupBox2.Controls.Add(this.lab_x); + this.groupBox2.Controls.Add(this.checkBox1); + this.groupBox2.Controls.Add(this.label5); + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Controls.Add(this.button3); + this.groupBox2.Controls.Add(this.button2); + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox2.Font = new System.Drawing.Font("宋体", 12F); + this.groupBox2.Location = new System.Drawing.Point(3, 17); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(556, 140); + this.groupBox2.TabIndex = 18; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "病理"; + // + // button5 + // + this.button5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button5.Location = new System.Drawing.Point(388, 98); + this.button5.Margin = new System.Windows.Forms.Padding(2); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(127, 31); + this.button5.TabIndex = 30; + this.button5.Text = "图片转换成DCM"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Visible = false; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // txt_h + // + this.txt_h.Location = new System.Drawing.Point(487, 25); + this.txt_h.Name = "txt_h"; + this.txt_h.Size = new System.Drawing.Size(28, 26); + this.txt_h.TabIndex = 25; + // + // lab_h + // + this.lab_h.AutoSize = true; + this.lab_h.Location = new System.Drawing.Point(466, 31); + this.lab_h.Name = "lab_h"; + this.lab_h.Size = new System.Drawing.Size(15, 16); + this.lab_h.TabIndex = 24; + this.lab_h.Text = "h"; + // + // txt_w + // + this.txt_w.Location = new System.Drawing.Point(430, 25); + this.txt_w.Name = "txt_w"; + this.txt_w.Size = new System.Drawing.Size(28, 26); + this.txt_w.TabIndex = 23; + // + // lab_w + // + this.lab_w.AutoSize = true; + this.lab_w.Location = new System.Drawing.Point(409, 31); + this.lab_w.Name = "lab_w"; + this.lab_w.Size = new System.Drawing.Size(15, 16); + this.lab_w.TabIndex = 22; + this.lab_w.Text = "w"; + // + // txt_y + // + this.txt_y.Location = new System.Drawing.Point(377, 25); + this.txt_y.Name = "txt_y"; + this.txt_y.Size = new System.Drawing.Size(28, 26); + this.txt_y.TabIndex = 21; + // + // lab_y + // + this.lab_y.AutoSize = true; + this.lab_y.Location = new System.Drawing.Point(356, 31); + this.lab_y.Name = "lab_y"; + this.lab_y.Size = new System.Drawing.Size(15, 16); + this.lab_y.TabIndex = 20; + this.lab_y.Text = "y"; + // + // txt_x + // + this.txt_x.Location = new System.Drawing.Point(319, 25); + this.txt_x.Name = "txt_x"; + this.txt_x.Size = new System.Drawing.Size(28, 26); + this.txt_x.TabIndex = 19; + // + // lab_x + // + this.lab_x.AutoSize = true; + this.lab_x.Location = new System.Drawing.Point(298, 28); + this.lab_x.Name = "lab_x"; + this.lab_x.Size = new System.Drawing.Size(15, 16); + this.lab_x.TabIndex = 18; + this.lab_x.Text = "x"; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(145, 27); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(154, 20); + this.checkBox1.TabIndex = 17; + this.checkBox1.Text = "是否开启区域截图"; + this.checkBox1.UseVisualStyleBackColor = true; + this.checkBox1.Click += new System.EventHandler(this.checkBox1_Click); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(239, 66); + this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(15, 16); + this.label5.TabIndex = 16; + this.label5.Text = "0"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(142, 66); + this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(87, 16); + this.label4.TabIndex = 16; + this.label4.Text = "截图数量:"; + // + // button3 + // + this.button3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button3.Location = new System.Drawing.Point(19, 59); + this.button3.Margin = new System.Windows.Forms.Padding(2); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(112, 31); + this.button3.TabIndex = 16; + this.button3.Text = "上传"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button2 + // + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(19, 24); + this.button2.Margin = new System.Windows.Forms.Padding(2); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(109, 31); + this.button2.TabIndex = 16; + this.button2.Text = "开启截图"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.groupBox1); + this.groupBox3.Controls.Add(this.gb_ButtonBox); + this.groupBox3.Controls.Add(this.groupBox2); + this.groupBox3.Dock = System.Windows.Forms.DockStyle.Left; + this.groupBox3.Location = new System.Drawing.Point(0, 0); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(562, 994); + this.groupBox3.TabIndex = 19; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "操作"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.dGVPatient); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.groupBox1.Location = new System.Drawing.Point(3, 361); + this.groupBox1.Margin = new System.Windows.Forms.Padding(2); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(2); + this.groupBox1.Size = new System.Drawing.Size(556, 630); + this.groupBox1.TabIndex = 19; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "患者信息"; + // + // dGVPatient + // + this.dGVPatient.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dGVPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.name, + this.sex, + this.age, + this.jianchamingcheng, + this.kaifangsi}); + this.dGVPatient.Dock = System.Windows.Forms.DockStyle.Fill; + this.dGVPatient.Location = new System.Drawing.Point(2, 21); + this.dGVPatient.Name = "dGVPatient"; + this.dGVPatient.ReadOnly = true; + this.dGVPatient.RowTemplate.Height = 23; + this.dGVPatient.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dGVPatient.Size = new System.Drawing.Size(552, 607); + this.dGVPatient.TabIndex = 0; + this.dGVPatient.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dGVPatient_CellDoubleClick); + // + // Column1 + // + this.Column1.DataPropertyName = "jianchaid"; + this.Column1.HeaderText = "检查ID"; + this.Column1.Name = "Column1"; + this.Column1.ReadOnly = true; + // + // name + // + this.name.DataPropertyName = "name"; + this.name.HeaderText = "姓名"; + this.name.Name = "name"; + this.name.ReadOnly = true; + this.name.Width = 70; + // + // sex + // + this.sex.DataPropertyName = "sex"; + this.sex.HeaderText = "性别"; + this.sex.Name = "sex"; + this.sex.ReadOnly = true; + this.sex.Width = 70; + // + // age + // + this.age.DataPropertyName = "age"; + this.age.HeaderText = "年龄"; + this.age.Name = "age"; + this.age.ReadOnly = true; + this.age.Width = 70; + // + // jianchamingcheng + // + this.jianchamingcheng.DataPropertyName = "jianchamingcheng"; + this.jianchamingcheng.HeaderText = "检查项目"; + this.jianchamingcheng.Name = "jianchamingcheng"; + this.jianchamingcheng.ReadOnly = true; + // + // kaifangsi + // + this.kaifangsi.DataPropertyName = "kaifangsj"; + this.kaifangsi.HeaderText = "日期"; + this.kaifangsi.Name = "kaifangsi"; + this.kaifangsi.ReadOnly = true; + // + // gb_CameraPanel + // + this.gb_CameraPanel.Controls.Add(this.vsp_Panel); + this.gb_CameraPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.gb_CameraPanel.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.gb_CameraPanel.Location = new System.Drawing.Point(562, 0); + this.gb_CameraPanel.Margin = new System.Windows.Forms.Padding(2); + this.gb_CameraPanel.Name = "gb_CameraPanel"; + this.gb_CameraPanel.Padding = new System.Windows.Forms.Padding(2); + this.gb_CameraPanel.Size = new System.Drawing.Size(1153, 994); + this.gb_CameraPanel.TabIndex = 20; + this.gb_CameraPanel.TabStop = false; + this.gb_CameraPanel.Text = "拍摄"; + // + // vsp_Panel + // + this.vsp_Panel.Dock = System.Windows.Forms.DockStyle.Fill; + this.vsp_Panel.Location = new System.Drawing.Point(2, 21); + this.vsp_Panel.Margin = new System.Windows.Forms.Padding(2); + this.vsp_Panel.Name = "vsp_Panel"; + this.vsp_Panel.Size = new System.Drawing.Size(1149, 971); + this.vsp_Panel.TabIndex = 1; + this.vsp_Panel.VideoSource = null; + // + // backgroundWorker1 + // + this.backgroundWorker1.WorkerReportsProgress = true; + this.backgroundWorker1.WorkerSupportsCancellation = true; + this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork); + this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted); + // + // video + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1715, 994); + this.Controls.Add(this.gb_CameraPanel); + this.Controls.Add(this.groupBox3); + this.DoubleBuffered = true; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "video"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "视频采集"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.Load += new System.EventHandler(this.Form1_Load); + this.gb_ButtonBox.ResumeLayout(false); + this.gb_ButtonBox.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dGVPatient)).EndInit(); + this.gb_CameraPanel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.ComboBox cb_CameraSelect; + private System.Windows.Forms.Button btn_Capture; + private System.Windows.Forms.Button btn_Close; + private System.Windows.Forms.GroupBox gb_ButtonBox; + private System.Windows.Forms.Button btn_EndVideo; + private System.Windows.Forms.Button btn_PauseVideo; + private System.Windows.Forms.Button btn_StartVideo; + private System.Windows.Forms.Button btn_Connect; + private System.Windows.Forms.Label lab_Time; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox txt_h; + private System.Windows.Forms.Label lab_h; + private System.Windows.Forms.TextBox txt_w; + private System.Windows.Forms.Label lab_w; + private System.Windows.Forms.TextBox txt_y; + private System.Windows.Forms.Label lab_y; + private System.Windows.Forms.TextBox txt_x; + private System.Windows.Forms.Label lab_x; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox gb_CameraPanel; + private AForge.Controls.VideoSourcePlayer vsp_Panel; + private System.Windows.Forms.DataGridView dGVPatient; + private System.Windows.Forms.DataGridViewTextBoxColumn Column1; + private System.Windows.Forms.DataGridViewTextBoxColumn name; + private System.Windows.Forms.DataGridViewTextBoxColumn sex; + private System.Windows.Forms.DataGridViewTextBoxColumn age; + private System.Windows.Forms.DataGridViewTextBoxColumn jianchamingcheng; + private System.Windows.Forms.DataGridViewTextBoxColumn kaifangsi; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label6; + private System.ComponentModel.BackgroundWorker backgroundWorker1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + } +} + diff --git a/video.cs b/video.cs new file mode 100644 index 0000000..56ebd5b --- /dev/null +++ b/video.cs @@ -0,0 +1,1734 @@ + +using AForge.Imaging; +using AForge.Video.FFMPEG; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.InteropServices; +using System.Security.Policy; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Shapes; +using static AForge.Imaging.Filters.HitAndMiss; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace videoGather +{ + public partial class video : Form + { + public video() + { + InitializeComponent(); + } + #region 属性 + /// + /// 设备源 + /// 用来操作摄像头 + /// + private AForge.Video.DirectShow.VideoCaptureDevice videoCapture; + /// + /// 摄像头设备集合 + /// + private AForge.Video.DirectShow.FilterInfoCollection infoCollection; + /// + /// 图片 + /// + private System.Drawing.Bitmap imgMap; + /// + /// 文件保存路径 + /// + private readonly string filePath = Application.StartupPath + @"\"; + /// + /// 文件名称 + /// + private readonly string fileName = $"{DateTime.Now.ToString("yyyyMMddhhmmssffff")}"; + /// + /// 用与把每一帧图像写入到视频文件 + /// + private AForge.Video.FFMPEG.VideoFileWriter videoWriter; + /// + /// 是否开始录像 + /// + private bool IsStartVideo = false; + /// + /// 写入次数 + /// + private int tick_num = 0; + /// + /// 录制多少小时,只是为了定时间计算录制时间使用 + /// + private int Hour = 0; + /// + /// 计时器 + /// + private System.Timers.Timer timer_count; + /// + /// 视频保存名称 + /// + private string videoName = string.Empty; + /// + /// 路径地址 + /// + private string _url = string.Empty; + + private string _path = string.Empty; + /// + /// 当前类型 + /// + private string _type = string.Empty; + /// + /// 病理截图临时存放位置 + /// + private string _blpath = string.Empty; + /// + /// 病理访问前缀 + /// + private string _blprefix = string.Empty; + /// + /// 病理截图热键 + /// + private string strkey = string.Empty; + /// + /// 区域截图设置 + /// + private string _xywh = string.Empty; + + /// + /// 文件上传模式 + /// + private string _model = string.Empty; + //超声存放文件访问地址 + ArrayList imagearray = new ArrayList(); + /// + /// 存放双击选择的患者数据 + /// + private HisInfo rowhisinfo; + /// + /// 存放自己新增的数据源 + /// + List hisInfos = new List(); + #endregion + + #region 窗口加载与关闭 + /// + /// 讲题加载事件 + /// + /// + /// + private void Form1_Load(object sender, EventArgs e) + { + + dGVPatient.AutoGenerateColumns = false; + + InitCamera(); + InitCameraSelect(); + //读取配置信息 + _url = ConfigurationManager.AppSettings["URL"]; + _path = ConfigurationManager.AppSettings["path"]; + _type = ConfigurationManager.AppSettings["type"]; + _blpath = ConfigurationManager.AppSettings["blpath"]; + strkey = ConfigurationManager.AppSettings["strkey"]; + _blprefix = ConfigurationManager.AppSettings["blprefix"]; + _xywh = ConfigurationManager.AppSettings["xywh"]; + _model = ConfigurationManager.AppSettings["model"]; + if (_type == "1") + { + + gb_ButtonBox.Visible = true; + groupBox2.Visible = false; + } + else if (_type == "2") + { + + gb_ButtonBox.Visible = false; + groupBox2.Visible = true; + + txt_x.Enabled = false; + txt_y.Enabled = false; + txt_w.Enabled = false; + txt_h.Enabled = false; + txt_x.Text = _xywh.Split(',')[0]; + txt_y.Text = _xywh.Split(',')[1]; + txt_w.Text = _xywh.Split(',')[2]; + txt_h.Text = _xywh.Split(',')[3]; + } + this.btn_Capture.Enabled = false; + + + //秒表 + timer_count = new System.Timers.Timer(); //实例化Timer类,设置间隔时间为1000毫秒; + timer_count.Elapsed += new System.Timers.ElapsedEventHandler(tick_count); //到达时间的时候执行事件; + timer_count.AutoReset = true; //设置是执行一次(false)还是一直执行(true); + timer_count.Interval = 1000; + HookStart(); + btn_Connect_Click(null, null); + GetHisInfo(); + label4.Focus(); + } + /// + /// 窗口关闭时 + /// + /// + /// + private void Form1_FormClosing(object sender, FormClosingEventArgs e) + { + EndCamera(); + } + #endregion + + #region 实例化 + /// + /// 实例化摄像头 + /// + public void InitCamera() + { + try + { + //检测电脑上的摄像头设备 + infoCollection = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); + } + catch (Exception ex) + { + MessageBox.Show($"没有找到设备:{ex.Message}", "Error"); + } + + } + //加载摄像头选择 + public void InitCameraSelect() + { + this.cb_CameraSelect.DropDownStyle = ComboBoxStyle.DropDownList; + //根据读取到的摄像头加载选择项 + foreach (AForge.Video.DirectShow.FilterInfo item in infoCollection) + { + this.cb_CameraSelect.Items.Add(item.Name); + } + //for (int i = 1; i <= infoCollection.Count; i++) + //{ + // this.cb_CameraSelect.Items.Add("摄像头" + i); + //} + if (cb_CameraSelect.Items.Count > 0) + { + cb_CameraSelect.SelectedIndex = 0; + } + + } + #endregion + + #region 连接读取与关闭 + /// + /// 连接按钮 + /// + /// + /// + private void btn_Connect_Click(object sender, EventArgs e) + { + var CameraSelect = this.cb_CameraSelect.Text; + var selectIndex = this.cb_CameraSelect.SelectedIndex; + if (string.IsNullOrEmpty(CameraSelect)) + { + MessageBox.Show("请先选择视频源"); + return; + } + //已有连接的摄像头时先关闭 + if (videoCapture != null) + { + EndCamera(); + } + videoCapture = new AForge.Video.DirectShow.VideoCaptureDevice(infoCollection[selectIndex].MonikerString); + //启动摄像头 + this.vsp_Panel.VideoSource = videoCapture; + this.vsp_Panel.Start(); + this.btn_Capture.Enabled = true; + } + /// + /// 关闭按钮 + /// + /// + /// + private void btn_Close_Click(object sender, EventArgs e) + { + HookStop(); + EndCamera(); + } + /// + /// 关闭摄像头 + /// + public void EndCamera() + { + if (this.vsp_Panel.VideoSource != null) + { + //也可以用 Stop() 方法关闭 + //指示灯停止且等待 + this.vsp_Panel.SignalToStop(); + //停止且等待 + this.vsp_Panel.WaitForStop(); + this.vsp_Panel.VideoSource = null; + + } + } + #endregion + + #region 拍照与保存 + /// + /// 拍照 + /// + /// + /// + private void btn_Capture_Click(object sender, EventArgs e) + { + if (videoCapture == null) + { + MessageBox.Show("设备未连接"); + return; + } + imgMap = this.vsp_Panel.GetCurrentVideoFrame(); + if (imgMap == null) + { + return; + } + var saveName = $"{filePath}{$"{DateTime.Now.ToString("yyyyMMddhhmmssffff")}"}.jpg"; + imgMap.Save(saveName); + imagearray.Add(saveName); + label1.Text = imagearray.Count.ToString(); + } + /// + /// 保存事件 + /// + /// + /// + private void btn_Save_Click(object sender, EventArgs e) + { + + + + } + #endregion + + #region 录像 + /// + /// 开始录像 + /// + /// + /// + private void btn_StartVideo_Click(object sender, EventArgs e) + { + if (videoCapture == null) + { + MessageBox.Show("设备未连接"); + return; + } + if (rowhisinfo == null) + { + MessageBox.Show("请选择患者"); + return; + } + btn_StartVideo.Enabled = false; + videoName = $"{filePath}{fileName}.mp4"; + IsStartVideo = true; + //开始计时 + timer_count.Enabled = true; + //配置录像参数(宽,高,帧率,比特率等参数)VideoCapabilities这个属性会返回摄像头支持哪些配置,从这里面选一个赋值接即可 + videoCapture.VideoResolution = videoCapture.VideoCapabilities[0]; + //设置回调,aforge会不断从这个回调推出图像数据 + videoCapture.NewFrame += Camera_NewFrame; + videoWriter = new AForge.Video.FFMPEG.VideoFileWriter(); + //打开摄像头 + //videoCapture.Start(); + int videoBitrate = 5000000; // 1000 Kbps + //打开录像文件(如果没有则创建,如果有也会清空),这里还有关于视频宽高、帧率、格式、比特率 + videoWriter.Open( + videoName, + videoCapture.VideoResolution.FrameSize.Width, + videoCapture.VideoResolution.FrameSize.Height, + videoCapture.VideoResolution.AverageFrameRate, + AForge.Video.FFMPEG.VideoCodec.MPEG4, + videoBitrate + ); + } + //this.lab_Time + //摄像头输出回调 + private void Camera_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) + { + imgMap = eventArgs.Frame; + lock (imgMap) + { + if (eventArgs != null && eventArgs.Frame != null) + { + try + { + //写到文件 + videoWriter.WriteVideoFrame(eventArgs.Frame); + } + catch (Exception ex) + { + //MessageBox.Show("写入文件错误"+ex.Message); + } + } + } + } + /// + /// 暂停录像 + /// + /// + /// + private void btn_PauseVideo_Click(object sender, EventArgs e) + { + if (videoCapture == null) + { + MessageBox.Show("设备未连接"); + return; + } + var stopBtnName = this.btn_PauseVideo.Text; + if (stopBtnName == "暂停录像") + { + this.btn_PauseVideo.Text = "恢复录像"; + //暂停计时 + timer_count.Enabled = false; + IsStartVideo = false; + } + if (stopBtnName == "恢复录像") + { + this.btn_PauseVideo.Text = "暂停录像"; + //恢复计时 + timer_count.Enabled = true; + IsStartVideo = true; + } + } + /// + /// 停止录像 + /// + /// + /// + private void btn_EndVideo_Click(object sender, EventArgs e) + { + if (videoCapture == null) + { + MessageBox.Show("设备未连接"); + return; + } + btn_StartVideo.Enabled = true; + IsStartVideo = false; + timer_count.Enabled = false; + if (videoWriter != null) + { + videoWriter.Close(); + } + + tick_num = 0; + + + } + #endregion + + #region 计时器响应函数 + /// + /// 计时器 + /// + /// + /// + public void tick_count(object source, System.Timers.ElapsedEventArgs e) + { + tick_num++; + int Temp = tick_num; + int Second = Temp % 60; + int Minute = Temp / 60; + if (Minute % 60 == 0) + { + Hour = Minute / 60; + Minute = 0; + } + else + { + Minute = Minute - Hour * 60; + } + string HourStr = Hour < 10 ? $"0{Hour}" : Hour.ToString(); + string MinuteStr = Minute < 10 ? $"0{Minute}" : Minute.ToString(); + string SecondStr = Second < 10 ? $"0{Second}" : Second.ToString(); + String tick = $"{HourStr}:{MinuteStr}:{SecondStr}"; + this.Invoke((EventHandler)(delegate + { + this.lab_Time.Text = tick; + })); + } + #endregion + + /// + /// 视频上传 + /// + /// + /// + private void button1_Click(object sender, EventArgs e) + { + + + + } + + #region 请求接口 + + private void UploadFileUrl(string filename, string filetype) + { + if (!string.IsNullOrEmpty(filename) && !string.IsNullOrEmpty(filetype)) + { + string imgType = "1";//1图片2 视频 + string ID = string.Empty; + string imagebase = string.Empty; + string imgDescription = "超声图像"; + string orgId = string.Empty; + if (filetype == ".mp4") + { + imgType = "2"; + imgDescription = "超声视频"; + + } + imagebase = _path + @"/" + rowhisinfo.jianchaid + "/" + filename; + ID = rowhisinfo.jianchaid; + orgId = rowhisinfo.yiyuancode; + insimagescreenshotVO vO = new insimagescreenshotVO(); + vO.id = ID; + vO.imagebase = imagebase; + vO.imgDescription = imgDescription; + vO.imgType = imgType; + vO.orgId = orgId; + var json = JsonConvert.SerializeObject(vO); + string msg = Post(_url + "/admin-api/ultrasoniccom/ultrasonic/insimagescreenshot", json); + } + } + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// Post提交数据内容(utf-8编码的) + /// + public static string Post(string url, string content) + { + string result = ""; + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + + #region 添加Post 参数 + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + + return result; + } + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// Post提交数据内容(utf-8编码的) + /// + public static string Post(string url, string content, string headerKey, string headerValue) + { + string result = ""; + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Headers[headerKey] = headerValue; + #region 添加Post 参数 + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + + return result; + } + + /// + /// Get请求 + /// + /// 请求url + /// + public static string Get(string url) + { + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "GET"; + req.Timeout = 30000; + + + if (req == null || req.GetResponse() == null) + { + MessageBox.Show("请求对象为空"); + return string.Empty; + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + if (resp == null) + { + MessageBox.Show("响应对象为空"); + return string.Empty; + } + + using (var stream = resp.GetResponseStream()) + using (var reader = new StreamReader(stream, Encoding.UTF8)) + { + var content = new StringBuilder(); + char[] buffer = new char[1024]; + int read; + while ((read = reader.Read(buffer, 0, buffer.Length)) > 0) + { + content.Append(new string(buffer, 0, read)); + } + return content.ToString(); + } + } + catch (Exception ex) + { + MessageBox.Show("发生错误: " + ex.Message); + return string.Empty; + } + } + + /// + /// Get请求 + /// + /// + /// + /// + /// + public static string Get(string url, string headerKey, string headerValue) + { + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "GET"; + req.Timeout = 30000; + + req.Headers[headerKey] = headerValue; + + if (req == null || req.GetResponse() == null) + { + MessageBox.Show("请求对象为空"); + return string.Empty; + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + if (resp == null) + { + MessageBox.Show("响应对象为空"); + return string.Empty; + } + + using (var stream = resp.GetResponseStream()) + using (var reader = new StreamReader(stream, Encoding.UTF8)) + { + var content = new StringBuilder(); + char[] buffer = new char[1024]; + int read; + while ((read = reader.Read(buffer, 0, buffer.Length)) > 0) + { + content.Append(new string(buffer, 0, read)); + } + return content.ToString(); + } + } + catch (Exception ex) + { + MessageBox.Show("发生错误: " + ex.Message); + return string.Empty; + } + + } + /// + /// 获取HIS患者信息 + /// + public void GetHisInfo() + { + //存放绑定界面的患者数据 一个患者有多个检查 按照检查拆分 一个检查一条数据 + List hisInfos = new List(); + //获取福乐云HIS接口的token + string hisToken = getHisToken(ConfigurationManager.AppSettings["hisGetTokenUrl"], ConfigurationManager.AppSettings["hisAppkey"], ConfigurationManager.AppSettings["appsecret"]); + + //获取当天的患者信息 + FlyHisEcgDataModel FHEDM = GetHisEcgData(ConfigurationManager.AppSettings["hisGetDataUrl"], ConfigurationManager.AppSettings["inHisCode"], DateTime.Now.ToString("yyyy-MM-dd"), hisToken);// + if (FHEDM != null) + { + foreach (patientInfo item in FHEDM.rows) + { + foreach (projectsInfo projectsInfo in item.projects) + { + if (projectsInfo.category == "US") + { + HisInfo info = new HisInfo(); + info.jianchaid = item.jianchaid; + info.name = item.name; + info.jianchabh = item.jianchabh; + info.sfz = item.sfz; + info.birthdate = item.birthdate; + info.age = item.age; + info.sex = item.sex; + info.yiyuanname = item.yiyuanname; + info.yiyuanid = item.yiyuanid; + info.yiyuancode = item.yiyuancode; + info.kaifangsj = item.kaifangsj; + info.departmentCode = item.departmentCode; + info.departmentName = item.departmentName; + info.resDoctorName = item.resDoctorName; + info.resDoctorCode = item.resDoctorCode; + info.nation = item.nation; + info.patientCode = item.patientCode; + info.visitType = item.visitType; + info.jianchamingcheng = projectsInfo.jianchamingcheng; + info.nhbm = projectsInfo.nhbm; + info.category = projectsInfo.category; + hisInfos.Add(info); + } + + } + } + dGVPatient.DataSource = hisInfos; + rowhisinfo = null; + } + } + + + /// + /// 获取福乐云HIS系统的token + /// + /// + /// + /// + public string getHisToken(string url1, string appkey, string appsecret) + { + Dictionary dic = new Dictionary(); + dic.Add("appkey", appkey); + dic.Add("appsecret", appsecret); + + string resultV = PostFile3(url1, dic); + FlyHisTokenMsgModel tm = JsonConvert.DeserializeObject(resultV); + return tm.data.access_token; + } + + /// + /// 获取福乐云HIS系统的患者基本信息 + /// + /// + /// + /// + public FlyHisEcgDataModel GetHisEcgData(string url1, string Yiyuanid, string kaifangsj, string token) + { + Dictionary dic = new Dictionary(); + dic.Add("Yiyuanid", Yiyuanid); + dic.Add("dateStart", kaifangsj); + dic.Add("dateEnd", kaifangsj); + dic.Add("token", token); + string resultV = PostFile3(url1, dic); + FlyHisEcgDataModel tm = JsonConvert.DeserializeObject(resultV); + return tm; + } + + + + /// + /// post form-data 参数 + /// + /// + /// + /// + public string PostFile3(string url, Dictionary items) + { + string boundary = DateTime.Now.Ticks.ToString("x"); + HttpWebRequest request = null; + //如果是发送HTTPS请求               + if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) + { + //处理HttpWebRequest访问https有安全证书的问题( 请求被中止: 未能创建 SSL/TLS 安全通道。) + ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + request = WebRequest.Create(url) as HttpWebRequest; + request.ProtocolVersion = HttpVersion.Version10; + } + else + { + request = WebRequest.Create(url) as HttpWebRequest; + } + + request.ContentType = "multipart/form-data; boundary=" + boundary; + request.Method = "POST"; + // request.Headers.Add("Authorization", "Bearer " + token); + // 最后的结束符 + var endBoundary = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); + + //文件数据 + string fileFormdataTemplate = + "--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + + "\r\nContent-Type: application/octet-stream" + + "\r\n\r\n"; + + //文本数据 + string dataFormdataTemplate = + "\r\n--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"" + + "\r\n\r\n{1}"; + //FileInfo fi = new FileInfo(filePath); + //string fileHeader = string.Format(fileFormdataTemplate, "file", fi.Name); + //var fileBytes = Encoding.UTF8.GetBytes(fileHeader); + + using (var postStream = new MemoryStream()) + { + ////写入文件格式串 + //postStream.Write(fileBytes, 0, fileBytes.Length); + + //#region 写入文件流 + //using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + //{ + // byte[] buffer = new byte[1024]; + // int bytesRead = 0; + // while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) + // { + // postStream.Write(buffer, 0, bytesRead); + // } + //} + //#endregion + + #region 写入其他表单参数 + foreach (KeyValuePair key in items) + { + var p = string.Format(dataFormdataTemplate, key.Key, key.Value); + var bp = Encoding.UTF8.GetBytes(p); + postStream.Write(bp, 0, bp.Length); + } + #endregion + + //写入结束边界 + postStream.Write(endBoundary, 0, endBoundary.Length); + + #region 写入流 + + request.ContentLength = postStream.Length; + postStream.Position = 0; + using (Stream ds = request.GetRequestStream()) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) + { + ds.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 获取返回值 + + string result = string.Empty; + using (HttpWebResponse rep = (HttpWebResponse)request.GetResponse()) + { + using (Stream ds = rep.GetResponseStream()) + { + using (StreamReader sr = new StreamReader(ds)) + { + result = sr.ReadToEnd(); + } + } + } + + return result; + + #endregion + } + } + #endregion + + #region 视频转换 + + /// + /// 转换文件 + /// + /// + /// 转换后文件 + private string ConvertVideo(string filename) + { + Process p = new Process(); + + p.StartInfo.FileName = Application.StartupPath + @"\ffmpeg\" + "ffmpeg"; + + //p.StartInfo.FileName = path + "ffmpeg.exe"; + + p.StartInfo.UseShellExecute = false; + string srcFileName = ""; + srcFileName = "\"" + filename + "\""; + string destFileName = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".mp4"; + //-preset:指定编码的配置。x264编码算法有很多可供配置的参数, + //不同的参数值会导致编码的速度大相径庭,甚至可能影响质量。 + //为了免去用户了解算法,然后手工配置参数的麻烦。x264提供了一些预设值, + //而这些预设值可以通过preset指定。这些预设值有包括: + //ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow和placebo。 + //ultrafast编码速度最快,但压缩率低,生成的文件更大,placebo则正好相反。x264所取的默认值为medium。 + //需要说明的是,preset主要是影响编码的速度,并不会很大的影响编码出来的结果的质量。 + //-crf:这是最重要的一个选项,用于指定输出视频的质量,取值范围是0-51,默认值为23,数字越小输出视频的质量越高。 + //这个选项会直接影响到输出视频的码率。一般来说,压制480p我会用20左右,压制720p我会用16-18,1080p我没尝试过。 + //个人觉得,一般情况下没有必要低于16。最好的办法是大家可以多尝试几个值,每个都压几分钟,看看最后的输出质量和文件大小,自己再按需选择。 + p.StartInfo.Arguments = "-i " + srcFileName + " -y -vcodec h264 -threads " + 1 + " -crf " + 25 + " " + "\"" + destFileName + "\""; //执行参数 + + p.StartInfo.UseShellExecute = false; ////不使用系统外壳程序启动进程 + p.StartInfo.CreateNoWindow = true; //不显示dos程序窗口 + + p.StartInfo.RedirectStandardInput = true; + + p.StartInfo.RedirectStandardOutput = true; + + p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中 + + p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived); + + p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); + + p.StartInfo.UseShellExecute = false; + + p.Start(); + + p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + + p.BeginErrorReadLine();//开始异步读取 + + p.WaitForExit();//阻塞等待进程结束 + + p.Close();//关闭进程 + + p.Dispose();//释放资源 + + return destFileName.TrimStart('\\'); + + } + + private static void p_ErrorDataReceived(object sender, DataReceivedEventArgs e) + { + //WriteLog(e.Data); + } + + private static void p_OutputDataReceived(object sender, DataReceivedEventArgs e) + { + + //WriteLog(e.Data); + + } + #endregion + + #region 病理相关 + /// + /// 开启或关闭全局监测 + /// + /// + /// + private void button2_Click(object sender, EventArgs e) + { + var CameraSelect = this.cb_CameraSelect.Text; + if (string.IsNullOrEmpty(CameraSelect)) + { + MessageBox.Show("请先选择视频源"); + return; + } + if (button2.Text == "开启截图") + { + HookStart(); + button2.Text = "关闭截图"; + } + else if (button2.Text == "关闭截图") + { + HookStop(); + button2.Text = "开启截图"; + } + + } + /// + /// 保存病理截图并且转换成dcm + /// + private void SaveImageDcm() + { + Bitmap currentFrame = this.vsp_Panel.GetCurrentVideoFrame(); + if (currentFrame != null) + { + //开启区域截图 + if (checkBox1.Checked) + { + int x = int.Parse(txt_x.Text.Trim()); + int y = int.Parse(txt_y.Text.Trim()); + int w = int.Parse(txt_w.Text.Trim()); + int h = int.Parse(txt_h.Text.Trim()); + // 定义你想要裁剪的区域 imgMap + System.Drawing.Rectangle region = new System.Drawing.Rectangle(x, y, w, h); // 例如,从(10,10)开始,宽100,高100的区域 + + // 裁剪图像区域 + imgMap = currentFrame.Clone(region, currentFrame.PixelFormat); + } + else + { + imgMap = currentFrame; + } + + bool bol = Imaganddcm.ImportImage("123456", "2", "3", "测试", imgMap, _blpath); + if (bol) + { + label5.Text = Imaganddcm.Array.Count.ToString(); + imgMap.Dispose(); + currentFrame.Dispose(); + } + } + } + /// + /// 上传病理dcm并且传递数据 + /// + /// + /// + private void button3_Click(object sender, EventArgs e) + { + //给当前患者创建FTP路径 + FtpHelper.MakeDir("123456"); + //读取当前患者截图文件上传FTP + string[] filePaths = Directory.GetFiles(_blpath); + if (!filePaths.Any()) + { + MessageBox.Show("文件为空"); + return; + + } + //存放文件访问地址 + ArrayList arrayList = new ArrayList(); + foreach (string filePath in filePaths) + { + string fileName = System.IO.Path.GetFileName(filePath); + string returnStr = FtpHelper.FileUpLoad(filePath, "123456", fileName);//上传文件 + arrayList.Add("123456" + "/" + fileName); + File.Delete(filePath); + } + //调用患者信息接口 + //先获取token + string msg = Get(_url + "/admin-api/system/jwtToken/getToken?key_public=c4c7dde887706361d8480909043bfdbd"); + if (!string.IsNullOrEmpty(msg)) + { + MsgInfo person = JsonConvert.DeserializeObject(msg); + if (person != null) + { + InsPatientInfo(person.data); + + InsImageInfo(person.data, arrayList); + + MessageBox.Show("上传成功"); + Imaganddcm.Array.Clear(); + label5.Text = "0"; + } + + } + } + /// + /// 插入患者信息 + /// + /// + private void InsPatientInfo(string token) + { + string strjson = @"[ + { + ""examId"": ""1234567"", + ""pname"": ""病理测试插入患者"", + ""gender"": ""男"", + ""birthday"": ""1727075391000"", + ""deviceType"": ""CSH1"", + ""deviceName"": ""设备测试12"", + ""seDc"": """", + ""examDate"": ""1727075391000"", + ""examItemCode"": ""Z0000000210"", + ""examItemName"": ""病理"", + ""reportstatus"": ""待分析"", + ""applicationDate"": ""1727075391000"", + ""orgId"": ""9f65555c-ce59-4f4c-8f1c-af245ebe5ce6"", + ""orgName"": ""科右前旗康立寿医院"", + ""regId"": ""123456"" + } + ]"; + string msg = Post(_url + "/admin-api/tblist/patientexamlist/addPatientExamInfo", strjson, "AuthToken", token); + + } + /// + /// 插入影像数据 + /// + /// + /// + private void InsImageInfo(string token, ArrayList arrayList) + { + if (arrayList != null) + { + + int count = 0; + List images = new List(); + foreach (string str in arrayList) + { + count++; + image imageInfo = new image(); + imageInfo.ImageNumber = count.ToString(); + imageInfo.ObjectFile = str; + imageInfo.UrlPrefix = _blprefix; + images.Add(imageInfo); + + } + Series series = new Series + { + SeriesNumb = "1", + SeriesDesc = "病理", + Modality = "CSH1", + image = images + }; + + //检查项目信息 + Study study = new Study + { + StudyDescr = "病理", + StudyID = "Z0000000033", + StudyModal = "CSH1", + Series = new List { series } + }; + //患者信息 + Patient patient = new Patient + { + PatientID = "123456", + PatientNam = "病理测试插入患者", + PatientBir = "511200000000", + PatientSex = "F", + OrgId = "9f65555c-ce59-4f4c-8f1c-af245ebe5ce6", + OrgName = "测试插入1", + StudyDate = "2024-9-20 13:03:30", + Studies = new List { study } + }; + List patientList = new List(); + patientList.Add(patient); + // 将对象转换为JSON字符串 + string json = JsonConvert.SerializeObject(patientList); + + string msg = Post(_url + "/admin-api/ultrasoniccom/ultrasonic/InsImageInfo", json, "AuthToken", token); + } + + + + + } + #endregion + + #region 钩子相关 + //定义变量 + public delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam); + static int hKeyboardHook = 0; + HookProc KeyboardHookProcedure; + + /************************* + * 声明API函数 + * ***********************/ + + // 安装钩子 (using System.Runtime.InteropServices;) + [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId); + // 卸载钩子 + [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern bool UnhookWindowsHookEx(int idHook); + // 继续下一个钩子 + [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int CallNextHookEx(int idHook, int nCode, Int32 wParam, IntPtr lParam); + // 取得当前线程编号(线程钩子需要用到) + [DllImport("kernel32.dll")] + static extern int GetCurrentThreadId(); + + //钩子子程:就是钩子所要做的事情 + private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam) + { + if (nCode >= 0) + { + /**************** + //线程键盘钩子判断是否按下键 + Keys keyData = (Keys)wParam; + if(lParam.ToInt32() > 0) + { + // 键盘按下 + } + if(lParam.ToInt32() < 0) + { + // 键盘抬起 + } + ****************/ + + /**************** + //全局键盘钩子判断是否按下键 + wParam = = 0x100 // 键盘按下 + wParam = = 0x101 // 键盘抬起 + ****************/ + KeyMSG m = (KeyMSG)Marshal.PtrToStructure(lParam, typeof(KeyMSG));//键盘 + Keys key = (Keys)m.vkCode; + if (wParam == 0x100) // WM_KEYDOWN + { + string keyString = key.ToString(); + // MessageBox.Show(keyString); + + if (keyString == strkey) + { + SaveImageDcm(); + } + switch (keyString) + { + case "F6": + if (!IsStartVideo) + { + btn_StartVideo_Click(null, null); + } + break; + case "F7": + btn_PauseVideo_Click(null, null); + break; + case "F8": + if (IsStartVideo) + { + btn_EndVideo_Click(null, null); + } + break; + case "F9": + btn_Capture_Click(null, null); + break; + + } + // MessageBox.Show("Key down: " + key.ToString()); + + } + else if (wParam == 0x101) // WM_KEYUP + { + // MessageBox.Show("Key up: " + key.ToString()); + } + + + // return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); + return 0;//如果返回1,则结束消息,这个消息到此为止,不再传递。如果返回0或调用CallNextHookEx函数则消息出了这个钩子继续往下传递,也就是传给消息真正的接受者 + } + return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); + } + + //键盘结构 + public struct KeyMSG + { + public int vkCode; //键值 + public int scanCode; + public int flags; + public int time; + public int dwExtraInfo; + } + // 安装钩子 + public void HookStart() + { + if (hKeyboardHook == 0) + { + // 创建HookProc实例 + KeyboardHookProcedure = new HookProc(KeyboardHookProc); + // 设置线程钩子 + + hKeyboardHook = SetWindowsHookEx(13, KeyboardHookProcedure, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0); + + //************************************ + //键盘线程钩子 + //SetWindowsHookEx( 2,KeyboardHookProcedure, IntPtr.Zero, GetCurrentThreadId()); + //键盘全局钩子,需要引用空间(using System.Reflection;) + //SetWindowsHookEx( 13,KeyboardHookProcedure,Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]),0); + // + //关于SetWindowsHookEx (int idHook, HookProc lpfn, IntPtr hInstance, int threadId)函数将钩子加入到钩子链表中,说明一下四个参数: + //idHook 钩子类型,即确定钩子监听何种消息,上面的代码中设为2,即监听键盘消息并且是线程钩子,如果是全局钩子监听键盘消息应设为13, + //线程钩子监听鼠标消息设为7,全局钩子监听鼠标消息设为14。 + // + //lpfn 钩子子程的地址指针。如果dwThreadId参数为0 或是一个由别的进程创建的线程的标识,lpfn必须指向DLL中的钩子子程。 除此以外,lpfn可 + //以指向当前进程的一段钩子子程代码。钩子函数的入口地址,当钩子钩到任何消息后便调用这个函数。 + // + //hInstance应用程序实例的句柄。标识包含lpfn所指的子程的DLL。如果threadId 标识当前进程创建的一个线程,而且子程代码位于当前 + //进程,hInstance必须为NULL。可以很简单的设定其为本应用程序的实例句柄。 + // + //threadedId 与安装的钩子子程相关联的线程的标识符。如果为0,钩子子程与所有的线程关联,即为全局钩子。 + //************************************ + + + // 如果设置钩子失败 + if (hKeyboardHook == 0) + { + HookStop(); + throw new Exception("SetWindowsHookEx failed."); + } + } + } + // 卸载钩子 + public void HookStop() + { + bool retKeyboard = true; + if (hKeyboardHook != 0) + { + retKeyboard = UnhookWindowsHookEx(hKeyboardHook); + hKeyboardHook = 0; + } + if (!(retKeyboard)) + throw new Exception("UnhookWindowsHookEx failed."); + } + + + #endregion + /// + /// 是否开启区域截图 + /// + /// + /// + private void checkBox1_Click(object sender, EventArgs e) + { + if (!checkBox1.Checked) + { + txt_x.Enabled = false; + txt_y.Enabled = false; + txt_w.Enabled = false; + txt_h.Enabled = false; + } + else + { + txt_x.Enabled = true; + txt_y.Enabled = true; + txt_w.Enabled = true; + txt_h.Enabled = true; + } + } + /// + /// 双击患者列 选中患者 + /// + /// + /// + private void dGVPatient_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + // 检查是否双击了整行 + if (e.RowIndex >= 0) // 确保是行内的单元格被双击 + { + // 获取当前行的所有单元格 + DataGridViewRow row = dGVPatient.Rows[e.RowIndex]; + rowhisinfo = (HisInfo)row.DataBoundItem; + label3.Text = "双击选择患者" + " 当前患者:" + rowhisinfo.name; + + + } + } + /// + /// 患者数据上传 + /// + /// + /// + private void button4_Click(object sender, EventArgs e) + { + if (rowhisinfo == null) + { + MessageBox.Show("请选择患者"); + return; + } + if (imagearray.Count <= 0 && string.IsNullOrEmpty(videoName)) + { + MessageBox.Show("暂无需要上传的患者和文件"); + return; + } + this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 + + ProcessForm form = new ProcessForm(this.backgroundWorker1);// 显示进度条窗体 + form.ShowDialog(this); + form.Close(); + MessageBox.Show("上传成功"); + } + + + #region 线程执行 + + private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + if (e.Error != null) + { + MessageBox.Show(e.Error.Message); + } + else if (e.Cancelled) + { + } + else + { + } + } + + //你可以在这个方法内,实现你的调用,方法等。 + private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) + { + BackgroundWorker worker = sender as BackgroundWorker; + + //上传图片 + #region 上传图片 + + string returnStr = string.Empty; + foreach (var item in imagearray) + { + string fileName = System.IO.Path.GetFileName(item.ToString()); + if (_model == "0") + { + returnStr = SaveFile(item.ToString(), ConfigurationManager.AppSettings["filepath"] + "\\" + rowhisinfo.jianchaid, fileName.Split('.')[0], "jpg"); + } + else + { + returnStr = FtpHelper.FileUpLoad(item.ToString(), ConfigurationManager.AppSettings["path1"], fileName);//上传文件 + } + + if (!string.IsNullOrEmpty(returnStr) && returnStr == "上传成功") + { + //上传成功 清除文件 + try + { + UploadFileUrl(fileName, ".jpg"); + // 删除文件 + File.Delete(item.ToString()); + worker.ReportProgress(10); + } + catch (IOException ex) + { + MessageBox.Show("删除文件时出错: " + ex.Message); + return; + } + catch (UnauthorizedAccessException ex) + { + MessageBox.Show("没有权限删除文件: " + ex.Message); + return; + } + + } + } + + #endregion + + #region 上传视频 + if (!string.IsNullOrEmpty(videoName)) + { + bool fileExists = File.Exists(videoName); + if (fileExists) + { + string newfilename = ConvertVideo(videoName); + if (_model == "0") + { + returnStr = SaveFile(newfilename, ConfigurationManager.AppSettings["filepath"] + "\\" + rowhisinfo.jianchaid, fileName, "mp4"); + } + else + { + returnStr = FtpHelper.FileUpLoad(newfilename, ConfigurationManager.AppSettings["path1"], fileName + ".mp4");//上传文件 + } + + if (!string.IsNullOrEmpty(returnStr) && returnStr == "上传成功") + { + //上传成功 清除文件 + try + { + UploadFileUrl(fileName + ".mp4", ".mp4"); + // 删除文件 + File.Delete(videoName); + // 删除文件 + File.Delete(newfilename); + worker.ReportProgress(10); + } + catch (IOException ex) + { + MessageBox.Show("删除文件时出错: " + ex.Message); + return; + } + catch (UnauthorizedAccessException ex) + { + MessageBox.Show("没有权限删除文件: " + ex.Message); + return; + } + this.Invoke(new Action(() => + { + tick_num = 0; + lab_Time.Text = "00:00:00"; + })); + } + } + } + + #endregion + + #region 插入患者 + worker.ReportProgress(70); + string token = Get(_url + "/admin-api/system/jwtToken/getToken?key_public=c4c7dde887706361d8480909043bfdbd"); + if (!string.IsNullOrEmpty(token)) + { + MsgInfo person = JsonConvert.DeserializeObject(token); + List Record = new List(); + + ExamRecord examRecord = new ExamRecord(); + examRecord.examId = rowhisinfo.jianchabh + "_" + GetRandomNumber(1, 100); + examRecord.pname = rowhisinfo.name; + examRecord.gender = rowhisinfo.sex; + examRecord.birthday = GetTimestampFromBirthdate(rowhisinfo.birthdate).ToString(); + examRecord.deviceType = "US";//rowhisinfo.category + examRecord.deviceName = "彩超"; + examRecord.seDc = "1/1"; + examRecord.examDate = GetTimestampFromdate(rowhisinfo.kaifangsj).ToString(); + examRecord.examItemName = rowhisinfo.jianchamingcheng; + examRecord.examItemCode = rowhisinfo.nhbm; + examRecord.reportstatus = "待分析"; + examRecord.applicationDate = GetTimestampFromdate(rowhisinfo.kaifangsj).ToString(); + examRecord.orgId = rowhisinfo.yiyuancode;//9f65555c-ce59-4f4c-8f1c-af245ebe5ce6 rowhisinfo.yiyuanid + examRecord.orgName = rowhisinfo.yiyuanname; + examRecord.regId = rowhisinfo.jianchaid; + Record.Add(examRecord); + + + var json = JsonConvert.SerializeObject(Record); + string msg = Post(_url + "/admin-api/tblist/patientexamlist/addPatientExamInfo", json, "AuthToken", person.data); + worker.ReportProgress(100); + this.Invoke(new Action(() => + { + //截图数量置为0 + label1.Text = "0"; + //选择患者置为空 + rowhisinfo = null; + imagearray.Clear(); + videoName = string.Empty; + label3.Text = "双击选择患者"; + })); + + } + + #endregion + + } + #endregion + + + + + private void gb_ButtonBox_Enter(object sender, EventArgs e) + { + + } + + public static int GetRandomNumber(int minValue, int maxValue) + { + Random random = new Random(); // 实例化Random类 + return random.Next(minValue, maxValue); // 返回一个随机整数 + } + + // 获取当前时间的Unix时间戳(毫秒) + public static string GetCurrentTimestamp() + { + // DateTime.UtcNow 获取当前UTC时间 + // Subtract 方法减去1970年1月1日的时间 + // TotalMilliseconds 获取总毫秒数 + return DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString(); + } + + // 将指定的出生日期转换为Unix时间戳(毫秒) + public static long GetTimestampFromBirthdate(string birthdate) + { + + // 尝试解析日期字符串 + DateTime birthDateTime; + if (DateTime.TryParseExact(birthdate, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out birthDateTime)) + { + // 将本地时间转换为UTC时间 + DateTime birthDateTimeUtc = birthDateTime.ToUniversalTime(); + // 计算时间戳 + TimeSpan elapsedTime = birthDateTimeUtc - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + return (long)elapsedTime.TotalMilliseconds; + } + else + { + // 如果日期格式不正确,抛出异常 + throw new ArgumentException("无效的日期格式。正确的格式应该是yyyy-MM-dd。"); + } + } + + public static long GetTimestampFromdate(string birthdate) + { + + // 尝试解析日期字符串 + DateTime birthDateTime; + if (DateTime.TryParseExact(birthdate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out birthDateTime)) + { + + // 将本地时间转换为UTC时间 + DateTime birthDateTimeUtc = birthDateTime.ToUniversalTime(); + // 计算时间戳 + return (long)birthDateTimeUtc.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; + } + else + { + // 如果日期格式不正确,抛出异常或返回0 + throw new ArgumentException("无效的日期格式。正确的格式应该是yyyy-MM-dd。"); + // 或者返回0,取决于你希望如何处理错误 + // return 0; + } + } + /// + /// 刷新患者 + /// + /// + /// + private void button1_Click_1(object sender, EventArgs e) + { + GetHisInfo(); + } + + private void button5_Click(object sender, EventArgs e) + { + // 创建一个OpenFileDialog实例 + OpenFileDialog openFileDialog = new OpenFileDialog(); + + try + { + // 设置OpenFileDialog的属性 + openFileDialog.InitialDirectory = "C:\\"; // 初始目录 + openFileDialog.Title = "请选择一个图像文件"; // 对话框标题 + openFileDialog.Filter = "图像文件 (*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp"; // 文件过滤器 + + // 显示OpenFileDialog + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + // 获取选中的文件路径 + string selectedFilePath = openFileDialog.FileName; + using (FileStream fs = new FileStream(selectedFilePath, FileMode.Open, FileAccess.Read)) + { + using (Bitmap bitmap = new Bitmap(fs)) + { + bool bol = Imaganddcm.ImportImage("M20241025", "202410253", "202410253", "树艳", bitmap, _blpath); + } + } + + + } + } + catch (Exception ex) + { + // 异常处理 + Console.WriteLine("发生异常:" + ex.Message); + } + + } + + #region 调用接口上传文件 + /// + /// 调用接口上传文件 + /// + /// 文件所在的路径 + /// 文件保存的文件夹路径 + /// 文件名(不包含扩展名) + /// 文件扩展名(例如 "png", "jpg", "txt") + /// + private string SaveFile(string imageBase, string folderPath, string fileName, string extension) + { + string base64String = ConvertFileToBase64(imageBase); + if (string.IsNullOrEmpty(base64String)) + { + return "文件为空"; + } + SaveFile saveFile = new SaveFile(); + saveFile.imagebase = base64String; + saveFile.folderPath = folderPath; + saveFile.fileName = fileName; + saveFile.extension = extension; + + var json = JsonConvert.SerializeObject(saveFile); + string msg = Post(_url + "/admin-api/ultrasoniccom/ultrasonic/SaveFileBase64", json); + return msg; + } + + /// + /// 文件转换成base64 + /// + /// + /// + /// + private string ConvertFileToBase64(string filePath) + { + string base64String = string.Empty; + // 确保文件存在 + if (File.Exists(filePath)) + { + // 读取文件内容到字节数组中 + byte[] fileBytes = File.ReadAllBytes(filePath); + + // 将字节数组转换为Base64字符串 + base64String = Convert.ToBase64String(fileBytes); + } + return base64String; + } + #endregion + + /// + /// 添加患者 + /// + /// + /// + private void button6_Click(object sender, EventArgs e) + { + InfoForm infoForm = new InfoForm(); + if (infoForm.ShowDialog() == DialogResult.OK) + { + //先赋空再绑定 + dGVPatient.DataSource=null; + hisInfos.Add(infoForm.info); + dGVPatient.DataSource = hisInfos; + rowhisinfo = null; + } + } + } + +} diff --git a/video.resx b/video.resx new file mode 100644 index 0000000..9a14eca --- /dev/null +++ b/video.resx @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + + + + AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAADJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQoAAAAAAADJsQrJsQrJ + sQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrIsArJsQoAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAADJsQrIsArJsQoAAAAAAAAAAAAAAADJsQrJsQrJsQrJsQrIsAkA + AAAAAAAAAAAAAADJsQrIsArJsQoAAAAAAADJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQoAAAAAAADJ + sQrIsArJsQoAAADJsQrJsQoAAAAAAADJsQrJsQrJsQoAAAAAAADJsQrJsQoAAADJsQrIsArJsQoAAAAA + AADJsQoAAADJsQrJsQrJsQrJsQrJsQoAAADJsQoAAAAAAADJsQrIsArJsQoAAAAAAADJsQoAAAAAAAAA + AAAAAAAAAAAAAAAAAADJsQoAAAAAAADJsQrIsArJsQoAAAAAAADJsQrJsQoAAADJsQrJsQrJsQoAAADJ + sQrJsQoAAAAAAADJsQrIsArJsQoAAAAAAAAAAADJsQoAAAAAAAAAAAAAAAAAAADJsQoAAAAAAAAAAADJ + sQrIsArJsQoAAAAAAAAAAADJsQrJsQrJsQrJsQrJsQrJsQrJsQoAAAAAAAAAAADJsQrIsArJsQoAAAAA + AAAAAAAAAADJsQrJsQrJsQrJsQrJsQrIrQkAAAAAAAAAAADJsQrIsArJsQoAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAADJsQoAAADJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJ + sQrJsQrJsQrJsQrJsQoAAAAAAADJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQrJsQoA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAQAAgAAAAD/+ + AAA8HgAAMAYAACYyAAA0FgAAN/YAADImAAA77gAAOA4AADwOAAA//gAAgAAAAMABAAD//wAA + + + \ No newline at end of file diff --git a/videoGather.csproj b/videoGather.csproj new file mode 100644 index 0000000..d3673a3 --- /dev/null +++ b/videoGather.csproj @@ -0,0 +1,189 @@ + + + + + Debug + AnyCPU + {2990C129-31D9-4AA3-B10D-D2773F140FF4} + WinExe + videoGather + videoGather + v4.6.1 + 512 + true + true + + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + true + + + 超声.ico + + + + packages\AForge.2.2.5\lib\AForge.dll + + + packages\AForge.Controls.2.2.5\lib\AForge.Controls.dll + + + packages\AForge.Imaging.2.2.5\lib\AForge.Imaging.dll + + + packages\AForge.Math.2.2.5\lib\AForge.Math.dll + + + packages\AForge.Video.2.2.5\lib\AForge.Video.dll + + + packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll + + + packages\AForge.Video.FFMPEG.2.2.5.1-rc\lib\AForge.Video.FFMPEG.dll + + + packages\fo-dicom.Desktop.4.0.0\lib\net45\Dicom.Core.dll + + + packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + InfoForm.cs + + + + + + Form + + + ProcessForm.cs + + + + + + Form + + + video.cs + + + + + InfoForm.cs + + + ProcessForm.cs + + + video.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + + + \ No newline at end of file diff --git a/videoGather.sln b/videoGather.sln new file mode 100644 index 0000000..7358064 --- /dev/null +++ b/videoGather.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34916.146 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "videoGather", "videoGather.csproj", "{2990C129-31D9-4AA3-B10D-D2773F140FF4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Debug|x86.ActiveCfg = Debug|x86 + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Debug|x86.Build.0 = Debug|x86 + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Release|Any CPU.Build.0 = Release|Any CPU + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Release|x86.ActiveCfg = Release|x86 + {2990C129-31D9-4AA3-B10D-D2773F140FF4}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3E17FD25-7A81-4A33-875D-BBE10821FECA} + EndGlobalSection +EndGlobal diff --git a/超声.ico b/超声.ico new file mode 100644 index 0000000..5b15972 Binary files /dev/null and b/超声.ico differ diff --git a/超声诊断仪.ico b/超声诊断仪.ico new file mode 100644 index 0000000..ea03ce8 Binary files /dev/null and b/超声诊断仪.ico differ