public AopResult Begin(AopEnum action) { AopResult ar = AopResult.Continue; if (outerAop != null && (aopOp == AopOp.OpenAll || aopOp == AopOp.OnlyOuter)) { ar = outerAop.Begin(action, Para); if (ar == AopResult.Return) { return(ar); } } if (aopOp == AopOp.OpenAll || aopOp == AopOp.OnlyInner) { if (AppConfig.Cache.IsAutoCache && !IsTxtDataBase) // 只要不是直接返回 { isHasCache = AutoCache.GetCache(action, Para); //找看有没有Cache } if (isHasCache) //找到Cache { if (outerAop == null || ar == AopResult.Default) //不执行End { return(AopResult.Return); } return(AopResult.Break);//外部Aop说:还需要执行End } } return(ar);// 没有Cache,默认返回 }
public AopResult Begin(AopEnum action, AopInfo aopInfo) { Console.WriteLine("开始方法:我已经拦截到用了方法"); AopResult ar = AopResult.Continue; return(ar); }
/// <summary> /// Returns the number of rows affected [used to insert update or delete], and returns -2 if an exception is executed /// <para>返回受影响的行数[用于更新或删除],执行异常时返回-2</para> /// </summary> public int ExeNonQuery() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeNonQuery); if (aopResult == AopResult.Return) { return(_aop.Para.RowCount); } else { if (aopResult != AopResult.Break) { switch (dalHelper.dalType) { case DalType.Txt: case DalType.Xml: _aop.Para.RowCount = _noSqlCommand.ExeNonQuery(); break; default: _aop.Para.RowCount = dalHelper.ExeNonQuery(_procName, _isProc); break; } _aop.Para.IsSuccess = _aop.Para.RowCount > 0; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeNonQuery); } return(_aop.Para.RowCount); } }
/// <summary> /// Get MDataTable /// </summary> public MDataTable ExeMDataTable() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeMDataTable); if (aopResult == AopResult.Return) { return(_aop.Para.Table); } else { if (aopResult != AopResult.Break) { _aop.Para.Table = dalHelper.ExeDataReader(_procName, _isProc); _aop.Para.Table.Columns.DataBaseType = DataBaseType; _aop.Para.Table.Conn = dalHelper.ConnName; _aop.Para.IsSuccess = _aop.Para.Table.Rows.Count > 0; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeMDataTable); } return(_aop.Para.Table); } }
/// <summary> /// Get List T 预先实现,后续再考虑是否开放。 /// </summary> internal List <T> ExeList <T>() where T : class { CheckDisposed(); List <T> list; AopResult aopResult = SetAopResult(AopEnum.ExeList); if (aopResult == AopResult.Return) { if (_aop.Para.ExeResult is String) { string result = _aop.Para.ExeResult as String; return(JsonHelper.ToList <T>(result)); } return(_aop.Para.ExeResult as List <T>); } else { if (aopResult != AopResult.Break) { list = ConvertTool.ChangeReaderToList <T>(dalHelper.ExeDataReader(_procName, _isProc)); _aop.Para.ExeResult = list; _aop.Para.IsSuccess = list.Count > 0; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeList); } return(_aop.Para.ExeResult as List <T>); } }
/// <summary> /// 返回MDataTable /// </summary> /// <returns></returns> public MDataTable ExeMDataTable() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeMDataTable); if (aopResult == AopResult.Return) { return(_aop.Para.Table); } else { if (aopResult != AopResult.Break) { switch (dalHelper.dalType) { case DalType.Txt: case DalType.Xml: _aop.Para.Table = _noSqlCommand.ExeMDataTable(); break; default: _aop.Para.Table = dalHelper.ExeDataReader(_procName, _isProc); _aop.Para.Table.Columns.dalType = DalType; // dalHelper.ResetConn();//重置Slave break; } _aop.Para.Table.Conn = _conn; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeMDataTable); } return(_aop.Para.Table); } }
/// <summary> /// Get MDataTables /// </summary> public List <MDataTable> ExeMDataTableList() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeMDataTableList); if (aopResult == AopResult.Return) { return(_aop.Para.TableList); } else { if (aopResult != AopResult.Break) { List <MDataTable> dtList = new List <MDataTable>(); switch (dalHelper.DataBaseType) { case DataBaseType.Txt: case DataBaseType.Xml: case DataBaseType.Oracle: if (_isProc && dalHelper.DataBaseType == DataBaseType.Oracle) { goto isProc; } foreach (string sql in _procName.TrimEnd(';').Split(';')) { MDataTable dt = dalHelper.ExeDataReader(sql, false); if (dt != null) { dtList.Add(dt); } } break; default: isProc: DbDataReader reader = dalHelper.ExeDataReader(_procName, _isProc); if (reader != null) { do { dtList.Add(MDataTable.CreateFrom(reader)); }while (reader.NextResult()); reader.Close(); reader.Dispose(); reader = null; } break; } _aop.Para.TableList = dtList; _aop.Para.IsSuccess = dtList.Count > 0; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeMDataTableList); } return(_aop.Para.TableList); } }
/// <summary> /// Returns the value of the first column of the first row /// <para>返回首行首列的值</para> /// </summary> public T ExeScalar <T>() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeScalar); if (aopResult == AopResult.Default || aopResult == AopResult.Continue) { switch (dalHelper.dalType) { case DalType.Txt: case DalType.Xml: _aop.Para.ExeResult = _noSqlCommand.ExeScalar(); break; default: _aop.Para.ExeResult = dalHelper.ExeScalar(_procName, _isProc); break; } _aop.Para.IsSuccess = _aop.Para.ExeResult != null; } if (aopResult == AopResult.Continue || aopResult == AopResult.Break) { _aop.End(AopEnum.ExeScalar); } if (_aop.Para.ExeResult == null || _aop.Para.ExeResult == DBNull.Value) { return(default(T)); } Type t = typeof(T); object value = _aop.Para.ExeResult; switch (t.Name) { case "Int32": int intValue = 0; if (!int.TryParse(Convert.ToString(value), out intValue)) { return(default(T)); } value = intValue; break; default: try { value = StaticTool.ChangeType(value, t); } catch { } break; } return((T)value); }
public ActionResult SaveApp(string appno, string appevent, string description, bool enabled) { ServerManager.ServerHelper.GetSubImp.InsertOrUpdateApp(new App { AppNo = appno, AppEvent = appevent, Description = description, Enabled = enabled }); return(this.Json(AopResult.Success(0))); }
public ActionResult SaveSubMsg(string appno, string pubappno, string pubappevent, string receivetype, string receivecontent, bool enabled) { ServerManager.ServerHelper.GetSubImp.AddSubMsg(new SubMsg { AppNo = appno, PubAppNo = pubappno, PubAppEvent = pubappevent, ReceiveType = receivetype, ReceiveContent = receivecontent, Enabled = enabled }); return(this.Json(AopResult.Success(0))); }
/// <summary> /// 执行的语句有多个结果集返回(库此方法不支持文本数据和AOP) /// </summary> /// <returns></returns> public List <MDataTable> ExeMDataTableList() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeMDataTableList); if (aopResult == AopResult.Return) { return(_aop.Para.TableList); } else { if (aopResult != AopResult.Break) { List <MDataTable> dtList = new List <MDataTable>(); switch (dalHelper.dalType) { case DalType.Txt: case DalType.Xml: foreach (string sql in _procName.Split(';')) { _noSqlCommand.CommandText = sql; dtList.Add(_noSqlCommand.ExeMDataTable()); } break; default: DbDataReader reader = dalHelper.ExeDataReader(_procName, _isProc); if (reader != null) { do { dtList.Add(MDataTable.CreateFrom(reader)); }while (reader.NextResult()); reader.Close(); reader.Dispose(); reader = null; } break; } _aop.Para.TableList = dtList; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeMDataTableList); } return(_aop.Para.TableList); } }
public AopResult <PublishMsgResponse> Post(PublishMsgRequest request) { // 发布消息,需注册应用和事件 if (!base.ValidateApp(request.AppNo, request.AppEvent)) { return(AopResult.Fail <PublishMsgResponse>("非法调用!")); } var msgNo = NumHelper.GetRandomNo(); var msg = new MsgContent { MsgNo = msgNo, AppNo = request.AppNo, AppEvent = request.AppEvent, Content = request.Content }; // 记录消息日志 ServerHelper.GetLogImp.AddLog(msg); // 推送消息到队列 var queueId = ServerHelper.GetQueueImp.PushMsg(msg); return(AopResult.Success(new PublishMsgResponse { QueueId = queueId.ToString(), MsgNo = msgNo })); }
/// <summary> /// Returns the number of rows affected [used to insert update or delete], and returns -2 if an exception is executed /// <para>返回受影响的行数[用于更新或删除],执行异常时返回-2</para> /// </summary> public int ExeNonQuery() { CheckDisposed(); AopResult aopResult = SetAopResult(AopEnum.ExeNonQuery); if (aopResult == AopResult.Return) { return(_aop.Para.RowCount); } else { if (aopResult != AopResult.Break) { _aop.Para.RowCount = dalHelper.ExeNonQuery(_procName, _isProc); _aop.Para.IsSuccess = _aop.Para.RowCount > 0; } if (aopResult != AopResult.Default) { _aop.End(AopEnum.ExeNonQuery); } return(_aop.Para.RowCount); } }
public ActionResult GetApps() { var apps = ServerManager.ServerHelper.GetSubImp.GetApps(); return(this.Json(AopResult.Success(apps))); }
public ActionResult GetSubMsgs() { var msgs = ServerManager.ServerHelper.GetSubImp.GetSubMsgs(); return(this.Json(AopResult.Success(msgs))); }