public string DataRequest_By_String(string methodRequests) { var metodReq = CreateJsonSerial().Deserialize <MethodRequest>(methodRequests); var sh = new ShareSqlManager(); return(sh.ExecStoredProc(metodReq.ProceName, metodReq.ParamKeys, metodReq.ParamVals, metodReq.ProceDb, RetType.String).ToString()); }
//BaseTablesGetter public byte[] BaseDataRequest(byte[] methodBytes) { byte[] _metBts = GZipStreamHelper.GZipDecompress(methodBytes); MethodRequest[] _metodReqs = __JsonSerial.Deserialize <MethodRequest[]>(System.Text.Encoding.UTF8.GetString(_metBts)); if (_metodReqs == null) { return(null); } ShareSqlManager _sh = new ShareSqlManager(); List <List <SimpDataEntery> > _simpEtys = new List <List <SimpDataEntery> >(); for (int _i = 0, _iCnt = _metodReqs.Length; _i < _iCnt; _i++) { List <SimpDataEntery> _lis = BaseTablesGetter.GetBaseTablesGetterInstances(_metodReqs[_i].ProceDb).GetBaseTable( MethodRequestHelper.GetParam(_metodReqs[_i], "tableName"), MethodRequestHelper.GetParam(_metodReqs[_i], "ChangTime"), MethodRequestHelper.GetParam(_metodReqs[_i], "schemaMD5"), MethodRequestHelper.GetParam(_metodReqs[_i], "contentsMD5")); _simpEtys.Add(_lis); } string _jsonSimpEtys = __JsonSerial.Serialize(_simpEtys); byte[] _bts = System.Text.Encoding.UTF8.GetBytes(_jsonSimpEtys); return(GZipStreamHelper.GZipCompress(_bts)); }
public DataTable GetTableByStoredProc(string strConnectionString, string strSqlSPName, string strParaKeys, string[] strParaVals) { ShareSqlManager sql = new ShareSqlManager(strConnectionString); DataTable dt = (DataTable)sql.ExecStoredProc(strSqlSPName, strParaKeys, strParaVals, "Table"); dt.TableName = strSqlSPName; return(dt); }
public DataTable DataRequest_By_DataTable(string methodRequests) { var metodReq = CreateJsonSerial().Deserialize <MethodRequest>(methodRequests); var sh = new ShareSqlManager(); var dt = (DataTable)sh.ExecStoredProc(metodReq.ProceName, metodReq.ParamKeys, metodReq.ParamVals, metodReq.ProceDb, RetType.Table); dt.TableName = metodReq.ProceName; return(dt); }
public SimpDataEnterys DataRequest_By_SimpDataEnterys(string methodRequests) { var metodReq = CreateJsonSerial().Deserialize <MethodRequest>(methodRequests); var sh = new ShareSqlManager(); var lis = (List <SimpDataEntery>)sh.ExecStoredProc(metodReq.ProceName, metodReq.ParamKeys, metodReq.ParamVals, metodReq.ProceDb, RetType.SimpDEs); var sim = new SimpDataEnterys { ListSimpDEs = lis }; return(sim); }
public DataSet DataRequest_By_DataSet(string methodRequests) { var metodReq = CreateJsonSerial().Deserialize <MethodRequest>(methodRequests); var sh = new ShareSqlManager(); var ds = (DataSet)sh.ExecStoredProc(metodReq.ProceName, metodReq.ParamKeys, metodReq.ParamVals, metodReq.ProceDb, RetType.DataSet); for (int i = 0, iCnt = ds.Tables.Count; i < iCnt; i++) { ds.Tables[i].TableName = string.Format("{0}_{1}", metodReq.ProceName, i); } return(ds); }
/// <summary> /// 从数据库读取更新信息 和更新数据 /// </summary> /// <param name="tableName">表名称</param> /// <param name="svcChangTime">服务端保存的更新时候</param> /// <param name="dbTableKey">数据库返回主键信息</param> /// <param name="dbChangTime">数据库返回的更新时间</param> /// <param name="dbDelKeys">数据库返回删除信息</param> /// <param name="dtNew">数据库返回的更新记录</param> private void ReadBaseTableFormDb(string tableName, object svcChangTime, out object dbTableKey, out object dbChangTime, out DataTable dtDel, out DataTable dtNew) { dbTableKey = dbChangTime = string.Empty; dtNew = null; ShareSqlManager _sh = new ShareSqlManager(); DataSet _ds = (DataSet)_sh.ExecStoredProc(DB_PROC_NAME, new string[] { "tableName", "ChangTime" }, new string[] { tableName, svcChangTime.ToString() }, TableChgLogKey, RetType.DataSet); //SELECT DataTableName,DataKeyField,CONVERT(varchar(30),DataChangTime,121) AS DataChangTime //FROM dbo.Sys_DataChangLog //WHERE DataTableName=@tableName DataTable _dtTableInf = _ds.Tables[0]; if (_dtTableInf != null) { if (_dtTableInf.Rows.Count == 0) { throw (new System.Exception(string.Format("{0} 表设置错误.", tableName))); } if (_dtTableInf.Columns.Contains("ERROR")) { throw (new System.Exception(_dtTableInf.Rows[0]["ERROR"].ToString())); } } DataRow _dr = _dtTableInf.Rows[0]; dbTableKey = _dr[BaseTableChangLog.DATA_TABLE_KEY]; dbChangTime = _dr[BaseTableChangLog.DATA_CHANG_TIME]; //SELECT A.DataDeTime AS DeleteTime,A.DataDelId AS DeleteKey //FROM Sys_DataDeleteLog AS A //WHERE DataTableName=@tableName //dbDelKeys = _ds.Tables[1].Rows[0][BaseTableChangLog.DATA_DELETE_KEYS]; dtDel = _ds.Tables[1]; //SELECT x,x,x FROM BaseTable dtNew = _ds.Tables[2]; _ds.Tables.Remove(_ds.Tables[2]); _ds.Tables.Remove(_ds.Tables[1]); _ds.Tables[0].Dispose(); _ds.Dispose(); _ds = null; }
private void ReadClientBaseTableFormDb(string tableName, string clientChangTime, out DataTable dtNew) { ShareSqlManager _sh = new ShareSqlManager(); DataSet _dsClient = (DataSet)_sh.ExecStoredProc(DB_PROC_NAME, new string[] { "tableName", "ChangTime" }, new string[] { tableName, clientChangTime.ToString() }, TableChgLogKey, RetType.DataSet); dtNew = _dsClient.Tables[2]; _dsClient.Tables.Remove(_dsClient.Tables[2]); _dsClient.Tables[1].Dispose(); _dsClient.Tables[0].Dispose(); _dsClient.Dispose(); _dsClient = null; }
public string GetPicture(string methodRequests) { /// 主要写你处理的代码; /// 1、前台上传的数据;进行反序列化成数据库请求的对象和约定的内容; List <List <SimpDataEntery> > result = new List <List <SimpDataEntery> >(); List <SimpDataEntery> _lis = new List <SimpDataEntery>(); var jsonserial = CreateJsonSerial(); #if SUDID_KEY_REGE if (!MachineCode.CurrentMachineCode.Hash.Equals(SUDID_KEY_REGE)) { return(null); } #endif MethodRequest[] metodReq_1 = jsonserial.Deserialize <MethodRequest[]>(methodRequests); MethodRequest metodReq = metodReq_1[0]; var sh = new ShareSqlManager(); var _ds = (DataSet)sh.ExecStoredProc(metodReq.ProceName, metodReq.ParamKeys, metodReq.ParamVals, metodReq.ProceDb, RetType.DataSet); for (var i = 0; i < _ds.Tables.Count; i++) { _ds.Tables[i].TableName = string.Format("{0}_{1}", metodReq.ProceName, i); } if (_ds.Tables[0].Rows[0][0].ToString() == "1") { //直接返回结果,返回地址给客户端 _lis.Add(SimpDataConvertHelper.DataTableToSimpDataEntery(_ds.Tables[0])); _lis.Add(SimpDataConvertHelper.DataTableToSimpDataEntery(_ds.Tables[1])); _lis.Add(SimpDataConvertHelper.DataTableToSimpDataEntery(_ds.Tables[2])); result.Add(_lis); _ds.Dispose(); return(jsonserial.Serialize(result)); } else if (_ds.Tables[0].Rows[0][0].ToString() == "0") { //需要调用DcmToJpg算法,再返回地址给客户端 DataSet ds = updatePicFile(metodReq.ParamVals[0], metodReq.ProceDb, _ds.Tables[1]); _lis.Add(SimpDataConvertHelper.DataTableToSimpDataEntery(ds.Tables[0])); _lis.Add(SimpDataConvertHelper.DataTableToSimpDataEntery(ds.Tables[1])); _lis.Add(SimpDataConvertHelper.DataTableToSimpDataEntery(ds.Tables[2])); result.Add(_lis); _ds.Dispose(); return(jsonserial.Serialize(result)); } _ds.Dispose(); return(jsonserial.Serialize(result)); }
public string DataRequest_By_SimpDEs(string methodRequests) { var metodReqs = CreateJsonSerial().Deserialize <MethodRequest[]>(methodRequests); var sh = new ShareSqlManager(); var simpEtys = new List <List <SimpDataEntery> >(); for (int i = 0, iCnt = metodReqs.Length; i < iCnt; i++) { var lis = (List <SimpDataEntery>)sh.ExecStoredProc(metodReqs[i].ProceName, metodReqs[i].ParamKeys, metodReqs[i].ParamVals, metodReqs[i].ProceDb, RetType.SimpDEs); if (string.IsNullOrWhiteSpace(metodReqs[i].ProceName)) { throw (new Exception("调用名称为空.")); } simpEtys.Add(lis); } return(CreateJsonSerial().Serialize(simpEtys)); }
public DataTable DataRequest_By_DataTable(string methodRequests) { JavaScriptSerializer _jsonserial = CreateJsonSerial(); #if SUDID_KEY_REGE if (!MachineCode.CurrentMachineCode.Hash.Equals(SUDID_KEY_REGE)) { return(null); } #endif MethodRequest _metodReq = _jsonserial.Deserialize <MethodRequest>(methodRequests); ShareSqlManager _sh = new ShareSqlManager(); DataTable _dt = (DataTable)_sh.ExecStoredProc( _metodReq.ProceName, _metodReq.ParamKeys, _metodReq.ParamVals, _metodReq.ProceDb, RetType.Table); _dt.TableName = _metodReq.ProceName; return(_dt); }
public static string GetMd5(string tableName, string editTime, string dbCon) { string _md5Key = string.Format("{0}-{1}", dbCon, tableName); if (!_SnyMD5.ContainsKey(_md5Key)) { lock (_Sny) { if (!_SnyMD5.ContainsKey(_md5Key)) { _SnyMD5.Add(_md5Key, new object()); } } } lock (_SnyMD5[_md5Key]) { if (!_BaseTableCheck.ContainsKey(_md5Key) || (editTime.Length > 0 && !_BaseTableCheck[_md5Key].EditTime.Equals(editTime))) { ShareSqlManager _sh = new ShareSqlManager(); DataSet _ds = (DataSet)_sh.ExecStoredProc( "Sys_BasicTable_Geter", new string[] { "tableName" }, new string[] { tableName }, dbCon, RetType.DataSet); InitTablePrimaryKey(_ds.Tables[2], _ds.Tables[0].Rows[0]["DataKeyField"].ToString().Trim()); _ds.Tables[2].TableName = tableName; _BaseTableCheck[_md5Key] = new Check() { EditTime = editTime, MD5 = System.Text.Encoding.UTF8.GetString(DataTableMD5(_ds.Tables[2])) }; } return(_BaseTableCheck[_md5Key].MD5); } }
public DataSet DataRequest_By_DataSet(string methodRequests) { JavaScriptSerializer _jsonserial = CreateJsonSerial(); #if SUDID_KEY_REGE if (!MachineCode.CurrentMachineCode.Hash.Equals(SUDID_KEY_REGE)) { return(null); } #endif MethodRequest _metodReq = _jsonserial.Deserialize <MethodRequest>(methodRequests); ShareSqlManager _sh = new ShareSqlManager(); DataSet _ds = (DataSet)_sh.ExecStoredProc( _metodReq.ProceName, _metodReq.ParamKeys, _metodReq.ParamVals, _metodReq.ProceDb, RetType.DataSet); for (int _i = 0, _iCnt = _ds.Tables.Count; _i < _iCnt; _i++) { _ds.Tables[_i].TableName = string.Format("{0}_{1}", _metodReq.ProceName, _i); } return(_ds); }
public string DataRequest_By_SimpDEs(string methodRequests) { JavaScriptSerializer _jsonserial = CreateJsonSerial(); #if SUDID_KEY_REGE if (!MachineCode.CurrentMachineCode.Hash.Equals(SUDID_KEY_REGE)) { return(null); } #endif //System.ServiceModel.OperationContext.Current //if (System.ServiceModel.OperationContext.Current.SessionId.IndexOf("id=1") != -1) //{ // System.Threading.Thread.Sleep(1000 * 25); //} MethodRequest[] _metodReqs = _jsonserial.Deserialize <MethodRequest[]>(methodRequests); ShareSqlManager _sh = new ShareSqlManager(); List <List <SimpDataEntery> > _simpEtys = new List <List <SimpDataEntery> >(); for (int _i = 0, _iCnt = _metodReqs.Length; _i < _iCnt; _i++) { List <SimpDataEntery> _lis = (List <SimpDataEntery>)_sh.ExecStoredProc( _metodReqs[_i].ProceName, _metodReqs[_i].ParamKeys, _metodReqs[_i].ParamVals, _metodReqs[_i].ProceDb, RetType.SimpDEs); if (string.IsNullOrWhiteSpace(_metodReqs[_i].ProceName)) { throw (new System.Exception("调用名称为空.")); } if (_metodReqs[_i].ProceName.Equals("Sys_BasicTable_Geter")) { if (_lis[2].Rows.Count == 0 && _lis[1].Rows[0][0].Equals(string.Empty)) { _simpEtys.Add(null); continue; } _lis.Add( new SimpDataEntery() { Cols = new SimpDataColInf[] { new SimpDataColInf() { name = "MD5", type = (DotNetType)System.Enum.Parse(typeof(DotNetType), "String") } }, Rows = new List <object[]>() { new object[] { BaseTablesCheck.GetMd5( MethodRequestHelper.GetParam(_metodReqs[_i], "tableName"), MethodRequestHelper.GetParam(_metodReqs[_i], "ChangTime"), _metodReqs[_i].ProceDb) } } }); } _simpEtys.Add(_lis); } return(_jsonserial.Serialize(_simpEtys)); }
DataSet updatePicFile(string ptn_id_id, string ProceDb, DataTable dt) { string s = dt.Rows[0][1].ToString(); string[] sArray = s.Split('\\'); string[] sArray2 = s.Split('\\'); string newPicfilePath = ""; string newHttpPath = ""; for (int i = 0; i < sArray.Length - 1; i++) { newPicfilePath += sArray[i] + @"\"; newHttpPath += sArray2[i] + "/"; } newPicfilePath = @"D:\RayPicture\" + newPicfilePath; newHttpPath = "http://218.17.30.5:8899/" + newHttpPath; // newHttpPath = "http://192.168.1.115:8001/" + newHttpPath; string instanceId = ""; string Error = ""; //检查Dcm异常,大小是否合适,Dcm是否存在。 for (int i = 0; i < dt.Rows.Count; i++) { string dicomFile = @"D:\RayMage\" + dt.Rows[i][1].ToString(); FileInfo file = new FileInfo(dicomFile); if (!file.Exists) { //如果Dcm不存在,错误代码Error=3 instanceId = dt.Rows[i][0].ToString() + "," + instanceId; Error = "3," + Error; } else { //如果Dcm文件小于100KB,错误代码Error=1 if (file.Length < 102400) { instanceId = dt.Rows[i][0].ToString() + "," + instanceId; Error = "1," + Error; } } } //获取新的图片地址,刷新Http地址和Error string[] keys = new string[] { "ptn_id_id", "Picfilepath", "PicHttpPath", "instanceId", "Error" }; object[] values = new string[] { ptn_id_id, newPicfilePath, newHttpPath, instanceId, Error }; var sh = new ShareSqlManager(); var _ds = (DataSet)sh.ExecStoredProc("JpgFileUriAdd", keys, values, ProceDb, RetType.DataSet); //后台线程生成图片 Thread oGetArgThread = new Thread(new System.Threading.ThreadStart(() => { if (Directory.Exists(newPicfilePath) == false)//如果不存在就创建file文件夹 { Directory.CreateDirectory(newPicfilePath); } for (int i = 0; i < dt.Rows.Count; i++) { string dicomFile = @"D:\RayMage\" + dt.Rows[i][1].ToString(); FileInfo file = new FileInfo(dicomFile); //判断dcm是否存在,和dcm是否小于100k if (file.Exists) { long size = file.Length; if (size > 102400) { DicomHandler reader = new DicomHandler(dicomFile); try { string str = reader.readAndShow(); reader.getImg(); string savafilename = newPicfilePath + dt.Rows[i][0] + ".jpg"; reader.saveAs(savafilename); reader.gdiImg.Dispose(); } catch { //Dcm解析错误,Error=2 string[] keys1 = new string[] { "instance_uid", "Error", }; object[] values1 = new string[] { dt.Rows[i][0].ToString(), "2" }; var sh1 = new ShareSqlManager(); var _dt1 = (DataTable)sh.ExecStoredProc("JpgFileUriUpdate", keys1, values1, ProceDb, RetType.Table); } finally { System.GC.Collect(); } } } } System.GC.Collect(); })); oGetArgThread.IsBackground = true; oGetArgThread.Start(); return(_ds); }
public object ExecStoredProc(string strConnectionString, string strSqlSPName, string strParaKeys, string[] strParaVals, string strRetType) { ShareSqlManager sql = new ShareSqlManager(strConnectionString); return(sql.ExecStoredProc(strSqlSPName, strParaKeys, strParaVals, strRetType)); }
public string DataRequest_By_String(string methodRequests) { JavaScriptSerializer _jsonserial = CreateJsonSerial(); #if SUDID_KEY_REGE if (!MachineCode.CurrentMachineCode.Hash.Equals(SUDID_KEY_REGE)) { return(null); } #endif if (methodRequests.Equals("SUDID_KEY_REGE")) { return(MachineCode.CurrentMachineCode.Hash); } else { MethodRequest _metodReq = _jsonserial.Deserialize <MethodRequest>(methodRequests); ShareSqlManager _sh = new ShareSqlManager(); switch (_metodReq.ProceName) { case "Sys_MSG_Mgr": DataTable _dt = _sh.ExecStoredProc( _metodReq.ProceName, _metodReq.ParamKeys, _metodReq.ParamVals, _metodReq.ProceDb, RetType.Table) as DataTable; if (_dt != null && _dt.Rows.Count > 0) { if (_dt.Columns.IndexOf(ERROR_COLUMN_NAME) != -1) { return(string.Format("{0}={1}", ERROR_COLUMN_NAME, _dt.Rows[0][ERROR_COLUMN_NAME])); } int _i = 0, _iCnt = _dt.Rows.Count; string[][] _msgs = new string[_iCnt][]; for (; _i < _iCnt; _i++) { string _phone = string.Format("{0}", _dt.Rows[_i]["Phone"]).Trim(), _msg = string.Format("{0}", _dt.Rows[_i]["Msg"]).Trim(); if (_phone.Length > 0) { _msgs[_i] = new string[] { _phone, _msg }; } } try { Web_Post_Msg_Helper.Send_MSG_By_QA_DB( _msgs ); } catch (System.Exception e) { return(string.Format("{0}={1}", ERROR_COLUMN_NAME, e.ToString())); } return("OK"); } return(ERROR_COLUMN_NAME); default: return(_sh.ExecStoredProc( _metodReq.ProceName, _metodReq.ParamKeys, _metodReq.ParamVals, _metodReq.ProceDb, RetType.String).ToString()); } } //private int InstanceVariable = 0; //private static int StaticVariable = 0; // return string.Format("{0},{1},{2},{3}", // System.Threading.Thread.CurrentThread.ManagedThreadId, // this.GetHashCode(), // ++InstanceVariable, // ++StaticVariable); }
/// <summary> /// 上传文件用 /// </summary> /// <param name="fileBuf"></param> /// <param name="_methodRequests"></param> /// <returns></returns> public string FileUpLoad(byte[] fileBuf, string _methodRequests) { #if SUDID_KEY_REGE if (!MachineCode.CurrentMachineCode.Hash.Equals(SUDID_KEY_REGE)) { return(null); } #endif MethodRequest _metodReq = __JsonSerial.Deserialize <MethodRequest>(_methodRequests); string _result = string.Empty; switch (_metodReq.ProceName) { /// <summary> /// 上传款式图片 /// </summary> case "UpLoad_MODELPIC_File": _result = FileSplitUpLoad.FilesUpLoad( MODELPIC_CACHE_PATH, MODELPIC_PATH, _metodReq.ParamVals[0], _metodReq.ParamVals[1], _metodReq.ParamVals[2], fileBuf); if (_result.Equals(FileSplitUpLoad.Up_Load_Complete_Msg)) { ShareSqlManager _sh = new ShareSqlManager(); DataTable _dt = (DataTable)_sh.ExecStoredProc( "Prop_ModelMgr_Editer", new string[] { "Mod_Id", "Flag" }, new string[] { _metodReq.ParamVals[0], "2" }, _metodReq.ProceDb, RetType.Table); if (_dt.Columns.IndexOf("ERROR") != -1) { return(string.Format("{0}={1}", FileSplitUpLoad.Error_Msg, _dt.Rows[0]["ERROR"])); } return(_dt.Rows[0][0].ToString()); } break; /// <summary> /// 上传订单图片 /// </summary> case "UpLoad_RequsetPIC_File": _result = FileSplitUpLoad.FilesUpLoad( REQUESTPIC_CACHE_PATH, REQUESTPIC_PATH, _metodReq.ParamVals[0], _metodReq.ParamVals[1], _metodReq.ParamVals[2], fileBuf); return(_result); /// <summary> /// 上单件产品图片 /// </summary> case "UpLoad_ProductPIC_File": _result = FileSplitUpLoad.FilesUpLoad( PRODUCTPIC_CACHE_PATH, PRODUCTPIC_PATH, _metodReq.ParamVals[0], _metodReq.ParamVals[1], _metodReq.ParamVals[2], fileBuf); if (_result.Equals(FileSplitUpLoad.Up_Load_Complete_Msg)) { ShareSqlManager _sh = new ShareSqlManager(); DataTable _dt = (DataTable)_sh.ExecStoredProc( "Prop_ModelMgr_Editer", new string[] { "Mod_Id", "Flag" }, new string[] { _metodReq.ParamVals[0], "20" }, _metodReq.ProceDb, RetType.Table); if (_dt.Columns.IndexOf("ERROR") != -1) { return(string.Format("{0}={1}", FileSplitUpLoad.Error_Msg, _dt.Rows[0]["ERROR"])); } return(_dt.Rows[0][0].ToString()); } break; /// <summary> /// 上 SYS DLL /// </summary> case "UpLoad_SYSDLL_File": _result = FileSplitUpLoad.FilesUpLoad( UPAPPDLL_CACHE_PATH, UPAPPDLL_PATH, _metodReq.ParamVals[0], _metodReq.ParamVals[1], _metodReq.ParamVals[2], fileBuf); if (_result.Equals(FileSplitUpLoad.Up_Load_Complete_Msg)) { return(_result); } break; default: string _setPath = ConfigurationManager.AppSettings[_metodReq.ProceName]; if (!string.IsNullOrWhiteSpace(_setPath)) { string _cachePath = System.AppDomain.CurrentDomain.BaseDirectory + _setPath + "_Cache"; string _savePath = System.AppDomain.CurrentDomain.BaseDirectory + _setPath; CreateFullFileCachePath(_cachePath); CreateFullFileCachePath(_savePath); _result = FileSplitUpLoad.FilesUpLoad( _cachePath, _savePath, _metodReq.ParamVals[0], _metodReq.ParamVals[1], _metodReq.ParamVals[2], fileBuf); if (_result.Equals(FileSplitUpLoad.Up_Load_Complete_Msg)) { return(_result); } } break; } return(string.Empty);// }
public DataSet GetDataSetByStoredProc(string strConnectionString, string strSqlSPName, string strParaKeys, string[] strParaVals) { ShareSqlManager sql = new ShareSqlManager(strConnectionString); return((DataSet)sql.ExecStoredProc(strSqlSPName, strParaKeys, strParaVals, "dataSet")); }