Exemplo n.º 1
0
        /// <summary>
        /// Update an application instance record
        /// </summary>
        /// <param name="applicationInstance"></param>
        /// <returns></returns>
        public int ApplicationInstanceUpdate(ApplicationInstance applicationInstance)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "UPDATE APPLICATION_INSTANCES SET " +
                            "_PRODUCTID = @cProductID " +
                            ",_CDKEY = @cCDKey " +
                            "WHERE _INSTANCEID = @nInstanceID";

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            command.Parameters.AddWithValue("@cProductID", applicationInstance.Serial.ProductId);
                            command.Parameters.AddWithValue("@cCDKey", applicationInstance.Serial.CdKey);
                            command.Parameters.AddWithValue("nInstanceID", applicationInstance.InstanceID);

                            command.ExecuteNonQuery();
                        }
                    }
                }
                catch (SqlCeException ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");
                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
                catch (Exception ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");

                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
            }
            else
            {
                AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();
                lAuditWizardDataAccess.ApplicationInstanceUpdate(applicationInstance);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(0);
        }