64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace DatabaseImport
|
|
{
|
|
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
|
|
{
|
|
//if (_allGlobalSetting == null)
|
|
//{
|
|
// _allGlobalSetting = GetAllGlobalSetting();
|
|
//}
|
|
//foreach (var gs in _allGlobalSetting)
|
|
//{
|
|
// if (gs.PropertyId != PropertyId) continue;
|
|
// _propertyValue = gs._propertyValue;
|
|
// return;
|
|
//}
|
|
|
|
using (var cmd = DbOperations.GetSQLCommand(true))
|
|
{
|
|
try
|
|
{
|
|
cmd.CommandType = CommandType.StoredProcedure;
|
|
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SettingsGet.ToString();
|
|
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.NVarChar) { Value = SYSTEM });
|
|
cmd.Parameters.Add(new SqlParameter("@PropertyId", SqlDbType.NVarChar) { Value = PropertyId });
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
finally { cmd.Connection.Dispose(); }
|
|
}
|
|
}
|
|
catch (Exception) //TODO: handle exception properly
|
|
{
|
|
_propertyValue = defaultValue;
|
|
}
|
|
}
|
|
}
|
|
}
|