private static int _updateParameterBusiness(string userName, string parameterName, string parameterValue) { int rowsAffected = 0; try { string connStr = SAFConfiguration.readConnectionStringBusiness(); using (IDbConnection connection = new SqlConnection(connStr)) { connection.Open(); using (IDbCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "SetConfigurationParameter"; command.Parameters.Add(new SqlParameter("@UserName", userName)); command.Parameters.Add(new SqlParameter("@ParameterName", parameterName)); command.Parameters.Add(new SqlParameter("@ParameterValue", parameterValue)); rowsAffected = (int)command.ExecuteScalar(); } } } catch (Exception ex) { LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Configuration.SAFConfiguration::_updateParameterBusiness failed. Err:" + ex.Message, ex); } //Refresh parameters _CheckCache(0); return(rowsAffected); }
/// <summary> /// StoreStackLog Logs to storage. /// Remember that it will be automatically called during Dispose (even if explicitly being called once) if suppressLog is false. /// </summary> /// <remarks> /// Remember that it will be automatically called during Dispose (even if explicitly being called once) if suppressLog is false. /// </remarks> /// <returns></returns> public virtual bool StoreStackLog() { if (disposed) { return(false); } if (stackData.suppressLog) { return(true); } try { short trnRes = stackData.StatsData.TrnRes; if (trnRes < 0) { stackData.LogData.LevelName = "ERROR"; } else { stackData.LogData.LevelName = "INFO"; } SAFDbLog dbLog = new SAFDbLog(SAFConfiguration.readConnectionStringBusiness()); int idLog = dbLog.AppendLog(stackData.LogData); return(idLog != -1); } catch (Exception ex) { LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Utils.WSStacker::StoreStackLog. Err:" + ex.Message, ex); } return(false); }
private static SAFConfigurationParametersMap GetAllParametersFromDB() { SAFConfigurationParametersMap cacheData = new SAFConfigurationParametersMap(); try { string connStr = SAFConfiguration.readConnectionStringBusiness(); using (IDbConnection connection = new SqlConnection(connStr)) { connection.Open(); using (IDbCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "GetAllConfiguration"; IDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { SAFConfigurationParameter par = new SAFConfigurationParameter(); par.section = dr.GetString(0); par.name = dr.GetString(1); par.value = dr.IsDBNull(2) ? null : dr.GetString(2); par.lastUTCupdate = dr.GetDateTime(3); par.frozen = dr.GetBoolean(4); par.hidden = dr.GetBoolean(5); string fullname = par.section + "@" + par.name; cacheData.Add(fullname, par); } } } //All went fine return(cacheData); } catch (Exception ex) { LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Configuration.SAFConfiguration::GetAllParameters failed. Err:" + ex.Message, ex); return(null); } }