//压缩时GZipStream构造函数第三个参数一定要设置为true, //并且一定要先调用Close再来复制,否则不能正常解压(测试发现调用Close后会追加几字节内容) public MemoryStream GZipCompress(String str) { str = CSTR.trim(str); if (str.Length <= 0) { return(null); } //字符串转换为字节数组byte[] byte[] buffer = System.Text.Encoding.UTF8.GetBytes(str); MemoryStream streamRet = null; try { using (MemoryStream msTemp = new MemoryStream()) { using (GZipStream gzip = new GZipStream(msTemp, CompressionMode.Compress, true)) { //压缩 gzip.Write(buffer, 0, buffer.Length); gzip.Close(); //复制到返回的Stream streamRet = new MemoryStream(msTemp.GetBuffer(), 0, (int)msTemp.Length); } } } catch (Exception exp) { Console.WriteLine(exp.Message); streamRet = null; } return(streamRet); }
//----------------查找STUDY有无原始的[312][313]房间------------------------------------------- private bool StudyHas_312_313_Room() { //[RoomID]:register_table.CheckRoom if (CSTR.IsTableEmpty(register_table)) { return(false); } //[规则]只要任意Exam的房间串中包含[312]或[313],就是拥有职检检查 bool bRet = false; foreach (DataRow row in register_table.Rows) { String roomID = CSTR.ObjectTrim(row["CheckRoom"]); if (roomID.IndexOf("[312]") >= 0 || roomID.IndexOf("[313]") >= 0 || roomID.IndexOf("[308]") >= 0) { bRet = true; } } return(bRet); }
//获取多个房间中最少活动检查的队列人数 public static int Queue_Length_Min_Count_MultiRoom_Active_Exam(String clusterRooms) { //1.分解房间串 String[] arrRooms = CSTR.splitRooms(clusterRooms); if (null == arrRooms) { return(0); } if (arrRooms.Length <= 0) { return(0); } //遍历所有房间的队列长度,找到最小的那个 int min_length = 9999; foreach (String strRoom in arrRooms) { int count = Queue_Length_Count_Specified_Room_Active_Exam(strRoom); if (count < min_length) { min_length = count; } } return(min_length); }
//获取系统中未完成的[超声科]房间的检查列表 private List <String> getUltrasoundExamList() { DataTable tbl = DatabaseCache.DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(tbl)) { return(null); } DataRow[] rows = tbl.Select("RoomID='[超声科]' and IsOver='0'"); if (CSTR.IsRowArrEmpty(rows)) { return(null); } List <String> list = new List <string>(); foreach (DataRow row in rows) { String DJLSH = CSTR.ObjectTrim(row["DJLSH"]); if (CSTR.isEmpty(DJLSH)) { continue; } DJLSH = DJLSH.Replace("'", ""); list.Add(DJLSH); } return(list); }
//设置指定的IndexID记录为活动检查 public bool Call_SP_Activate_Specified_IndexID(String strIndexID) { strIndexID = CSTR.trim(strIndexID); if (strIndexID.Length <= 0) { return(false); } int nIndexID = CSTR.convertToInt(strIndexID); if (nIndexID <= 0) { return(false); } try { MySqlConnection connection = getConn(); if (null == connection) { return(false); } //指定存储过程名称和连接 MySqlDataAdapter adapter = new MySqlDataAdapter(); adapter.SelectCommand = new MySqlCommand(); adapter.SelectCommand.Connection = connection; adapter.SelectCommand.CommandText = "TJ_Queue_Activate_Specified_IndexID";//存储过程名称 adapter.SelectCommand.CommandType = CommandType.StoredProcedure; //设置参数 //mysql的存储过程参数是以?打头的!!!! //in - parameter_Handler_Name MySqlParameter parameter_in_index_id = new MySqlParameter("?in_index_id", MySqlDbType.Int32, 11); parameter_in_index_id.Direction = ParameterDirection.Input; parameter_in_index_id.Value = nIndexID; adapter.SelectCommand.Parameters.Add(parameter_in_index_id); //out - out_result_flag MySqlParameter parameter_out_result_flag = new MySqlParameter("?out_result_flag", MySqlDbType.Int32, 11); parameter_out_result_flag.Direction = ParameterDirection.Output; adapter.SelectCommand.Parameters.Add(parameter_out_result_flag); //把返回结果填入DataSet DataSet ds = new DataSet(); adapter.Fill(ds); //取得Out参数 int result_flag = CSTR.convertToInt(CSTR.ObjectTrim(parameter_out_result_flag.Value)); return((result_flag == 1) ? true : false); } catch (Exception exp) { Console.WriteLine(exp.Message); Log.log("[mysql.Call_SP_Activate_Specified_IndexID()] " + exp.Message); conn = null; } return(false); }
public int insert(DataTable tbl) { if (CSTR.IsTableEmpty(tbl)) { return(0); } //拼接字段名字 String colNames = ""; foreach (DataColumn column in tbl.Columns) { colNames += column.ColumnName + ","; } colNames = colNames.TrimEnd(',');//去掉最后一个逗号 foreach (DataRow row in tbl.Rows) { String colValue = getRowDataCluster(row, tbl.Columns); String sql = String.Format("Insert Into {0} ({1}) VALUES ({2})", target_table, colNames, colValue); getDB().update(sql); } return(0); }
//恢复窗口字体 public void restoreFont(Form wnd) { if (null == wnd) { return; } String fontName = CSTR.trim(font_family()); if (fontName.Length <= 0) { return; } int fontSize = font_size(); if (fontSize <= 3 || fontSize > 100) { return; } //最大化时不保存大小和位置,而是保留上一次非最大化时的值 try { wnd.Font = new System.Drawing.Font(fontName, fontSize); } catch (Exception exp) { Console.WriteLine(exp.Message); } }
//保存窗口字体到ini文件 public void saveFont(Form wnd, String fontName, int fontSize) { if (null == wnd) { return; } fontName = CSTR.trim(fontName); if (fontName.Length <= 0) { return; } if (fontSize <= 3 || fontSize > 100) { return; } //最大化时不保存大小和位置,而是保留上一次非最大化时的值 try { //wnd.Font = new System.Drawing.Font(fontName, fontSize); INI_FILE.INIWriteValue(ini_file, "params", "font_family", fontName); INI_FILE.INIWriteValue(ini_file, "params", "font_size", fontSize.ToString()); } catch (Exception exp) { Console.WriteLine(exp.Message); } }
private String ini_file_getParamValue(String strName) { strName = CSTR.trim(strName); if (strName.Length <= 0) { return(""); } String strRet = ""; try { //确保ini文件存在,没有则创建 ini_file_exist_suarance(); //读取ini文件,并更新g_version strRet = CSTR.trim(INI_FILE.INIGetStringValue(ini_file, "params", strName, null)); } catch (Exception exp) { Console.WriteLine(exp.Message); strRet = ""; } return(strRet); }
//-------------从指定的房间串中返回active的房间过滤---------------------------------------- private String get_active_RoomID_Cluster(String roomCluster) { if (CSTR.isEmpty(roomCluster)) { return(""); } String[] room_arr = CSTR.splitRooms(roomCluster); if (null == room_arr || room_arr.Length <= 0) { return(""); } String retCluster = ""; foreach (String roomID in room_arr) { bool is_active = DatabaseCache.RoomInfo_is_active(roomID); if (is_active) { retCluster += roomID; } } return(retCluster); }
//获取指定行的字段值: JiaohaoTable_get_Field_String_by_IndexID("63","status") public static String JiaohaoTable_Get_Field_Value_by_IndexID(String indexID, String fieldName) { indexID = CSTR.trim(indexID); fieldName = CSTR.trim(fieldName); if (CSTR.isEmpty(indexID)) { return(""); } if (CSTR.isEmpty(fieldName)) { return(""); } //获取JiaohaoTable表 DataTable cache_tbl = DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(cache_tbl)) { return(null); } //查询符合条件的行集合 DataRow[] row_result = cache_tbl.Select(String.Format("IndexID='{0}'", indexID)); if (CSTR.IsArrayEmpty(row_result)) { return(""); } //从第一行中返回指定的列数据 return(CSTR.ObjectTrim(row_result[0][fieldName])); }
public static bool DB_Reflesh_AllTable() { is_tbl_initiated = false; //Reflash each Table DB_Reflash_JiaohaoTable_And_JiaohaoExamInfo(); DB_Reflesh_JiaohaoRfid(); DB_Reflesh_JiaohaoRoomInfo(); DB_Reflesh_JiaohaoSpecialExam(); //任何一个配置Table无内容,都被认为异常 is_tbl_initiated = true; if (CSTR.IsTableEmpty(tbl_JiaohaoRfid)) { is_tbl_initiated = false; } if (CSTR.IsTableEmpty(tbl_JiaohaoRoomInfo)) { is_tbl_initiated = false; } if (CSTR.IsTableEmpty(tbl_JiaohaoSpecialExam)) { is_tbl_initiated = false; } return(is_tbl_initiated); }
public static Dictionary <Status, bool> getStatus(DataRow row) { if (null == row) { return(null); } bool isNormal = false; bool isActive = false; bool isCalling = false; bool isReadOnce = false; bool isCheckOver = false; bool isPass = false; String statusCluster = getStatusCluser(row); if (statusCluster.Equals("0000")) { isNormal = true; } else if (statusCluster.Equals("1000")) { isActive = true; } else if (statusCluster.Equals("1110")) { isCalling = true; } else if (statusCluster.Equals("0100")) { isPass = true; } else if (statusCluster.Equals("0101")) { //如果EndTime为空是读卡一次的检查 if (CSTR.isEmpty(CSTR.ObjectTrim(row["EndTime"]))) { isReadOnce = true; } else { isCheckOver = true; } } Dictionary <Status, bool> map = new Dictionary <Status, bool>(); map.Add(Status.Normal, isNormal); map.Add(Status.Active, isActive); map.Add(Status.Calling, isCalling); map.Add(Status.Pass, isPass); map.Add(Status.ReadOnce, isReadOnce); map.Add(Status.CheckOver, isCheckOver); return(map); }
public static bool RFID_Is_Rfid_registed(String rfid) { DataRow[] rowArr = RFID_get_Rfid_row(rfid); if (CSTR.IsRowArrEmpty(rowArr)) { return(false); } return(true); }
//定时刷新RoomInfo表数据 public Dictionary <String, Object> Call_SP_RoomInfo_Reflesh(int last_trigger_RoomInfo_id) { Dictionary <String, Object> map = new Dictionary <string, object>(); try { MySqlConnection connection = getConn(); if (null == connection) { return(map); } //指定存储过程名称和连接 MySqlDataAdapter adapter = new MySqlDataAdapter(); adapter.SelectCommand = new MySqlCommand(); adapter.SelectCommand.Connection = connection; adapter.SelectCommand.CommandText = "Reflesh_RoomInfo";//存储过程名称 adapter.SelectCommand.CommandType = CommandType.StoredProcedure; //设置参数 //mysql的存储过程参数是以?打头的!!!! //inout - in_trigger_RoomInfo_id MySqlParameter parameter_in_trigger_RoomInfo_id = new MySqlParameter("?in_trigger_RoomInfo_id", MySqlDbType.Int32, 11); parameter_in_trigger_RoomInfo_id.Direction = ParameterDirection.InputOutput; parameter_in_trigger_RoomInfo_id.Value = last_trigger_RoomInfo_id; adapter.SelectCommand.Parameters.Add(parameter_in_trigger_RoomInfo_id); //out - out_reflesh_flag MySqlParameter parameter_out_reflesh_flag = new MySqlParameter("?out_reflesh_flag", MySqlDbType.Int32, 11); parameter_out_reflesh_flag.Direction = ParameterDirection.Output; adapter.SelectCommand.Parameters.Add(parameter_out_reflesh_flag); //把返回结果填入DataSet DataSet ds = new DataSet(); adapter.Fill(ds); //取得Out参数 int result_flag = CSTR.convertToInt(CSTR.ObjectTrim(parameter_out_reflesh_flag.Value)); int result_max_id1 = CSTR.convertToInt(CSTR.ObjectTrim(parameter_in_trigger_RoomInfo_id.Value)); //构建返回的映射表 map.Add("flag", result_flag); map.Add("max_id_1", result_max_id1); map.Add("data_set", ds); } catch (Exception exp) { Console.WriteLine(exp.Message); Log.log("[mysql.Call_SP_RoomInfo_Reflesh()] " + exp.Message); conn = null; map = null; } return(map); }
//调用者写入需要播报的语音文本 public void speak(String str) { str = CSTR.trim(str); if (CSTR.isEmpty(str)) { return; } text_speak = str; need_speak = true; }
public static String RFID_get_ringNo(String rfid) { DataRow[] rowArr = RFID_get_Rfid_row(rfid); if (CSTR.IsRowArrEmpty(rowArr)) { return(""); } String strRet = CSTR.ObjectTrim(rowArr[0]["CardNo"]); return(strRet); }
//根据手环号码获取检查列表(不分状态,全部)-------------------------------------------------- public static DataRow[] JiaohaoTable_Get_All_Exam_By_DJLSH(String DJLSH) { String sql = String.Format("DJLSH='{0}'", DJLSH); DataTable tbl = DatabaseCache.DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(tbl)) { return(null); } return(tbl.Select(sql)); }
//获取指定IndexID的JiaohaoTable一条记录(不分状态,全部)-------------------------------------------------- public static DataRow[] JiaohaoTable_Get_One_Item_By_IndexID(String indexID) { String sql = String.Format("IndexID='{0}'", indexID); DataTable tbl = DatabaseCache.DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(tbl)) { return(null); } return(tbl.Select(sql)); }
//Token获取 public int Call_SP_Token(String strHandlerName) { if (CSTR.isEmpty(strHandlerName)) { return(0); } try { MySqlConnection connection = getConn(); if (null == connection) { return(0); } //指定存储过程名称和连接 MySqlDataAdapter adapter = new MySqlDataAdapter(); adapter.SelectCommand = new MySqlCommand(); adapter.SelectCommand.Connection = connection; adapter.SelectCommand.CommandText = "Tocken";//存储过程名称 adapter.SelectCommand.CommandType = CommandType.StoredProcedure; //设置参数 //mysql的存储过程参数是以?打头的!!!! //in - parameter_Handler_Name MySqlParameter parameter_Handler_Name = new MySqlParameter("?Handler_Name", MySqlDbType.VarChar, 128); parameter_Handler_Name.Direction = ParameterDirection.Input; parameter_Handler_Name.Value = strHandlerName; adapter.SelectCommand.Parameters.Add(parameter_Handler_Name); //out - out_token_flag MySqlParameter parameter_out_token_flag = new MySqlParameter("?out_token_flag", MySqlDbType.Int32, 11); parameter_out_token_flag.Direction = ParameterDirection.Output; adapter.SelectCommand.Parameters.Add(parameter_out_token_flag); //把返回结果填入DataSet DataSet ds = new DataSet(); adapter.Fill(ds); //取得Out参数 int result_flag = CSTR.convertToInt(CSTR.ObjectTrim(parameter_out_token_flag.Value)); return(result_flag); } catch (Exception exp) { Console.WriteLine(exp.Message); Log.log("[mysql.Call_SP_Token()] " + exp.Message); conn = null; } return(0); }
//根据手环号码获取检查列表(不分状态,全部)-------------------------------------------------- public static DataRow[] JiaohaoTable_Get_All_Exam_By_ringNo(String ringNo) { String sql = String.Format("RfidName='{0}'", ringNo); DataTable tbl = DatabaseCache.DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(tbl)) { return(null); } return(tbl.Select(sql)); }
//获取RISServer的当前时间 private DateTime getRISServerTime() { DateTime dt = new DateTime(); try { //1.连接服务器,取得时间 ExamQueue queue = new ExamQueue(); String sql = "select date_format(now(),'%Y') as nYear," + "date_format(now(),'%m') as nMonth," + "date_format(now(),'%d') as nDay," + "date_format(now(),'%H') as nHour," + "date_format(now(),'%i') as nMinute," + "date_format(now(),'%s') as nSecond"; DataTable tbl = queue.getDB().query(sql); if (CSTR.IsTableEmpty(tbl)) { return(dt); } //2.转换 String strYear = CSTR.ObjectTrim(tbl.Rows[0]["nYear"]); String strMonth = CSTR.ObjectTrim(tbl.Rows[0]["nMonth"]); String strDay = CSTR.ObjectTrim(tbl.Rows[0]["nDay"]); String strHour = CSTR.ObjectTrim(tbl.Rows[0]["nHour"]); String strMinute = CSTR.ObjectTrim(tbl.Rows[0]["nMinute"]); String strSecond = CSTR.ObjectTrim(tbl.Rows[0]["nSecond"]); if (CSTR.isEmpty(strYear) || CSTR.isEmpty(strMonth) || CSTR.isEmpty(strDay) || CSTR.isEmpty(strHour) || CSTR.isEmpty(strMinute) || CSTR.isEmpty(strSecond)) { return(dt); } //3.生成DateTime格式时间 int nYear = Int16.Parse(strYear); int nMonth = Int16.Parse(strMonth); int nDay = Int16.Parse(strDay); int nHour = Int16.Parse(strHour); int nMinute = Int16.Parse(strMinute); int nSecond = Int16.Parse(strSecond); dt = new DateTime(nYear, nMonth, nDay, nHour, nMinute, nSecond); } catch (Exception exp) { Console.Out.WriteLine(exp.Message); } return(dt); }
public static DataRow[] TJ_Exam_Get_Same_Room_Item_Form_JiaohaoExamInfo_By_RingNo(String ringNo, String roomID) { DataTable tbl = ExamInfo_get_All_Items_by_RingNo(ringNo); if (CSTR.IsTableEmpty(tbl)) { return(null); } String sql = String.Format("RoomID='{0}'", roomID); return(tbl.Select(sql)); }
public static bool RoomInfo_is_active(String roomID) { String sql = String.Format("RoomID='{0}'", roomID); DataRow[] sel_rows = DB_Get_JiaohaoRoomInfo_table().Select(sql); if (CSTR.IsArrayEmpty(sel_rows)) { return(false); } String strValue = CSTR.ObjectTrim(sel_rows[0]["RoomState"]); return((strValue.Equals("active")) ? true : false); }
public static String RoomInfo_get_BackupRoom(String roomID) { String sql = String.Format("RoomID='{0}'", roomID); DataRow[] sel_rows = DB_Get_JiaohaoRoomInfo_table().Select(sql); if (CSTR.IsArrayEmpty(sel_rows)) { return(""); } String strValue = CSTR.ObjectTrim(sel_rows[0]["BackupRoom"]); return(strValue); }
public static DataRow[] Exam_Get_Doing() { //取得本进程对应的ModalityID(room_id) String strRoomID = CONFIG.system_param["room_id"]; String sql = String.Format("QueueActive='1' and status='1' and IsChecking='1' and IsOver='0' and RoomID='{0}'", strRoomID); DataTable tbl = DatabaseCache.DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(tbl)) { return(null); } //order by QueueID return(tbl.Select(sql, "QueueID DESC")); }
public static DataRow[] Exam_Get_Unfinished_Exams() { //取得本进程对应的ModalityID(room_id) String strRoomID = CONFIG.system_param["room_id"]; String sql = String.Format("RoomID='{0}' and IsOver='0'", strRoomID); DataTable tbl = DatabaseCache.DB_Get_JiaohaoTable_table(); if (CSTR.IsTableEmpty(tbl)) { return(null); } //order by QueueID return(tbl.Select(sql, "QueueID")); }
public static bool RoomInfo_is_need_voice(String roomID) { String sql = String.Format("RoomID='{0}'", roomID); DataRow[] sel_rows = DB_Get_JiaohaoRoomInfo_table().Select(sql); if (CSTR.IsArrayEmpty(sel_rows)) { return(false); } String strValue = CSTR.ObjectTrim(sel_rows[0]["IsNeedVoice"]); //return (strValue.Equals("1")) ? true : false; return((strValue.Equals("0")) ? false : true); }
//取得检查的状态串 public static String getStatusCluser(DataRow row) { if (null == row) { return(""); } String strCluster = String.Format("{0}{1}{2}{3}", CSTR.ObjectTrim(row["QueueActive"]), CSTR.ObjectTrim(row["status"]), CSTR.ObjectTrim(row["IsChecking"]), CSTR.ObjectTrim(row["IsOver"])); return(strCluster); }
//---------<<< 封装 >>>-------------------------------------------------------------------- public String toJson(DataTable tbl) { String strRet = ""; if (CSTR.IsTableEmpty(tbl)) { return(""); } try { JavaScriptSerializer json = new JavaScriptSerializer(); json.MaxJsonLength = Int32.MaxValue;//设置JSON串的最大值 //封装列名 List <String> columnList = new List <string>(); foreach (DataColumn column in tbl.Columns) { columnList.Add(CSTR.trim(column.ColumnName)); } int columnCount = columnList.Count; //封装字段内容 List <List <String> > rowList = new List <List <string> >(); foreach (DataRow row in tbl.Rows) { List <String> tempList = new List <string>(); for (int i = 0; i < columnCount; i++) { tempList.Add(CSTR.ObjectTrim(row[columnList[i]])); } rowList.Add(tempList);//添加一行记录 } //总装 Dictionary <String, Object> tblMap = new Dictionary <string, object>(); tblMap.Add("column", columnList); tblMap.Add("data", rowList); strRet = json.Serialize(tblMap); //返回一个json字符串 } catch (Exception exp) { Console.WriteLine(exp.Message); strRet = ""; } return(strRet); }