Ejemplo n.º 1
0
 /// <summary>
 /// Save the passed in Firmware Upgrade Setting.
 /// </summary>
 /// <param name="firmwareUpgradeSetting"></param>
 public void Save(FirmwareUpgradeSetting firmwareUpgradeSetting)
 {
     using (DataAccessTransaction trx = new DataAccessTransaction())
     {
         Save(firmwareUpgradeSetting, trx);
         trx.Commit();
     }
 }
Ejemplo n.º 2
0
        private void InsertFirmwareUpgradeSetting(FirmwareUpgradeSetting firmwareUpgradeSetting, DataAccessTransaction trx)
        {
            using (IDbCommand cmd = GetCommand("INSERT INTO " + TableName + " ( EQUIPMENTCODE, EQUIPMENTSUBTYPECODE, EQUIPMENTFULLCODE, VERSION, CHECKSUM, FILENAME ) VALUES ( @EQUIPMENTCODE, @EQUIPMENTSUBTYPECODE, @EQUIPMENTFULLCODE, @VERSION, @CHECKSUM, @FILENAME )", trx))
            {
                cmd.Parameters.Add(GetDataParameter("@EQUIPMENTCODE", firmwareUpgradeSetting.EquipmentCode));
                cmd.Parameters.Add(GetDataParameter("@EQUIPMENTSUBTYPECODE", firmwareUpgradeSetting.EquipmentSubTypeCode));
                cmd.Parameters.Add(GetDataParameter("@EQUIPMENTFULLCODE", firmwareUpgradeSetting.EquipmentFullCode));
                cmd.Parameters.Add(GetDataParameter("@VERSION", firmwareUpgradeSetting.Version));
                cmd.Parameters.Add(GetDataParameter("@CHECKSUM", firmwareUpgradeSetting.CheckSum));
                cmd.Parameters.Add(GetDataParameter("@FILENAME", firmwareUpgradeSetting.FileName));

                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Find the Firmware Upgrade Settings based on passed equipmentCode and version
        /// </summary>
        /// <param name="equipmentCode"></param>
        /// <param name="equipmentSubTypeCode"></param>
        /// <param name="version"></param>
        /// <returns>FirmwareUpgradeSetting</returns>
        public FirmwareUpgradeSetting Find(string equipmentCode, string equipmentSubTypeCode, string version)
        {
            using (DataAccessTransaction trx = new DataAccessTransaction(true))
            {
                string equipmentSubTypeClause = string.IsNullOrEmpty(equipmentSubTypeCode) ? "EQUIPMENTSUBTYPECODE IS NULL" : "EQUIPMENTSUBTYPECODE = @EQUIPMENTSUBTYPECODE";
                using (IDbCommand cmd = GetCommand(string.Format("SELECT * FROM " + TableName + " WHERE EQUIPMENTCODE = @EQUIPMENTCODE AND VERSION = @VERSION AND {0}", equipmentSubTypeClause), trx))
                {
                    cmd.Parameters.Add(GetDataParameter("@EQUIPMENTCODE", equipmentCode));
                    cmd.Parameters.Add(GetDataParameter("@VERSION", version));
                    if (!string.IsNullOrEmpty(equipmentSubTypeCode))
                    {
                        cmd.Parameters.Add(GetDataParameter("@EQUIPMENTSUBTYPECODE", equipmentSubTypeCode));
                    }

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        DataAccessOrdinals ordinals = new DataAccessOrdinals(reader);

                        if (!reader.Read())
                        {
                            Log.Debug("No Firmware Upgrade Settings record found");
                            return(null);
                        }

                        FirmwareUpgradeSetting firmewareUpgradeSetting = new FirmwareUpgradeSetting();
                        firmewareUpgradeSetting.EquipmentCode        = SqlSafeGetString(reader, ordinals["EQUIPMENTCODE"]);
                        firmewareUpgradeSetting.EquipmentSubTypeCode = SqlSafeGetString(reader, ordinals["EQUIPMENTSUBTYPECODE"]);
                        firmewareUpgradeSetting.EquipmentFullCode    = SqlSafeGetString(reader, ordinals["EQUIPMENTFULLCODE"]);
                        firmewareUpgradeSetting.Version  = SqlSafeGetString(reader, ordinals["VERSION"]);
                        firmewareUpgradeSetting.CheckSum = SqlSafeGetBLOB(reader, ordinals["CHECKSUM"]);
                        firmewareUpgradeSetting.FileName = SqlSafeGetString(reader, ordinals["FILENAME"]);

                        return(firmewareUpgradeSetting);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Save the passed in Firmware Upgrade Settings, delete if any available already.
 /// </summary>
 /// <param name="firmwareUpgradeSetting"></param>
 /// <param name="trx"></param>
 public void Save(FirmwareUpgradeSetting firmwareUpgradeSetting, DataAccessTransaction trx)
 {
     Delete(firmwareUpgradeSetting.EquipmentCode, firmwareUpgradeSetting.EquipmentSubTypeCode, firmwareUpgradeSetting.Version, trx);
     InsertFirmwareUpgradeSetting(firmwareUpgradeSetting, trx);
 }