Skip to content

Commit

Permalink
关闭文本数据库的自动缓存。
Browse files Browse the repository at this point in the history
  • Loading branch information
cyq1162 committed May 10, 2019
1 parent e80f571 commit d3c5131
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Aop/InterAop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public AopResult Begin(AopEnum action)
}
if (aopOp == AopOp.OpenAll || aopOp == AopOp.OnlyInner)
{
//if (AppConfig.Cache.IsAutoCache && !IsTxtDataBase) // 只要不是直接返回,------调整机制,由Aop参数控制。
//{
isHasCache = AutoCache.GetCache(action, Para); //找看有没有Cache
// }
if (!IsTxtDataBase) // 只要不是直接返回,------调整机制,由Aop参数控制。
{
isHasCache = AutoCache.GetCache(action, Para); //找看有没有Cache
}
if (isHasCache) //找到Cache
{

Expand Down
30 changes: 20 additions & 10 deletions DAL/NoSql/NoSqlAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ private MDataTable Table
Error.Throw("MDataTable can't load data from file : " + _FileFullName);
}

DateTime _lastWriteTimeUtc = new IOInfo(_FileFullName).LastWriteTimeUtc;
DateTime lastWriteTime = new IOInfo(_FileFullName).LastWriteTime;
if (!_lastWriteTimeList.ContainsKey(_FileFullName))
{
_lastWriteTimeList.Add(_FileFullName, _lastWriteTimeUtc);
_lastWriteTimeList.Add(_FileFullName, lastWriteTime);
}
if (_Table.Rows.Count > 0)
{
Expand Down Expand Up @@ -486,9 +486,11 @@ public void Dispose()
{
Save();//失败,则重新尝试写入!
}
else
{
needToSaveState = 0;
}
}
needToSaveState = 0;//重置为0
CheckFileChanged(false);//通过检测重置最后修改时间。
}
}
/// <summary>
Expand All @@ -497,13 +499,13 @@ public void Dispose()
/// <param name="isNeedToReloadTable"></param>
private void CheckFileChanged(bool isNeedToReloadTable)
{
if (isNeedToReloadTable && !_isDeleteAll.Contains(_FileFullName))
if (!_isDeleteAll.Contains(_FileFullName))
{
DateTime _lastWriteTimeUtc = _lastWriteTimeList[_FileFullName];
if (IOHelper.IsLastFileWriteTimeChanged(_FileFullName, ref _lastWriteTimeUtc))
DateTime lastWriteTime = _lastWriteTimeList[_FileFullName];
if (IOHelper.IsLastFileWriteTimeChanged(_FileFullName, ref lastWriteTime))
{
_lastWriteTimeList[_FileFullName] = _lastWriteTimeUtc;
if (_tableList.ContainsKey(_FileFullName))
_lastWriteTimeList[_FileFullName] = lastWriteTime;
if (isNeedToReloadTable && _tableList.ContainsKey(_FileFullName))
{
try
{
Expand All @@ -514,8 +516,9 @@ private void CheckFileChanged(bool isNeedToReloadTable)
{

}
_Table = null;//需要重新加载数据。
}
_Table = null;//需要重新加载数据。

}
}

Expand All @@ -538,6 +541,13 @@ private void Save()
{

IOHelper.Write(_FileFullName, text, _DalType == DataBaseType.Txt ? IOHelper.DefaultEncoding : Encoding.UTF8);
needToSaveState = 0;//重置为0
DateTime lastWriteTime = _lastWriteTimeList[_FileFullName];
if (IOHelper.IsLastFileWriteTimeChanged(_FileFullName, ref lastWriteTime))
{
//更新最后文件时间
_lastWriteTimeList[_FileFullName] = lastWriteTime;
}
tryAgainCount = 0;
if (_isDeleteAll.Contains(_FileFullName))
{
Expand Down
6 changes: 3 additions & 3 deletions Tool/IOHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ public static bool Delete(string fileName)
return false;
}

internal static bool IsLastFileWriteTimeChanged(string fileName, ref DateTime compareTimeUtc)
internal static bool IsLastFileWriteTimeChanged(string fileName, ref DateTime compareTime)
{
bool isChanged = false;
IOInfo info = new IOInfo(fileName);
if (info.Exists && info.LastWriteTimeUtc != compareTimeUtc)
if (info.Exists && info.LastWriteTime != compareTime)
{
isChanged = true;
compareTimeUtc = info.LastWriteTimeUtc;
compareTime = info.LastWriteTime;
}
return isChanged;
}
Expand Down
12 changes: 9 additions & 3 deletions Xml/XHtmlAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,18 @@ public void Set(XmlNode node, SetType setType, params string[] values)
}
else
{
string lowerValue = values[0].ToLower();
foreach (XmlNode option in node.ChildNodes)
{
if (option.Attributes["value"] != null && (option.Attributes["value"].Value == values[0] || option.Attributes["value"].Value.Split(',')[0] == values[0]))
if (option.Attributes["value"] != null)
{
SetAttrValue(option, "selected", "selected");
break;
string opValue = option.Attributes["value"].Value.Split(',')[0].ToLower();
if (opValue == lowerValue || opValue == (lowerValue == "true" ? "1" : (lowerValue == "false" ? "0" : lowerValue)))
{
SetAttrValue(option, "selected", "selected");
break;
}

}
}
}
Expand Down

0 comments on commit d3c5131

Please sign in to comment.