General tidy.

This commit is contained in:
Andy Howard
2024-06-13 14:32:44 +01:00
parent 0c44e9ddd3
commit bf6bb966bc
159 changed files with 1166 additions and 972 deletions
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:28
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal.Control
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -9,7 +9,7 @@ using System.Data.Common;
using System.Linq;
//---------------------------------------------------------------------------
// Code generated by Sarand Database Utilities Sat 10-Jul-2021 16:26:30
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
//---------------------------------------------------------------------------
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
{
@@ -130,7 +130,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetAddress\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return address;
@@ -149,7 +149,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert Address.
public override bool InsertAddress(SbmAddress address, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAddress";
ClearErrorState();
if (!IsValidAddress(address)) return false;
if (SysId.IsValid(address.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -169,7 +168,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbAddress.ExecuteInsertCommand(dbCommand);
address.Id = new SysId(dbAddress._Id);
address.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted.\n\tId: " + GetLogProperties(address).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(address).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -180,13 +179,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update Address.
public override bool UpdateAddress(SbmAddress address, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateAddress";
ClearErrorState();
if (!IsValidAddress(address)) return false;
if (!SysId.IsValid(address.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!address.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed.\n\tId: " + GetLogProperties(address).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(address).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -197,14 +195,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve Address.
dbConnection.Open();
Address_Db dbAddress = new Address_Db(DbInfo);
dbAddress.PopulateFrom(dbCommand, aliasAddress, "Id=" + SysId.ToString(address.Id));
dbAddress.PopulateFrom(dbCommand, aliasAddress, $"Id={SysId.ToString(address.Id)}");
SbmUpdateLogItemMonitor_Address updateLogMonitor = new SbmUpdateLogItemMonitor_Address(Internals, CreateAddress(dbAddress));
// Update properties.
PopulateTo(dbAddress, address, dbUpdateInfo);
dbAddress.ExecuteUpdateCommand(dbCommand);
address.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated.\n\tId: " + GetLogProperties(address).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(address).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(address);
@@ -225,7 +223,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteAddress(SbmAddress address, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteAddress";
ClearErrorState();
if (!AddressCanBeDeleted(address)) return false;
using (var dbConnection = db.CreateConnection())
@@ -242,7 +239,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address) + " WHERE Id=" + SysId.ToString(address.Id) + ";";
dbCommand.ExecuteNonQuery();
address.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted.\n\tId: " + GetLogProperties(address).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(address).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -678,7 +675,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Address list.
public override List<SbmAddress> GetAddressList(SbmAddress.Params prm)
{
List<SbmAddress> Addresses = new List<SbmAddress>();
ClearErrorState();
List<SbmAddress> addresses = new List<SbmAddress>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAddress);
Address_Db dbAddress = new Address_Db(DbInfo);
@@ -699,16 +697,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbAddress = new Address_Db(DbInfo);
dbAddress.PopulateFrom(dbDataReader);
Addresses.Add(CreateAddress(dbAddress));
addresses.Add(CreateAddress(dbAddress));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetAddressList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Addresses;
return addresses;
}
//-------------------------------------------------------------------
@@ -78,7 +78,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetAffiliate\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return affiliate;
@@ -171,7 +171,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert Item.
public override bool InsertAffiliate(SbmAffiliate affiliate, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAffiliate";
ClearErrorState();
if (!IsValidAffiliate(affiliate)) return false;
if (SysId.IsValid(affiliate.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -191,7 +190,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbAffiliate.ExecuteInsertCommand(dbCommand);
affiliate.Id = new SysId(dbAffiliate._Id);
affiliate.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -202,13 +201,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update Affiliate.
public override bool UpdateAffiliate(SbmAffiliate affiliate, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateAffiliate";
ClearErrorState();
if (!IsValidAffiliate(affiliate)) return false;
if (!SysId.IsValid(affiliate.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!affiliate.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -226,7 +224,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
PopulateTo(dbAffiliate, affiliate, dbUpdateInfo);
dbAffiliate.ExecuteUpdateCommand(dbCommand);
affiliate.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(affiliate);
@@ -247,7 +245,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteAffiliate(SbmAffiliate affiliate, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteAffiliate";
ClearErrorState();
if (!AffiliateCanBeDeleted(affiliate)) return false;
using (var dbConnection = db.CreateConnection())
@@ -264,7 +261,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate) + " WHERE Id=" + SysId.ToString(affiliate.Id) + ";";
dbCommand.ExecuteNonQuery();
affiliate.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -866,7 +863,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Affiliate list.
public override List<SbmAffiliate> GetAffiliateList(SbmAffiliate.Params prm)
{
List<SbmAffiliate> prmAffiliates = new List<SbmAffiliate>();
ClearErrorState();
List<SbmAffiliate> affiliates = new List<SbmAffiliate>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasAffiliate);
Affiliate_Db dbAffiliate = new Affiliate_Db(DbInfo);
@@ -887,16 +885,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbAffiliate = new Affiliate_Db(DbInfo);
dbAffiliate.PopulateFrom(dbDataReader);
prmAffiliates.Add(CreateAffiliate(dbAffiliate));
affiliates.Add(CreateAffiliate(dbAffiliate));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetAffiliateList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmAffiliates;
return affiliates;
}
//-------------------------------------------------------------------
@@ -266,7 +266,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetAssociation\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return association;
@@ -344,7 +344,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert Association.
public override bool InsertAssociation(SbmAssociation association, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAssociation";
ClearErrorState();
if (!IsValidAssociation(association)) return false;
if (SysId.IsValid(association.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -364,7 +363,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbAssociation.ExecuteInsertCommand(dbCommand);
association.Id = new SysId(dbAssociation._Id);
association.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted.\n\tId: " + GetLogProperties(association).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(association).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -375,13 +374,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update Association.
public override bool UpdateAssociation(SbmAssociation association, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateAssociation";
ClearErrorState();
if (!IsValidAssociation(association)) return false;
if (!SysId.IsValid(association.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!association.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(association).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(association).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -399,7 +397,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
PopulateTo(dbAssociation, association, dbUpdateInfo);
dbAssociation.ExecuteUpdateCommand(dbCommand);
association.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(association).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(association).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(association);
@@ -420,7 +418,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteAssociation(SbmAssociation association, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteAssociation";
ClearErrorState();
if (!AssociationCanBeDeleted(association)) return false;
using (var dbConnection = db.CreateConnection())
@@ -437,7 +434,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association) + " WHERE Id=" + SysId.ToString(association.Id) + ";";
dbCommand.ExecuteNonQuery();
association.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted.\n\tId: " + GetLogProperties(association).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(association).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -1911,7 +1908,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Association list.
public override List<SbmAssociation> GetAssociationList(SbmAssociation.Params prm)
{
List<SbmAssociation> prmAssociations = new List<SbmAssociation>();
ClearErrorState();
List<SbmAssociation> associations = new List<SbmAssociation>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAssociation);
Association_Db dbAssociation = new Association_Db(DbInfo);
@@ -1932,16 +1930,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbAssociation = new Association_Db(DbInfo);
dbAssociation.PopulateFrom(dbDataReader);
prmAssociations.Add(CreateAssociation(dbAssociation));
associations.Add(CreateAssociation(dbAssociation));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetAssociationList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmAssociations;
return associations;
}
//-------------------------------------------------------------------
@@ -78,7 +78,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetSysParam\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return sysParam;
@@ -97,7 +97,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert SysParam.
public override bool InsertSysParam(SbmSysParam sysparam, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertSysParam";
ClearErrorState();
if (!IsValidSysParam(sysparam)) return false;
if (SysId.IsValid(sysparam.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -117,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbSysParam.ExecuteInsertCommand(dbCommand);
sysparam.Id = new SysId(dbSysParam._Id);
sysparam.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -128,13 +127,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update SysParam.
public override bool UpdateSysParam(SbmSysParam sysparam, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateSysParam";
ClearErrorState();
if (!IsValidSysParam(sysparam)) return false;
if (!SysId.IsValid(sysparam.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!sysparam.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -152,7 +150,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
PopulateTo(dbSysParam, sysparam, dbUpdateInfo);
dbSysParam.ExecuteUpdateCommand(dbCommand);
sysparam.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(sysparam);
@@ -173,7 +171,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteSysParam(SbmSysParam sysparam, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteSysParam";
ClearErrorState();
if (!SysParamCanBeDeleted(sysparam)) return false;
using (var dbConnection = db.CreateConnection())
@@ -190,7 +187,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SysParam) + " WHERE Id=" + SysId.ToString(sysparam.Id) + ";";
dbCommand.ExecuteNonQuery();
sysparam.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -430,7 +427,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// SysParam list.
public override List<SbmSysParam> GetSysParamList(SbmSysParam.Params prm)
{
List<SbmSysParam> prmSysParams = new List<SbmSysParam>();
ClearErrorState();
List<SbmSysParam> sysParams = new List<SbmSysParam>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SysParam), aliasSysParam);
SysParam_Db dbSysParam = new SysParam_Db(DbInfo);
@@ -451,16 +449,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbSysParam = new SysParam_Db(DbInfo);
dbSysParam.PopulateFrom(dbDataReader);
prmSysParams.Add(CreateSysParam(dbSysParam));
sysParams.Add(CreateSysParam(dbSysParam));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetSysParamList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmSysParams;
return sysParams;
}
//-------------------------------------------------------------------
@@ -85,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetSystemAccount\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return systemAccount;
@@ -104,7 +104,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert SystemAccount.
public override bool InsertSystemAccount(SbmSystemAccount systemAccount, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertSystemAccount";
ClearErrorState();
if (!IsValidSystemAccount(systemAccount)) return false;
if (SysId.IsValid(systemAccount.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -124,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbSystemAccount.ExecuteInsertCommand(dbCommand);
systemAccount.Id = new SysId(dbSystemAccount._Id);
systemAccount.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -135,13 +134,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update SystemAccount.
public override bool UpdateSystemAccount(SbmSystemAccount systemAccount, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateSystemAccount";
ClearErrorState();
if (!IsValidSystemAccount(systemAccount)) return false;
if (!SysId.IsValid(systemAccount.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!systemAccount.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -159,7 +157,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
PopulateTo(dbSystemAccount, systemAccount, dbUpdateInfo);
dbSystemAccount.ExecuteUpdateCommand(dbCommand);
systemAccount.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t")}");
// Record updates.
/*updateLogMonitor.RecordUpdatedValues(systemAccount);
@@ -180,7 +178,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteSystemAccount(SbmSystemAccount systemAccount, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteSystemAccount";
ClearErrorState();
if (!SystemAccountCanBeDeleted(systemAccount)) return false;
using (var dbConnection = db.CreateConnection())
@@ -197,7 +194,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount) + " WHERE Id=" + SysId.ToString(systemAccount.Id) + ";";
dbCommand.ExecuteNonQuery();
systemAccount.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -464,7 +461,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// SystemAccount list.
public override List<SbmSystemAccount> GetSystemAccountList(SbmSystemAccount.Params prm)
{
List<SbmSystemAccount> SystemAccounts = new List<SbmSystemAccount>();
ClearErrorState();
List<SbmSystemAccount> systemAccounts = new List<SbmSystemAccount>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount), aliasSystemAccount);
SystemAccount_Db dbSystemAccount = new SystemAccount_Db(DbInfo);
@@ -485,16 +483,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbSystemAccount = new SystemAccount_Db(DbInfo);
dbSystemAccount.PopulateFrom(dbDataReader);
SystemAccounts.Add(CreateSystemAccount(dbSystemAccount));
systemAccounts.Add(CreateSystemAccount(dbSystemAccount));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetSystemAccountList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return SystemAccounts;
return systemAccounts;
}
//-------------------------------------------------------------------
@@ -78,7 +78,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetSystemAccountUser\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return SystemAccountUser;
@@ -97,7 +97,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert SystemAccountUser.
public override bool InsertSystemAccountUser(SbmSystemAccountUser systemAccountUser, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertSystemAccountUser";
ClearErrorState();
if (!IsValidSystemAccountUser(systemAccountUser)) return false;
if (SysId.IsValid(systemAccountUser.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -117,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbSystemAccountUser.ExecuteInsertCommand(dbCommand);
systemAccountUser.Id = new SysId(dbSystemAccountUser._AccountId);
systemAccountUser.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -128,14 +127,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update SystemAccountUser.
public override bool UpdateSystemAccountUser(SbmSystemAccountUser systemAccountUser, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateSystemAccountUser";
ClearErrorState();
if (!IsValidSystemAccountUser(systemAccountUser)) return false;
if (!SysId.IsValid(systemAccountUser.AccountId)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!SysId.IsValid(systemAccountUser.UserId)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!systemAccountUser.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -153,7 +151,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
PopulateTo(dbSystemAccountUser, systemAccountUser, dbUpdateInfo);
dbSystemAccountUser.ExecuteUpdateCommand(dbCommand);
systemAccountUser.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t")}");
// Record updates.
/*updateLogMonitor.RecordUpdatedValues(systemAccountUser);
@@ -174,7 +172,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteSystemAccountUser(SbmSystemAccountUser systemAccountUser, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteSystemAccountUser";
ClearErrorState();
if (!SystemAccountUserCanBeDeleted(systemAccountUser)) return false;
using (var dbConnection = db.CreateConnection())
@@ -191,7 +188,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser) + " WHERE Id=" + SysId.ToString(systemAccountUser.Id) + ";";
dbCommand.ExecuteNonQuery();
systemAccountUser.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -457,7 +454,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// SystemAccountUser list.
public override List<SbmSystemAccountUser> GetSystemAccountUserList(SbmSystemAccountUser.Params prm)
{
List<SbmSystemAccountUser> SystemAccountUseres = new List<SbmSystemAccountUser>();
ClearErrorState();
List<SbmSystemAccountUser> systemAccountUsers = new List<SbmSystemAccountUser>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser), aliasSystemAccountUser);
SystemAccountUser_Db dbSystemAccountUser = new SystemAccountUser_Db(DbInfo);
@@ -478,16 +476,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbSystemAccountUser = new SystemAccountUser_Db(DbInfo);
dbSystemAccountUser.PopulateFrom(dbDataReader);
SystemAccountUseres.Add(CreateSystemAccountUser(dbSystemAccountUser));
systemAccountUsers.Add(CreateSystemAccountUser(dbSystemAccountUser));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetSystemAccountUserList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return SystemAccountUseres;
return systemAccountUsers;
}
//-------------------------------------------------------------------
@@ -81,7 +81,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetSystemUser\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return SystemUser;
@@ -100,7 +100,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert SystemUser.
public override bool InsertSystemUser(SbmSystemUser systemUser, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertSystemUser";
ClearErrorState();
if (!IsValidSystemUser(systemUser)) return false;
if (SysId.IsValid(systemUser.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -120,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbSystemUser.ExecuteInsertCommand(dbCommand);
systemUser.Id = new SysId(dbSystemUser._Id);
systemUser.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted. {GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -131,13 +130,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update SystemUser.
public override bool UpdateSystemUser(SbmSystemUser systemUser, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateSystemUser";
ClearErrorState();
if (!IsValidSystemUser(systemUser)) return false;
if (!SysId.IsValid(systemUser.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!systemUser.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -155,7 +153,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
PopulateTo(dbSystemUser, systemUser, dbUpdateInfo);
dbSystemUser.ExecuteUpdateCommand(dbCommand);
systemUser.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated. {GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t")}");
// Record updates.
/*updateLogMonitor.RecordUpdatedValues(systemUser);
@@ -176,7 +174,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteSystemUser(SbmSystemUser systemUser, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteSystemUser";
ClearErrorState();
if (!SystemUserCanBeDeleted(systemUser)) return false;
using (var dbConnection = db.CreateConnection())
@@ -193,7 +190,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser) + " WHERE Id=" + SysId.ToString(systemUser.Id) + ";";
dbCommand.ExecuteNonQuery();
systemUser.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted. {GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -461,7 +458,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// SystemUser list.
public override List<SbmSystemUser> GetSystemUserList(SbmSystemUser.Params prm)
{
List<SbmSystemUser> SystemUseres = new List<SbmSystemUser>();
ClearErrorState();
List<SbmSystemUser> systemUsers = new List<SbmSystemUser>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser), aliasSystemUser);
SystemUser_Db dbSystemUser = new SystemUser_Db(DbInfo);
@@ -482,16 +480,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbSystemUser = new SystemUser_Db(DbInfo);
dbSystemUser.PopulateFrom(dbDataReader);
SystemUseres.Add(CreateSystemUser(dbSystemUser));
systemUsers.Add(CreateSystemUser(dbSystemUser));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetSystemUserList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return SystemUseres;
return systemUsers;
}
//-------------------------------------------------------------------
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetAsset\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return asset;
@@ -105,7 +105,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert Asset.
public override bool InsertAsset(SbmAsset asset, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAsset";
ClearErrorState();
if (!IsValidAsset(asset)) return false;
if (SysId.IsValid(asset.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -125,7 +124,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbAsset.ExecuteInsertCommand(dbCommand);
asset.Id = new SysId(dbAsset._Id);
asset.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(asset).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted.{GetLogProperties(asset).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -136,13 +135,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update Asset.
public override bool UpdateAsset(SbmAsset asset, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateAsset";
ClearErrorState();
if (!IsValidAsset(asset)) return false;
if (!SysId.IsValid(asset.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!asset.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(asset).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(asset).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -153,14 +151,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve Asset.
dbConnection.Open();
SaAsset_Db dbAsset = new SaAsset_Db(DbInfo);
dbAsset.PopulateFrom(dbCommand, aliasAsset, "Id=" + SysId.ToString(asset.Id));
dbAsset.PopulateFrom(dbCommand, aliasAsset, $"Id={SysId.ToString(asset.Id)}");
SbmUpdateLogItemMonitor_Asset updateLogMonitor = new SbmUpdateLogItemMonitor_Asset(Internals, CreateAsset(dbAsset));
// Update properties.
PopulateTo(dbAsset, asset, dbUpdateInfo);
dbAsset.ExecuteUpdateCommand(dbCommand);
asset.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated." + GetLogProperties(asset).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated.{GetLogProperties(asset).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(asset);
@@ -181,7 +179,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteAsset(SbmAsset asset, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAsset";
ClearErrorState();
if (!AssetCanBeDeleted(asset)) return false;
using (var dbConnection = db.CreateConnection())
@@ -192,13 +189,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve Asset.
dbConnection.Open();
SaAsset_Db dbAsset = new SaAsset_Db(DbInfo);
dbAsset.PopulateFrom(dbCommand, aliasAsset, "Id=" + asset.Id.ToString());
dbAsset.PopulateFrom(dbCommand, aliasAsset, $"Id={asset.Id.ToString()}");
// Delete Asset.
dbCommand.CommandType = System.Data.CommandType.Text;
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset) + " WHERE Id=" + SysId.ToString(asset.Id) + ";";
dbCommand.CommandText = $"DELETE FROM {SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset)} WHERE Id={SysId.ToString(asset.Id)};";
dbCommand.ExecuteNonQuery();
asset.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted." + GetLogProperties(asset).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted.{GetLogProperties(asset).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -480,24 +477,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String includedIds = prm.IncludedIds.Concat(",");
String colAsset_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasAsset);
if (!includedIds.IsEmpty())
filter.Add(colAsset_Id + " IN (" + includedIds + ")");
filter.Add($"{colAsset_Id} IN ({includedIds})");
String excludedIds = prm.ExcludedIds.Concat(",");
if (!excludedIds.IsEmpty())
filter.Add(colAsset_Id + " NOT IN (" + excludedIds + ")");
filter.Add($"{colAsset_Id} NOT IN ({excludedIds})");
// Asset CategoryId.
String colSaAsset_CategoryId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasAsset);
if (SysId.IsValid(prm.AssetCatId))
filter.Add(colSaAsset_CategoryId + "='" + prm.AssetCatId.ToString());
filter.Add($"{colSaAsset_CategoryId}={prm.AssetCatId.ToString()}");
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Item Type & Id.
String colAsset_ItemType = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemType, aliasAsset);
if (prm.ItemType > 0)
filter.Add(colAsset_ItemType + "=" + ((int)prm.ItemType).ToString());
filter.Add($"{colAsset_ItemType}={(int)prm.ItemType}");
String colAsset_ItemId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemId, aliasAsset);
if (ItemId.IsValid(prm.ItemId))
filter.Add(colAsset_ItemId + "=" + prm.ItemId.ToString());
filter.Add($"{colAsset_ItemId}={prm.ItemId.ToString()}");
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Partial SerialNumber.
@@ -505,20 +502,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String serialNumberPartial = DbQuery.FormatForCondition(prm.SerialNumberPartial);
String colAsset_SerialNumber = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber, aliasAsset);
if (!StringUtil.IsEmpty(serialNumberFull))
filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber, aliasAsset) + "='" + serialNumberFull + "'");
filter.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber, aliasAsset)}='{serialNumberFull}'");
else if (!StringUtil.IsEmpty(serialNumberPartial))
filter.Add(DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber, aliasAsset), prm.SerialNumberPartial.Length) + " ='" + serialNumberPartial + "'");
filter.Add($"{DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber, aliasAsset), prm.SerialNumberPartial.Length)}='{serialNumberPartial}'");
// Partial Description.
String description = DbQuery.FormatForCondition(prm.DescBriefPartial);
String colAsset_DescBrief = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_DescBrief, aliasAsset);
if (!StringUtil.IsEmpty(description))
filter.Add(DbQuery.FormatFn_Left(colAsset_DescBrief, prm.DescBriefPartial.Length) + " ='" + description + "'");
filter.Add($"{DbQuery.FormatFn_Left(colAsset_DescBrief, prm.DescBriefPartial.Length)}='{description}'");
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Next Process Id.
String colAsset_ProcessIdNext = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ProcessIdNext, aliasAsset);
if (SysId.IsValid(prm.ProcessIdNext))
filter.Add(colAsset_ProcessIdNext + "=" + prm.ProcessIdNext.ToString());
filter.Add($"{colAsset_ProcessIdNext}={prm.ProcessIdNext.ToString()}");
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Active Process Id.
@@ -597,7 +594,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Asset list.
public override List<SbmAsset> GetAssetList(SbmAsset.Params prm)
{
List<SbmAsset> Assetes = new List<SbmAsset>();
ClearErrorState();
List<SbmAsset> assets = new List<SbmAsset>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset), aliasAsset);
SaAsset_Db dbAsset = new SaAsset_Db(DbInfo);
@@ -618,16 +616,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbAsset = new SaAsset_Db(DbInfo);
dbAsset.PopulateFrom(dbDataReader);
Assetes.Add(CreateAsset(dbAsset));
assets.Add(CreateAsset(dbAsset));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetAssetList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Assetes;
return assets;
}
//-------------------------------------------------------------------
@@ -92,7 +92,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetAssetCategory\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return assetCategory;
@@ -122,7 +122,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
if (includeType)
{
String assetType = AssetTypes.GetDescForType(values.GetValue(colAssetCategory_AssetType).AsLong());
if (!StringUtil.IsEmpty(assetType)) caption += " (" + assetType + ")";
if (!StringUtil.IsEmpty(assetType)) caption += $" ({assetType})";
caption.Trim();
}
assetCats.Add(new SysId((int)values.GetValue(colAssetCategory_Id).AsLong()), caption);
@@ -163,7 +163,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert AssetCategory.
public override bool InsertAssetCategory(SbmAssetCategory assetCategory, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAssetCategory";
ClearErrorState();
if (!IsValidAssetCategory(assetCategory)) return false;
if (SysId.IsValid(assetCategory.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -183,7 +182,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbAssetCategory.ExecuteInsertCommand(dbCommand);
assetCategory.Id = new SysId(dbAssetCategory._Id);
assetCategory.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted.{GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -194,13 +193,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update AssetCategory.
public override bool UpdateAssetCategory(SbmAssetCategory assetCategory, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateAssetCategory";
ClearErrorState();
if (!IsValidAssetCategory(assetCategory)) return false;
if (!SysId.IsValid(assetCategory.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!assetCategory.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -211,14 +209,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve AssetCategory.
dbConnection.Open();
SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo);
dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, "Id=" + SysId.ToString(assetCategory.Id));
dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, $"Id={SysId.ToString(assetCategory.Id)}");
SbmUpdateLogItemMonitor_AssetCategory updateLogMonitor = new SbmUpdateLogItemMonitor_AssetCategory(Internals, CreateAssetCategory(dbAssetCategory));
// Update properties.
PopulateTo(dbAssetCategory, assetCategory, dbUpdateInfo);
dbAssetCategory.ExecuteUpdateCommand(dbCommand);
assetCategory.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated.{GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(assetCategory);
@@ -239,7 +237,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteAssetCategory(SbmAssetCategory assetCategory, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteAssetCategory";
ClearErrorState();
if (!AssetCategoryCanBeDeleted(assetCategory)) return false;
using (var dbConnection = db.CreateConnection())
@@ -250,13 +247,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve AssetCategory.
dbConnection.Open();
SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo);
dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, "Id=" + assetCategory.Id.ToString());
dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, $"Id={assetCategory.Id.ToString()}");
// Delete AssetCategory.
dbCommand.CommandType = System.Data.CommandType.Text;
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory) + " WHERE Id=" + SysId.ToString(assetCategory.Id) + ";";
dbCommand.CommandText = $"DELETE FROM {SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} WHERE Id={SysId.ToString(assetCategory.Id)};";
dbCommand.ExecuteNonQuery();
assetCategory.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted.{GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -439,32 +436,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String includedIds = prm.IncludedIds.Concat(",");
String colAssetCategory_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAssetCategory);
if (!includedIds.IsEmpty())
filter.Add(colAssetCategory_Id + " IN (" + includedIds + ")");
filter.Add($"{colAssetCategory_Id} IN ({includedIds})");
String excludedIds = prm.ExcludedIds.Concat(",");
if (!excludedIds.IsEmpty())
filter.Add(colAssetCategory_Id + " NOT IN (" + excludedIds + ")");
filter.Add($"{colAssetCategory_Id} NOT IN ({excludedIds})");
// Asset Category Type.
String colSaAssetCategory_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, aliasAssetCategory);
if (prm.AssetType > 0)
filter.Add(colSaAssetCategory_Type + "='" + ((int)prm.AssetType).ToString());
filter.Add($"{colSaAssetCategory_Type}='{(int)prm.AssetType}");
// Partial Code.
String code = DbQuery.FormatForCondition(prm.CodePartial);
String colAssetCategory_Code = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Code, aliasAssetCategory);
if (!StringUtil.IsEmpty(code))
filter.Add(DbQuery.FormatFn_Left(colAssetCategory_Code, prm.CodePartial.Length) + " ='" + code + "'");
filter.Add($"{DbQuery.FormatFn_Left(colAssetCategory_Code, prm.CodePartial.Length)}='{code}'");
// Partial Description.
String description = DbQuery.FormatForCondition(prm.DescBriefPartial);
String colAssetCategory_DescBrief = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DescBrief, aliasAssetCategory);
if (!StringUtil.IsEmpty(description))
filter.Add(DbQuery.FormatFn_Left(colAssetCategory_DescBrief, prm.DescBriefPartial.Length) + " ='" + description + "'");
filter.Add($"{DbQuery.FormatFn_Left(colAssetCategory_DescBrief, prm.DescBriefPartial.Length)}='{description}'");
// Status.
String colAssetCategory_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Status, aliasAssetCategory);
if (prm.RestrictToActive)
filter.Add(colAssetCategory_Status + "='" + StatusActive + "'");
filter.Add($"{colAssetCategory_Status}='{StatusActive}'");
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
return filter;
@@ -509,7 +506,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
private long GetAssetCategoryCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory) + " As " + aliasAssetCategory, filter);
return db.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} As {aliasAssetCategory}", filter);
}
public override long GetAssetCategoryCount(SbmAssetCategory.Params prm)
{
@@ -521,7 +518,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// AssetCategory list.
public override List<SbmAssetCategory> GetAssetCategoryList(SbmAssetCategory.Params prm)
{
List<SbmAssetCategory> AssetCategoryes = new List<SbmAssetCategory>();
ClearErrorState();
List<SbmAssetCategory> assetCategories = new List<SbmAssetCategory>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), aliasAssetCategory);
SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo);
@@ -542,16 +540,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbAssetCategory = new SaAssetCategory_Db(DbInfo);
dbAssetCategory.PopulateFrom(dbDataReader);
AssetCategoryes.Add(CreateAssetCategory(dbAssetCategory));
assetCategories.Add(CreateAssetCategory(dbAssetCategory));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetAssetCategoryList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return AssetCategoryes;
return assetCategories;
}
//-------------------------------------------------------------------
@@ -606,9 +605,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String tableAsset = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset);
DbQuery qryAssetCount = new DbQuery(db.DbmsType);
qryAssetCount.Tables.Add(tableAsset, aliasAsset);
qryAssetCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasAsset) + ")");
qryAssetCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasAsset) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAsset));
query.Columns.Add("(" + qryAssetCount.BuildQuery() + ")", "AssetCount");
qryAssetCount.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasAsset)})");
qryAssetCount.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasAsset)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAsset)}");
query.Columns.Add($"({qryAssetCount.BuildQuery()})", "AssetCount");
}
// Common Properties
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetAssetProcess\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return assetProcess;
@@ -105,7 +105,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert AssetProcess.
public override bool InsertAssetProcess(SbmAssetProcess assetProcess, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertAssetProcess";
ClearErrorState();
if (!IsValidAssetProcess(assetProcess)) return false;
if (SysId.IsValid(assetProcess.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -125,7 +124,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbAssetProcess.ExecuteInsertCommand(dbCommand);
assetProcess.Id = new SysId(dbAssetProcess._Id);
assetProcess.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted.{GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -136,13 +135,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update AssetProcess.
public override bool UpdateAssetProcess(SbmAssetProcess assetProcess, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateAssetProcess";
ClearErrorState();
if (!IsValidAssetProcess(assetProcess)) return false;
if (!SysId.IsValid(assetProcess.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!assetProcess.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -153,14 +151,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve AssetProcess.
dbConnection.Open();
SaAssetProcess_Db dbAssetProcess = new SaAssetProcess_Db(DbInfo);
dbAssetProcess.PopulateFrom(dbCommand, aliasAssetProcess, "Id=" + SysId.ToString(assetProcess.Id));
dbAssetProcess.PopulateFrom(dbCommand, aliasAssetProcess, $"Id={SysId.ToString(assetProcess.Id)}");
SbmUpdateLogItemMonitor_AssetProcess updateLogMonitor = new SbmUpdateLogItemMonitor_AssetProcess(Internals, CreateAssetProcess(dbAssetProcess));
// Update properties.
PopulateTo(dbAssetProcess, assetProcess, dbUpdateInfo);
dbAssetProcess.ExecuteUpdateCommand(dbCommand);
assetProcess.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated.{GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(assetProcess);
@@ -181,7 +179,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteAssetProcess(SbmAssetProcess assetProcess, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteAssetProcess";
ClearErrorState();
if (!AssetProcessCanBeDeleted(assetProcess)) return false;
using (var dbConnection = db.CreateConnection())
@@ -192,13 +189,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve AssetProcess.
dbConnection.Open();
SaAssetProcess_Db dbAssetProcess = new SaAssetProcess_Db(DbInfo);
dbAssetProcess.PopulateFrom(dbCommand, aliasAssetProcess, "Id=" + assetProcess.Id.ToString());
dbAssetProcess.PopulateFrom(dbCommand, aliasAssetProcess, $"Id={assetProcess.Id.ToString()}");
// Delete AssetProcess.
dbCommand.CommandType = System.Data.CommandType.Text;
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess) + " WHERE Id=" + SysId.ToString(assetProcess.Id) + ";";
dbCommand.CommandText = $"DELETE FROM {SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess)} WHERE Id={SysId.ToString(assetProcess.Id)};";
dbCommand.ExecuteNonQuery();
assetProcess.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted.{GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -344,10 +341,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String includedIds = prm.IncludedIds.Concat(",");
String colAssetProcess_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetProcess_Id, aliasAssetProcess);
if (!includedIds.IsEmpty())
filter.Add(colAssetProcess_Id + " IN (" + includedIds + ")");
filter.Add($"{colAssetProcess_Id} IN ({includedIds})");
String excludedIds = prm.ExcludedIds.Concat(",");
if (!excludedIds.IsEmpty())
filter.Add(colAssetProcess_Id + " NOT IN (" + excludedIds + ")");
filter.Add($"{colAssetProcess_Id} NOT IN ({excludedIds})");
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
return filter;
@@ -404,7 +401,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// AssetProcess list.
public override List<SbmAssetProcess> GetAssetProcessList(SbmAssetProcess.Params prm)
{
List<SbmAssetProcess> AssetProcesses = new List<SbmAssetProcess>();
ClearErrorState();
List<SbmAssetProcess> assetProcesses = new List<SbmAssetProcess>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess), aliasAssetProcess);
SaAssetProcess_Db dbAssetProcess = new SaAssetProcess_Db(DbInfo);
@@ -425,16 +423,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbAssetProcess = new SaAssetProcess_Db(DbInfo);
dbAssetProcess.PopulateFrom(dbDataReader);
AssetProcesses.Add(CreateAssetProcess(dbAssetProcess));
assetProcesses.Add(CreateAssetProcess(dbAssetProcess));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetAssetProcessList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return AssetProcesses;
return assetProcesses;
}
//-------------------------------------------------------------------
@@ -68,7 +68,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetVehicle\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return vehicle;
@@ -103,7 +103,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Insert Vehicle.
public override bool InsertVehicle(SbmVehicle vehicle, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".InsertVehicle";
ClearErrorState();
if (!IsValidVehicle(vehicle)) return false;
if (SysId.IsValid(vehicle.Id)) return SetErrorState(ErrorMessage.ValiditemId);
@@ -123,7 +122,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
dbVehicle.ExecuteInsertCommand(dbCommand);
vehicle.Id = new SysId(dbVehicle._Id);
vehicle.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Inserted. " + GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Inserted.{GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -134,13 +133,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Update Vehicle.
public override bool UpdateVehicle(SbmVehicle vehicle, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".UpdateVehicle";
ClearErrorState();
if (!IsValidVehicle(vehicle)) return false;
if (!SysId.IsValid(vehicle.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
if (!vehicle.Changed)
{
if (DebugMode) SaLogger.Debug(fn + " Data not changed. " + GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t")}");
return true;
}
using (var dbConnection = db.CreateConnection())
@@ -151,14 +149,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve Vehicle.
dbConnection.Open();
SaVehicle_Db dbVehicle = new SaVehicle_Db(DbInfo);
dbVehicle.PopulateFrom(dbCommand, aliasVehicle, "Id=" + SysId.ToString(vehicle.Id));
dbVehicle.PopulateFrom(dbCommand, aliasVehicle, $"Id={SysId.ToString(vehicle.Id)}");
SbmUpdateLogItemMonitor_Vehicle updateLogMonitor = new SbmUpdateLogItemMonitor_Vehicle(Internals, CreateVehicle(dbVehicle));
// Update properties.
PopulateTo(dbVehicle, vehicle, dbUpdateInfo);
dbVehicle.ExecuteUpdateCommand(dbCommand);
vehicle.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Updated. " + GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Updated.{GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t")}");
// Record updates.
updateLogMonitor.RecordUpdatedValues(vehicle);
@@ -179,7 +177,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
public override bool DeleteVehicle(SbmVehicle vehicle, DbUpdateInfo dbUpdateInfo)
{
String fn = GetType().Name + ".DeleteVehicle";
ClearErrorState();
if (!VehicleCanBeDeleted(vehicle)) return false;
using (var dbConnection = db.CreateConnection())
@@ -190,13 +187,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Retrieve prm.
dbConnection.Open();
SaVehicle_Db dbVehicle = new SaVehicle_Db(DbInfo);
dbVehicle.PopulateFrom(dbCommand, aliasVehicle, "Id=" + vehicle.Id.ToString());
dbVehicle.PopulateFrom(dbCommand, aliasVehicle, $"Id={vehicle.Id.ToString()}");
// Delete prm.
dbCommand.CommandType = System.Data.CommandType.Text;
dbCommand.CommandText = "DELETE FROM " + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle) + " WHERE Id=" + SysId.ToString(vehicle.Id) + ";";
dbCommand.CommandText = $"DELETE FROM {SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle)} WHERE Id={SysId.ToString(vehicle.Id)};";
dbCommand.ExecuteNonQuery();
vehicle.Changed = false;
if (DebugMode) SaLogger.Debug(fn + " Deleted. " + GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t"));
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Deleted.{GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t")}");
}
catch (Exception exc) { SetErrorState(exc.Message); }
}
@@ -502,15 +499,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String includedIds = prm.IncludedIds.Concat(",");
String colVehicle_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle);
if (!StringUtil.IsEmpty(includedIds))
filter.Add(colVehicle_Id + " IN (" + includedIds + ")");
filter.Add($"{colVehicle_Id} IN ({includedIds})");
String excludedIds = prm.ExcludedIds.Concat(",");
if (!StringUtil.IsEmpty(excludedIds))
filter.Add(colVehicle_Id + " NOT IN (" + excludedIds + ")");
filter.Add($"{colVehicle_Id} NOT IN ({excludedIds})");
//---------------------------------------------------------------
// Vehicle Class.
String colVehicle_VehicleClassId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VehicleClassId, aliasVehicle);
if (SysId.IsValid(prm.VehicleClassId))
filter.Add(colVehicle_VehicleClassId + "=" + prm.VehicleClassId.ToString());
filter.Add($"{colVehicle_VehicleClassId}={prm.VehicleClassId.ToString()}");
String classDesc = DbQuery.FormatForCondition(prm.ClassDescPartial);
if (!StringUtil.IsEmpty(prm.MakeCode) || !classDesc.IsEmpty())
{
@@ -518,21 +515,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
qryVehicleClass.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass), aliasVehicle_VehicleClass);
qryVehicleClass.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_Id, aliasVehicle_VehicleClass));
if (!StringUtil.IsEmpty(prm.MakeCode))
qryVehicleClass.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_MakeCode, aliasVehicle_VehicleClass) + "='" + prm.MakeCode + "'");
qryVehicleClass.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_MakeCode, aliasVehicle_VehicleClass)}='{prm.MakeCode}'");
if (!StringUtil.IsEmpty(classDesc))
qryVehicleClass.Filters.Add(DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_DescBrief, aliasVehicle_VehicleClass), prm.ClassDescPartial.Length) + "='" + classDesc + "'");
filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VehicleClassId, aliasVehicle) + " IN (" + qryVehicleClass.BuildQuery() + ")");
qryVehicleClass.Filters.Add($"{DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_DescBrief, aliasVehicle_VehicleClass), prm.ClassDescPartial.Length)}='{classDesc}'");
filter.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VehicleClassId, aliasVehicle)} IN ({qryVehicleClass.BuildQuery()})");
}
//---------------------------------------------------------------
// Partial Registration.
String regNumber = DbQuery.FormatForCondition(prm.RegNumberPartial);
if (!StringUtil.IsEmpty(regNumber))
filter.Add(DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_RegNumber, aliasVehicle), prm.RegNumberPartial.Length) + " ='" + regNumber + "'");
filter.Add($"{DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_RegNumber, aliasVehicle), prm.RegNumberPartial.Length)}='{regNumber}'");
// Partial VIN:
String vin = DbQuery.FormatForCondition(prm.VinPartial);
if (!StringUtil.IsEmpty(vin))
filter.Add(DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VIN, aliasVehicle), prm.VinPartial.Length) + " ='" + vin + "'");
filter.Add($"{DbQuery.FormatFn_Left(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VIN, aliasVehicle), prm.VinPartial.Length)}='{vin}'");
//---------------------------------------------------------------
// Associated Assets.
@@ -542,29 +539,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
DbQuery qryAsset = new DbQuery(db.DbmsType);
qryAsset.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset), aliasVehicle_Asset);
qryAsset.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasVehicle_Asset));
qryAsset.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemType, aliasVehicle_Asset) + "=" + ((int)Sbm.ItemType.Vehicle).ToString());
qryAsset.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemId, aliasVehicle_Asset) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle));
qryAsset.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemType, aliasVehicle_Asset)}={(int)Sbm.ItemType.Vehicle}");
qryAsset.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemId, aliasVehicle_Asset)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle)}");
String colAsset_AssetCategoryId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasVehicle_Asset);
String colAsset_ProcessIdNext = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ProcessIdNext, aliasVehicle_Asset);
if (SysId.IsValid(prm.AssetCatIdInclude) || SysId.IsValid(prm.AssetProcessIdNext))
{
if (SysId.IsValid(prm.AssetCatIdInclude))
qryAsset.Filters.Add(colAsset_AssetCategoryId + "=" + prm.AssetCatIdInclude.ToString());
qryAsset.Filters.Add($"{colAsset_AssetCategoryId}={prm.AssetCatIdInclude.ToString()}");
if (SysId.IsValid(prm.AssetProcessIdNext))
qryAsset.Filters.Add(colAsset_ProcessIdNext + "=" + prm.AssetProcessIdNext.ToString());
filter.Add(" EXISTS(" + qryAsset.BuildQuery() + ")");
qryAsset.Filters.Add($"{colAsset_ProcessIdNext}={prm.AssetProcessIdNext.ToString()}");
filter.Add($" EXISTS({qryAsset.BuildQuery()})");
}
if (SysId.IsValid(prm.AssetCatIdExclude))
{
qryAsset.Filters.Add(colAsset_AssetCategoryId + "=" + prm.AssetCatIdExclude.ToString());
filter.Add(" NOT EXISTS(" + qryAsset.BuildQuery() + ")");
qryAsset.Filters.Add($"{colAsset_AssetCategoryId}={prm.AssetCatIdExclude.ToString()}");
filter.Add($" NOT EXISTS({qryAsset.BuildQuery()})");
}
}
//---------------------------------------------------------------
// Restrict to active:
String colVehicle_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Status, aliasVehicle);
if (!StringUtil.IsEmpty(prm.RestrictToActive))
filter.Add(colVehicle_Status + "='" + SacsSystem.GetStatusDesc(SaStatus.Active) + "'");
filter.Add($"{colVehicle_Status}='{StatusActive}'");
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
return filter;
@@ -609,7 +606,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
private long GetVehicleCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle) + " As " + aliasVehicle, filter);
return db.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle)} As {aliasVehicle}", filter);
}
public override long GetVehicleCount(SbmVehicle.Params prm)
{
@@ -621,7 +618,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Vehicle list.
public override List<SbmVehicle> GetVehicleList(SbmVehicle.Params prm)
{
List<SbmVehicle> Vehiclees = new List<SbmVehicle>();
ClearErrorState();
List<SbmVehicle> vehicles = new List<SbmVehicle>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle), aliasVehicle);
SaVehicle_Db dbVehicle = new SaVehicle_Db(DbInfo);
@@ -642,16 +640,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbVehicle = new SaVehicle_Db(DbInfo);
dbVehicle.PopulateFrom(dbDataReader);
Vehiclees.Add(CreateVehicle(dbVehicle));
vehicles.Add(CreateVehicle(dbVehicle));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetVehicleList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Vehiclees;
return vehicles;
}
//-------------------------------------------------------------------
@@ -697,7 +696,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
DbQueryJoin joinVehCat = new DbQueryJoin(DbJoinType.LeftOuter);
joinVehCat.Table = new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass), aliasVehicle_VehicleClass);
joinVehCat.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_Id, aliasVehicle_VehicleClass) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VehicleClassId, aliasVehicle));
joinVehCat.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_Id, aliasVehicle_VehicleClass)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_VehicleClassId, aliasVehicle)}");
query.Joins.Add(joinVehCat);
// Add the Vehicle Category columns:
List<SbmDbDfn.ColumnIdx> dbColumns = new List<SbmDbDfn.ColumnIdx>();
@@ -726,9 +725,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String aliasVehicle_VehicleEvent = "aVehVehEvt";
DbQuery qryEvent = new DbQuery(db.DbmsType);
qryEvent.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent), aliasVehicle_VehicleEvent);
qryEvent.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_Id, aliasVehicle_VehicleEvent) + ")");
qryEvent.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_VehicleId, aliasVehicle_VehicleEvent) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle));
query.Columns.Add("(" + qryEvent.BuildQuery() + ")", dataNameVehEventCount);
qryEvent.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_Id, aliasVehicle_VehicleEvent)})");
qryEvent.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_VehicleId, aliasVehicle_VehicleEvent)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle)}");
query.Columns.Add($"({qryEvent.BuildQuery()})", dataNameVehEventCount);
}
}
//---------------------------------------------------------------
@@ -742,9 +741,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String aliasVehicle_VehicleFeature = "aVehVehFtr";
DbQuery qryFeature = new DbQuery(db.DbmsType);
qryFeature.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature), aliasVehicle_VehicleFeature);
qryFeature.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicle_VehicleFeature) + ")");
qryFeature.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicle_VehicleFeature) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle));
query.Columns.Add("(" + qryFeature.BuildQuery() + ")", dataNameVehFeatureCount);
qryFeature.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicle_VehicleFeature)})");
qryFeature.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicle_VehicleFeature)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle)}");
query.Columns.Add($"({qryFeature.BuildQuery()})", dataNameVehFeatureCount);
}
}
@@ -760,12 +759,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
String aliasVehicle_ItemData = "aVehItmDat";
DbQuery qryItemData = new DbQuery(db.DbmsType);
qryItemData.Tables.Add(SaItemDataDbDfn.GetTableName(SaItemDataDbDfn.TableIdx.SaItemData), aliasVehicle_ItemData);
qryItemData.Columns.Add("Count(" + SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_Id, aliasVehicle_ItemData) + ")");
qryItemData.Filters.Add(SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_ItemType, aliasVehicle_ItemData) + "=" + ((int)Sbm.ItemType.Vehicle).ToString());
qryItemData.Filters.Add(SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_ItemId, aliasVehicle_ItemData) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle));
qryItemData.Columns.Add($"Count({SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_Id, aliasVehicle_ItemData)})");
qryItemData.Filters.Add($"{SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_ItemType, aliasVehicle_ItemData)}={(int)Sbm.ItemType.Vehicle}");
qryItemData.Filters.Add($"{SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_ItemId, aliasVehicle_ItemData)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle)}");
List<TypeCodeDesc> itemDataTypes = new List<TypeCodeDesc>();
qryItemData.Filters.Add(SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_DataType, aliasVehicle_ItemData) + "='" + itemDataTypes.GetCodeForType(Sbm.ItemDataType.Vehicle_HpiResponse) + "'");
query.Columns.Add("(" + qryItemData.BuildQuery() + ")", dataNameHpiCheckCount);
qryItemData.Filters.Add($"{SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_DataType, aliasVehicle_ItemData)}='{itemDataTypes.GetCodeForType(Sbm.ItemDataType.Vehicle_HpiResponse)}'");
query.Columns.Add($"({qryItemData.BuildQuery()})", dataNameHpiCheckCount);
}
}
// Common Properties
@@ -148,7 +148,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetVehicleClass\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return vehicleClass;
@@ -619,7 +619,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// VehicleClass list.
public override List<SbmVehicleClass> GetVehicleClassList(SbmVehicleClass.Params prm)
{
List<SbmVehicleClass> VehicleClasses = new List<SbmVehicleClass>();
ClearErrorState();
List<SbmVehicleClass> vehicleClasses = new List<SbmVehicleClass>();
DbQuery qryVehicleClass = new DbQuery(db.DbmsType);
qryVehicleClass.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass), aliasVehicleClass);
SaVehicleClass_Db dbVehicleClass = new SaVehicleClass_Db(DbInfo);
@@ -640,16 +641,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbVehicleClass = new SaVehicleClass_Db(DbInfo);
dbVehicleClass.PopulateFrom(dbDataReader);
VehicleClasses.Add(CreateVehicleClass(dbVehicleClass));
vehicleClasses.Add(CreateVehicleClass(dbVehicleClass));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetVehicleClassList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return VehicleClasses;
return vehicleClasses;
}
//-------------------------------------------------------------------
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetVehicleEvent\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return vehicleEvent;
@@ -478,7 +478,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// VehicleEvent list.
public override List<SbmVehicleEvent> GetVehicleEventList(SbmVehicleEvent.Params prm)
{
List<SbmVehicleEvent> VehicleEventes = new List<SbmVehicleEvent>();
ClearErrorState();
List<SbmVehicleEvent> vehicleEvents = new List<SbmVehicleEvent>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent), aliasVehicleEvent);
SaVehicleEvent_Db dbVehicleEvent = new SaVehicleEvent_Db(DbInfo);
@@ -499,16 +500,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbVehicleEvent = new SaVehicleEvent_Db(DbInfo);
dbVehicleEvent.PopulateFrom(dbDataReader);
VehicleEventes.Add(CreateVehicleEvent(dbVehicleEvent));
vehicleEvents.Add(CreateVehicleEvent(dbVehicleEvent));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetVehicleEventList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return VehicleEventes;
return vehicleEvents;
}
//-------------------------------------------------------------------
@@ -164,7 +164,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetVehicleFeature\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return vehicleFeature;
@@ -534,7 +534,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// VehicleFeature list.
public override List<SbmVehicleFeature> GetVehicleFeatureList(SbmVehicleFeature.Params prm)
{
List<SbmVehicleFeature> VehicleFeaturees = new List<SbmVehicleFeature>();
ClearErrorState();
List<SbmVehicleFeature> vehicleFeatures = new List<SbmVehicleFeature>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature), aliasVehicleFeature);
SaVehicleFeature_Db dbVehicleFeature = new SaVehicleFeature_Db(DbInfo);
@@ -555,16 +556,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbVehicleFeature = new SaVehicleFeature_Db(DbInfo);
dbVehicleFeature.PopulateFrom(dbDataReader);
VehicleFeaturees.Add(CreateVehicleFeature(dbVehicleFeature));
vehicleFeatures.Add(CreateVehicleFeature(dbVehicleFeature));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetVehicleFeatureList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return VehicleFeaturees;
return vehicleFeatures;
}
//-------------------------------------------------------------------
@@ -586,7 +586,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetCommodity\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return commodity;
@@ -2656,7 +2656,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Commodity list.
public override List<SbmCommodity> GetCommodityList(SbmCommodity.Params prm)
{
List<SbmCommodity> Commodities = new List<SbmCommodity>();
ClearErrorState();
List<SbmCommodity> commodities = new List<SbmCommodity>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), aliasCommodity);
Commodity_Db dbCommodity = new Commodity_Db(DbInfo);
@@ -2677,16 +2678,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbCommodity = new Commodity_Db(DbInfo);
dbCommodity.PopulateFrom(dbDataReader);
Commodities.Add(CreateCommodity(dbCommodity));
commodities.Add(CreateCommodity(dbCommodity));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetCommodityList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Commodities;
return commodities;
}
//-------------------------------------------------------------------
@@ -178,7 +178,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetCommodityCustomer\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmCommodityCustomer;
@@ -597,7 +597,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Item list.
public override List<SbmCommodityCustomer> GetCommodityCustomerList(SbmCommodityCustomer.Params prm)
{
List<SbmCommodityCustomer> CommodityCustomeres = new List<SbmCommodityCustomer>();
ClearErrorState();
List<SbmCommodityCustomer> commodityCustomers = new List<SbmCommodityCustomer>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), aliasCommodityCustomer);
CommodityCustomer_Db dbCommodityCustomer = new CommodityCustomer_Db(DbInfo);
@@ -618,16 +619,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbCommodityCustomer = new CommodityCustomer_Db(DbInfo);
dbCommodityCustomer.PopulateFrom(dbDataReader);
CommodityCustomeres.Add(CreateCommodityCustomer(dbCommodityCustomer));
commodityCustomers.Add(CreateCommodityCustomer(dbCommodityCustomer));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetCommodityCustomerList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return CommodityCustomeres;
return commodityCustomers;
}
//-------------------------------------------------------------------
@@ -71,7 +71,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetCommoditySupplier\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return commoditySupplier;
@@ -498,7 +498,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Item list.
public override List<SbmCommoditySupplier> GetCommoditySupplierList(SbmCommoditySupplier.Params prm)
{
List<SbmCommoditySupplier> CommoditySupplieres = new List<SbmCommoditySupplier>();
ClearErrorState();
List<SbmCommoditySupplier> commoditySuppliers = new List<SbmCommoditySupplier>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier), aliasCommoditySupplier);
CommoditySupplier_Db dbCommoditySupplier = new CommoditySupplier_Db(DbInfo);
@@ -519,16 +520,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbCommoditySupplier = new CommoditySupplier_Db(DbInfo);
dbCommoditySupplier.PopulateFrom(dbDataReader);
CommoditySupplieres.Add(CreateCommoditySupplier(dbCommoditySupplier));
commoditySuppliers.Add(CreateCommoditySupplier(dbCommoditySupplier));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetCommoditySupplierList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return CommoditySupplieres;
return commoditySuppliers;
}
//-------------------------------------------------------------------
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetContainer\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return container;
@@ -538,7 +538,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Container list.
public override List<SbmContainer> GetContainerList(SbmContainer.Params prm)
{
List<SbmContainer> Containers = new List<SbmContainer>();
ClearErrorState();
List<SbmContainer> containers = new List<SbmContainer>();
DbQuery DbQuery = new DbQuery(db.DbmsType);
DbQuery.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container), aliasContainer);
Container_Db dbContainer = new Container_Db(DbInfo);
@@ -559,16 +560,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbContainer = new Container_Db(DbInfo);
dbContainer.PopulateFrom(dbDataReader);
Containers.Add(CreateContainer(dbContainer));
containers.Add(CreateContainer(dbContainer));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetContainerList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Containers;
return containers;
}
//-------------------------------------------------------------------
@@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetContainerItem\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return containerItem;
@@ -671,7 +671,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Item list.
public override List<SbmContainerItem> GetContainerItemList(SbmContainerItem.Params prm)
{
List<SbmContainerItem> ContainerItemes = new List<SbmContainerItem>();
ClearErrorState();
List<SbmContainerItem> containerItems = new List<SbmContainerItem>();
DbQuery DbQuery = new DbQuery(db.DbmsType);
DbQuery.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasContainerItem);
ContainerItem_Db dbContainerItem = new ContainerItem_Db(DbInfo);
@@ -692,16 +693,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbContainerItem = new ContainerItem_Db(DbInfo);
dbContainerItem.PopulateFrom(dbDataReader);
ContainerItemes.Add(CreateContainerItem(dbContainerItem));
containerItems.Add(CreateContainerItem(dbContainerItem));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetContainerItemList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return ContainerItemes;
return containerItems;
}
//-------------------------------------------------------------------
@@ -276,7 +276,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetPortfolioItem\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return portfolioItem;
@@ -893,7 +893,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Item list.
public override List<SbmPortfolioItem> GetPortfolioItemList(SbmPortfolioItem.Params prm)
{
List<SbmPortfolioItem> PortfolioItemes = new List<SbmPortfolioItem>();
ClearErrorState();
List<SbmPortfolioItem> portfolioItems = new List<SbmPortfolioItem>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem), aliasPortfolioItem);
PortfolioItem_Db dbPortfolioItem = new PortfolioItem_Db(DbInfo);
@@ -914,16 +915,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbPortfolioItem = new PortfolioItem_Db(DbInfo);
dbPortfolioItem.PopulateFrom(dbDataReader);
PortfolioItemes.Add(CreatePortfolioItem(dbPortfolioItem));
portfolioItems.Add(CreatePortfolioItem(dbPortfolioItem));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetPortfolioItemList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return PortfolioItemes;
return portfolioItems;
}
//-------------------------------------------------------------------
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetItemBatch\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return itemBatch;
@@ -424,7 +424,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// ItemBatch list.
public override List<SbmItemBatch> GetItemBatchList(SbmItemBatch.Params prm)
{
List<SbmItemBatch> ItemBatches = new List<SbmItemBatch>();
ClearErrorState();
List<SbmItemBatch> itemBatches = new List<SbmItemBatch>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemBatch), aliasItemBatch);
ItemBatch_Db dbItemBatch = new ItemBatch_Db(DbInfo);
@@ -445,16 +446,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbItemBatch = new ItemBatch_Db(DbInfo);
dbItemBatch.PopulateFrom(dbDataReader);
ItemBatches.Add(CreateItemBatch(dbItemBatch));
itemBatches.Add(CreateItemBatch(dbItemBatch));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetItemBatchList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return ItemBatches;
return itemBatches;
}
//-------------------------------------------------------------------
@@ -133,7 +133,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetItemLink\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return itemLink;
@@ -632,7 +632,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// ItemLink list.
public override List<SbmItemLink> GetItemLinkList(SbmItemLink.Params prm)
{
List<SbmItemLink> ItemLinkes = new List<SbmItemLink>();
ClearErrorState();
List<SbmItemLink> itemLinks = new List<SbmItemLink>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), aliasItemLink);
ItemLink_Db dbItemLink = new ItemLink_Db(DbInfo);
@@ -653,16 +654,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbItemLink = new ItemLink_Db(DbInfo);
dbItemLink.PopulateFrom(dbDataReader);
ItemLinkes.Add(CreateItemLink(dbItemLink));
itemLinks.Add(CreateItemLink(dbItemLink));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetItemLinkList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return ItemLinkes;
return itemLinks;
}
//-------------------------------------------------------------------
@@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetPrice\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return price;
@@ -479,7 +479,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Price list.
public override List<SbmPrice> GetPriceList(SbmPrice.Params prm)
{
List<SbmPrice> Prices = new List<SbmPrice>();
ClearErrorState();
List<SbmPrice> prices = new List<SbmPrice>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPrice);
SaPrice_Db dbPrice = new SaPrice_Db(DbInfo);
@@ -500,16 +501,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbPrice = new SaPrice_Db(DbInfo);
dbPrice.PopulateFrom(dbDataReader);
Prices.Add(CreatePrice(dbPrice));
prices.Add(CreatePrice(dbPrice));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetPriceList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Prices;
return prices;
}
//-------------------------------------------------------------------
@@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetPriceSet\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return priceSet;
@@ -435,7 +435,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Item list.
public override List<SbmPriceSet> GetPriceSetList(SbmPriceSet.Params prm)
{
List<SbmPriceSet> PriceSetes = new List<SbmPriceSet>();
ClearErrorState();
List<SbmPriceSet> priceSets = new List<SbmPriceSet>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet), aliasPriceSet);
SaPriceSet_Db dbPriceSet = new SaPriceSet_Db(DbInfo);
@@ -456,16 +457,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbPriceSet = new SaPriceSet_Db(DbInfo);
dbPriceSet.PopulateFrom(dbDataReader);
PriceSetes.Add(CreatePriceSet(dbPriceSet));
priceSets.Add(CreatePriceSet(dbPriceSet));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetPriceSetList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return PriceSetes;
return priceSets;
}
//-------------------------------------------------------------------
@@ -128,8 +128,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
public override List<SbmItemProcess> GetProcessesForItem(SbmItemProcess.Params prm)
{
List<SbmItemProcess> itemProcesses = new List<SbmItemProcess>();
ClearErrorState();
List<SbmItemProcess> itemProcesses = new List<SbmItemProcess>();
if (prm.ItemType != Sbm.ItemType.Commodity && prm.ItemType != Sbm.ItemType.AssetCategory && prm.ItemType != Sbm.ItemType.Asset) SetErrorState("invalid item type");
if (!SysId.IsValid(prm.ItemId)) SetErrorState("invalid item Id");
@@ -106,7 +106,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetProcess\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmProcess;
@@ -485,7 +485,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Process list.
public override List<SbmProcess> GetProcessList(SbmProcess.Params prm)
{
List<SbmProcess> Processes = new List<SbmProcess>();
ClearErrorState();
List<SbmProcess> processes = new List<SbmProcess>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), aliasProcess);
Process_Db dbProcess = new Process_Db(DbInfo);
@@ -506,16 +507,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbProcess = new Process_Db(DbInfo);
dbProcess.PopulateFrom(dbDataReader);
Processes.Add(CreateProcess(dbProcess));
processes.Add(CreateProcess(dbProcess));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetProcessList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Processes;
return processes;
}
//-------------------------------------------------------------------
@@ -67,7 +67,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetLocation\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return location;
@@ -448,7 +448,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Location list.
public override List<SbmLocation> GetLocationList(SbmLocation.Params prm)
{
List<SbmLocation> Locationes = new List<SbmLocation>();
ClearErrorState();
List<SbmLocation> Locations = new List<SbmLocation>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location), aliasLocation);
Location_Db dbLocation = new Location_Db(DbInfo);
@@ -469,16 +470,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbLocation = new Location_Db(DbInfo);
dbLocation.PopulateFrom(dbDataReader);
Locationes.Add(CreateLocation(dbLocation));
Locations.Add(CreateLocation(dbLocation));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetLocationList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Locationes;
return Locations;
}
//-------------------------------------------------------------------
@@ -186,7 +186,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetMovement\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return movement;
@@ -832,7 +832,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Movement list.
public override List<SbmMovement> GetMovementList(SbmMovement.Params prm)
{
List<SbmMovement> Movementes = new List<SbmMovement>();
ClearErrorState();
List<SbmMovement> movements = new List<SbmMovement>();
DbQuery DbQuery = new DbQuery(db.DbmsType);
DbQuery.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasMovement);
Movement_Db dbMovement = new Movement_Db(DbInfo);
@@ -853,16 +854,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbMovement = new Movement_Db(DbInfo);
dbMovement.PopulateFrom(dbDataReader);
Movementes.Add(CreateMovement(dbMovement));
movements.Add(CreateMovement(dbMovement));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetMovementList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Movementes;
return movements;
}
//-------------------------------------------------------------------
@@ -331,7 +331,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetConstituent\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmituent;
@@ -929,7 +929,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Constituent list.
public override List<SbmConstituent> GetConstituentList(SbmConstituent.Params prm)
{
List<SbmConstituent> Constituentes = new List<SbmConstituent>();
ClearErrorState();
List<SbmConstituent> constituents = new List<SbmConstituent>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), aliasConstituent);
Constituent_Db dbConstituent = new Constituent_Db(DbInfo);
@@ -950,16 +951,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbConstituent = new Constituent_Db(DbInfo);
dbConstituent.PopulateFrom(dbDataReader);
Constituentes.Add(CreateConstituent(dbConstituent));
constituents.Add(CreateConstituent(dbConstituent));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetConstituentList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Constituentes;
return constituents;
}
//-------------------------------------------------------------------
@@ -396,7 +396,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
catch (Exception exc)
{
SetErrorState("Database query exception");
SaLogger.Warn(GetType().Name + ".GetRequirement\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmRequirement;
@@ -2149,7 +2149,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Requirement list.
public override List<SbmRequirement> GetRequirementList(SbmRequirement.Params prm)
{
List<SbmRequirement> Requirementes = new List<SbmRequirement>();
ClearErrorState();
List<SbmRequirement> requirements = new List<SbmRequirement>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasRequirement);
Requirement_Db dbRequirement = new Requirement_Db(DbInfo);
@@ -2170,16 +2171,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbRequirement = new Requirement_Db(DbInfo);
dbRequirement.PopulateFrom(dbDataReader);
Requirementes.Add(CreateRequirement(dbRequirement));
requirements.Add(CreateRequirement(dbRequirement));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetRequirementList\n\tQuery: " + dbCommand.CommandText + "\n\tException: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Requirementes;
return requirements;
}
public override List<SbmRequirement> GetRequirementsForTransaction(SysId transactionId)
{
@@ -419,8 +419,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
}
catch (Exception exc)
{
SetErrorState("Database query errorState");
SaLogger.Warn(GetType().Name + ".GetTransaction\n\tQuery: " + dbCommand.CommandText + "\n\tErrorState: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return prmTransaction;
@@ -1656,9 +1656,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
if (prm.TransactionType == Sbm.TransactionType.Project)
earliestTransaction = new DateTime(today.Year - 3, 1, 1);
filter.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Raised, tableAlias) + ">=" + DbQuery.FormatDateForCondition(earliestTransaction));
if (DebugMode) SaLogger.Trace(GetType().Name + ".GetTransactionQueryFilter Including 'Archive' filter: " + filter.Concat(" AND ", "(", ")") + "");
if (DebugMode) SaLogger.Trace($"{SysUtil.Fn} Including 'Archive' filter: {filter.Concat(" AND ", "(", ")")}");
}
//else if (DebugMode) SaLogger.Trace(GetType().Name + ".GetTransactionQueryFilter Excluding 'Archive' filter: " + filter.Concat(" AND ", "(", ")") + "");
//else if (DebugMode) SaLogger.Trace($"{SysUtil.Fn} Excluding 'Archive' filter: {filter.Concat(" AND ", "(", ")")}");
//---------------------------------------------------------------
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
@@ -1718,7 +1718,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
// Item list.
public override List<SbmTransaction> GetTransactionList(SbmTransaction.Params prm)
{
List<SbmTransaction> Transactiones = new List<SbmTransaction>();
ClearErrorState();
List<SbmTransaction> transactions = new List<SbmTransaction>();
DbQuery qry = new DbQuery(db.DbmsType);
qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasTransaction);
Transaction_Db dbTransaction = new Transaction_Db(DbInfo);
@@ -1739,16 +1740,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
dbTransaction = new Transaction_Db(DbInfo);
dbTransaction.PopulateFrom(dbDataReader);
Transactiones.Add(CreateTransaction(dbTransaction));
transactions.Add(CreateTransaction(dbTransaction));
}
}
}
catch (Exception exc)
{
SaLogger.Warn(GetType().Name + ".GetTransactionList\n\tQuery: " + dbCommand.CommandText + "\n\tErrorState: " + exc.Message);
SetErrorState("Database query exception");
SaLogger.Warn($"{SysUtil.Fn}\n\tQuery: {dbCommand.CommandText}\n\t{ExceptionUtil.GetErrorStateMessage(exc)}");
}
}
return Transactiones;
return transactions;
}
//-------------------------------------------------------------------
@@ -2148,7 +2150,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
if (maxTransactions > 0)
{
query.RowLimit = (uint)maxTransactions;
if (DebugMode) SaLogger.Trace(GetType().Name + ".ExecuteTransactionQuery Transactions query throttled at max rows: " + maxTransactions.ToString());
if (DebugMode) SaLogger.Trace($"{SysUtil.Fn}Transactions query throttled at max rows: {maxTransactions.ToString()}");
}
}
@@ -14,7 +14,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Utils
{
//-------------------------------------------------------------------
// Data members.
//private static string messageBoxTitle = "BusinessMgr database definition generator";
private static String className = nameof(SbmDbDfnGenerator);
public enum DatabaseInstance
{
Control,
@@ -27,8 +27,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Utils
/// </summary>
public static bool Generate(DatabaseInstance dbInstance, String connectionString)
{
String fn = nameof(SbmDbDfnGenerator) + ".Generate";
SaLogger.Info(fn + " Connection: " + connectionString);
String fn = className + ".Generate";
SaLogger.Info($"{fn} Connection: {connectionString}");
// Locate output folder:
String directory = GetOutputFolder(dbInstance);
@@ -47,7 +47,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Utils
}
catch (Exception exc)
{
SaLogger.Error(fn + " " + ExceptionUtil.GetErrorStateMessage(exc));
SaLogger.Error($"{fn} {ExceptionUtil.GetLogMessage(exc, "generating database definition")}");
}
return false;
}
@@ -98,31 +98,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Utils
//-------------------------------------------------------------------
private static String GetOutputFolder(DatabaseInstance dbInstance)
{
String fn = nameof(SbmDbDfnGenerator) + ".GetOutputFolder";
String fn = className + ".GetOutputFolder";
String assemblyDirectory = FileUtil.GetParentDirectory((Assembly.GetAssembly(typeof(DatabaseDefinitionGenerator)).Location));
String directory = assemblyDirectory;
SaLogger.Debug(fn + " Assembly folder: " + directory);
SaLogger.Debug($"{fn} Assembly folder: {directory}");
// Locate the parent of the 'Workspace' solution root folder.
String projectFolder = "Workspace";
while (!String.IsNullOrEmpty(directory))
{
if (FileUtil.IsDirectory(directory + Path.DirectorySeparatorChar + projectFolder))
{
if (FileUtil.IsDirectory(Path.Combine(directory, projectFolder)))
break;
}
directory = FileUtil.GetParentDirectory(directory);
}
if (String.IsNullOrEmpty(directory))
{
SaLogger.Error(fn + " Failed to find '" + projectFolder + "' solution root folder in assembly path:\n\t" + assemblyDirectory);
SaLogger.Error($"{fn} Failed to find '{projectFolder}' solution root folder in assembly path: {assemblyDirectory}");
return String.Empty;
}
// Code files are generated to '..\Dbas\Generated\BusinessMgr\' folder.
directory += Path.DirectorySeparatorChar + "Database" + Path.DirectorySeparatorChar + "Generated" + Path.DirectorySeparatorChar + "BusMgr-" + dbInstance.ToString();
SaLogger.Debug(fn + " Output folder: " + directory);
// Code files are generated to '..\Database\Generated\BusMgr-[instance]\' folder.
directory = Path.Combine(directory, "Database", "Generated", "BusMgr-" + dbInstance.ToString());
SaLogger.Debug($"{fn} Output folder: {directory}");
if (!FileUtil.ValidateDirectory(directory, true))
{
SaLogger.Error(fn + " Output folder not found:\n\n" + directory);
SaLogger.Error($"{fn} Output folder not found: {directory}");
return String.Empty;
}
return directory;
@@ -7,7 +7,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Utils
{
//=======================================================================
/// <summary>
/// Static implementations of fucntions required by FileUtil.
/// Static implementations of functions required by FileUtil.
/// </summary>
public class SbmFileUtil
{