private void SaveFile(SequenceReport report)
        {
            var bytes = Convert.FromBase64String(report.ReportDocBase64String);

            var path = ConfigurationManager.AppSettings["fileLocalPath"] + @"\";

            path += report.ReportPath;

            //如果目录不存在则新建
            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }

            //组合文件名
            if (path.EndsWith(@"\") == false)
            {
                path += @"\";
            }
            path += report.Name + "_" + report.PathNo + "_" + report.ReportName;

            using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                fs.Write(bytes, 0, bytes.Length);
                fs.Flush();
            }
        }
        private void InsertLog(SequenceReport report)
        {
            string sql =
                $@" insert into t_sequence_report_log (id,blh,file_path,file_name,
                        brbh,xm,xb)
                    values 
                    ('{Guid.NewGuid()}','{report.PathNo}','{report.ReportPath}','{report.ReportName}',
                    '{report.PatientId}','{report.Name}','{report.Gender}') ";

            var count = _aa.ExecuteSQL(sql);

            if (count == 0)
            {
                log.WriteMyLog("二代测序报告插入数据库失败,sql:\r\n" + sql);
                throw new Exception("二代测序报告插入数据库失败,sql:\r\n" + sql);
            }
        }
Example #3
0
        public void UploadReportTest()
        {
            SequencingServiceSoap service = new SequencingServiceSoapClient();

            SequenceReport report = new SequenceReport();

            report.PathNo                = "20170001";
            report.Name                  = "测试1";
            report.Gender                = "男性";
            report.ReportPath            = @"2017\10\24";
            report.ReportName            = "测试报告.doc";
            report.ReportDocBase64String = base64TestString;

            UploadSequenceReportRequest serviceRequest = new UploadSequenceReportRequest();

            serviceRequest.Body        = new UploadSequenceReportRequestBody();
            serviceRequest.Body.report = report;

            service.UploadSequenceReport(serviceRequest);
        }
        public bool UploadSequenceReport(SequenceReport report)
        {
            log.WriteMyLog("收到请求:UploadSequenceReport" +
                           "\r\n来自:" + this.Context.Request.UserHostAddress +
                           "\r\n入参:" +
                           $"\r\nreport:" + report.Name + "_" + report.PathNo);

            if (report == null)
            {
                return(true);
            }

            //插入数据库
            InsertLog(report);

            //文件转换为Word并放在指定位置
            SaveFile(report);

            return(true);
        }
        public List <SequenceReport> GetReportBySendDept(string deptName, DateTime startReportTime, DateTime endReportTime)
        {
            log.WriteMyLog("收到请求:GetReportBySendDept" +
                           "\r\n来自:" + this.Context.Request.UserHostAddress +
                           "\r\n入参:" +
                           $"\r\ndeptName:" + deptName +
                           $"\r\nstartReportTime:" + startReportTime +
                           $"\r\nendReportTime" + endReportTime);

            string sqlWhere = " and  (  1=1 ";

            sqlWhere += $" and convert(datetime,f_spare5) >=  convert(datetime,'{startReportTime}')";
            sqlWhere += $" and convert(datetime,f_spare5) <=  convert(datetime,'{endReportTime}')";
            sqlWhere += " ) ";
            //  sqlWhere += $" and f_blk='二代测序' ";
            sqlWhere += $" and f_bgzt='已审核' ";
            sqlWhere += $" and f_sjdw='{deptName}' ";

            var lstJcxx = (new T_JCXX_DAL()).GetBySqlWhere(sqlWhere);

            var lstSr = new List <SequenceReport>();

            foreach (T_JCXX jcxx in lstJcxx)
            {
                var sr = new SequenceReport();
                sr.PatientId    = jcxx.F_BRBH;
                sr.Name         = jcxx.F_XM;
                sr.Gender       = jcxx.F_XB;
                sr.PathNo       = jcxx.F_BLH;
                sr.RegTime      = Convert.ToDateTime(jcxx.F_SDRQ + ":00");
                sr.TestItemName = jcxx.F_YZXM;
                sr.SendDept     = jcxx.F_SJDW;
                sr.Diag         = jcxx.F_BLZD;
                sr.ReportTime   = Convert.ToDateTime(jcxx.F_BGRQ);
                lstSr.Add(sr);
            }

            return(lstSr);
        }
        public SequenceReport GetReporyWithPdfByPathNo(string pathNo)
        {
            log.WriteMyLog("收到请求:GetReporyWithPdfByPathNo\r\n" +
                           "来自:" + this.Context.Request.UserHostAddress +
                           "\r\n入参:" +
                           $"\r\npathNo:" + pathNo);

            string sqlWhere = "";

            //sqlWhere += $" and f_blk='二代测序' ";
            sqlWhere += $" and f_bgzt='已审核' ";
            sqlWhere += $" and f_blh='{pathNo}' ";

            var lstJcxx = (new T_JCXX_DAL()).GetBySqlWhere(sqlWhere);

            if (lstJcxx.Count == 0)
            {
                throw new Exception("没有找到该报告,或报告尚未审核!");
            }
            //获得pdf地址
            var dtPdf = _aa.GetDataTable($"select * from t_bg_pdf where f_blh = '{pathNo}' ", "dt1");

            if (dtPdf.Rows.Count == 0)
            {
                throw new Exception("该病人没有生成PDF!");
            }

            //获取本地pdf存放地址,读取并转成base64
            var        drPdf            = dtPdf.Rows[0];
            var        pdfbgLocalPath   = ConfigurationManager.AppSettings["pdfbgLocalPath"];
            var        pdfLocalFileName = pdfbgLocalPath + "\\" + drPdf["F_ML"] + "\\" + drPdf["F_FILENAME"].ToString();
            FileStream filestream       = null;

            try
            {
                filestream = new FileStream(pdfLocalFileName, FileMode.Open);
                byte[] bt = new byte[filestream.Length];
                //调用read读取方法
                filestream.Read(bt, 0, bt.Length);
                var base64Str = Convert.ToBase64String(bt, Base64FormattingOptions.None);

                var jcxx = lstJcxx[0];
                var sr   = new SequenceReport();
                sr.PatientId    = jcxx.F_BRBH;
                sr.Name         = jcxx.F_XM;
                sr.Gender       = jcxx.F_XB;
                sr.PathNo       = jcxx.F_BLH;
                sr.RegTime      = Convert.ToDateTime(jcxx.F_SDRQ + ":00");
                sr.ReportTime   = Convert.ToDateTime(jcxx.F_SPARE5);
                sr.TestItemName = jcxx.F_YZXM;
                sr.SendDept     = jcxx.F_SJDW;
                sr.Diag         = jcxx.F_BLZD;
                sr.PdfBase64    = base64Str;

                return(sr);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                filestream?.Close();
            }
        }