基本信息
源码名称:Dicom图像自动接收并上传
源码大小:18.78M
文件格式:.rar
开发语言:C#
更新时间:2017-10-05
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
DICOM图像自动接收并上传

 /// <summary>
        /// 上传
        /// </summary>
        /// <param name="obj"></param> 
        /// 
        private void upload(object obj)
        {
            //定义文件路径
            string sPath = string.Empty;
            //定义文件的数量
            int num;
            //定义连接的数据库
            SQLiteConnection sQLiteConnection = new SQLiteConnection("Data Source=" Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HCPACS.db3"));
            try
            {
                //判断时间秒数小于10秒之差自动上传
                string newDateTime = DateTime.Now.AddSeconds(-10.0).ToString("yyyy-MM-dd HH:mm:ss");
                //打开数据库
                sQLiteConnection.Open();
                string strsql = "select * from pacs_study where Status='' and updateDateTime<'" newDateTime "' limit 0,1";
                SQLiteDataAdapter sQLiteDataAdapter = new SQLiteDataAdapter(strsql, sQLiteConnection);
                DataSet ds = new DataSet();
                sQLiteDataAdapter.Fill(ds);
                //判断ds是否null 数据为0
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    timerClose.Dispose();
                    IEnumerator iEnumerator = ds.Tables[0].Rows.GetEnumerator();
                    DataRow dr;
                    while (iEnumerator.MoveNext())
                    {
                        dr = (DataRow)iEnumerator.Current;
                        //获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用Invoke方法
                        if (listView1.InvokeRequired)
                        {
                            //委托代理
                            listView1.Invoke(new MethodInvoker(delegate
                                {
                                    ListViewItem listViewItem = new ListViewItem(dr["PatientID"].ToString());//患者检查号
                                    listViewItem.SubItems.Add(dr["PatientName"].ToString());//患者姓名
                                    listViewItem.SubItems.Add(dr["PatientSex"].ToString());//患者性别
                                    listViewItem.SubItems.Add(dr["PatientAge"].ToString());//患者年龄
                                    listViewItem.SubItems.Add(dr["StudyDateTime"].ToString());//检查时间
                                    listViewItem.SubItems.Add(dr["Modality"].ToString());//检查类型
                                    listViewItem.SubItems.Add(dr["DicomCount"].ToString());//图像数量
                                    listViewItem.SubItems.Add("正在压缩中...");//状态
                                    listViewItem.SubItems.Add(dr["StudyID"].ToString());//自动生成的StudyID        
                                    listViewItem.SubItems.Add(dr["StudyUID"].ToString());
                                    for (int i = 0; i < listView1.Items.Count; i )
                                    {
                                        if (dr["StudyUID"].ToString().Equals(listView1.Items[i].SubItems[9].Text))
                                        {
                                            listView1.Items[i].Remove();
                                        }
                                    }
                                    //插入到集合中指定的索引处
                                    listView1.Items.Insert(0, listViewItem);
                                }));
                        }
                        try
                        {
                            //创建压缩的路径、名字
                            num = int.Parse(dr["DicomCount"].ToString());//得到图像的数量
                            sPath = dr["Path"].ToString();//得到需要压缩图像的路径
                            //定义需要压缩文件的路径以及名字
                            string str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DicomZip\\" dr["StudyUID"].ToString() ".zip");
                            //判断DicomZip是否存在
                            if (!Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DicomZip")))
                            {
                                Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DicomZip"));
                            }
                            //开始压缩文件
                            Utility utility = new Utility();
                            utility.ZipFile(sPath, str);
                            notifyIcon1.ShowBalloonTip(100, "提示", "图像压缩完毕,上传中...", ToolTipIcon.Info);
                            if (listView1.InvokeRequired)
                            {
                                listView1.Invoke(new MethodInvoker(delegate
                                    {
                                        listView1.Items[0].SubItems[7].Text = "上传中...";
                                    }));
                            }
                            //同时更改表pacs_study中字段Status
                            strsql = "select DicomCount from pacs_study where StudyID='" dr["StudyID"].ToString() "' ";
                            SQLiteCommand sQLiteCommand = new SQLiteCommand(strsql, sQLiteConnection);
                            //判断图像数量是否一样
                            if (int.Parse(sQLiteCommand.ExecuteScalar().ToString()) == num)
                            {
                                strsql = "update pacs_study set Status='上传中...' where StudyID='" dr["StudyID"].ToString() "'";
                                sQLiteCommand = new SQLiteCommand(strsql, sQLiteConnection);
                                sQLiteCommand.ExecuteNonQuery();
                            }