Add project files.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmUpdateLogItemMonitor : SaUpdateLogItemMonitor
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public new class Config : SaUpdateLogItemMonitor.Config
|
||||
{
|
||||
public Config(SbmUserContext userContext) :
|
||||
base(SbmGlobals.Application.GetUpdateLogConsole(userContext), userContext.DbUpdateInfo)
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
public SbmUserContext UserContext { get; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Config config;
|
||||
private SbmConfigConsole configConsole = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmUpdateLogItemMonitor(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SbmUserContext UserContext { get { return config.UserContext; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Internal utilities.
|
||||
protected virtual bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx columnIdx)
|
||||
{
|
||||
if (!config.UpdateLogConsole.CanUpdateDatabase) return false;
|
||||
if (configConsole == null)
|
||||
configConsole = SbmGlobals.Application.GetConfigConsole(config.UserContext.SessionContext);
|
||||
if (!configConsole.IsColumnChangeLogged(UserContext, columnIdx)) return false;
|
||||
return true;
|
||||
}
|
||||
protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, String value, bool newValue)
|
||||
{
|
||||
return RecordAttrValue(columnIdx, new DataValue(value), newValue);
|
||||
}
|
||||
protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, int value, bool newValue, bool blankZeroValue = true)
|
||||
{
|
||||
return RecordAttrValue(columnIdx, new DataValue(value == 0 && blankZeroValue ? "" : value.ToString()), newValue);
|
||||
}
|
||||
protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, decimal value, bool newValue, bool blankZeroValue = true, ushort decimals = 2)
|
||||
{
|
||||
return RecordAttrValue(columnIdx, new DataValue(value == 0.0m && blankZeroValue ? "" : value.ToString("N" + decimals.ToString())), newValue);
|
||||
}
|
||||
protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, DateTime value, bool newValue, bool includeTime = true)
|
||||
{
|
||||
return RecordAttrValue(columnIdx, new DataValue(DateUtil.Format(value, (includeTime ? "d-MMM-yyyy HH:mm" : "d-MMM-yyyy"))), newValue);
|
||||
}
|
||||
protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, DataValue value, bool newValue)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!IsColumnChangeLogged(columnIdx)) return true;
|
||||
String attrName = SbmDbDfn.GetColumnName(columnIdx, false);
|
||||
if (attrName.IsEmpty()) return SetErrorState("Blank attribute name [" + columnIdx.ToString() + "]");
|
||||
return RecordAttrValue(attrName, value, newValue);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user