예제 #1
0
        public string[] GetImageExt(int userCd, string serialNo, string imagePath)
        {
            List <string> ret = new List <string>();

            try
            {
                int history = 0;
                List <ReportImage> lstImage = new List <ReportImage>();

                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" HistoryNo");
                        sql.Append(" FROM");
                        sql.Append(" ReportTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            if (dr.Read())
                            {
                                history = Convert.ToInt32(dr["HistoryNo"]);
                            }
                    }

                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append(" HistoryNo");
                        sql.Append(" FROM");
                        sql.Append(" ReportTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();
                    }


                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" ImageData");
                        sql.Append(",ImageExt");
                        sql.Append(" FROM");
                        sql.Append(" ImageTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);
                        sql.Append(" AND");
                        sql.Append(" HistoryNo = " + cmd.Add(history).ParameterName);
                        sql.Append(" ORDER BY SeqNo ASC");

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            while (dr.Read())
                            {
                                ReportImage tmpImage = new ReportImage();
                                tmpImage.ImageData = (byte[])dr["ImageData"];
                                tmpImage.ImageExt  = (string)dr["ImageExt"];

                                lstImage.Add(tmpImage);
                            }
                    }
                }

                outputReportImage(userCd, Convert.ToInt32(serialNo), imagePath, lstImage, ref ret);
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:GetImageExt", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:GetImageExt", ex.StackTrace);
            }

            return(ret.ToArray());
        }
예제 #2
0
        //変更履歴の取得
        public bool GetChangeHistory(int userCD, int SerialNo, string imagePath, out List <string[]> HistoryDataList, out List <string[]> ImageDataList, out string retErrMsg)
        {
            bool bRet = false;

            retErrMsg       = "";
            HistoryDataList = new List <string[]>(); // 変更履歴リスト
            ImageDataList   = new List <string[]>(); // イメージデータリスト

            try
            {
                using (DBAcc clsDB = new DBAcc(DBRemote))
                {
                    // パラメータのセット
                    DbParamClass sqlDbParam = new DbParamClass();
                    sqlDbParam.Add(SerialNo);
                    DbParameter[] dbprms = sqlDbParam.GetDbParameter(clsDB);

                    //読影履歴テーブルからデータ取得
                    StringBuilder sql = new StringBuilder("SELECT * FROM HistoryTbl  ");
                    sql.Append(" WHERE SerialNo = @0 and ");
                    sql.Append(" ( ReportStatus = 2 ");
                    sql.Append("   or ");
                    sql.Append("   historyno in (select max(historyno) as historyno from historytbl where serialno = @0 and ReportStatus = 3 group by edition )");
                    sql.Append(" )");
                    sql.Append(" ORDER BY HistoryNo DESC");

                    //string str = sql.ToString();

                    DbDataReader dr;
                    clsDB.SqlQuery(sql.ToString(), dbprms, out dr);

                    //履歴テーブルにデータが存在する場合、データ取得
                    while (dr.Read())
                    {
                        List <string> HistoryArray = new List <string>();

                        RsHistoryTbl rsHistoryTbl = new RsHistoryTbl();                   // 読影テーブル
                        rsHistoryTbl.SerialNo          = (int)dr["SerialNo"];             // シリアル番号
                        rsHistoryTbl.HistoryNo         = (int)dr["HistoryNo"];            // 読影番号
                        rsHistoryTbl.ReadDate          = (string)dr["ReadDate"];          // 読影日
                        rsHistoryTbl.ReadTime          = (string)dr["ReadTime"];          // 読影時刻
                        rsHistoryTbl.ReadPhysicianName = (string)dr["ReadPhysicianName"]; // 読影医
                        rsHistoryTbl.Finding           = (string)dr["Finding"];           // 画像所見
                        rsHistoryTbl.Diagnosing        = (string)dr["Diagnosing"];        // 結論・診断

                        HistoryArray.Add(rsHistoryTbl.SerialNo.ToString());
                        HistoryArray.Add(rsHistoryTbl.HistoryNo.ToString());
                        HistoryArray.Add(rsHistoryTbl.ReadDate);
                        HistoryArray.Add(rsHistoryTbl.ReadTime);
                        HistoryArray.Add(rsHistoryTbl.ReadPhysicianName);
                        HistoryArray.Add(rsHistoryTbl.Finding);
                        HistoryArray.Add(rsHistoryTbl.Diagnosing);
                        HistoryArray.Add("");

                        HistoryDataList.Add(HistoryArray.ToArray());
                    }
                    dr.Close();


                    int nIdx = 0;
                    // 読影データ分繰り返す
                    foreach (string[] HistoryData in HistoryDataList)
                    {
                        List <ReportImage> lstImage = new List <ReportImage>();

                        int HistoryNo = int.Parse(HistoryData[1]);// 読影番号の取得

                        List <string> ImageArray = new List <string>();
                        ImageArray.Add(HistoryNo.ToString());

                        // パラメータのセット
                        sqlDbParam = new DbParamClass();
                        sqlDbParam.Add(SerialNo);
                        sqlDbParam.Add(HistoryNo);
                        dbprms = sqlDbParam.GetDbParameter(clsDB);

                        // 画像テーブルからデータ取得
                        sql = new StringBuilder("SELECT * FROM ImageTbl WHERE SerialNo = @0 and HistoryNo = @1");
                        clsDB.SqlQuery(sql.ToString(), dbprms, out dr);

                        List <RsImageTbl> rsImgList = new List <RsImageTbl>();
                        // 画像テーブルにデータが存在する場合、データ取得
                        while (dr.Read())
                        {
                            ReportImage rImage = new ReportImage();

                            rImage.ImageData = (byte[])dr["ImageData"];
                            rImage.ImageExt  = (string)dr["ImageExt"];

                            lstImage.Add(rImage);

/*
 *                          RsImageTbl rsImageTbl = new RsImageTbl();
 *                          rsImageTbl.SeqNo = (int)dr["SeqNo"];    // SEQ番号
 *                          //rsImageTbl.ImageData = (byte[])dr["ImageData"]; // 画像データ
 *                          rsImageTbl.ImageExt = (string)dr["ImageExt"];   // 画像拡張子
 *                          rsImageTbl.ImageName = (string)dr["ImageName"];
 *                          rsImgList.Add(rsImageTbl);
 *
 *                          List<string> ImageArray = new List<string>();
 *                          ImageArray.Add(SerialNo.ToString());
 *                          ImageArray.Add(rsImageTbl.SeqNo.ToString());
 *                          ImageArray.Add(rsImageTbl.ImageName);
 *                          ImageArray.Add(rsImageTbl.ImageExt);
 *
 *                          ImageDataList.Add(ImageArray.ToArray());
 */
                        }
                        // 読影データ/画像テーブルへセット
                        // rsReadingData.ImageTblList = rsImgList;

                        // 画像配列へセット

                        dr.Close();

                        if (lstImage.Count > 0)
                        {
                            List <string> lstImageFileName = new List <string>();
                            outputReportImage(userCD, SerialNo, imagePath, lstImage, ref lstImageFileName);

                            foreach (string ImgName in lstImageFileName)
                            {
                                ImageArray.Add(ImgName);
                            }
                        }
                        ImageDataList.Add(ImageArray.ToArray());
                    }

                    bRet = true;
                }
            }
            catch (Exception ex)
            {
                retErrMsg = ex.Message;
            }
            return(bRet);
        }