Skip to content

Commit

Permalink
345:DBTool.CreateTable或DBTool.DropTable后的缓存处理(2016-08-27)。
Browse files Browse the repository at this point in the history
346:MAction、MProc取消SetAopOn和SetAopOff方法,统一为:SetAopState方法(简化方法,同时能处理更多的状态)(2016-08-27)
347:MDataTable的Select方法增强(对浮点数的比较)(2016-08-27)
  • Loading branch information
cyq1162 committed Aug 26, 2016
1 parent e57e14a commit 0fd7db8
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 145 deletions.
17 changes: 9 additions & 8 deletions Action/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,13 @@ public static string SchemaMapPath
}
/// <summary>
/// 删除字段名称(若表存在此设置的字段名称时,MActon的删除操作将变更变为更新操作)
/// 默认:IsDeleted
/// </summary>
public static string DeleteField
{
get
{
return GetApp("DeleteField", string.Empty);
return GetApp("DeleteField", "IsDeleted");
}
set
{
Expand Down Expand Up @@ -502,16 +503,16 @@ public static string HiddenFields
{
get
{
string result = GetApp("HiddenFields", string.Empty);
if (result == string.Empty)
{
result = "cyqrownum,rowguid," + DeleteField;
}
string result = GetApp("HiddenFields", "cyqrownum,rowguid");
//if (result == string.Empty)
//{
// result = "cyqrownum,rowguid," + DeleteField;
//}
return result;
}
set
{
if (!value.Contains("cyqrownum,rowguid,"))
if (!value.Contains("cyqrownum,rowguid"))
{
value = "cyqrownum,rowguid," + value;
}
Expand Down Expand Up @@ -628,7 +629,7 @@ public static string NoCacheTables
{
get
{
return GetApp("NoCacheTables","");
return GetApp("NoCacheTables", "");
}
set
{
Expand Down
68 changes: 18 additions & 50 deletions Action/MAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public bool Insert(bool autoSetValue, InsertOp option)
_UI.GetAll(!AllowInsertID);//允许插入ID时,也需要获取主键。
}
AopResult aopResult = AopResult.Default;
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MAction = this;
_aop.Para.TableName = _sourceTableName;
Expand Down Expand Up @@ -634,7 +634,7 @@ public bool Insert(bool autoSetValue, InsertOp option)
_Data = _aop.Para.Row;
InitGlobalObject(false);
}
if (_aop.IsCustomAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
if (_aop.IsLoadAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
{
_aop.End(Aop.AopEnum.Insert);
}
Expand Down Expand Up @@ -710,7 +710,7 @@ public bool Update(object where, bool autoSetValue)
where = _sqlCreate.GetPrimaryWhere();
}
AopResult aopResult = AopResult.Default;
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MAction = this;
_aop.Para.TableName = _sourceTableName;
Expand All @@ -737,7 +737,7 @@ public bool Update(object where, bool autoSetValue)
break;
}
}
if (_aop.IsCustomAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
if (_aop.IsLoadAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
{
_aop.End(Aop.AopEnum.Update);
}
Expand Down Expand Up @@ -769,7 +769,7 @@ public bool Delete(object where)
where = _sqlCreate.GetPrimaryWhere();
}
AopResult aopResult = AopResult.Default;
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MAction = this;
_aop.Para.TableName = _sourceTableName;
Expand Down Expand Up @@ -805,7 +805,7 @@ public bool Delete(object where)
break;
}
}
if (_aop.IsCustomAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
if (_aop.IsLoadAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
{
_aop.End(Aop.AopEnum.Delete);
}
Expand Down Expand Up @@ -861,7 +861,7 @@ public MDataTable Select(int pageIndex, int pageSize, object where, out int rowC
CheckDisposed();
rowCount = 0;
AopResult aopResult = AopResult.Default;
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MAction = this;
_aop.Para.PageIndex = pageIndex;
Expand Down Expand Up @@ -957,7 +957,7 @@ public MDataTable Select(int pageIndex, int pageSize, object where, out int rowC
{
rowCount = _aop.Para.Table.RecordsAffected;//返回记录总数
}
if (_aop.IsCustomAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
if (_aop.IsLoadAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
{
_aop.End(Aop.AopEnum.Select);
}
Expand Down Expand Up @@ -1010,7 +1010,7 @@ public bool Fill(object where)
where = _sqlCreate.GetPrimaryWhere();
}
AopResult aopResult = AopResult.Default;
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MAction = this;
_aop.Para.TableName = _sourceTableName;
Expand Down Expand Up @@ -1050,7 +1050,7 @@ public bool Fill(object where)
_Data.LoadFrom(_aop.Para.Row, RowOp.None, true);
}

if (_aop.IsCustomAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
if (_aop.IsLoadAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
{
_aop.Para.Row = _Data;
_aop.End(Aop.AopEnum.Fill);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ public int GetCount(object where)
{
CheckDisposed();
AopResult aopResult = AopResult.Default;
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MAction = this;
_aop.Para.TableName = _sourceTableName;
Expand Down Expand Up @@ -1141,7 +1141,7 @@ public int GetCount(object where)
break;
}
}
if (_aop.IsCustomAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
if (_aop.IsLoadAop && (aopResult == AopResult.Break || aopResult == AopResult.Continue))
{
_aop.End(Aop.AopEnum.GetCount);
}
Expand Down Expand Up @@ -1249,7 +1249,7 @@ public MAction SetPara(object paraName, object value, DbType dbType)
para.Value = value;
para.ParaDbType = dbType;
customParaNames.Add(para);
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.CustomDbPara = customParaNames;
}
Expand Down Expand Up @@ -1485,49 +1485,17 @@ public partial class MAction
{
#region Aop操作
private InterAop _aop = new InterAop();
//private IAop _aop = Aop.InterAop.Instance;//切入点
//private AopInfo _aopInfo = new AopInfo();
/// <summary>
/// 临时备份Aop,用于切换后的还原。
/// 设置Aop状态
/// </summary>
// Aop.IAop _aopBak = null;
/// <summary>
/// 取消Aop,在Aop独立模块使用MAction时必须调用
/// </summary>
public MAction SetAopOff()
{
_aop.IsCustomAop = false;
//if (_aop.IsCustomAop)
//{
// _aopBak = _aop;//设置好备份。
// _aop = Aop.InterAop.Instance;
// _aop.IsCustomAop = false;
//}
return this;
}
/// <summary>
/// 恢复默认配置的Aop。
/// </summary>
public MAction SetAopOn()
/// <param name="op">Aop状态选项</param>
/// <returns></returns>
public MProc SetAopState(AopOp op)
{
_aop.IsCustomAop = true;
//if (!_aop.IsCustomAop)
//{
// SetAop(_aopBak);
//}
_aop.aopOp = op;
return this;
}
/// <summary>
/// 主动设置注入新的Aop,一般情况下不需要用到。
/// </summary>
/// <param name="aop"></param>
//private MAction SetAop(Aop.IAop aop)
//{
// _aop = aop;
// _aop.IsCustomAop = true;
// return this;
//}
/// <summary>
/// 需要传递额外的参数供Aop使用时可设置。
/// </summary>
/// <param name="para"></param>
Expand Down
55 changes: 21 additions & 34 deletions Action/MProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void ResetProc(object procNameOrSql)
}
private AopResult SetAopResult(AopEnum action)
{
if (_aop.IsCustomAop)
if (_aop.IsLoadAop)
{
_aop.Para.MProc = this;
_aop.Para.ProcName = _procName;
Expand Down Expand Up @@ -553,43 +553,29 @@ public object OutPutValue

#region Aop 相关操作
/// <summary>
/// 临时备份Aop,用于切换后的还原。
/// 设置Aop状态
/// </summary>
// Aop.IAop _aopBak = null;

/// <summary>
/// 取消AOP
/// </summary>
public MProc SetAopOff()
{
_aop.IsCustomAop = false;
//if (_aopInfo.IsCustomAop)
//{
// _aopBak = _aop;//设置好备份。
// _aop = Aop.InterAop.Instance;
// _aopInfo.IsCustomAop = false;
//}
return this;
}
/// <summary>
/// 恢复默认配置的Aop。
/// </summary>
public MProc SetAopOn()
/// <param name="op">Aop状态选项</param>
/// <returns></returns>
public MProc SetAopState(AopOp op)
{
_aop.IsCustomAop = true;
//if (!_aopInfo.IsCustomAop)
//{
// SetAop(_aopBak);
//}
_aop.aopOp = op;
return this;
}
/// <summary>
/// 设置Aop对象。
/// </summary>
//private MProc SetAop(Aop.IAop aop)
///// <summary>
///// 取消AOP
///// </summary>
//public MProc SetAopOff()
//{
// _aop = aop;
// _aopInfo.IsCustomAop = true;
// _aop.IsCustomAop = false;
// return this;
//}
///// <summary>
///// 恢复默认配置的Aop。
///// </summary>
//public MProc SetAopOn()
//{
// _aop.IsCustomAop = true;
// return this;
//}
/// <summary>
Expand All @@ -598,7 +584,8 @@ public MProc SetAopOn()
/// <param name="para"></param>
public MProc SetAopPara(object para)
{
_aop.Para.AopPara = para; return this;
_aop.Para.AopPara = para;
return this;
}

void helper_OnExceptionEvent(string errorMsg)
Expand Down
23 changes: 23 additions & 0 deletions Aop/AopEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,27 @@ public enum AopResult
/// </summary>
Return,
}

/// <summary>
/// Aop开关选项
/// </summary>
public enum AopOp
{
/// <summary>
/// 正常打开
/// </summary>
OpenAll,
/// <summary>
/// 仅打开内部Aop(即自动缓存,关闭外部Aop)
/// </summary>
OnlyInner,
/// <summary>
/// 仅打开外部Aop(关闭自动缓存)
/// </summary>
OnlyOuter,
/// <summary>
/// 内外都关(自动缓存和外部Aop)
/// </summary>
CloseAll
}
}
Loading

0 comments on commit 0fd7db8

Please sign in to comment.