Exemplo n.º 1
0
        public CMSTC(Protocol protocol, string devicename, string ip, int port, int deviceid, byte[] hw_status, byte opmode, byte opstatus, byte comm_state)
            : base(protocol, devicename, ip, port, deviceid, hw_status, opmode, opstatus,comm_state)
        {
            this.OnTCReport += new OnTCReportHandler(CMSTC_OnTCReport);
               this.OnTCReceiveText += new OnTCReportHandler(CMSTC_OnTCReceiveText);
             //  this.m_device.OnReceiveText += new OnTextPackageEventHandler(m_device_OnReceiveText);
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select show_icon,CRmode from tblCmsConfig where DeviceName='" + this.DeviceName + "'");
            cmd.Connection = cn;

            try
            {

                cn.Open();
                System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();
                if (rd.Read())
                {
                    isIcon = (System.Convert.ToInt32(rd[0])==0)?false:true;
                    CrMode = System.Convert.ToInt32(rd[1]);
                }
                rd.Close();

            }
            catch (Exception ex)
            {
                ConsoleServer.WriteLine(ex.Message + ex.StackTrace);
            }
            finally
            {
                cn.Close();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 用指定类型创建连接
        /// </summary>
        /// <param name="conn">连接字符串</param>
        /// <param name="cte">连接类型</param>
        /// <param name="dt">连接超时时间</param>
        /// <returns>返回创建的连接</returns>
        private ConnStruct CreateConnection(string conn, ConnTypeEnum cte)
        {
            DbConnection db = null;

            if (cte == ConnTypeEnum.Odbc)
            {
                db = new System.Data.Odbc.OdbcConnection(conn);//ODBC数据源连接
            }
            else if (cte == ConnTypeEnum.OleDb)
            {
                db = new System.Data.OleDb.OleDbConnection(conn);//OLE DB数据连接,Access数据库
            }
            else if (cte == ConnTypeEnum.SqlClient)
            {
                db = new System.Data.SqlClient.SqlConnection(conn);//SqlServer数据库连接
            }
            else if (cte == ConnTypeEnum.MySqlClient)
            {
                db = new MySql.Data.MySqlClient.MySqlConnection(conn);//MySqlServer数据库连接
            }
            else if (cte == ConnTypeEnum.OracleClient)
            {
                db = new System.Data.OracleClient.OracleConnection(conn);//Oracle数据库连接
            }
            else if (cte == ConnTypeEnum.MsModelClient)
            {
                db = new System.Data.EntityClient.EntityConnection(conn);//Microsoft数据库连接
            }
            ConnStruct cs = new ConnStruct(db, cte, DateTime.Now);

            cs.Open();
            return(cs);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            PANELcond_InviteCreateWS.Visible     = false;
            PANELcond_Locked.Visible             = false;
            PANELcond_NewSubpr.Visible           = false;
            PANELcond_IsOwnerOfCurrentWS.Visible = false;

            System.Data.Odbc.OdbcConnection conn = HELPERS.NewOdbcConn();



            session.ObtainWorkspaceContext_SAP();


            if (session.idWorkspace_SAP >= 0)
            {
                // A workspace already exists for this subprocess.
                PANELcond_IsOwnerOfCurrentWS.Visible = session.isWorkspaceOwner_SAP;
                PANELcond_IsOwnerOfCurrentWS.Visible = !session.isWorkspaceOwner_SAP;
            }
            else
            {
                if (session.idActiveTASS_SAP >= 0)
                {
                    PANELcond_InviteCreateWS.Visible = true;
                }
                else
                {
                    PANELcond_NewSubpr.Visible = true;
                }
            }
        }
Exemplo n.º 4
0
        // UPLOAD BUTTON HANDLER -------------------------------------------------------------------------------------------------------

        protected void uploadbutton_Click(object sender, EventArgs e)
        {
            // Get button ID
            Button getbuttonID = (Button)sender;
            string id          = getbuttonID.ID.Replace("_button", "");

            // Use button ID to find similarly named upload control ID
            FileUpload uploadcontrol = (FileUpload)Form.FindControl(id);

            // Only upload if control has file selected
            if (uploadcontrol.HasFile)
            {
                // Add upload path
                String savePath = @"c:\temp\";

                // Retrieve filename from upload control
                String fileName = uploadcontrol.FileName;

                // Save data to web server
                uploadcontrol.SaveAs(savePath + fileName);

                // Fill GridView

                // Establish text driver connection
                System.Data.Odbc.OdbcConnection  csv_connection;
                System.Data.Odbc.OdbcDataAdapter csv_adapter;

                // Create temporary data table to store CSV data
                DataTable csv_data = new DataTable();

                // Create connection string and execute connection to CSV
                string csv_connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + savePath + ";";
                csv_connection = new System.Data.Odbc.OdbcConnection(csv_connectionString);

                // Fill adapter with SELECT * query from CSV
                csv_adapter = new System.Data.Odbc.OdbcDataAdapter("select * from [" + fileName + "]", csv_connection);
                csv_adapter.Fill(csv_data);

                // Close CSV connection
                csv_connection.Close();

                // Find GridView and fill
                GridView filedata = (GridView)Form.FindControl(id + "_table");
                filedata.DataSource = csv_data;
                filedata.DataBind();

                // SESSION MODIFICATION //

                DataSet session_datanew = new DataSet();
                session_datanew.Tables.Add(csv_data);
                session_datanew.DataSetName = "PCADATA";

                Registry.Registry registry = Registry.Registry.getRegistry(Session);
                registry.registerDataset(session_datanew);
                Analysis.ParameterStream stream = Analysis.ParameterStream.getStream(Session);
                stream.set("dataSetName", "PCADATA");

                //----------------------//
            }
        }
Exemplo n.º 5
0
        private void Form4_Load(object sender, EventArgs e)
        {
            using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(gbCn))
            {
                try
                {
                    conn.Open();
                    System.Data.Odbc.OdbcCommand    command = new System.Data.Odbc.OdbcCommand("SELECT name, database_id, create_date FROM sys.databases", conn);
                    System.Data.Odbc.OdbcDataReader reader  = command.ExecuteReader();

                    //agrega nombre de base datos
                    comboBox3.Items.Clear();
                    while (reader.Read())
                    {
                        comboBox3.Items.Add(reader[0].ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ocurrio un error al obtener las bases de datos");
                    Console.WriteLine("Ocurrio un error al obtener las bases de datos");
                    Console.WriteLine(ex.Message);
                    conn.Close();
                    this.Hide();
                }
                //MessageBox.Show("ODBC Conexión Satisfatoria");
                //onsole.WriteLine("ODBC Connection test PASSED!");
                conn.Close();
            }
        }
Exemplo n.º 6
0
        public static object ExecuteScalarOnDB(string sSQL, string s_ConnectionString)
        {
            System.Data.Odbc.OdbcConnection QConnection = null;
            System.Data.Odbc.OdbcCommand    QCommand    = null;
            try
            {
                QConnection = new System.Data.Odbc.OdbcConnection(s_ConnectionString);
                QCommand    = new System.Data.Odbc.OdbcCommand(sSQL, QConnection);

                QConnection.Open();

                return(QCommand.ExecuteScalar());
            }
            finally
            {
                if (QCommand != null)
                {
                    QCommand.Dispose();
                }
                QCommand = null;
                if (QConnection != null && QConnection.State != System.Data.ConnectionState.Closed)
                {
                    QConnection.Close();
                }
                if (QConnection != null)
                {
                    QConnection.Dispose();
                }
                QConnection = null;
            }
        }
Exemplo n.º 7
0
        //check that a connection can be made to the database
        private bool CheckConnection()
        {
            if (mConnection == null)
            {
                mConnection = new System.Data.Odbc.OdbcConnection(ConnectionString);
            }
            int sleeptime = 0;

            while ((mConnection.State == System.Data.ConnectionState.Connecting ||
                    mConnection.State == System.Data.ConnectionState.Connecting ||
                    mConnection.State == System.Data.ConnectionState.Connecting) &&
                   sleeptime < 5000
                   )
            {
                sleeptime += 100;
                System.Threading.Thread.Sleep(100);
            }
            if (sleeptime > 5000)
            {
                throw new System.Net.WebException("Could not connect to database");
            }

            if (mConnection.State != System.Data.ConnectionState.Open)
            {
                mConnection.Open();
            }

            return(true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            PANELcond_AbortUpload.Visible = false;
            PANELcond_AllowUpload.Visible = false;

            System.Data.Odbc.OdbcConnection conn = HELPERS.NewOdbcConn();

            session.ObtainWorkspaceContext();

            if ((session.idWorkspace >= 0) && session.isWorkspaceOwner)
            {
                PANELcond_AllowUpload.Visible = true;
                PANELcond_AbortUpload.Visible = false;
            }
            else
            {
                PANELcond_AbortUpload.Visible = true;
                PANELcond_AllowUpload.Visible = false;
            }

            // This next line exposes a bug in WEB.UI:
            // If we do this, the selected index is LOCKED to 0.
            // If user changes the selection and then submits,
            // the selindex is still 0 from within the C# code.
            // This has to be conditionalized: not in a postback?
            if (!IsPostBack)
            {
                COMBOXchooseUnregEntAction.SelectedIndex = 0;
            }
        }
Exemplo n.º 9
0
        // The following methods handles SQL Server, Oledb, Odbc
        public static IDbConnection CreateConnection(EnumProviders provider)
        {
            IDbConnection cnn;

            switch (provider)
            {
                case EnumProviders.SqlServer:
                    cnn = new System.Data.SqlClient.SqlConnection();
                    break;
                case EnumProviders.OleDb:
                    cnn = new System.Data.OleDb.OleDbConnection();
                    break;
                case EnumProviders.Odbc:
                    cnn = new System.Data.Odbc.OdbcConnection();
                    break;
                case EnumProviders.Oracle:
                    throw new NotImplementedException("Provider not implemented");
                    break;
                default:
                    cnn = new System.Data.SqlClient.SqlConnection();
                    break;
            }

            return cnn;
        }
Exemplo n.º 10
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            string SqlStr = "";

            System.Data.Odbc.OdbcConnection Cn;
            System.Data.Odbc.OdbcCommand    Cmd;
            System.Data.Odbc.OdbcDataReader Res;
            string insertTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            Cn = new System.Data.Odbc.OdbcConnection(@"Driver={ODBC Driver 13 for SQL Server};Server=tcp:monkdb.database.windows.net,1433;Database=monkdb;Uid=monk;Pwd=!@#$qwer19;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;");
            //SqlStr = @"INSERT INTO lineid (lineid,name,type,ENABLE,createTime,UPDATETime) VALUES (N'abcdefedfsdfef',N'蘇永昇',N'userid',1,N'" + insertTime + "',N'" + insertTime + "');";
            //SqlStr = @"insert into Replymsg (keyValue,returnMSG,ENABLE,CreateTime,UPDATETime) values
            //(N'你是誰',N'我?你竟然不知道我是誰?其實我也不知道我是誰?要問邀我進來的那個白目仔。',1,'20200512_100000','20200512_100000' );";

            //SqlStr = @"insert into Receivemsg (  MSG, fromUser, fromRoom ) values (  N'msgmsgmsg',  'userid', 'roomid' );  ";      接收訊息db

//            SqlStr = @"insert into Replymsg (keyValue,returnMSG,ENABLE,CreateTime,UPDATETime) values (N'白鳥',N'據傳他的奶茶是瀉藥中的勞斯萊斯!',1,'20200512_100000','20200512_100000' );
//insert into Replymsg (keyValue,returnMSG,ENABLE,CreateTime,UPDATETime) values (N'小號',N'其實sax比較帥,不然你問monk',1,'20200512_100000','20200512_100000' );
//insert into Replymsg (keyValue,returnMSG,ENABLE,CreateTime,UPDATETime) values (N'長號',N'老話一句,其實sax比較帥',1,'20200512_100000','20200512_100000' );";

            Cmd = new System.Data.Odbc.OdbcCommand(SqlStr, Cn);
            try
            {
                Cn.Open( );
                Cmd.ExecuteNonQuery( );
                lbinsertMSG.Text = "insert ok";
            }
            catch (Exception ex)
            {
                lbinsertMSG.Text = ex.ToString( );
            }
        }
Exemplo n.º 11
0
        public string ExecuteNonQuery(string sQuery)
        {
            string sFuncName = "ExecuteNonQuery()";

            string sConstr = ConfigurationManager.ConnectionStrings["adapterConnection"].ToString();

            System.Data.Odbc.OdbcConnection oCon = new System.Data.Odbc.OdbcConnection(sConstr);
            System.Data.Odbc.OdbcCommand    oCmd = new System.Data.Odbc.OdbcCommand();

            try
            {
                oCon.Open();
                oCmd.CommandType    = CommandType.Text;
                oCmd.CommandText    = sQuery;
                oCmd.Connection     = oCon;
                oCmd.CommandTimeout = 120;
                oCmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Completed with ERROR", sFuncName);
                }
                oCon.Dispose();
                throw new Exception(ex.Message);
            }
            return("SUCCESS");
        }
Exemplo n.º 12
0
        public IDbConnection CreateConnection()
        {
            object connObj = null;

            switch (Name)
            {
            case "System.Data.SqlClient":
                connObj = new System.Data.SqlClient.SqlConnection();
                break;

            case "System.Data.Odbc":
                connObj = new System.Data.Odbc.OdbcConnection();
                break;

            case "System.Data.OleDb":
                connObj = new System.Data.OleDb.OleDbConnection();
                break;

            default:
                connObj = Activator.CreateInstance(ConnectionType);
                break;
            }

            if (connObj == null)
            {
                throw new Exception(String.Format("Unable to create instance of connection class: {0} from assembly: {1}",
                                                  connectionTypeName, assemblyName));
            }

            return((IDbConnection)connObj);
        }
Exemplo n.º 13
0
        public override List <DDD_MSJ.DOM.Mensaje> getMensajes()
        {
            var sqlConexion = new System.Data.Odbc.OdbcConnection("Dsn=prova");
            var sqlComando  = new System.Data.Odbc.OdbcCommand();

            System.Data.Odbc.OdbcDataReader sqlReader;

            sqlComando.CommandText = "select * from mensajeria.Mensaje;";
            sqlComando.CommandType = System.Data.CommandType.Text;
            sqlComando.Connection  = sqlConexion;

            try
            {
                sqlConexion.Open();
                sqlReader = sqlComando.ExecuteReader();

                string IdMensaje   = "";
                string Descripcion = "";
                DDD_MSJ.DOM.Mensaje Mensaje;

                while (sqlReader.Read())
                {
                    IdMensaje   = sqlReader.GetString(0);
                    Descripcion = sqlReader.GetString(1);
                    Mensaje     = new DDD_MSJ.DOM.Mensaje(IdMensaje, Descripcion);
                    this.m_lstMensajes.Add(Mensaje);
                }
            }
            finally
            {
                sqlConexion.Close();
            }

            return(this.m_lstMensajes);
        }
Exemplo n.º 14
0
        public DataTable ExecuteSelectQuery(string sQuery)
        {
            string sFuncName = "ExecuteSelectQuery()";

            string sConstr = ConfigurationManager.ConnectionStrings["adapterConnection"].ToString();

            System.Data.Odbc.OdbcConnection oCon = new System.Data.Odbc.OdbcConnection(sConstr);
            System.Data.Odbc.OdbcCommand    oCmd = new System.Data.Odbc.OdbcCommand();
            DataSet oDs = new DataSet();

            try
            {
                oCon.Open();
                oCmd.CommandType    = CommandType.Text;
                oCmd.CommandText    = sQuery;
                oCmd.Connection     = oCon;
                oCmd.CommandTimeout = 120;
                System.Data.Odbc.OdbcDataAdapter da = new System.Data.Odbc.OdbcDataAdapter(oCmd);
                da.Fill(oDs);
            }
            catch (Exception ex)
            {
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Completed with Error", sFuncName);
                }
                oCon.Dispose();
                throw new Exception(ex.Message);
            }
            return(oDs.Tables[0]);
        }
Exemplo n.º 15
0
        public bool DesmaterializaDado(cDados dado)
        {
            string sql;

            try
            {
                sql = "INSERT INTO dados(id_avaliacao, data_hora, freq_cardiaca) values (?, ?, ?)";

                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();


                sqlCmd = new System.Data.Odbc.OdbcCommand(sql, sqlConn);

                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value      = dado.id_avaliacao;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.DateTime).Value = dado.data;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value      = dado.fc;


                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    sqlConn.Close();
                    return(true);
                }
                else
                {
                    sqlConn.Close();
                    return(false);
                }
            }
            catch (Exception Ex)
            {
                return(false);
            }
        }
Exemplo n.º 16
0
        public bool DesmaterializaPessoa(cPessoa objPessoa)
        {
            string sql;

            try
            {
                sql = "INSERT INTO pessoa(nome, sexo, dt_nascimento) values (?, ?, ?)";

                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();


                sqlCmd = new System.Data.Odbc.OdbcCommand(sql, sqlConn);

                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.VarChar, 255).Value = objPessoa.sNome;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.VarChar, 1).Value   = objPessoa.sSexo;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Date).Value         = objPessoa.dtDataNasc;


                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    sqlConn.Close();
                    return(true);
                }
                else
                {
                    sqlConn.Close();
                    return(false);
                }
            }
            catch (Exception Ex)
            {
                return(false);
            }
        }
Exemplo n.º 17
0
        public HostInfo[] getHostInfos()
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection("dsn=TCS;uid=db2inst1;pwd=db2inst1");
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select HostID,HostIP from tblHostConfig  where  hosttype='1'");
            System.Data.Odbc.OdbcDataReader rd;
            try
            {
                cmd.Connection=cn;
                cn.Open();
                rd = cmd.ExecuteReader();
                System.Collections.Generic.List<HostInfo> lst = new List<HostInfo>();
                while (rd.Read())
                {
                    HostInfo hi = new HostInfo();
                    hi.HostName = rd["HostID"].ToString();
                    hi.IP = rd["HostIP"].ToString();
                    lst.Add(hi);

                }
                return lst.ToArray();
            }

            finally
            {
                cn.Close();
            }
        }
        /* Construct a connection string. If a user specifies their own connection
         * string, the contents of the 'server', 'database', 'username', and 'password'
         * fields are disregarded. */
        private void DSNAccept_Click(object sender, EventArgs e)
        {
            dsnSource = "DSN=" + DSNOp.Text.ToString()  + ";";

            /*Try connection String, catch if string is improperly
             * formatted*/
            try
            {
                System.Data.Odbc.OdbcConnection connection = new System.Data.Odbc.OdbcConnection(dsnSource);

                /*Try to connect with the provided MySqlConnection. If successful, launch
                 * The main application. If the connection fails to reach a source, catch
                 * and produce an error message. */
                try
                {
                    connection.Open();
                    connection.Close();
                    main = new MajorEvaluator.MainWindow(this);
                    main.ShowDialog(this);
                    this.Close();

                }
                catch (Exception s)
                {
                    MessageBox.Show("Could not connect to server. Please try again.");
                    //MessageBox.Show(s.ToString());
                    DSNOp.Clear();
                }
            } catch (Exception s) {
                MessageBox.Show("Improper connection string.");
                //MessageBox.Show(s.ToString());
            }
        }
Exemplo n.º 19
0
        protected new void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            PANELcond_AbortUpload.Visible = false;
            PANELcond_AllowUpload.Visible = false;

            System.Data.Odbc.OdbcConnection conn = HELPERS.NewOdbcConn();
            // Is there a currently active ed workspace for this subprocess?\
            IEditingWorkspace engineWS = new IEditingWorkspace(conn);

            returnListEditingWorkspaceBySubProcess[] listWS =
                engineWS.ListEditingWorkspaceBySubProcess(null, session.idSubprocess);
            if (listWS.Length > 1)
            {
                throw new Exception("Internal error: more than one workspace for subprocess "
                                    + session.idSubprocess);
            }
            if (listWS.Length == 1)
            {
                // A workspace already exists for this subprocess.
                // If the WS owner matches this user, invite them to visit the WS.
                PANELcond_AbortUpload.Visible = true;
            }
            else
            {
                PANELcond_AllowUpload.Visible = true;
            }
        }
Exemplo n.º 20
0
        public void loadValidCheckRule()
        {
            ConsoleServer.WriteLine("Loaad Range Table");
             System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
             System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select minvalue,maxvalue from tblRDvalidRange");
             try
             {
             cn.Open();
             cmd.Connection = cn;
             System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();
             if (rd.Read())
             {
                 minvalue = System.Convert.ToInt32(rd[0]);
                 maxvalue = System.Convert.ToInt32(rd[1]);
             }

             }
             catch (Exception ex)
             {
             ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
             }
             finally
             {
             cn.Close();
             }
        }
Exemplo n.º 21
0
        public DataTable ExecuteSQLQuery(string sQuery, string sCompanyCode, System.Data.Odbc.OdbcParameter[] param)
        {
            string sFuncName = "ExecuteSQLQuery()";
            string sConstr   = ConfigurationManager.ConnectionStrings["DBSSG"].ToString();

            string[] sArray           = sConstr.Split(';');
            string   sSplitCompany    = sConstr.Split(';').Last();
            string   sSplit1          = sSplitCompany.Split('=').First();
            string   sCompanyGenerate = sSplit1 + "=" + sCompanyCode;

            sConstr = sArray[0] + ";" + sArray[1] + ";" + sArray[2] + ";" + sArray[3] + ";" + sCompanyGenerate;
            if (p_iDebugMode == DEBUG_ON)
            {
                oLog.WriteToLogFile_Debug("Connection String : " + sConstr, sFuncName);
            }

            System.Data.Odbc.OdbcConnection oCon = new System.Data.Odbc.OdbcConnection(sConstr);
            System.Data.Odbc.OdbcCommand    oCmd = new System.Data.Odbc.OdbcCommand();
            DataSet oDs = new DataSet();

            try
            {
                oCon.Open();
                oCmd.CommandType = CommandType.Text;
                oCmd.CommandText = sQuery;
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("SQL Query : " + sQuery, sFuncName);
                }
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Before adding Parameters", sFuncName);
                }
                foreach (var item in param)
                {
                    oCmd.Parameters.Add(item);
                }
                //oCmd.Parameters.Add((param);
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("After adding parameters", sFuncName);
                }

                oCmd.Connection     = oCon;
                oCmd.CommandTimeout = 120;
                System.Data.Odbc.OdbcDataAdapter da = new System.Data.Odbc.OdbcDataAdapter(oCmd);
                da.Fill(oDs);
            }
            catch (Exception ex)
            {
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Completed With Error", sFuncName);
                }
                oCon.Dispose();
                throw new Exception(ex.Message);
            }
            return(oDs.Tables[0]);
        }
Exemplo n.º 22
0
        public FederateRegister()
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["FederateNamespaceDatabaseConnection"].ConnectionString;
            mConnection = new System.Data.Odbc.OdbcConnection(ConnectionString);

            if (!CheckConnection())
                throw (new SystemException("Could not connect to Federate Register Database"));
        }
Exemplo n.º 23
0
 public void NamedParametersAreConvertedToPositionalParameters()
 {
     var c = new System.Data.Odbc.OdbcConnection(ConfigurationManager.ConnectionStrings["Odbc"].ConnectionString);
     dynamic i = c.QuerySql("SELECT p=@p, q=@q, r=@p", new { p = 5, q = 9 }).First();
     Assert.AreEqual(5, i.p);
     Assert.AreEqual(9, i.q);
     Assert.AreEqual(5, i.r);
 }
Exemplo n.º 24
0
        /// <summary>
        /// 取消门诊发药状态
        /// </summary>
        /// <param name="dset"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string SaveMzQxFyzt(DataSet dset, RelationalDatabase db)
        {
            try
            {
                DataTable tb    = dset.Tables[0];
                string    ssql  = "";
                DataRow   row   = tb.Rows[0];
                string    BIZID = row["BIZID"].ToString();
                string    DH    = row["DH"].ToString();

                #region 老HIS事务处理
                System.Data.Odbc.OdbcConnection  connection = new System.Data.Odbc.OdbcConnection(DAL.BaseDal.oldhis_constr);
                System.Data.Odbc.OdbcTransaction tx         = null;
                System.Data.Odbc.OdbcCommand     cmd        = new System.Data.Odbc.OdbcCommand();
                try
                {
                    connection.Open();
                    cmd.Connection  = connection;
                    tx              = connection.BeginTransaction();
                    cmd.Transaction = tx;

                    cmd.CommandText = "update MZ_CFD_ZB set sfty='N',qrty='',tyr='', tyrq=null  where dh='" + DH + "' and sftf='N'";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "update MZ_CFD_CB set sfty='N',qrty='',tyr=''  where dh='" + DH + "'";
                    cmd.ExecuteNonQuery();

                    tx.Commit();
                    cmd.Dispose();
                    connection.Close();
                }
                catch (Exception ex)
                {
                    //事务回滚
                    tx.Rollback();
                    cmd.Dispose();
                    connection.Close();
                    tx.Dispose();
                    throw new Exception(ex.Message);
                }

                #endregion

                #region 回填新HIS记录
                for (int nrow = 0; nrow <= tb.Rows.Count - 1; nrow++)
                {
                    ssql = "update EVENTLOG set FINISH=1 ,FINISH_DATE='" + DateTime.Now.ToString() + "' where EVENT='MZQXFYZT' AND BIZID='" + BIZID + "'";
                    db.DoCommand(ssql);
                }
                #endregion

                System.String[] str = { "0", "保存成功" };
                return(HisFunctions.GetResponseString("SaveKcph", str));
            }
            catch (Exception err)
            {
                throw err;
            }
        }
Exemplo n.º 25
0
        public void NamedParametersAreConvertedToPositionalParameters()
        {
            var     c = new System.Data.Odbc.OdbcConnection("Driver={SQL Server};Server=.;Database=InsightDbTests; Trusted_Connection=Yes;");
            dynamic i = c.QuerySql("SELECT p=@p, q=@q, r=@p", new { p = 5, q = 9 }).First();

            Assert.AreEqual(5, i.p);
            Assert.AreEqual(9, i.q);
            Assert.AreEqual(5, i.r);
        }
Exemplo n.º 26
0
        public void NamedParametersAreConvertedToPositionalParameters()
        {
            var     c = new System.Data.Odbc.OdbcConnection(ConfigurationManager.ConnectionStrings["Odbc"].ConnectionString);
            dynamic i = c.QuerySql("SELECT p=@p, q=@q, r=@p", new { p = 5, q = 9 }).First();

            Assert.AreEqual(5, i.p);
            Assert.AreEqual(9, i.q);
            Assert.AreEqual(5, i.r);
        }
        protected override void SavePersonalizationBlob
            (WebPartManager webPartManager, string path, string userName,
            byte[] dataBlob)
        {
            System.Data.Odbc.OdbcCommand    updateCommand    = null;
            System.Data.Odbc.OdbcConnection updateConnection = null;
            string sSQL = null;

            try
            {
                sSQL             = "SELECT COUNT(`username`) FROM `personalization` WHERE `username` = '" + userName + "' AND `path` = '" + path + "' and `applicationname` = '" + m_ApplicationName + "';";
                updateConnection = new System.Data.Odbc.OdbcConnection(System.Configuration.ConfigurationManager.ConnectionStrings[m_ConnectionStringName].ToString());
                if (int.Parse(RawDBQuery.ExecuteScalarOnDB(sSQL, System.Configuration.ConfigurationManager.ConnectionStrings[m_ConnectionStringName].ToString()).ToString()) > 0)
                {
                    sSQL          = "UPDATE `personalization` SET `personalizationblob` = ? WHERE `username` = ? AND `applicationname` = ? AND `path` = ?;";
                    updateCommand = new System.Data.Odbc.OdbcCommand(sSQL, updateConnection);
                    updateCommand.Parameters.Clear();
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("personalizationblob", dataBlob));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("username", userName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("applicationname", m_ApplicationName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("path", path));
                }
                else
                {
                    sSQL          = "INSERT INTO `personalization` (`username`,`path`,`applicationname`,`personalizationblob`) VALUES (?, ?, ?, ?);";
                    updateCommand = new System.Data.Odbc.OdbcCommand(sSQL, updateConnection);
                    updateCommand.Parameters.Clear();
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("username", userName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("path", path));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("applicationname", m_ApplicationName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("personalizationblob", dataBlob));
                }
                updateConnection.Open();
                updateCommand.ExecuteNonQuery();
            }
            finally
            {
                if (updateConnection != null)
                {
                    if (updateConnection.State != System.Data.ConnectionState.Closed)
                    {
                        updateConnection.Close();
                    }
                    else
                    {
                        updateConnection.Dispose();
                    }
                }
                updateConnection = null;
                if (updateCommand != null)
                {
                    updateCommand.Dispose();
                }
                updateCommand = null;
                sSQL          = null;
            }
        }
Exemplo n.º 28
0
        public bool MaterializaAvaliacao(cAvaliacao obj)
        {
            string sql;

            try
            {
                sql  = "SELECT a.id as id, ";
                sql += " a.data as data, ";
                sql += " a.idade as idade, ";
                sql += " a.peso as peso, ";
                sql += " a.altura as altura, ";
                sql += " a.nivel_atividade as nivel_atividade, ";
                sql += " a.gordura as gordura, ";
                sql += " a.vo2 as vo2, ";
                sql += " a.desc_atividade as desc_atividade, ";
                sql += " a.observacoes as observacoes, ";
                sql += " a.fc_max_obtida as fc_max_obtida, ";
                sql += " a.fc_min_obtida as fc_min_obtida, ";
                sql += " a.fc_media_obtida as fc_media_obtida, ";
                sql += " a.tmb as tmb, ";
                sql += " a.fc_basal as fc_basal, ";
                sql += " p.nome as x_nome ";
                sql += " FROM avaliacao AS a LEFT JOIN pessoa AS p ON p.id = a.id_pessoa WHERE a.id = " + obj.id.ToString();

                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();

                sqlCmd     = new System.Data.Odbc.OdbcCommand(sql, sqlConn);
                sqlAdapter = new System.Data.Odbc.OdbcDataAdapter();

                sqlAdapter.SelectCommand = sqlCmd;

                sqlDataSet = new System.Data.DataSet();
                sqlAdapter.Fill(sqlDataSet);

                System.Data.DataTable dt = sqlDataSet.Tables[0];

                if (dt.Rows.Count > 0)
                {
                    System.Data.DataRow linha = dt.Rows[0];
                    obj.id              = int.Parse(linha["id"].ToString());
                    obj.idade           = int.Parse(linha["idade"].ToString());
                    obj.peso            = float.Parse(linha["peso"].ToString());
                    obj.data_hora       = DateTime.Parse(linha["data"].ToString());
                    obj.x_nome          = linha["x_nome"].ToString();
                    obj.altura          = float.Parse(linha["altura"].ToString());
                    obj.nivel_atividade = int.Parse(linha["altura"].ToString());
                }

                sqlConn.Close();
                return(true);
            }
            catch (Exception Ex)
            {
                return(false);
            }
        }
Exemplo n.º 29
0
        void AddID(String UserID, String UserName, string IDtype)
        {
            string strPath = HttpContext.Current.Request.PhysicalApplicationPath + "LineID.csv";// "C:\\Test.csv";

            System.IO.FileInfo file;
            FileStream         fs;
            StreamWriter       sw;

            //CHECK LineID.csv exist   &   create lineID.csv
            if (File.Exists(strPath) == false)
            {
                file = new FileInfo(strPath);
                fs   = new FileStream(strPath, FileMode.Append, FileAccess.Write);
                sw   = new StreamWriter(fs, Encoding.Default);
                sw.Write("LineID,Name,type,CreateTime", true);
                sw.Write(Environment.NewLine, true);
                sw.Close( );
            }


            string csvStr = "";

            System.Data.Odbc.OdbcConnection csvCn;
            System.Data.Odbc.OdbcCommand    csvCmd;
            System.Data.Odbc.OdbcDataReader csvRes;
            csvCn = new System.Data.Odbc.OdbcConnection(@"Driver={Microsoft Text Driver (*.txt; *.csv)};extensions=csv,txt;DBQ=" + HttpContext.Current.Request.PhysicalApplicationPath + ";");
            csvCn.Open( );
            csvStr = @"SELECT Name FROM LineID.csv WHERE LineID = '" + UserID + "'";
            csvCmd = new System.Data.Odbc.OdbcCommand(csvStr, csvCn);
            var tmp = csvCmd.ExecuteScalar( );

            if (tmp == null)
            {
                //add id
                file = new FileInfo(strPath);
                fs   = new FileStream(strPath, FileMode.Append, FileAccess.Write);
                sw   = new StreamWriter(fs, Encoding.Default);
                sw.Write(UserID + "," + UserName + "," + IDtype + "," + DateTime.Now.ToString("yyyyMMdd_HHmmssfff"), true);
                sw.Write(Environment.NewLine, true);
                sw.Close( );
            }
            else if (tmp.ToString( ) != UserName.ToString( ) && IDtype == "UserID")
            {
                //add id
                file = new FileInfo(strPath);
                fs   = new FileStream(strPath, FileMode.Append, FileAccess.Write);
                sw   = new StreamWriter(fs, Encoding.Default);
                sw.Write(UserID + "," + UserName + "," + IDtype + "," + DateTime.Now.ToString("yyyyMMdd_HHmmssfff"), true);
                sw.Write(Environment.NewLine, true);
                sw.Close( );
            }
            else
            {
            }
            csvCn.Close( );
        }
Exemplo n.º 30
0
        // Code changes done here with Param
        public DataTable ExecuteSelectQuery(string sQuery, System.Data.Odbc.OdbcParameter[] param)
        {
            string sFuncName = "ExecuteSelectQuery()";

            if (p_iDebugMode == DEBUG_ON)
            {
                oLog.WriteToLogFile_Debug("Starting Function", sFuncName);
            }
            string sConstr = ConfigurationManager.ConnectionStrings["adapterConnection"].ToString();

            System.Data.Odbc.OdbcConnection oCon = new System.Data.Odbc.OdbcConnection(sConstr);
            System.Data.Odbc.OdbcCommand    oCmd = new System.Data.Odbc.OdbcCommand();
            DataSet oDs = new DataSet();

            try
            {
                oCon.Open();
                oCmd.CommandType = CommandType.Text;
                oCmd.CommandText = sQuery;
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("SQL Query : " + sQuery, sFuncName);
                }
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Before adding Parameters", sFuncName);
                }
                foreach (var item in param)
                {
                    oCmd.Parameters.Add(item);
                }
                //oCmd.Parameters.Add((param);
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("After adding parameters", sFuncName);
                }
                oCmd.Connection     = oCon;
                oCmd.CommandTimeout = 120;
                System.Data.Odbc.OdbcDataAdapter da = new System.Data.Odbc.OdbcDataAdapter(oCmd);
                da.Fill(oDs);
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Completed with Success", sFuncName);
                }
            }
            catch (Exception ex)
            {
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToLogFile_Debug("Completed with Error", sFuncName);
                }
                oCon.Dispose();
                throw new Exception(ex.Message);
            }
            return(oDs.Tables[0]);
        }
Exemplo n.º 31
0
        public FederateRegister()
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["FederateNamespaceDatabaseConnection"].ConnectionString;
            mConnection      = new System.Data.Odbc.OdbcConnection(ConnectionString);

            if (!CheckConnection())
            {
                throw (new SystemException("Could not connect to Federate Register Database"));
            }
        }
Exemplo n.º 32
0
        public void SendCmdImmediately(string sqlCmd)
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(DbCmdServer.getDbConnectStr());
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(sqlCmd);

            cmd.Connection = cn;

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
        }
Exemplo n.º 33
0
        } // End Constructor

        public cSybase(string strConnectionString)
        {
            //this.m_DatabaseConfiguration = dbcDBconfig;
            this.m_dbtDBtype           = DataBaseEngine_t.ODBC;
            this.m_providerFactory     = this.GetFactory();
            this.m_dictScriptTemplates = GetSQLtemplates();
            this.m_dblDBversion        = 0.0;
            this.m_ConnectionString    = new System.Data.Odbc.OdbcConnectionStringBuilder();

            this.m_SqlConnection = new System.Data.Odbc.OdbcConnection(strConnectionString);
        } // End Constructor 2
Exemplo n.º 34
0
 //check that a connection can be made to the database
 private System.Data.Odbc.OdbcConnection GetConnection()
 {
     if (mConnection == null)
     {
         mConnection = new System.Data.Odbc.OdbcConnection(ConnectionString);
     }
     if (mConnection.State == System.Data.ConnectionState.Closed)
     {
         mConnection.Open();
     }
     return(mConnection);
 }
Exemplo n.º 35
0
        /// <summary>
        /// 获取医保结算结果
        /// </summary>
        /// <returns></returns>
        public static int GetSiResult(string path, string tablename, ref Neusoft.HISFC.Models.RADT.PatientInfo p, ref string errTxt)
        {
            if (tablename.Substring(0, 1).ToUpper() != "S")
            {
                tablename = "S" + tablename;
            }
            string connect = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277; Dbq=" + path;

            System.Data.Odbc.OdbcConnection myconn = new System.Data.Odbc.OdbcConnection(connect);
            //个人身份号码	住院号	在院总金额	社保支付金额	个人自费金额		纯自费金额		起伏金额	按比例自负	统筹记账金额	大额记账金额	公务员记账金额	帐户支付金额	现金支付金额	医保记账总额	医保帐户余额	就诊记录号
            //GMSFHM	ZYH	ZYZJE	SBZFJE	GRZFJE	ZFYY	CZFJE	BFZFJE	QFJE	ABLZF	TCJZJE	DEJZJE	GWYJZJE	ZHZFJE	XJZFJE	YBJZZE	YBZHYE	JZJLH
            string select = "select * from " + tablename;

            System.Data.Odbc.OdbcCommand    cmSelect = new System.Data.Odbc.OdbcCommand(select, myconn);
            System.Data.Odbc.OdbcDataReader cmReader;
            try
            {
                myconn.Open();
                cmReader = cmSelect.ExecuteReader();
            }
            catch (Exception ex)
            {
                errTxt = "导出医保信息失败!" + ex.Message;
                return(-1);
            }
            if (!cmReader.Read())
            {
                errTxt = "医保结算数据不存在!";
                return(-2);
            }
            try
            {
                p.IDCard                       = cmReader["GMSFHM"].ToString();                                      //公民身份号码
                p.SIMainInfo.RegNo             = cmReader["ZYH"].ToString();                                         //住院号
                p.SIMainInfo.TotCost           = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["ZYZJE"]);   //住院总金额
                p.SIMainInfo.OwnCost           = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["XJZFJE"]);  //现金支付
                p.SIMainInfo.PayCost           = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["ZHZFJE"]);  //账户支付
                p.SIMainInfo.PubCost           = p.SIMainInfo.TotCost - p.SIMainInfo.OwnCost - p.SIMainInfo.PayCost; //统筹支付
                p.SIMainInfo.OverCost          = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["DEJZJE"]);  //大额记账金额
                p.SIMainInfo.BaseCost          = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["QFJE"]);    //起付金额
                p.SIMainInfo.IndividualBalance = Neusoft.FrameWork.Function.NConvert.ToDecimal(cmReader["YBZHYE"]);  //医保账户余额

                cmReader.Close();
                cmSelect.Dispose();
                myconn.Close();
            }
            catch (Exception e)
            {
                errTxt = e.ToString();
                return(-1);
            }
            return(1);
        }
Exemplo n.º 36
0
        /// <summary>
        /// DBF数据导入
        /// </summary>
        /// <returns>成功返回1 失败返回-1</returns>
        protected int ImportDBF(string dataFilePath)
        {
            if (this.ds != null)
            {
                this.ds.Clear();
            }
            else
            {
                this.ds = new DataSet();
            }

            try
            {
                Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm(Neusoft.FrameWork.Management.Language.Msg("正在读入数据 请稍候.."));
                Application.DoEvents();

                string sourcePathName = dataFilePath.Substring(0, dataFilePath.LastIndexOf("\\"));
                string sourceFileName = dataFilePath.Substring(dataFilePath.LastIndexOf("\\") + 1, dataFilePath.Length - dataFilePath.LastIndexOf("\\") - 1);

                this.odbcDataAdapter    = new System.Data.Odbc.OdbcDataAdapter();
                this.odbcDataCommand    = new System.Data.Odbc.OdbcCommand();
                this.odbcDataConnection = new System.Data.Odbc.OdbcConnection();
                this.odbcDataConnection.ConnectionString = "MaxBufferSize=2048;DSN=dBASE Files;PageTimeout=5;DefaultDir=" + sourcePathName + "\\;DBQ=" + sourcePathName + "\\;DriverId=" + "533";
                this.odbcDataCommand.Connection          = this.odbcDataConnection;
                this.odbcDataAdapter.SelectCommand       = this.odbcDataCommand;
                this.odbcDataCommand.CommandText         = "SELECT *  FROM " + sourceFileName;
                this.odbcDataAdapter.Fill(this.ds);

                if (this.ds.Tables.Count <= 0)
                {
                    MessageBox.Show(Neusoft.FrameWork.Management.Language.Msg("无数据"));
                    return(1);
                }

                int column = this.ds.Tables[0].Columns.Count;
                int row    = this.ds.Tables[0].Rows.Count;

                this.lbDataInfo.Text = "该数据文件共有" + column.ToString() + "列。共有" + row.ToString() + "条记录。";

                this.neuSpread1_Sheet1.DataSource = this.ds;

                this.rs = DialogResult.OK;

                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message.ToString());
                return(-1);
            }

            return(1);
        }
Exemplo n.º 37
0
        public int DesmaterializaAvaliacao(cAvaliacao obj)
        {
            string sql;

            try
            {
                sql  = "INSERT INTO avaliacao(id_pessoa, data, idade, peso, altura, nivel_atividade, gordura, vo2, ";
                sql += " desc_atividade, observacoes, fc_max_obtida, fc_min_obtida, fc_media_obtida, fc_basal, tmb) ";
                sql += " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();


                sqlCmd = new System.Data.Odbc.OdbcCommand(sql, sqlConn);

                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.id_pessoa;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.DateTime).Value     = obj.data_hora;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.idade;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Double).Value       = obj.peso;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Double).Value       = obj.altura;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.nivel_atividade;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Double).Value       = obj.gordura;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Double).Value       = obj.vo2;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.VarChar, 255).Value = obj.atividade;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Text).Value         = obj.observacoes;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.fc_max;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.fc_min;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.fc_med;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.fc_basal;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value          = obj.tmb;


                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    sql    = "select @@identity";
                    sqlCmd = new System.Data.Odbc.OdbcCommand(sql, sqlConn);
                    int id = (int)sqlCmd.ExecuteScalar();
                    sqlConn.Close();
                    return(id);
                }
                else
                {
                    sqlConn.Close();
                    return(-1);
                }
            }
            catch (Exception Ex)
            {
                return(-1);
            }
        }
Exemplo n.º 38
0
 public static System.Data.DataSet GetDataSet(System.Data.Odbc.OdbcConnection conn, string sql)
 {
     try{
         var command = new System.Data.Odbc.OdbcCommand(sql, conn);
         var adapter = new System.Data.Odbc.OdbcDataAdapter(command);
         var set     = new System.Data.DataSet();
         adapter.Fill(set);
         return(set);
     }catch (Exception ex) {
         throw ex;
     }finally{
     }
 }
Exemplo n.º 39
0
                public override void PreImportar()
                {
                        if (ConexionExterna != null) {
                                if (ConexionExterna.State == System.Data.ConnectionState.Open)
                                        ConexionExterna.Close();
                                ConexionExterna.Dispose();
                        }

                        ConexionExterna = new System.Data.Odbc.OdbcConnection();
                        ConexionExterna.ConnectionString = @"dsn=" + this.Dsn + ";";
                        ConexionExterna.Open();

                        base.PreImportar();
                }
Exemplo n.º 40
0
        /// <summary>
        /// 使用离线数据库连接器,无需使用Open方法,获取数据库当前时间
        /// </summary>
        public override DateTime GetDateTimeNow()
        {
            DateTime ret = DateTime.Now;
            using (System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection(this.ConnectionText))
            {
                using (System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select now()", con))
                {
                    con.Open();
                    ret = Convert.ToDateTime(cmd.ExecuteScalar());
                    con.Close();
                }
            }

            return ret;
        }
Exemplo n.º 41
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pid"></param>
 public void DisableTempDatastreams(string pid)
 {
     using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(connectionString))
     {
         conn.Open();
         using (var command = conn.CreateCommand())
         {
             command.CommandText = "CALL RemoveFromCurrentUploads(?)";
             command.CommandType = System.Data.CommandType.StoredProcedure;
             command.Parameters.AddWithValue("targetpid", pid);
             //if (command.ExecuteNonQuery() != 1) { throw new Exception("Stored procedure call RemoveFromCurrentUploads failed."); }
             command.ExecuteNonQuery();
         }
         conn.Close();
     }
 }
Exemplo n.º 42
0
        public MovingConstructManager()
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Global.Db2ConnectionString);
              //  System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select id, notifier, timeStamp, lineID, directionID, startMileage, endMileage, blockTypeId, blocklane, description,Execution,originalEventid from TBLIIPMCNSLOG");
               System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select id, notifier, t1.timeStamp, t1.lineID, directionID, startMileage, endMileage, blockTypeId, blocklane, description,t1.Execution,t1.originalEventid,t2.eventid,t2.status"+
               " from TBLIIPMCNSLOG t1 inner join tblsysAlarmlog t2 on t2.originaleventid=t1.originaleventid  where t2.ifclose=0");
                 System.Data.Odbc.OdbcDataReader rd;
                 cmd.Connection = cn;
                 int id,originalEventid,evtid, status;
                 string notifier;
                 DateTime timeStamp;
                 string lineID, directionID;
                 int startMileage,  endMileage,  blockTypeId;
                 string blocklane,  description,IsExecution;
                 try
                 {
                     cn.Open();
                     rd = cmd.ExecuteReader();
                     while (rd.Read())
                     {

                         id = System.Convert.ToInt32( rd[0]);
                         notifier= rd[1].ToString();
                         timeStamp=System.Convert.ToDateTime(rd[2]);
                         lineID=rd[3].ToString();
                         directionID=rd[4].ToString();
                         startMileage=System.Convert.ToInt32(rd[5]);
                         endMileage= System.Convert.ToInt32(rd[6]);
                         blockTypeId=System.Convert.ToInt32(rd[7]);
                         blocklane=rd[8].ToString();
                         description=rd[9].ToString();
                         IsExecution = rd[10].ToString();
                         originalEventid = System.Convert.ToInt32(rd[11]);
                         evtid = System.Convert.ToInt32(rd[12]);
                         status=System.Convert.ToInt32(rd[13]);
                         this.setEvent(id, notifier, timeStamp, lineID, directionID, startMileage, endMileage, blockTypeId, blocklane, description, IsExecution, originalEventid,evtid,status);
                     }
                 }
                 catch(Exception ex)
                 {
                     RemoteInterface.ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
                 }
                 finally
                 {
                     cn.Close();
                 }
        }
Exemplo n.º 43
0
        private static void loadRangeRule()
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
              System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand();
              System.Data.Odbc.OdbcDataReader rd;
              cmd.Connection = cn;
              int num = 0;
              try
              {
              cn.Open();
              cmd.CommandText = "select count(*) from tblVDValidRange";
              num = System.Convert.ToInt32(cmd.ExecuteScalar());
              rangeDatas = new RangeData[num];

              cmd.CommandText = "select  type,maxvalue,minvalue from tblVDValidRange";
              rd = cmd.ExecuteReader();
              int i = 0;
              while (rd.Read())
              {
                  try
                  {
                      rangeDatas[i++] = new RangeData(System.Convert.ToString(rd[0]).Trim(), System.Convert.ToInt32(rd[1]), System.Convert.ToChar(rd[2]));
                  }
                  catch (Exception ex1)
                  {
                      RemoteInterface.ConsoleServer.WriteLine(ex1.Message + ex1.StackTrace);
                  }
                  //Value1[i] = System.Convert.ToInt32(rd[1]);
                  //type2[i] = System.Convert.ToChar(rd[2]);
                  //Value2[i] = System.Convert.ToInt32(rd[3]);

              }

              rd.Close();

              }
              catch (Exception ex)
              {

              RemoteInterface.ConsoleServer.WriteLine(ex.Message + ex.StackTrace);
              }
              finally
              {
              cn.Close();
              }
        }
Exemplo n.º 44
0
        void loadLine()
        {
            lock (this)
              {
              System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Global.Db2ConnectionString);
              try
              {
                  hsLines.Clear();
            #if !DEBUG
                  System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select lineid,linename,direction,startmileage,endmileage from tblGroupLine where enable='Y'  ");
            #else
                  System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select lineid,linename,direction,startmileage,endmileage from tblGroupLine where enable='Y'  ");
                 // System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select lineid,linename,direction,startmileage,endmileage from tblGroupLine where enable='Y' ");

            #endif
                  cmd.Connection = cn;
                  cn.Open();
                  System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();

                  while (rd.Read())
                  {
                      string linename, lineid, direction;
                      int startmileage, endmileage;

                      lineid = System.Convert.ToString(rd[0]);
                     // if (lineid != "N99") continue;
                      linename = System.Convert.ToString(rd[1]);
                      direction = System.Convert.ToString(rd[2]);
                      startmileage = System.Convert.ToInt32(rd[3]);
                      endmileage = System.Convert.ToInt32(rd[4]);
                      hsLines.Add(lineid, new Line(lineid, linename, direction, startmileage, endmileage));

                  }
              }
              catch (Exception ex)
              {
                  ConsoleServer.WriteLine(ex.Message + ex.StackTrace);
              }
              finally
              {
                  cn.Close();
              }

              }
        }
Exemplo n.º 45
0
        public DataSet ConnectCSV(string filetable, bool bFill)
        {
            DataSet ds = new DataSet();
            try
            {
                // You can get connected to driver either by using DSN or connection string

                // Create a connection string as below, if you want to use DSN less connection. The DBQ attribute sets the path of directory which contains CSV files
                string strConnString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + txtCSVFolderPath.Text.Trim() + ";Extensions=asc,csv,tab,txt;Persist Security Info=False";
                string sql_select;
                System.Data.Odbc.OdbcConnection conn;

                //Create connection to CSV file

                conn = new System.Data.Odbc.OdbcConnection(strConnString.Trim());

                // For creating a connection using DSN, use following line
                //conn	=	new System.Data.Odbc.OdbcConnection(DSN="MyDSN");

                //Open the connection
                conn.Open();
                //Fetch records from CSV
                sql_select = "select * from [" + filetable + "]";

                obj_oledb_da = new System.Data.Odbc.OdbcDataAdapter(sql_select, conn);
                //Fill dataset with the records from CSV file
                obj_oledb_da.Fill(ds, "Customers");

                if (bFill)
                {
                    //Set the datagrid properties
                    dGridCSVdata.DataSource = ds;
                    dGridCSVdata.DataMember = "Customers";
                    //Close Connection to CSV file
                }
                conn.Close();
            }
            catch (Exception exe) //Error
            {
                MMSUtility.LogFile(exe.Message, "", "ConnectCSV", exe.LineNumber(), "PrintLetterDialog");
                MessageBox.Show(exe.Message);
            }
            return ds;
        }
Exemplo n.º 46
0
 private void btnTest_Click(object sender, EventArgs e)
 {
     System.Data.Odbc.OdbcConnection connection = new System.Data.Odbc.OdbcConnection(txtConnectionString.Text);
     try
     {
         connection.Open();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Connection failed !");
     }
     finally
     {
         if (connection.State.Equals(ConnectionState.Open))
         {
             MessageBox.Show("Connection succeeded !");
         }
     }
 }
Exemplo n.º 47
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pid"></param>
 /// <param name="hash"></param>
 public void EnableTempDatastreams(string pid, string hash)
 {
     //Remove existing references that may occur from the user choosing a new file
     //before the upload to Fedora is finished
     DisableTempDatastreams(pid);
     using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(connectionString))
     {
         conn.Open();
         using (var command = conn.CreateCommand())
         {
             command.CommandText = "CALL AddToCurrentUploads(?,?)";
             command.CommandType = System.Data.CommandType.StoredProcedure;
             command.Parameters.AddWithValue("targetpid", pid);
             command.Parameters.AddWithValue("targethash", hash);
             //if (command.ExecuteNonQuery() != 1) { throw new Exception("Stored procedure call AddToCurrentUploads failed."); }
             command.ExecuteNonQuery();
         }
         conn.Close();
     }
 }
Exemplo n.º 48
0
        public void load_IID_Cam_Data()
        {
            hsCams.Clear();
               System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Global.Db2ConnectionString);
               System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand();
               System.Data.Odbc.OdbcDataReader rd;
               cmd.Connection = cn;
               cmd.CommandText = "select devicename,cam_id,direction,mileage,lane_id from tblIIDCamConfig";
               try
               {
               cn.Open();
               rd = cmd.ExecuteReader();
               while (rd.Read())
               {
                   string devname, direction;
                   int camid,laneid, mileage;
                   devname = rd[0].ToString();
                   camid = System.Convert.ToInt32(rd[1]);
                   direction = rd[2].ToString();
                   mileage = System.Convert.ToInt32(rd[3]);
                   laneid = System.Convert.ToInt32(rd[4]);

                   IID_CAM_Data camdata=new IID_CAM_Data("N6", direction, devname, camid, laneid, mileage);
                   camdata.OnEvent += new EventHandler(camdata_OnEvent);
                   hsCams.Add(camdata.Key,camdata);

               }
               rd.Close();
               }
               catch (Exception ex)
               {
               ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
               }
               finally
               {
               cn.Close();
               }

              // string sql="select camName,
        }
Exemplo n.º 49
0
        void loadETStatus()
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select deviceName,telcode,f1,f2,f3,x1,x2 from tblETConfig");
            cmd.Connection = cn;
            try
            {
                cn.Open();
                System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    string devicename;
                    string telcode;
                    byte[]f=new byte[3];
                    byte[] x = new byte[2];
                    devicename = rd[0].ToString();
                   // telcode = rd[1].ToString();
                    f[0] = System.Convert.ToByte(rd[2]);
                    f[1] = System.Convert.ToByte(rd[3]);
                    f[2] = System.Convert.ToByte(rd[4]);
                    x[0] = System.Convert.ToByte(rd[5]);
                    x[1] = System.Convert.ToByte(rd[6]);
                    try
                    {
                        hsEtStatus.Add(devicename, new ETStatus(devicename,  f, x));
                    }
                    catch (Exception ex1)
                    {
                        ConsoleServer.WriteLine(ex1.Message + "," + ex1.StackTrace);
                    }

                }

            }
            catch (Exception ex)
            {
                cn.Close();
            }
        }
Exemplo n.º 50
0
        public static object ExecuteScalarOnDB(string sSQL, string s_ConnectionString)
        {
            System.Data.Odbc.OdbcConnection QConnection = null;
            System.Data.Odbc.OdbcCommand QCommand = null;
            try
            {
                QConnection = new System.Data.Odbc.OdbcConnection(s_ConnectionString);
                QCommand = new System.Data.Odbc.OdbcCommand(sSQL, QConnection);

                QConnection.Open();

                return QCommand.ExecuteScalar();
            }
            finally
            {
                if (QCommand != null) QCommand.Dispose();
                QCommand = null;
                if (QConnection != null && QConnection.State != System.Data.ConnectionState.Closed) QConnection.Close();
                if (QConnection != null) QConnection.Dispose();
                QConnection = null;
            }
        }
Exemplo n.º 51
0
        public void loadRangeTable()
        {
            //type=A  avg wnd spd   ,I immediate wns speed
            ConsoleServer.WriteLine("Loaad Range Table");
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select type,minvalue,maxvalue from tblWDvalidRange");
            try
            {
                cn.Open();
                cmd.Connection = cn;
                System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    if (rd[0].ToString().Trim() == "A")
                    {
                        RangeTable[0, 0] = System.Convert.ToInt32(rd[1]);
                        RangeTable[0, 1] = System.Convert.ToInt32(rd[2]);
                    }
                    else
                    {

                        RangeTable[1, 0] = System.Convert.ToInt32(rd[1]);
                        RangeTable[1, 1] = System.Convert.ToInt32(rd[2]);
                    }
                }

            }
            catch (Exception ex)
            {
                ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
            }
            finally
            {
                cn.Close();
            }
        }
Exemplo n.º 52
0
 public static int getAlarmId()
 {
     System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Global.Db2ConnectionString);
     System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("SELECT NEXTVAL FOR DB2INST1.SEQ_ALARM FROM SYSIBM.SYSDUMMY1 ");
     cmd.Connection = cn;
     try
     {
         cn.Open();
        return System.Convert.ToInt32( cmd.ExecuteScalar());
     }
     catch (Exception ex)
     {
         ConsoleServer.WriteLine(ex.Message+","+ex.StackTrace);
         throw ex;
     }
     finally
     {
         try
         {
             cn.Close();
         }
         catch { ;}
     }
 }
        public static DbConnection ConnectionFactory(string dbName, string connStr = "")
        {

            if (dbName == "RMS" || dbName == "MRO")
            {
                //string connStr2 = @"Data Source=RMS_OP;Persist Security Info=True;User ID=RM_VIEW;Password=ahslxj1!";
                string connStr3 = @"DSN=RMS_OP;UID=RM_VIEW;PWD=ahslxj1!;";

                System.Data.Odbc.OdbcConnection odbcConn = new System.Data.Odbc.OdbcConnection(connStr3);

                //odbcConn.ConnectionString = 

                return odbcConn;
            }
            else
            {
                //SqlCeConnection connection = new SqlCeConnection(connStr);
                SqlCeConnection connection = new SqlCeConnection(connStr);

                return connection;
            }


        }
Exemplo n.º 54
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            if(txtHost.Text == "")
            {
                ITCMessageBox.Show(this, "Debes ingresar un Host", "Error!");
                txtHost.Focus();
            }
            else if (txtPort.Text == "")
            {
                ITCMessageBox.Show(this, "Debes ingresar un Puerto", "Error!");
                txtPort.Focus();
            }
            else if (txtUID.Text == "")
            {
                ITCMessageBox.Show(this, "Debes ingresar un Usuario", "Error!");
                txtUID.Focus();
            }
            else
            {
                string sCon;

                sCon = "DRIVER={Adaptive Server Enterprise};";
                //sCon = "DRIVER={SQL ANYWHERE 11};";
                sCon += "server=" + txtHost.Text + ";";
                sCon += "port=" + txtPort.Text + ";";
                sCon += "uid=" + txtUID.Text + ";";
                if(txtPSW.Text != "")
                {
                    sCon += "pwd=" + txtPSW.Text + ";";
                }
                if (txtDB.Text != "")
                {
                    sCon += "db=" + txtDB.Text + ";";
                }
                //sCon += "DSN=\"\"";

                System.Data.Odbc.OdbcConnection myConn = new System.Data.Odbc.OdbcConnection();
                myConn.ConnectionString = sCon;
                try
                {
                    myConn.Open();
                    ((Menu)this.Owner).sConexion = sCon;
                    ((Menu)this.Owner).bConexion = true;
                    myConn.Close();
                    this.Close();
                }
                catch(Exception ex)
                {
                    ITCMessageBox.Show(this, "Error en los datos de conexión, no se pude realizar la conexion con los parametros seleccionados", "Error!");
                    txtHost.Focus();
                }
            }
        }
Exemplo n.º 55
0
        public void ConnectToData()
        {
            System.Data.Odbc.OdbcConnection conn =
                new System.Data.Odbc.OdbcConnection();
            // TODO: Modify the connection string and include any
            // additional required properties for your database.
            conn.ConnectionString = "Dsn=C4A;dbq=C:/USERS/WBEINHAU/DROPBOX/AUTOMATEN/C4A/C4A_DEMO_2/C4A_DEMO_2/APP_DATA/C4A_Ressources_3.accdb;driverid=25;fil=MS Access;";
            try
            {
                conn.Open();

                HyperLink4.Text = conn.GetSchema().ToString();

                // Process data here.
            }
            catch (Exception ex)
            {
                HyperLink4.Text = "Schnubbeldibums";
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 56
0
        public static void LoadTrafficCSLSRule()
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(DbCmdServer.getDbConnectStr());
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand()
            {
                CommandText = "select ls,rs,level,lo,ro from tblvddegree where location='I' order by level",
                Connection = cn
            };
            lock (cslsRules)
            {
                cslsRules.Clear();

                try
                {
                    cn.Open();
                    System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        int ls, rs, level,lo,ro;
                        ls = System.Convert.ToInt32(rd["ls"]);
                        rs = System.Convert.ToInt32(rd["rs"]);
                        lo = System.Convert.ToInt32(rd["lo"]);
                        ro = System.Convert.ToInt32(rd["ro"]);
                        level = System.Convert.ToInt32(rd["level"]);
                        cslsRules.Add(new TrafficCSLSCOntrolRule()
                        {
                            level = level,
                            rs = rs,
                            ls = ls,
                            lo=lo,
                            ro=ro
                        });

                    }

                }
                catch (Exception ex)
                {
                    ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
                }
                finally
                {
                    cn.Close();
                }

            } //lock
        }
Exemplo n.º 57
0
        public static void NapuniListu()
        {
            System.Data.Odbc.OdbcCommand odbcCommand;
            System.Data.Odbc.OdbcConnection odbcConn = new System.Data.Odbc.OdbcConnection();
            string connectionString = Program.GetConnString();
            odbcConn = new System.Data.Odbc.OdbcConnection(connectionString);

            System.Data.Odbc.OdbcDataReader dr;
            odbcCommand = new System.Data.Odbc.OdbcCommand("SELECT ime, id FROM mobiteli", odbcConn);
            int id;
            lista.Clear();
            try
            {
                if (odbcConn.State != System.Data.ConnectionState.Open)
                    odbcConn.Open();
                dr = odbcCommand.ExecuteReader();

                while (dr.Read())
                {
                    int.TryParse(dr["id"].ToString(), out id);
                    lista.Add(new MobiteliBaza(dr["ime"].ToString(), id));
                }
                dr.Close();

            }
            catch { MessageBox.Show("Mobilni ureðaji nisu uèitani", "Greška"); }
            finally
            {
                if (odbcConn.State == System.Data.ConnectionState.Open)
                    odbcConn.Close();
            }
        }
        /*Queries the database for all the classes the currently selected student has taken.
         * Then, it constructs a List containing 'Course' objects which represent each course
         * the student has completed*/
        private void studentSelectionButton_Click(object sender, EventArgs e)
        {
            searchWindow.ShowDialog(this);
            String studentName = searchWindow.getName();
            String studentID = searchWindow.getId();
            if (studentID != null)
            {

                setStudent(studentID, studentName);

                //Overwrite the previous student course list
                this.studentCourseList = new List<Course>();

                System.Data.Odbc.OdbcConnection connection = new System.Data.Odbc.OdbcConnection(dsnSource);
                System.Data.Odbc.OdbcCommand command = connection.CreateCommand();
                System.Data.Odbc.OdbcDataReader Reader;
                command.CommandText = "select * from S_HIST_DETAIL where ID = '" + studentID + "'";
                try
                {
                    connection.Open();
                    Reader = command.ExecuteReader();
                    while (Reader.Read())
                    {

                        String courseSubject = Reader["SUBJECT"].ToString();
                        String courseNumber = Reader["COURSE_NUMBER"].ToString();
                        String CRN = Reader["CRN"].ToString();
                        Double gpa = Convert.ToDouble(Reader["DECIMAL_GRADE"]);
                        String term = Reader["TERM"].ToString();
                        Course currCourse = new Course(CRN, courseNumber, gpa, courseSubject, term);
                        studentCourseList.Add(currCourse);

                    }
                    connection.Close();
                }
                catch (Exception s)
                {
                    MessageBox.Show("There was a connection problem. Please try again later");
                    MessageBox.Show(s.ToString());
                }

                if (majEval.size() > 0)
                {
                    buildMajorEvaluation();
                }
            }
        }
Exemplo n.º 59
0
        public void LogMfccStart(string ProcessName, bool bPlay)
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection("dsn=TCS;uid=db2inst1;pwd=db2inst1");

             string sql=   "insert into  tblMFCCStateLog (TIMESTAMP,MFCCId,CONN_State) values('{0}','{1}',{2})" ;
             System.Data.Odbc.OdbcCommand cmd=new System.Data.Odbc.OdbcCommand(string.Format(sql, getTimeStampString(DateTime.Now), ProcessName, bPlay ? 1 : 3));
             try
             {
                 cn.Open();
                 cmd.Connection = cn;
                 cmd.ExecuteNonQuery();
             }
             finally
             {
                 cn.Close();
             }
        }
Exemplo n.º 60
0
        void DataRepairTask()
        {
            System.Collections.ArrayList aryThread = new System.Collections.ArrayList();

            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
            System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand();
            cmd.CommandTimeout = 120;
            StRepairData rpd=null;//=new StRepairData();

            cmd.Connection = cn;

              System.Collections.Queue queue = new System.Collections.Queue();

              int dayinx = 1;
            while (true)
            {
                Comm.TC.VDTC tc;

                if (!IsLoadTcCompleted )
                {
                    System.Threading.Thread.Sleep(1000);
                    continue;
                }

                try
                {
                  //  cn= new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
                    while (this.dbServer.getCurrentQueueCnt() > 50)
                        System.Threading.Thread.Sleep(1000 * 10);
                    cn.Open();
                    ConsoleServer.WriteLine("Repair task begin!");
                    cmd.Connection = cn;
                 //   string sqlGetRepair = "select * from (SELECT t1.DEVICENAME, t1.TIMESTAMP ,trycnt,datavalidity FROM TBLVDDATA1MIN t1 inner join tbldeviceconfig t2 on t1.devicename=t2.devicename WHERE  mfccid='{0}'  and comm_state <> 3  and  t1.TIMESTAMP between '{1}' and '{2}' and trycnt<3 fetch first 300 row only  )  where  DATAVALIDITY = 'N' order by trycnt,timestamp desc  ";
                    string sqlGetRepair = "select t1.DEVICENAME, TIMESTAMP ,trycnt,datavalidity,comm_state from TBLVDDATA1MIN  t1 inner join tblDeviceConfig t2 on t1.devicename=t2.devicename where mfccid='{0}' and  TIMESTAMP between '{1}' and '{2}' and trycnt <1 and datavalidity='N' and comm_state=1  and enable='Y'  order by timestamp desc  fetch first 300  row only ";

                    cmd.CommandText = string.Format(sqlGetRepair,mfccid, Comm.DB2.Db2.getTimeStampString(System.DateTime.Now.AddDays(-dayinx)), Comm.DB2.Db2.getTimeStampString(System.DateTime.Now.AddDays(-dayinx+1).AddMinutes(-10)));
                    System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();

                    while (rd.Read())
                    {
                         string devName="" ;
                          DateTime dt ;
                          devName = rd[0] as string;
                          dt = System.Convert.ToDateTime(rd[1]);
                            queue.Enqueue(new StRepairData(dt,devName));

                    }
                    rd.Close();

                    ConsoleServer.WriteLine("total:" + queue.Count + " to repair!");
                    if (queue.Count < 300)
                    {
                        dayinx++;
                        if (dayinx ==4)
                            dayinx = 1;

                    }
                    if(queue.Count<10)
                        System.Threading.Thread.Sleep(1000 * 60);

                    aryThread.Clear();
                    while (queue.Count!=0)
                    {
                        try
                        {

                             rpd =(StRepairData)queue.Dequeue() ;
                             if (Program.mfcc_vd.manager.IsContains(rpd.devName))
                                 tc = (Comm.TC.VDTC)Program.mfcc_vd.manager[rpd.devName];
                             else

                                 continue;

                             if (!tc.IsConnected)
                             {
                                 dbServer.SendSqlCmd(string.Format("update tbldeviceconfig  set comm_state=3 where devicename='{0}' ", rpd.devName));

                                 continue;
                             }

                            System.Threading.Thread th= new System.Threading.Thread(Repair_job);
                            aryThread.Add(th);
                            th.Start(rpd);

                            if (aryThread.Count >= 5)
                            {
                                for (int i = 0; i < aryThread.Count; i++)

                                    ((System.Threading.Thread)aryThread[i]).Join();

                                aryThread.Clear();
                            }

                        //   ConsoleServer.WriteLine("==>repair:" + rpd.devName + "," + rpd.dt.ToString());

                        }
                        catch (Exception ex)
                        {
                            ConsoleServer.WriteLine( ex.Message + ex.StackTrace);

                        }
                    }

                    for (int i = 0; i < aryThread.Count; i++)

                        ((System.Threading.Thread)aryThread[i]).Join();

                    aryThread.Clear();

                }
                catch (Exception x)
                {
                    ConsoleServer.WriteLine(x.Message+ x.StackTrace);
                }
                finally
                {
                    try
                    {
                        cn.Close();
                    }
                    catch { ;}
                }

            }
        }