示例#1
0
        /// <summary>
        /// 反射动态执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AutoExecute(object sender, EventArgs e)
        {
            Write_Log wl = new Write_Log();

            try
            {
                string strResult   = "";
                string strReserved = "";
                string strCmd      = "";
                string strSource   = sqlstr + "|" + conStr + "|" + databasetype + "|" + parastr; //SQL语句+连接串+数据库类型+其他参数

                string[] s = RemarkContent.Trim().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                MessageBox.Show("string[] s = RemarkContent.Trim().Split(new char[]{'|'},StringSplitOptions.RemoveEmptyEntries);" + ":" + s.ToString());
                if (s.Length > 0)
                {
                    for (int i = 0; i < s.Length; i++)
                    {
                        MessageBox.Show("s[i].Split(':')[1]" + ":" + s[i].Split(':')[1]);
                        if (s[i].IndexOf("targetDeviceID") != -1 && !string.IsNullOrEmpty(s[i].Split(':')[1]))
                        {
                            IResolve.ParseResult(strSource, ref strResult, ref s[i].Split(':')[1], ref strCmd);
                        }
                    }
                }
                else
                {
                    IResolve.ParseResult(strSource, ref strResult, ref strReserved, ref strCmd);
                }
            }
            catch (Exception ex)
            {
                wl.Write(ex.Message.ToString(), "log");
            }
        }
示例#2
0
        /// <summary>
        /// 反射动态执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AutoExecute(object sender, EventArgs e)
        {
            Write_Log wl = new Write_Log();

            try
            {
                string strResult   = "";
                string strReserved = "";
                string strCmd      = "";
                string strSource   = sqlstr + "|" + conStr + "|" + databasetype + "|" + parastr;   //SQL语句+连接串+数据库类型+其他参数
                IResolve.ParseResult(strSource, ref strResult, ref strReserved, ref strCmd);
            }
            catch (Exception ex)
            {
                wl.Write(ex.Message.ToString(), "log");
            }
        }
示例#3
0
        public void AutoExecute(object sender, EventArgs e)
        {
            Write_Log wl = new Write_Log();

            try
            {
                string strResult   = "";
                string strReserved = "";
                string strCmd      = "";
                //wl.Write(DateTime.Now.ToString()+" AUTO  \r\n", "log");
                string str = @"AAAI10P190000000139501072020111342013000090007011407005287849514403230901029013444501450931641340464000000000000000100000120500782550271930162360000000000000000000000000000000000000000000000000000000000001003004008014022029037045053057060059057057053049045045044041041038039039040038037038038037035033031033031031029031031031032031034033036036038039038036035034034034034035038041041042044043045044044045047050051055056060066067069073078080087092097104110112119131133139147152162171178184195203208217220226230229232238245249254253253255254250251249249248250251250245241241240242239239234231227219213203201193193190184180176172163156146141132125116114108106105101099094088084080074069063060056054050047046043041037035032030029027025024022021021019016014013012013011011010010009008008007007006006007007007006006005005004004004004004004004004004004004003004003003003002002002002002002002002002002003003002003003003003003003003003003000000000000000000000000000000000000000000000000000000000000000000000000000001001002003004004005005005005004004003003003002002002003003003004005006006008009012014017022025031038047057069080093107124141156172188201214227237241248253254255255253248242235226218207198185177169159151144138132128120116113109106102099096094091089085083081079077075073069069066063060058057054053050047045043039037035031029028026025023021019018016015013013012012012012011011010009008008008007007006006006006005005005004004004004004004003003004003003003003003003003003003002002002002002002003002003003002003002002002002002002001001001001001001001001001001001001001001001001001001001001001001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001002003005007010014018022028035042050061072085098112126139152163175184194202211220229235242247253254255253252249246242238236235233231231231229228228228226225224223221220219218219221219218217217213210205200194188184180176173169166164163160157156156156156157158160162164166167169170171172173172171169167164161158155151148145143141139136133131129126124121118116114112111109108107106104103100097095094091089087086085085084083082081079077074072069067065064062060058057055053051049047046045045044044045046047048049050051053052052051051051051050049049049048048046045044044043042041041041042043044045047048050050051051051050049047045042040038037035034032030029028026024021019018018017017017018019020020021021021021021021021021021021";
                // IResolve.ParseResult(str, ref strResult, ref strReserved, ref strCmd);
                // IResolve.ParseResult("", ref strResult, ref strReserved, ref strCmd);
                // System.Windows.Forms.MessageBox.Show("dd");


                string[] s = RemarkContent.Trim().Split('|');
                if (s.Length > 0 && !string.IsNullOrEmpty(RemarkContent))
                {
                    for (int i = 0; i < s.Length; i++)
                    {
                        if (s[i].IndexOf("targetDeviceID") != -1 && !string.IsNullOrEmpty(s[i].Split(':')[1]))
                        {
                            IResolve.ParseResult(str, ref strResult, ref s[i].Split(':')[1], ref strCmd);
                        }
                    }
                }
                else
                {
                    IResolve.ParseResult(str, ref strResult, ref strReserved, ref strCmd);
                }
            }
            catch (Exception ex)
            {
                wl.Write(ex.Message.ToString(), "log");
            }
        }
示例#4
0
        public DataSet GetDataSet(string column, string tablename, string strwhere)
        {
            using (OracleConnection _connection = new OracleConnection(OracleHelper.GetConnectionstring()))
            {
                writelog = new Write_Log();
                DataSet ds     = new DataSet();
                string  sqlstr = "select " + column + " from " + tablename;
                if (!String.IsNullOrEmpty(strwhere))
                {
                    sqlstr = sqlstr + " where " + strwhere;
                }
                try
                {
                    _connection.Open();
                    OracleDataAdapter da = new OracleDataAdapter();
                    da.SelectCommand = new OracleCommand(sqlstr, _connection);
                    da.Fill(ds);
                }
                catch (Exception ex)
                {
                    writelog.Write("填充数据时出错!" + ex.Message + System.Environment.NewLine + sqlstr, "log");
                    return(null);
                }
                finally {
                    _connection.Close();
                    _connection.Dispose();
                }

                writelog = null;
                return(ds);
            }



            //writelog = new Write_Log();
            //if (ConnectDB.con.State != ConnectionState.Open)
            //{
            //    init = new ConnectDB();
            //    strError = init.DBConnect();
            //    if (!string.IsNullOrEmpty(strError))
            //    {
            //        writelog.Write(strError, "log");
            //        return null;
            //    }
            //}


            //string sqlstr = "select " + column + " from " + tablename;
            //if (!String.IsNullOrEmpty(strwhere))
            //{
            //    sqlstr = sqlstr + " where " + strwhere;
            //}
            ////writelog.Write(sqlstr, "log");

            //DataSet ds = new DataSet();
            //writelog.Write("1连接状态:" + ConnectDB.con.State.ToString() + "\r\n 连接字符串:" + ConnectDB.con.ConnectionString, "log");
            //OracleDataAdapter ada = new OracleDataAdapter(sqlstr, ConnectDB.con);

            //try
            //{
            //    writelog.Write("2连接状态:"+ConnectDB.con.State.ToString()+"\r\n 连接字符串:"+ ConnectDB.con.ConnectionString, "log");
            //    ada.Fill(ds, tablename);
            //}
            //catch (Exception ex)
            //{

            //    writelog.Write("填充数据时出错!" + ex.Message + System.Environment.NewLine + sqlstr, "log");
            //    return null;
            //}

            ////init.DisConnectDB(ConnectDB.con);
            //init = null;
            //writelog = null;
            //return ds;
        }
示例#5
0
        /// <summary>
        /// type 调用类型
        /// 0 - 初始化
        /// 1 - 连接
        /// 9 - 断开
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public string CallDll(string para)
        {
            writeLog = new Write_Log();
            dsHandle = new DataSetHandle();
            ds       = new DataSet();

            string strInstrumentID   = "";
            string strMicroPlateID   = "";
            string strSampleNO       = "";
            string strSampleID       = "";
            string strCallSource     = "";
            string strInstrumentKind = "";
            string strPara           = "";
            string strType           = "";
            string strReadBatch      = "";
            string strDeviceId       = "";

            strInstrumentID = "";
            strType         = "";
            strMicroPlateID = "";
            strSampleID     = "";
            strSampleNO     = "";
            strCallSource   = "";

            if (boolRun)
            {
                return(strError);
            }

            Dictionary <string, string> para_dic = new Dictionary <string, string>();

            string[] para_value = para.Split(';');
            foreach (string para_col in para_value)
            {
                if (string.IsNullOrEmpty(para_col))
                {
                    break;
                }
                string[] tmp = para_col.Split('=');
                para_dic.Add(tmp[0].ToUpper(), tmp[1]);
            }
            strPara = "";
            //仪器ID
            if (para.ToUpper().IndexOf("TEST_INSTRUMENT_ID=") >= 0)
            {
                strInstrumentID = para_dic["TEST_INSTRUMENT_ID"];
                strPara         = strPara + "TEST_INSTRUMENT_ID=" + strInstrumentID + ";";
            }
            //类型
            if (para.ToUpper().IndexOf("TYPE=") >= 0)
            {
                strType = para_dic["TYPE"];
                strPara = strPara + "TYPE=" + strType + ";";
            }


            //检验标本ID
            if (para.ToUpper().IndexOf("TEST_SAMPLE_ID=") >= 0)
            {
                strSampleID = para_dic["TEST_SAMPLE_ID"];
                strPara     = strPara + "TEST_SAMPLE_ID=" + strSampleID + ";";
            }
            //标本ID
            if (para.ToUpper().IndexOf("SAMPLE_NO=") >= 0)
            {
                strSampleNO = para_dic["SAMPLE_NO"];
                if (!string.IsNullOrEmpty(strSampleNO))
                {
                    strPara = strPara + "SAMPLE_NO=" + strSampleNO + ";";
                }
            }
            //调用来源
            if (para.ToUpper().IndexOf("CALL_SOURCE=") >= 0)
            {
                strCallSource = para_dic["CALL_SOURCE"];
                strPara       = strPara + "CALL_SOURCE=" + strCallSource + ";";
            }
            //单个读取
            if (para.ToUpper().IndexOf("READ_BATCH=") >= 0)
            {
                strReadBatch = para_dic["READ_BATCH"];
                strPara      = strPara + "READ_BATCH=" + strReadBatch + ";";
            }

            if (ConnectDB.con.State != ConnectionState.Open)
            {
                ConnectDB init = new ConnectDB();
                init.DBConnect();
            }
            //处理一台电脑解析多个数据
            for (int j = 0; j < strInstrumentID.Split(',').Length; j++)
            {
                strDeviceId = strInstrumentID.Split(',')[j];
                ds          = dsHandle.GetDataSet("通讯类型,名称", "检验仪器", "ID = '" + strDeviceId + "'");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    strError = "未找到Id[" + strDeviceId + "]的仪器";
                    writeLog.Write(strError, "log");
                    break;
                }
                strCommType   = ds.Tables[0].Rows[0]["通讯类型"].ToString();
                strDeviceName = ds.Tables[0].Rows[0]["名称"].ToString();

                //strCallSource = "1";
                //BH调用exe
                if (strCallSource == "1")
                {
                    int WINDOW_HANDLER = FindWindow(null, @"解析程序");
                    if (WINDOW_HANDLER == 0)
                    //if (WINDOW_HANDLER.Equals(IntPtr.Zero))
                    {
                        strError = "解析程序未运行!";
                        MessageBox.Show(strError, "导入数据", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        writeLog.Write(strDeviceName, strError, "log");
                        break;
                    }
                    else
                    {
                        byte[] sarr = System.Text.Encoding.Default.GetBytes(strPara);
                        int    len  = sarr.Length;

                        COPYDATASTRUCT cds;
                        cds.dwData = (IntPtr)1000;
                        cds.lpData = strPara;
                        cds.cbData = len + 1;
                        SendMessage(WINDOW_HANDLER, WM_COPYDATA, 0, ref cds);
                    }
                }
                else
                {
                    if (strCommType == "1")
                    {
                        #region  时运行
                        if (strType != "9")
                        {
                            if (!dictionary_initDll_COM.ContainsKey(strDeviceName))
                            {
                                Init_COM initDll_COM = new Init_COM();


                                if (string.IsNullOrEmpty(initDll_COM.strSampleID) && !string.IsNullOrEmpty(strSampleID))
                                {
                                    initDll_COM.strSampleID = strSampleID;
                                }
                                if (string.IsNullOrEmpty(initDll_COM.strInstrumentID) && !string.IsNullOrEmpty(strInstrumentID))
                                {
                                    initDll_COM.strInstrumentID = strInstrumentID.Split(',')[j];
                                }
                                dictionary_initDll_COM.Add(strDeviceName, initDll_COM);
                            }
                        }
                        if (strType == "0")
                        {
                            //initDll_COM.Start(strDeviceId);
                            foreach (Init_COM item in dictionary_initDll_COM.Values)
                            {
                                if (string.IsNullOrEmpty(item.status))
                                {
                                    item.Start(strDeviceId);
                                }
                            }
                        }
                        else if (strType == "9")
                        {
                            //initDll_COM.Stop();
                            foreach (Init_COM item in dictionary_initDll_COM.Values)
                            {
                                item.Stop();
                                strError = item.strError;
                            }
                            dictionary_initDll_COM.Clear();
                        }
                        #endregion
                    }
                    else if (strCommType == "2")
                    {
                        if (initDll_TCP == null)
                        {
                            initDll_TCP = new Init_TCP();
                            initDll_TCP.strInstrumentID = strInstrumentID.Split(',')[j];
                        }
                        if (strType == "0")
                        {
                            initDll_TCP.Init();
                        }
                        else if (strType == "9")
                        {
                            initDll_TCP.Stop();
                        }
                        strError = initDll_TCP.strError;
                    }
                    //xt 数据库类型支持多个同时应用
                    else if (strCommType == "3")
                    {
                        if (initDll_DB == null)
                        {
                            initDll_DB = new Init_DB();
                            initDll_DB.strInstrumentID = strInstrumentID.Split(',')[j];
                            initDll_DB.strTestNO       = strSampleNO;
                            initDll_DB.Init();

                            #region  时运行
                            //if (strType != "9")
                            //{
                            //    if (!dictionary_initDll_DB.ContainsKey(strDeviceName))
                            //    {
                            //        initDll_DB = new Init_DB();


                            //        if (string.IsNullOrEmpty(initDll_DB.strTestNO) && !string.IsNullOrEmpty(strSampleID))
                            //        {
                            //            initDll_DB.strTestNO = strSampleID;
                            //        }
                            //        if (string.IsNullOrEmpty(initDll_DB.strInstrumentID) && !string.IsNullOrEmpty(strInstrumentID))
                            //        {
                            //            initDll_DB.strInstrumentID = strInstrumentID.Split(',')[j];
                            //        }
                            //        dictionary_initDll_DB.Add(strDeviceName, initDll_DB);
                            //    }

                            //}
                            //if (strType == "0")
                            //{
                            //    //initDll_COM.Start(strDeviceId);
                            //    foreach (Init_DB item in dictionary_initDll_DB.Values)
                            //    {
                            //        if (string.IsNullOrEmpty(item.status))
                            //            item.Init(strDeviceId);
                            //    }

                            //}
                            //else if (strType == "9")
                            //{
                            //    //initDll_COM.Stop();
                            //    foreach (Init_DB item in dictionary_initDll_DB.Values)
                            //    {

                            //        item.Stop();
                            //        strError = item.strError;

                            //    }
                            //    dictionary_initDll_DB.Clear();
                            //}
                            #endregion
                        }
                        strError = initDll_DB.strError;
                    }
                    else if (strCommType == "4")
                    {
                        if (initDll_TXT == null)
                        {
                            initDll_TXT = new Init_TXT();
                        }
                        initDll_TXT.strInstrumentID = strInstrumentID.Split(',')[j];
                        initDll_TXT.bnReadBatch     = (strReadBatch == "1" ? true : false);
                        initDll_TXT.Start();
                        strError = initDll_TXT.strError;
                    }
                    else
                    {
                        strError = "未设置仪器的通讯类型!";
                    }
                    if (strType == "9")
                    {
                        if (ConnectDB.con.State == ConnectionState.Open)
                        {
                            ConnectDB init = new ConnectDB();
                            init.DisConnectDB(ConnectDB.con);
                        }
                    }
                }
                if (!String.IsNullOrEmpty(strError))
                {
                    writeLog.Write(strDeviceName, strError, "log");
                }
            }
            return(strError);
        }