Example #1
0
        /// <summary>
        /// 保存二进制数值
        /// </summary>
        /// <param name="serialNumber">序号</param>
        /// <param name="dataValue">二进制数值</param>
        protected void SaveBytes(int serialNumber, byte[] dataValue)
        {
            AC.Base.Database.DbConnection dbConn = this.Device.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    System.Data.IDbDataParameter parDeviceId = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parDeviceId.ParameterName = "@" + Tables.DevicePropertyBytes.DeviceId;
                    parDeviceId.Value         = this.Device.DeviceId;

                    System.Data.IDbDataParameter parPropertyType = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parPropertyType.ParameterName = "@" + Tables.DevicePropertyBytes.PropertyType;
                    parPropertyType.Value         = Function.SqlStr(this.GetType().FullName);

                    System.Data.IDbDataParameter parSerialNumber = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parSerialNumber.ParameterName = "@" + Tables.DevicePropertyBytes.SerialNumber;
                    parSerialNumber.Value         = serialNumber;

                    System.Data.IDbDataParameter parDataValue = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parDataValue.ParameterName = "@" + Tables.DevicePropertyBytes.DataValue;
                    parDataValue.Value         = dataValue;

                    string strSql = "@" + Tables.DevicePropertyBytes.DeviceId + "," + "@" + Tables.DevicePropertyBytes.PropertyType + "," + "@" + Tables.DevicePropertyBytes.SerialNumber + "," + "@" + Tables.DevicePropertyBytes.DataValue;
                    strSql = "INSERT INTO " + Tables.DevicePropertyBytes.TableName + " (" + Tables.DevicePropertyBytes.DeviceId + "," + Tables.DevicePropertyBytes.PropertyType + "," + Tables.DevicePropertyBytes.SerialNumber + "," + Tables.DevicePropertyBytes.DataValue + ") VALUES (" + strSql + ")";
                    dbConn.ExecuteNonQuery(strSql, -1, System.Data.CommandType.Text, parDeviceId, parPropertyType, parSerialNumber, parDataValue);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }