Files

46 lines
1.9 KiB
C#
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
using System;
namespace DatabaseExport
{
public class GlobalSetting : Setting
{
private const string SYSTEM = "SYSTEM";
public GlobalSetting(string id, string defaultPropertyValue)
: base(id, PropertyTypes.Global, defaultPropertyValue, SYSTEM)
{
}
protected override void GetPropertyValue(string defaultValue)
{
try
{
using (var cmd = DbOperations.GetCommand())
{
cmd.CommandText = string.Format("SELECT * FROM {0} WHERE {1}=@{1} AND {2}=@{2}", DbOperations.Settings.Table,
DbOperations.Settings.UserFields.PropertyId.ToString(), DbOperations.Settings.UserFields.UserId.ToString());
DbOperations.CreateParam(cmd, string.Format("@{0}", DbOperations.Settings.UserFields.PropertyId.ToString()), System.Data.SqlDbType.NVarChar,
PropertyId);
DbOperations.CreateParam(cmd, string.Format("@{0}", DbOperations.Settings.UserFields.UserId.ToString()), System.Data.SqlDbType.NVarChar,
SYSTEM);
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
{
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
_propertyValue = Convert.ToString(ds.Tables[0].Rows[0][DbOperations.Settings.UserFields.PropertyValue.ToString()]);
}
else
{
_propertyValue = defaultValue;
//StoreInDB();
}
}
}
}
catch (System.Exception)
{
_propertyValue = defaultValue;
}
}
}
}