init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user