Beispiel #1
0
        void dgvTZLY_Down_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                var PGUID = dgvTZLY_Down.Rows[e.RowIndex].Cells[0].Value + "";
                switch (dgvTZLY_Down.Columns[e.ColumnIndex].Name)
                {
                case "dgvTZLYDwonDetail":
                {
                    var dt              = Mediator.sqliteHelper.ExecuteDatatable("select * from PatientInfoDown where PatientGUID={0} and Downer={1}", PGUID, this.cbBoxTZLY.Text);
                    var row             = dt.Rows[0];
                    var formAudioDetail = new FrmAudioDetail()
                    {
                        StetName    = this.cbBoxTZLY.Text,
                        PatientGUID = row["PatientGUID"] + "",
                        PatientID   = row["PatientID"] + "",
                        PatientName = row["PatientName"] + "",
                        DocName     = row["DocName"] + "",
                        PatientSex  = row["PatientSex"] + "",
                        PatientAge  = int.Parse(("0" + row["PatientAge"])),
                        DocDiagnose = row["DocDiagnose"] + "",
                        DocRemark   = row["DocRemark"] + "",
                        His         = row["Flag"] + "",
                        IInfo       = new LocalDown()
                    };
                    formAudioDetail.ShowDialog();
                }
                break;

                case "dgvTZLYDownDelete":
                {
                    if (DialogResult.OK == MessageBox.Show("你确定要删除该记录及其文件吗", "删除录音提示", MessageBoxButtons.OKCancel))
                    {
                        var k  = Mediator.sqliteHelper.ExecuteNonQuery("delete from PatientInfoDown where PatientGUID={0} and Downer={1}", PGUID, this.cbBoxTZLY.Text);
                        var dt = Mediator.sqliteHelper.ExecuteDatatable("select * from AudioInfoDown where PGUID={0}", PGUID);
                        foreach (DataRow row in dt.Rows)
                        {
                            var    guid       = row["GUID"] + "";
                            var    recordTime = (DateTime)row["RecordTime"];
                            string filePath   = Path.Combine(Setting.localData, @"DevicesData\DowmLoad\" + recordTime.Year
                                                             + "\\" + recordTime.Month + "\\" + recordTime.Day + "\\" + guid + ".MP3");
                            if (File.Exists(filePath))
                            {
                                File.Delete(filePath);
                            }
                        }
                        k = Mediator.sqliteHelper.ExecuteNonQuery("delete from AudioInfoDown where PGUID={0}", PGUID);
                        MessageBox.Show("删除成功");
                    }
                    LoadStetInfoTZLYDown();
                }
                break;
                }
            }
        }
Beispiel #2
0
        void dgvYDTZUpLoad_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!Setting.isConnected)
            {
                MessageBox.Show("网络连接异常...");
                return;
            }
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                var PGUID       = dgvYDTZUpLoad.Rows[e.RowIndex].Cells[0].Value + "";
                var PatientType = Setting.GetPatientTypeByName(dgvYDTZUpLoad.Rows[e.RowIndex].Cells[1].Value + "");
                var PatientName = dgvYDTZUpLoad.Rows[e.RowIndex].Cells[2].Value + "";
                //var CreateTime = (DateTime)dgvYDTZUpLoad.Rows[e.RowIndex].Cells[6].Value;
                switch (dgvYDTZUpLoad.Columns[e.ColumnIndex].Name)
                {
                case "dgvYDTZUpLoadDown":
                {
                    Mediator.ShowMsg("开始下载已上传的录音文件...");
                    using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                    {
                        MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        #region  载患者信息
                        string sqlPatient = "select * from PatientInfo where PatientGUID={0}";
                        var    ds         = Mediator.remoteService.ExecuteDataset(sqlPatient, new string[] { PGUID });
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            MessageBox.Show("分享信息 " + PGUID + " 被分享者删除了...");
                            return;
                        }
                        var r           = ds.Tables[0].Rows[0];
                        var patientInfo = new
                        {
                            StetName       = r["StetName"] + "",
                            PatientGroupID = (int)r["PatientGroupID"],
                            PatientID      = r["PatientID"] + "",
                            PatientName    = r["PatientName"] + "",
                            PatientSex     = r["PatientSex"] + "",
                            PatientAge     = (int)r["PatientAge"],
                            DocName        = r["DocName"] + "",
                            DocDiagnose    = r["DocDiagnose"] + "",
                            DocRemark      = r["DocRemark"] + "",
                            Flag           = r["Flag"] + "",
                        };
                        var sqlQueryDown = "select count(0) from PatientInfoDown where PatientGUID={0} and Downer={1}";
                        if (int.Parse(Mediator.sqliteHelper.ExecuteScalar(sqlQueryDown, PGUID, this.cbBoxYDTZ.Text).ToString()) == 0)
                        {
                            //下载自己上传的听诊  分享者=自己
                            var h = Mediator.sqliteHelper.ExecuteNonQuery(@"insert into PatientInfoDown(PatientGUID,StetName,PatientType,PatientGroupID ,PatientID,PatientName ,PatientSex,PatientAge
  ,DocName,DocDiagnose,DocRemark,Flag,Sharer,ShareTime,Downer ) select {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", PGUID, patientInfo.StetName, PatientType, patientInfo.PatientGroupID, patientInfo.PatientID, patientInfo.PatientName, patientInfo.PatientSex, patientInfo.PatientAge
                                                                          , patientInfo.DocName, patientInfo.DocDiagnose, patientInfo.DocRemark, patientInfo.Flag, null, null, this.cbBoxYDTZ.Text);
                            if (h > 0)
                            {
                                Mediator.ShowMsg(string.Format("患者{0}信息下载成功...", patientInfo.PatientName));
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            var h = Mediator.sqliteHelper.ExecuteNonQuery(@"update PatientInfoDown set DocName={0}, DocDiagnose={1},DocRemark={2},PatientID={4},PatientName={5},Flag={6} ,PatientSex={7},PatientAge={8}
  where PatientGUID={3}", patientInfo.DocName, patientInfo.DocDiagnose, patientInfo.DocRemark, PGUID, patientInfo.PatientSex, patientInfo.PatientAge);
                            // if (h > 0) Mediator.ShowMsg(string.Format("患者{0}信息更新成功...", PatientName));
                            if (h <= 0)
                            {
                                return;
                            }
                        }
                        //写下载记录
                        string sqlInsertDownLog = "insert into AudioDownLoadInfo (GUID,Downer) select {0},{1}";
                        Mediator.remoteService.ExecuteNonQuery(sqlInsertDownLog, new string[] { PGUID, this.cbBoxYDTZ.Text });

                        #endregion
                        #region   载录音信息 每次覆盖下载 保证最新
                        var sqlDelLocal = "delete from AudioInfoDown where PGUID={0}";
                        var c           = Mediator.sqliteHelper.ExecuteNonQuery(sqlDelLocal, PGUID);
                        var sqlReomte   = "select * from AudioInfo where PGUID={0}";
                        var dsAudioInfo = Mediator.remoteService.ExecuteDataset(sqlReomte, new string[] { PGUID });

                        foreach (DataRow row in dsAudioInfo.Tables[0].Rows)
                        {
                            var audioInfo = new
                            {
                                GUID       = row["GUID"] + "",
                                PGUID      = row["PGUID"] + "",
                                StetName   = row["StetName"] + "",
                                Part       = row["Part"] + "",
                                TakeTime   = (int)row["TakeTime"],
                                RecordTime = (DateTime)row["RecordTime"],
                                UpLoadTime = (DateTime)row["CreateTime"],
                            };
                            string sqlInsert = @"insert into AudioInfoDown( GUID, PGUID, StetName , Part, TakeTime 
  , RecordTime ,UpLoadTime ) select {0},{1},{2} ,{3},{4}  ,{5},{6}";
                            var    n         = Mediator.sqliteHelper.ExecuteNonQuery(sqlInsert, audioInfo.GUID, audioInfo.PGUID, audioInfo.StetName, audioInfo.Part, audioInfo.TakeTime
                                                                                     , audioInfo.RecordTime, audioInfo.UpLoadTime);
                            if (n > 0)
                            {
                                string fileLocalPath = Path.Combine(Setting.localData, @"DevicesData\DowmLoad\" + audioInfo.RecordTime.Year
                                                                    + "\\" + audioInfo.RecordTime.Month + "\\" + audioInfo.RecordTime.Day + "\\" + audioInfo.GUID + ".MP3");
                                if (File.Exists(fileLocalPath))
                                {
                                    File.Delete(fileLocalPath);
                                }
                                var fileRemotePath = Mediator.remoteService.GetFilePath2(audioInfo.RecordTime, audioInfo.GUID);
                                var fileSize       = Mediator.remoteService.GetFileLength(fileRemotePath);
                                //下载文件
                                if (!Directory.Exists(Path.GetDirectoryName(fileLocalPath)))
                                {
                                    Directory.CreateDirectory(Path.GetDirectoryName(fileLocalPath));
                                }
                                using (var stream = new FileStream(fileLocalPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                                {
                                    long position = 0;
                                    while (position < fileSize)
                                    {
                                        var bytes = Mediator.remoteService.DownLoadFile(fileRemotePath, position, 24 * 1024);
                                        position += bytes.Length;
                                        stream.Write(bytes, 0, bytes.Length);
                                    }
                                    stream.Close();
                                }
                                Mediator.WriteLog(this.Name, string.Format("文件{0}文件下载成功,下载的听诊器序号为{1}...", audioInfo.GUID, this.cbBoxYDTZ.Text));
                                Mediator.ShowMsg(string.Format("文件{0}下载成功...", audioInfo.GUID));
                            }
                        }
                        //删除本地所有
                        #endregion
                        #region 更新下载记录

                        #endregion

                        //下载附件
                        var remoteRoot = Mediator.remoteService.GetRoot();
                        var remoteDir  = Path.Combine(remoteRoot, string.Format("Enclosure\\{0}", PGUID));
                        if (Mediator.remoteService.isExistFolder(remoteDir))
                        {
                            var remoteFiles = Mediator.remoteService.GetFolderFiles(remoteDir, "*.*", true);
                            if (remoteFiles != null)
                            {
                                foreach (var remoteFile in remoteFiles)
                                {
                                    var fileSize      = Mediator.remoteService.GetFileLength(remoteFile);
                                    var fileLocalPath = string.Format("Enclosure\\Down\\{0}\\{1}", PGUID, Path.GetFileName(remoteFile));
                                    if (!Directory.Exists(Path.GetDirectoryName(fileLocalPath)))
                                    {
                                        Directory.CreateDirectory(Path.GetDirectoryName(fileLocalPath));
                                    }
                                    using (var stream = new FileStream(fileLocalPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                                    {
                                        long position = 0;
                                        while (position < fileSize)
                                        {
                                            var bytes = Mediator.remoteService.DownLoadFile(remoteFile, position, 24 * 1024);
                                            position += bytes.Length;
                                            stream.Write(bytes, 0, bytes.Length);
                                        }
                                        stream.Close();
                                    }
                                }
                            }
                        }
                    }
                }
                break;

                case "dgvYDTZUpLoadShare":
                {
                    using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                    {
                        MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        var formShare = new FrmShare(this.cbBoxYDTZ.Text);
                        if (formShare.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            var    selectStets = formShare.SelectedStethoscope;
                            string sql         = "SELECT * from  AudioShare where SrcStetName={0} and PatientGUID={1}";
                            var    ds          = Mediator.remoteService.ExecuteDataset(sql, new string[] { this.cbBoxYDTZ.Text, PGUID, });
                            string insertSql   = "insert into AudioShare(PatientGUID,PatientType,PatientName,SrcStetName,ToStetName) select {0},{1},{2},{3},{4}";
                            foreach (var toName in formShare.SelectedStethoscope)
                            {
                                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Select("ToStetName='" + toName + "'").Length > 0)
                                {
                                    Mediator.ShowMsg(string.Format("患者{0}听诊记录已经被{1}分享过给{2}了...", PatientName, this.cbBoxYDTZ.Text, toName));
                                    continue;
                                }
                                int n = Mediator.remoteService.ExecuteNonQuery(insertSql, new string[] { PGUID, PatientType + "", PatientName, this.cbBoxYDTZ.Text, toName });
                                if (n > 0)
                                {
                                    Mediator.ShowMsg(string.Format("患者{0}听诊记录成功被{1}分享给{2}...", PatientName, this.cbBoxYDTZ.Text, toName));
                                }
                                Mediator.WriteLog(this.Name, string.Format("患者{0}听诊记录被{1}分享给{2}...", PatientName, this.cbBoxYDTZ.Text, toName));
                            }
                        }
                    }
                }
                break;

                case "dgvYDTZLoaclDetail":
                {
                    using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                    {
                        MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        var ds              = Mediator.remoteService.ExecuteDataset("select * from PatientInfo where PatientGUID={0}", new string[] { PGUID });
                        var row             = ds.Tables[0].Rows[0];
                        var formAudioDetail = new FrmAudioDetail()
                        {
                            PatientGUID = row["PatientGUID"] + "",
                            PatientID   = row["PatientID"] + "",
                            PatientName = row["PatientName"] + "",
                            PatientSex  = row["PatientSex"] + "",
                            PatientAge  = (int)row["PatientAge"],
                            DocName     = row["DocName"] + "",
                            DocDiagnose = row["DocDiagnose"] + "",
                            DocRemark   = row["DocRemark"] + "",
                            His         = row["Flag"] + "",

                            IInfo = new CloudUpload()
                        };
                        formAudioDetail.ShowDialog();
                    }
                }
                break;

                case "dgvYDTZLoaclDelete":
                    if (DialogResult.OK == MessageBox.Show("你确定要删除该记录及其文件吗", "删除录音提示", MessageBoxButtons.OKCancel))
                    {
                        using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                        {
                            MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                            OperationContext.Current.OutgoingMessageHeaders.Add(header);
                            header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                            OperationContext.Current.OutgoingMessageHeaders.Add(header);
                            var k = Mediator.remoteService.ExecuteNonQuery("delete from PatientInfo where PatientGUID={0}", new string[] { PGUID });
                            if (k > 0)
                            {
                                dgvYDTZUpLoad.Rows.RemoveAt(e.RowIndex);
                                MessageBox.Show("删除上传记录成功...");
                            }
                        }
                    }
                    break;
                }
            }
        }
Beispiel #3
0
        void dgvYDTZShare_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var PGUID       = dgvYDTZShare.Rows[e.RowIndex].Cells[0].Value + "";
            var PatientType = Setting.GetPatientTypeByName(dgvYDTZShare.Rows[e.RowIndex].Cells[1].Value + "");
            var PatientID   = dgvYDTZShare.Rows[e.RowIndex].Cells[2].Value + "";
            var PatientName = dgvYDTZShare.Rows[e.RowIndex].Cells[3].Value + "";

            switch (dgvYDTZShare.Columns[e.ColumnIndex].Name)
            {
            case "dgvYDTZShareDown":
            {
                using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                {
                    MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);
                    header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);
                    #region  载患者信息
                    string sqlPatient  = @" select a.*,b.SrcStetName,b.ToStetName,b.ShareTime from PatientInfo a inner join AudioShare b
  on a.PatientGUID=b.PatientGUID where a.PatientGUID={0} and b.ToStetName={1}";
                    var    ds          = Mediator.remoteService.ExecuteDataset(sqlPatient, new string[] { PGUID, this.cbBoxYDTZ.Text });
                    var    r           = ds.Tables[0].Rows[0];
                    var    patientInfo = new
                    {
                        PatientGroupID = (int)r["PatientGroupID"],
                        DocName        = r["DocName"] + "",
                        DocDiagnose    = r["DocDiagnose"] + "",
                        DocRemark      = r["DocRemark"] + "",
                        Flag           = r["Flag"] + "",
                        Sharer         = r["SrcStetName"] + "",
                        ShareTime      = (DateTime)r["ShareTime"],
                    };
                    var sqlQueryDown = "select count(0) from PatientInfoDown where PatientGUID={0} and Downer={1}";
                    if (int.Parse(Mediator.sqliteHelper.ExecuteScalar(sqlQueryDown, PGUID, this.cbBoxYDTZ.Text).ToString()) == 0)
                    {
                        //下载别人分享的
                        var h = Mediator.sqliteHelper.ExecuteNonQuery(@"insert into PatientInfoDown(PatientGUID,PatientType,PatientGroupID ,PatientID,PatientName 
  ,DocName,DocDiagnose,DocRemark,Flag,Sharer,ShareTime,Downer ) select {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", PGUID, PatientType, patientInfo.PatientGroupID, PatientID, PatientName
                                                                      , patientInfo.DocName, patientInfo.DocDiagnose, patientInfo.DocRemark, patientInfo.Flag, patientInfo.Sharer, patientInfo.ShareTime, this.cbBoxYDTZ.Text);
                        if (h > 0)
                        {
                            Mediator.ShowMsg(string.Format("患者{0}信息下载成功...", PatientName));
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        var h = Mediator.sqliteHelper.ExecuteNonQuery(@"update PatientInfoDown set DocName={0}, DocDiagnose={1},DocRemark={2}
  where PatientGUID={3}", patientInfo.DocName, patientInfo.DocDiagnose, patientInfo.DocRemark, PGUID);
                        // if (h > 0) Mediator.ShowMsg(string.Format("患者{0}信息更新成功...", PatientName));
                        if (h <= 0)
                        {
                            return;
                        }
                    }
                    //写下载记录
                    string sqlInsertDownLog = "insert into AudioDownLoadInfo (GUID,Downer) select {0},{1}";
                    Mediator.remoteService.ExecuteNonQuery(sqlInsertDownLog, new string[] { PGUID, this.cbBoxYDTZ.Text });

                    #endregion
                    #region   载录音信息 每次覆盖下载 保证最新
                    var sqlDelLocal = "delete from AudioInfoDown where PGUID={0} ";
                    var c           = Mediator.sqliteHelper.ExecuteNonQuery(sqlDelLocal, PGUID);
                    var sqlReomte   = "select * from AudioInfo where PGUID={0}  ";
                    var dsAudioInfo = Mediator.remoteService.ExecuteDataset(sqlReomte, new string[] { PGUID });
                    foreach (DataRow row in dsAudioInfo.Tables[0].Rows)
                    {
                        var audioInfo = new
                        {
                            GUID       = row["GUID"] + "",
                            PGUID      = row["PGUID"] + "",
                            StetName   = row["StetName"] + "",
                            Part       = row["Part"] + "",
                            TakeTime   = (int)row["TakeTime"],
                            RecordTime = (DateTime)row["RecordTime"],
                            UpLoadTime = (DateTime)row["CreateTime"],
                        };
                        string sqlInsert = @"insert into AudioInfoDown( GUID, PGUID, StetName , Part, TakeTime 
  , RecordTime, UpLoadTime ) select {0},{1},{2} ,{3},{4}  ,{5},{6}";
                        var    n         = Mediator.sqliteHelper.ExecuteNonQuery(sqlInsert, audioInfo.GUID, audioInfo.PGUID, audioInfo.StetName, audioInfo.Part, audioInfo.TakeTime
                                                                                 , audioInfo.RecordTime, audioInfo.UpLoadTime);
                        if (n > 0)
                        {
                            string fileLocalPath = Path.Combine(Setting.localData, @"DevicesData\DowmLoad\" + audioInfo.RecordTime.Year
                                                                + "\\" + audioInfo.RecordTime.Month + "\\" + audioInfo.RecordTime.Day + "\\" + audioInfo.GUID + ".MP3");
                            if (File.Exists(fileLocalPath))
                            {
                                File.Delete(fileLocalPath);
                            }
                            var fileRemotePath = Mediator.remoteService.GetFilePath2(audioInfo.RecordTime, audioInfo.GUID);
                            var fileSize       = Mediator.remoteService.GetFileLength(fileRemotePath);
                            //下载文件
                            if (!Directory.Exists(Path.GetDirectoryName(fileLocalPath)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(fileLocalPath));
                            }
                            using (var stream = new FileStream(fileLocalPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                            {
                                long position = 0;
                                while (position < fileSize)
                                {
                                    var bytes = Mediator.remoteService.DownLoadFile(fileRemotePath, position, 24 * 1024);
                                    position += bytes.Length;
                                    stream.Write(bytes, 0, bytes.Length);
                                }
                                stream.Close();
                            }
                            Mediator.WriteLog(this.Name, string.Format("文件{0}文件下载成功,下载的听诊器序号为{1}...", audioInfo.GUID, this.cbBoxYDTZ.Text));
                            Mediator.ShowMsg(string.Format("文件{0}下载成功...", audioInfo.GUID));
                        }
                    }
                    #endregion

                    //下载附件
                    var remoteRoot = Mediator.remoteService.GetRoot();
                    var remoteDir  = Path.Combine(remoteRoot, string.Format("Enclosure\\{0}", PGUID));
                    if (Mediator.remoteService.isExistFolder(remoteDir))
                    {
                        var remoteFiles = Mediator.remoteService.GetFolderFiles(remoteDir, "*.*", true);

                        var localFiles = Directory.GetFiles(string.Format("Enclosure\\Down\\{0}", PGUID));


                        if (remoteFiles != null)
                        {
                            foreach (var file in localFiles)
                            {
                                if (!remoteFiles.Select(f => Path.GetFileName(f)).Contains(Path.GetFileName(file)))
                                {
                                    File.Delete(file);
                                }
                            }
                            foreach (var remoteFile in remoteFiles)
                            {
                                var fileSize      = Mediator.remoteService.GetFileLength(remoteFile);
                                var fileLocalPath = string.Format("Enclosure\\Down\\{0}\\{1}", PGUID, Path.GetFileName(remoteFile));
                                if (!Directory.Exists(Path.GetDirectoryName(fileLocalPath)))
                                {
                                    Directory.CreateDirectory(Path.GetDirectoryName(fileLocalPath));
                                }
                                if (File.Exists(fileLocalPath))
                                {
                                    File.Delete(fileLocalPath);
                                }
                                using (var stream = new FileStream(fileLocalPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                                {
                                    long position = 0;
                                    while (position < fileSize)
                                    {
                                        var bytes = Mediator.remoteService.DownLoadFile(remoteFile, position, 24 * 1024);
                                        position += bytes.Length;
                                        stream.Write(bytes, 0, bytes.Length);
                                    }
                                    stream.Close();
                                }
                            }
                        }
                        Mediator.ShowMsg("下载完毕!");
                    }
                }
            }
            break;

            case "dgvYDTZShareDetail":
            {
                using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                {
                    MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);
                    header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);
                    var ds              = Mediator.remoteService.ExecuteDataset("select * from PatientInfo where PatientGUID={0}", new string[] { PGUID });
                    var row             = ds.Tables[0].Rows[0];
                    var formAudioDetail = new FrmAudioDetail()
                    {
                        PatientGUID = row["PatientGUID"] + "",
                        PatientID   = row["PatientID"] + "",
                        PatientName = row["PatientName"] + "",
                        DocName     = row["DocName"] + "",
                        PatientSex  = row["PatientSex"] + "",
                        PatientAge  = int.Parse("0" + row["PatientAge"]),
                        DocDiagnose = row["DocDiagnose"] + "",
                        DocRemark   = row["DocRemark"] + "",
                        His         = row["Flag"] + "",
                        IInfo       = new CloudShare()
                    };
                    formAudioDetail.ShowDialog();
                }
            }
            break;

            case "dgvYDTZShareDelete":
                if (DialogResult.OK == MessageBox.Show("你确定要删除该分享记录吗", "删除分享记录提示", MessageBoxButtons.OKCancel))
                {
                    using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                    {
                        MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                        OperationContext.Current.OutgoingMessageHeaders.Add(header);
                        var k = Mediator.remoteService.ExecuteNonQuery("delete from AudioShare where PatientGUID={0} and ToStetName={1}", new string[] { PGUID, this.cbBoxYDTZ.Text });
                        if (k > 0)
                        {
                            dgvYDTZShare.Rows.RemoveAt(e.RowIndex);
                            MessageBox.Show("删除分享记录成功...");
                        }
                    }
                }
                break;
            }
        }