コード例 #1
0
ファイル: Program.cs プロジェクト: kelldog/OPCLoggin
        public static List<OPCField_ex> ProcessDataQuery(OPCStationInfo Station, string ToolServer)
        {
            OleDbCommand mCommand = new OleDbCommand("ProcessDataQuery");
            mCommand.CommandType = CommandType.StoredProcedure;
            OleDbConnection mConnection = new OleDbConnection(ToolServer);
            OleDbParameter IdIn = new OleDbParameter("@station", OleDbType.Integer);
            IdIn.Value = Station.StationID;
            mCommand.Parameters.Add(IdIn);
            mConnection.Open();
            mCommand.Connection = mConnection;
            OleDbDataReader mReader;
            mReader = mCommand.ExecuteReader();
            List<OPCField_ex> fields = new List<OPCField_ex>();

            while (mReader.Read())
            {
                OPCField_ex f = new OPCField_ex();
                f.StationInfo = Station;
                f.ScaleFactor = mReader.GetFloat(11);
                f.ClientTopicID = mReader.GetString(2);
                f.ClientItemID = mReader.GetString(1);
                f.DeviceType = (short)mReader.GetInt32(0);
                f.OPCItemID = mReader.GetString(3);
                f.RequestFromOPC = false;
                f.OPCprefix = mReader.GetString(4);
                f.OPCTopicID = mReader.GetString(5);
                //f.Type = (Int32)mReader["DataType"];********************************
                try
                {
                  //  f.DataType = GetTypeFromNum((Int32)mReader["DataType"]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message+"  "+mReader.GetString(9));
                }
               // if (f.DataType != typeof(float))
               // {

               // }
                fields.Add(f);
            }

            mReader.Close();
            mConnection.Close();
            return fields;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kelldog/OPCLoggin
        public static List<OPCStationInfo> GetDistinctStations(string source)
        {
            List<OPCStationInfo> AvailableStations = new List<OPCStationInfo>();
            //string source = CellWork;
            OleDbConnection mConnection = new OleDbConnection(source);
            try
            {
                OleDbCommand mCommand = new OleDbCommand("SELECT StationID,ChamberTypeID,StationTypeID from StationParameters");
                mCommand.CommandType = CommandType.Text;
                mConnection.Open();
                mCommand.Connection = mConnection;
                OleDbDataReader mReader;
                mReader = mCommand.ExecuteReader();

                while (mReader.Read())
                {
                    OPCStationInfo new_station = new OPCStationInfo();
                    new_station.StationID = mReader.GetInt16(0);
                    new_station.ChamberTypeID = mReader.GetInt16(1);
                    new_station.StationTypeID = mReader.GetInt16(2);
                    AvailableStations.Add(new_station);
                }
                mReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
                //Program.ErrorLog.WriteEntry(string.Format("Parse Error From pulling Station Info.  Station ID: {0} ", ex.Message));
            }
            finally
            {
                mConnection.Close();
            }

            return AvailableStations;
        }