|
@@ -19,7 +19,7 @@ namespace InABox.Database
|
|
|
// void UpdateCache();
|
|
|
// }
|
|
|
|
|
|
- public class Store<T> : IStore, IStore<T> where T : Entity, new()
|
|
|
+ public class Store<T> : IStore<T> where T : Entity, new()
|
|
|
{
|
|
|
public bool IsSubStore { get; set; }
|
|
|
|
|
@@ -219,19 +219,6 @@ namespace InABox.Database
|
|
|
return table;
|
|
|
}
|
|
|
|
|
|
- //#region Session / Transaction Handling
|
|
|
- //void //OpenSession(String action, bool write)
|
|
|
- //{
|
|
|
- // if (!IsSubStore)
|
|
|
- // Provider.OpenSession<T>(action, write);
|
|
|
- //}
|
|
|
- //void //CloseSession(String action, bool write)
|
|
|
- //{
|
|
|
- // if (!IsSubStore)
|
|
|
- // Provider.CloseSession<T>(action, write);
|
|
|
- //}
|
|
|
- //#endregion
|
|
|
-
|
|
|
#region Query Functions
|
|
|
|
|
|
protected virtual CoreTable OnQuery(Filter<T>? filter, Columns<T>? columns, SortOrder<T>? sort)
|
|
@@ -243,10 +230,6 @@ namespace InABox.Database
|
|
|
{
|
|
|
UpdateUserTracking(UserTrackingAction.Read);
|
|
|
|
|
|
- //last = DateTime.Now;
|
|
|
- //OpenSession("Query", false);
|
|
|
- //LogStep("OpenSession");
|
|
|
-
|
|
|
try
|
|
|
{
|
|
|
var flt = PrepareFilter(filter);
|
|
@@ -255,19 +238,14 @@ namespace InABox.Database
|
|
|
|
|
|
var result = OnQuery(filter, columns, sort);
|
|
|
|
|
|
- //LogStep("PopulateTable");
|
|
|
AfterQuery(result);
|
|
|
|
|
|
result = RunScript(ScriptType.AfterQuery, result);
|
|
|
|
|
|
- //CloseSession("Query", false);
|
|
|
- //LogStep("CloseSession");
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- //CloseSession("Query", false);
|
|
|
throw new Exception(e.Message + "\n\n" + e.StackTrace + "\n");
|
|
|
}
|
|
|
}
|
|
@@ -304,8 +282,6 @@ namespace InABox.Database
|
|
|
|
|
|
#region Saving Functions
|
|
|
|
|
|
- private static readonly Regex IsNumeric = new(@"^\d+$");
|
|
|
-
|
|
|
private void CheckAutoIncrement(params T[] entities)
|
|
|
{
|
|
|
if (ProcessNumericAutoInc(entities))
|
|
@@ -313,8 +289,6 @@ namespace InABox.Database
|
|
|
ProcessStringAutoIncrement(entities);
|
|
|
}
|
|
|
|
|
|
- //public static string AutoIncrementPrefix { get; set; }
|
|
|
-
|
|
|
private bool ProcessStringAutoIncrement(params T[] entities)
|
|
|
{
|
|
|
if (!entities.Any())
|
|
@@ -649,12 +623,10 @@ namespace InABox.Database
|
|
|
|
|
|
entity = RunScript(ScriptType.BeforeDelete, new[] { entity }).First();
|
|
|
|
|
|
- //OpenSession("Delete",false);
|
|
|
try
|
|
|
{
|
|
|
BeforeDelete(entity);
|
|
|
|
|
|
- //OpenSession("Delete",true);
|
|
|
try
|
|
|
{
|
|
|
OnDelete(entity);
|
|
@@ -662,22 +634,14 @@ namespace InABox.Database
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
Logger.Send(LogType.Error, "", $"Error in DoDelete(T entity, string auditnote):\n{CoreUtils.FormatException(e)}");
|
|
|
- //CloseSession("Delete", true);
|
|
|
- //throw e;
|
|
|
}
|
|
|
- //CloseSession("Delete",true);
|
|
|
|
|
|
AfterDelete(entity);
|
|
|
|
|
|
- //UpdateExternalLinks(entity, true);
|
|
|
-
|
|
|
- //CloseSession("Delete", false);
|
|
|
-
|
|
|
entity = RunScript(ScriptType.AfterDelete, new[] { entity }).First();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- //CloseSession("Delete", false);
|
|
|
throw new Exception(e.Message + "\n\n" + e.StackTrace + "\n");
|
|
|
}
|
|
|
}
|
|
@@ -688,13 +652,11 @@ namespace InABox.Database
|
|
|
|
|
|
entities = RunScript(ScriptType.BeforeDelete, entities);
|
|
|
|
|
|
- //OpenSession("Delete", false);
|
|
|
try
|
|
|
{
|
|
|
foreach (var entity in entities)
|
|
|
BeforeDelete(entity);
|
|
|
|
|
|
- //OpenSession("Delete", true);
|
|
|
try
|
|
|
{
|
|
|
OnDelete(entities);
|
|
@@ -702,20 +664,14 @@ namespace InABox.Database
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
Logger.Send(LogType.Error, "", $"Error in DoDelete(IEnumerable<T> entities, string auditnote):\n{CoreUtils.FormatException(e)}");
|
|
|
- ////CloseSession("Delete", true);
|
|
|
}
|
|
|
|
|
|
- ////CloseSession("Delete", true);
|
|
|
-
|
|
|
foreach (var entity in entities) AfterDelete(entity);
|
|
|
- //UpdateExternalLinks(entity, true);
|
|
|
- ////CloseSession("Delete", false);
|
|
|
|
|
|
entities = RunScript(ScriptType.AfterDelete, entities);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- ////CloseSession("Delete", false);
|
|
|
throw new Exception(e.Message + "\n\n" + e.StackTrace + "\n");
|
|
|
}
|
|
|
}
|
|
@@ -748,20 +704,5 @@ namespace InABox.Database
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
-
|
|
|
- #region BulkUpdate Functions
|
|
|
-
|
|
|
- public void BulkUpdate(IEnumerable<Entity> entities)
|
|
|
- {
|
|
|
- BulkUpdate((IEnumerable<T>)entities);
|
|
|
- }
|
|
|
-
|
|
|
- public virtual void BulkUpdate(IEnumerable<T> entities)
|
|
|
- {
|
|
|
- UpdateUserTracking(UserTrackingAction.Write);
|
|
|
- Provider.Save(entities);
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
}
|
|
|
}
|