public SqlRequest(string query, ExecuteQueryAs queryAs, ExecuteMode queryMode, params MySqlParameter[] @params) { Query = query; QueryAs = queryAs; QueryMode = queryMode; Params = @params; }
public LedColorType GetLedStatus(LoopMachineMode recPlay, ExecuteMode executeMode) { switch (recPlay) { case LoopMachineMode.Reset: case LoopMachineMode.Record: switch (executeMode) { case ExecuteMode.Arm: //REC ARM break; case ExecuteMode.Execute: //REC EXECUTE break; } break; case LoopMachineMode.Play: break; } return(LedColorType.Off); }
/// <summary> /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="recCollection"></param> /// <param name="execMode"></param> /// <returns>返回成功行数</returns> public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode, string type) { int count = 0; foreach (Record record in recCollection) { if (ProcessRecord(record, execMode) != -1) { //addLog(record); if (type == "err") { //cmd_OnProgressOK((string)record.FieldCollection["EID"].Value); cmd_OnProgressOK(record.SetOldKeyValue()); } count++; } else { if (this._conn.mTransaction != null) { throw new Exception("更新有错"); } } } return(count); }
public formPanelSelectForItem(LedPanel panel) { this.InitializeComponent(); this.originalPanel = panel; this.mode = ExecuteMode.CopyPanelItems; this.DisplayLanuageText(); }
public formPanelSelectForItem(LedItem item) { this.InitializeComponent(); this.originalItem = item; this.mode = ExecuteMode.CopyItem; this.DisplayLanuageText(); }
/// <summary> /// 执行数据记录对象的操作 /// </summary> /// <param name="execMode">操作模式选项:Insert,Update,Delete,InsertOrUpdate</param> /// <returns></returns> internal int Process(ExecuteMode execMode) { keyVuale = SetKeyValue(); int rVal = 0; switch (execMode) { case ExecuteMode.Insert: rVal = Insert(); break; case ExecuteMode.Update: rVal = Update(); break; case ExecuteMode.InsertOrUpdate: rVal = InsertOrUpdate(); break; case ExecuteMode.Delete: rVal = Delete(); break; } return(rVal); }
public void ExecuteCommand(ExecuteMode mode, string name, ArgList args) { if (IsAliasRegistered(name)) { name = aliases[name]; } if (!IsCommandRegistered(name)) { Engine.Log.WriteLine("error/system", "Could not find command {0}", name); return; } switch (mode) { case ExecuteMode.Append: commandBuffer.Append(commands[name], args); break; case ExecuteMode.Immediate: commands[name].Execute(args); break; case ExecuteMode.Insert: commandBuffer.Insert(commands[name], args); break; } }
/// <summary> /// 创建一个定时器对象并立即开始 /// </summary> /// <param name="action">定时器要完成的任务委托</param> /// <param name="interval">间隔时间</param> /// <param name="mode">运行模式<see cref="ExecuteMode"/></param> /// <param name="immediately">是否要立即执行一次任务内容</param> public static Timing StartNewTiming(Action action, TimeSpan timeSpan, ExecuteMode mode, bool immediately = false) { var timing = new Timing(action); timing.Start(timeSpan, mode, immediately); return(timing); }
/// <summary> /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="recCollection"></param> /// <param name="execMode"></param> /// <returns>返回成功行数</returns> public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode) { int count = 0; try { foreach (Record record in recCollection) { if (ProcessRecord(record, execMode) != -1) { //addLog(record); count++; } else { if (this._conn.mTransaction != null) { this._conn.mTransaction.Rollback(); return(0); } } } if (this._conn.mTransaction != null) { this._conn.mTransaction.Commit(); return(count); } } finally { this.CloseConn(); } return(count); }
/// <summary> /// 提供对Record对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="record">数据记录对象</param> /// <param name="execMode">插入、更新、删除、插入或更新</param> /// <param name="isAddLog">是否添加日志</param> /// <param name="isAddLog">是否生成新id</param> /// <returns></returns> public int ProcessRecord(Record record, ExecuteMode execMode, bool isAddLog, bool isNewID) { record.OnException += new ExceptionHandler(record_OnException); record.OnExceptionEx += new ExceptionExHandler(cmd_OnExceptionEx); record.OnExceptionXP += new ExceptionXPHandler(record_OnExceptionXP); if (isNewID) { if (record.FieldCollection["EID"] == null || record.FieldCollection["EID"].Value == null) { string eid = record.CreateEID(); if (record.FieldCollection["EID"] == null) { record.FieldCollection["EID"].Value = eid; } else { record.FieldCollection.Add(new Field("EID", eid)); } } } if (OnProgress != null) { OnProgress(string.Format(@"{2} 处理一条数据记录。记录关联表:{0};操作:{1}", record.TableName, execMode.ToString(), DateTime.Now)); } record.Connection = this._conn; DateTime dt1 = DateTime.Now; int i = record.Process(execMode); if (record.Process(execMode) != -1) { DateTime dt2 = DateTime.Now; #if debug DateTime dt2 = DateTime.Now; TimeSpan ts = dt2 - dt1; if (OnProgress != null) { OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};操作花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds)); } #endif dt1 = DateTime.Now; if (isAddLog) { i = record.AddLog(this._emlogtable); } dt2 = DateTime.Now; #if debug ts = dt2 - dt1; if (OnProgress != null) { OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};写入log花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds)); } #endif return(i); } return(-1); }
public SingleApplication(ApplicationModel applicationModel, ISeacRuntimeClient seacRuntimeClient) : base(applicationModel, seacRuntimeClient) { directory = $"{App.RuntimeSettings.Repo}{Name}_{Platform}_{ExecuteMode.ToString().ToLower()}"; file = $"{directory}\\{Name}.seac"; MenuContextButtons.Add(new MenuContextViewModel("Update", async() => await Update())); MenuContextButtons.Add(new MenuContextViewModel("Delete", async() => await Delete())); }
public void ExecuteCommand(ExecuteMode mode, string name, string argString) { ArgList args = new ArgList(); args.Parse(argString); ExecuteCommand(mode, name, args); }
public formPanelSelectForItem(LedItem item, string name) { this.InitializeComponent(); this.originalItem = item; this.itemName = name; this.mode = ExecuteMode.ShareItem; this.DisplayLanuageText(); }
public virtual void Completed() { last_execute = DateTime.Now; executed = true; if (execute_mode == ExecuteMode.Alarm) { execute_mode = ExecuteMode.Once; } Commands.DoSomething(); }
public Engine(string dbpath, ExecuteMode mode = ExecuteMode.Verbose) { this.dbpath = dbpath; ExecuteMode = mode; DB = new DataBase(dbpath); var date = DateTime.Now; string logFileName = Path.ChangeExtension(dbpath, "." + string.Join("_", date.Day, date.Month, date.Year, date.Hour, date.Minute, date.Second + ".log")); Logger = new Logger(logFileName, false, true); Logger.WriteLine($"Подключено: '{dbpath}'"); }
public void PathFind(Vector2 start, Vector2 goal, System.Action <List <Vector2> > onEnd = null, ExecuteMode mode = ExecuteMode.ASync) { this.executeMode = mode; System.Action <List <Vector2> > onFinish = r => { RemoveCell(this.startCell); RemoveCell(this.goalCell); if (this.DebugHaltMode && r == null) { this.DebugHalt = true; } else { onEnd(r); } }; if (mode != ExecuteMode.StepNext) { // 初回のPathFind this.goalCell = AddCellImmediate(goal, AstarCell.Type.Goal); this.startCell = AddCellImmediate(start, AstarCell.Type.Start); if (this.startCell == null || this.goalCell == null) { Debug.LogWarning("start or gold is in block"); RemoveCell(this.startCell); RemoveCell(this.goalCell); Reset(false); onEnd(null); return; } this.logic.PathFind(startCell, goalCell, this.MakeRelation, onFinish, mode != ExecuteMode.Sync); return; } switch (mode) { case ExecuteMode.Sync: break; case ExecuteMode.ASync: pathFindProcessCoroutine(); break; case ExecuteMode.StepFirst: case ExecuteMode.StepNext: this.logic.pathFindProcess(); break; default: throw new System.InvalidOperationException(); } }
public static string GetModeName(this ExecuteMode mode) { switch (mode) { case ExecuteMode.BuildApks: return("Build APKs"); case ExecuteMode.InstallApks: return("Install APKs"); case ExecuteMode.ShowApkSize: return("Show APK size"); default: throw new NotImplementedException(mode.ToString()); } }
/// <summary> /// 提供对Record对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="record">数据记录对象</param> /// <param name="execMode">插入、更新、删除、插入或更新</param> /// <returns></returns> public int ProcessRecord(Record record, ExecuteMode execMode) { record.OnException += new ExceptionHandler(record_OnException); record.OnExceptionEx += new ExceptionExHandler(cmd_OnExceptionEx); record.OnExceptionXP += new ExceptionXPHandler(record_OnExceptionXP); if (OnProgress != null) { OnProgress(string.Format(@"{2} 处理一条数据记录。记录关联表:{0};操作:{1}", record.TableName, execMode.ToString(), DateTime.Now)); } //record.dbType = this._conn.ConnectionType; record.Connection = this._conn; return(record.Process(execMode)); }
/// <summary> /// 提供对Record对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="record">数据记录对象</param> /// <param name="execMode">插入、更新、删除、插入或更新</param> /// <param name="isAddLog">是否添加日志</param> /// <returns></returns> public int ProcessRecord(Record record, ExecuteMode execMode, bool isAddLog) { record.OnException += new ExceptionHandler(record_OnException); record.OnExceptionXP += new ExceptionXPHandler(record_OnExceptionXP); record.OnExceptionEx += new ExceptionExHandler(cmd_OnExceptionEx); if (OnProgress != null) { OnProgress(string.Format(@"{2} 处理一条数据记录。记录关联表:{0};操作:{1}", record.TableName, execMode.ToString(), DateTime.Now)); } record.Connection = this._conn; DateTime dt1 = DateTime.Now; int i = record.Process(execMode); if (i != -1) { //#if debug DateTime dt2 = DateTime.Now; TimeSpan ts = dt2 - dt1; if (OnProgress != null) { OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};操作花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds)); } dt1 = DateTime.Now; //#endif if (isAddLog) { i = record.AddLog(this._emlogtable); } #if debug dt2 = DateTime.Now; ts = dt2 - dt1; if (OnProgress != null) { OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};写入log花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds)); } #endif return(i); } return(-1); }
public ExecuteResult Next(string name, string platform, string mode, string next) { ExecuteMode executeMode = (ExecuteMode)Enum.Parse(typeof(ExecuteMode), mode, true); var application = databaseContext.Applications.FirstOrDefault(x => x.Name == name && x.Platform == platform && x.ExecuteMode == executeMode); if (application == null) { return(null); } var uri = Path.Combine(runtimeSettings.Repo, $"{application.Name}_{application.Platform}_{application.ExecuteMode.ToString().ToLower()}", $"{next}.seac"); FileStream fileStream = new FileStream(uri, FileMode.Open); return(new ExecuteResult { CodeStream = fileStream }); }
public ExecuteResult Execute(string name, string platform, string mode) { ExecuteMode executeMode = (ExecuteMode)Enum.Parse(typeof(ExecuteMode), mode, true); var application = databaseContext.Applications.FirstOrDefault(x => x.Name == name && x.Platform == platform && x.ExecuteMode == executeMode); if (application == null) { return(null); } switch (executeMode) { case ExecuteMode.Single: case ExecuteMode.Remote: case ExecuteMode.FullRemote: return(RemoteExecute(application)); } return(null); }
static public string Execute(ExecuteMode mode, string text=null) { ThemeSetting setting = ThemeTool.ThemeSetting.Load(text ?? AnotherThemeTool.Strings.YamlThemeSchema); using (var strw = new System.IO.StringWriter()) { foreach (var node in setting.Elements) { string result = null; switch (mode) { case ExecuteMode.ThemeToString: result = NodeToString (node); break; case ExecuteMode.StringToTheme: result = StringToNode (node); break; case ExecuteMode.ClassString: result = NodeToClassTheme (node); break; case ExecuteMode.ClassData: result = NodeToClassSetting (node); break; } if (!string.IsNullOrEmpty(result)) strw.WriteLine(result); } return strw.ToString(); } }
/// <summary> /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="recCollection">RecordCollection对象集</param> /// <param name="execMode">插入、更新、删除、插入或更新</param> /// <param name="type">err:处理错误记录</param> /// <param name="isAddLog">是否写入emlog</param> /// <returns>返回成功行数</returns> public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode, string type, bool isAddLog, bool isSub) { int count = 0; try { foreach (Record record in recCollection) { if (ProcessRecord(record, execMode, isAddLog) != -1) { //addLog(record); if (type == "err" && !isSub) { cmd_OnProgressOK(record.SetOldKeyValue()); } count++; } else { if (this._conn.mTransaction != null) { this._conn.mTransaction.Rollback(); count = -1; return(count); } } } if (this._conn.mTransaction != null) { this._conn.mTransaction.Commit(); return(count); } } finally { this.CloseConn(); } return(count); }
public static bool SatissfyExecutionCondition(this IBootstrapperTask task, ExecuteMode executeMode, Dictionary<Type, BootstrapperTaskExecution> bootstrapperTasksExecutionPool) { // if execution mode does not match return false if (task.ExecuteMode != executeMode) return false; // get the task type var _taskType = task.GetType(); // if not in the pool return true if (!bootstrapperTasksExecutionPool.ContainsKey(_taskType)) return true; // get the task from the pool var _executedTask = bootstrapperTasksExecutionPool[_taskType]; // if in the pool and can not be execute again return false if (_executedTask.IsExecuted && _executedTask.ExecuteType == ExecuteType.Initalize) return false; // if in the pool and can execute mutiple times if (_executedTask.IsExecuted && _executedTask.ExecuteType == ExecuteType.Always) return true; return false; }
/// <summary> /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新 /// </summary> /// <param name="recCollection"></param> /// <param name="execMode"></param> /// <param name="type">正常同步,处理错误同步</param> /// <param name="dbType">源记录的数据库类型</param> /// <returns></returns> public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode, string type, DBType dbType) { int count = 0; foreach (Record record in recCollection) { if (ProcessRecord(record, execMode) != -1) { if (type == "err") { cmd_OnProgressOK(record.SetOldKeyValue(dbType)); } count++; } else { if (this._conn.mTransaction != null) { throw new Exception("更新有错"); } } } return(count); }
public static string DisplayName(this ExecuteMode me) { return(_name[(int)me]); }
public Instruction(ExecuteMode execute_mode, double execute_rate_sec, Action action) { this.action = action; this.execute_mode = execute_mode; this.execute_rate_sec = execute_rate_sec; }
public bool Execute(string TranId, string OptionId, string ServiceId, string Name, string Source, ExecuteType ExecType, ExecuteMode ExecMode, byte ParSys) { if (_ErrorInfo.Codigo != 0) { return(false); } if ((short)ExecType < 0 || (short)ExecType > 1) { SetError(-1, "Tipo ExecType incorrecto", ""); return(false); } if ((short)ExecMode < 0 || (short)ExecMode > 3) { SetError(-1, "Modo ExecMode incorrecto", ""); return(false); } // la sesion ya es validada en la capa ciu por el token /*if (!(TranId.Equals("00000") && OptionId.Equals("LG"))) * if ((HttpContext.Current.Session["BIZUserId"] == null) || (HttpContext.Current.Session["BIZLoginId"] == null) || ((string)HttpContext.Current.Session["BIZLoginId"] == "0")) * { * SetError(-1, "Session expirada", ""); * return false; * }*/ ClearErrorInfo(); // gmv // Aqui ya se hace la llamada a la siguiente CAPA // ClientSocket socket = null; try { _Transaction.Name = Name; _Transaction.OptionId = OptionId; _Transaction.ServiceId = ServiceId; _Transaction.TranId = TranId; _Transaction.Source = Source; _Transaction.ExecMode = (short)ExecMode; _Transaction.ExecType = (short)ExecType; _Transaction.LoginId = cabeceraDBMS.LoginId.ToString(); _Transaction.BankId = cabeceraDBMS.BankId.ToString(); _Transaction.CompanyId = cabeceraDBMS.CompanyId.ToString(); _Transaction.SessionId = cabeceraDBMS.SessionId.ToString(); _Transaction.StationId = cabeceraDBMS.StationId.ToString(); _Transaction.UserId = cabeceraDBMS.UserId.ToString(); _Transaction.UserType = cabeceraDBMS.UserType.ToString(); InternalProcess proceso = new InternalProcess(_Transaction); this.respuesta = proceso.Ejecutar(); var myJObject = JObject.Parse(this.respuesta.ToString()); ClearTransactionInfo(); if (CheckErrorBTS()) { return(false); } else { return(true); } } catch (Exception ex) { SetError(-1, ex.Message, ex.Source); return(false); } }
/// <summary> /// /// </summary> /// <param name="argv"></param> /// <param name="isOutputValue"></param> /// <param name="mode"></param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"></exception> /// <exception cref="InvalidOperationException"></exception> /// <returns></returns> public Executor Execute([NotNull, ItemNotNull] string[] argv, bool isOutputValue = true, ExecuteMode mode = ExecuteMode.Default) { if (argv == null) { throw new ArgumentNullException(nameof(argv)); } if (argv.Any(string.IsNullOrEmpty)) { throw new ArgumentException($"Elements in <{nameof(argv)}> Cannot be Null Or Empty.", nameof(argv)); } if (this._engine == null) { throw new InvalidOperationException($"{nameof(Executor)} should Create by {nameof(Engine)}."); } if (this.Value != null) { var router = CommandRouter.Build(this._engine.ServiceProvider, this.Value); using (var s = this._engine.ServiceProvider.CreateScope()) { var configurator = s.ServiceProvider.GetRequiredService <SessionConfigurator>(); configurator.Argv = argv; configurator.Mode = mode; var session = (Session)s.ServiceProvider.GetRequiredService <ISession>(); // init session. try { var value = router.Execute(s.ServiceProvider); if (value != null && isOutputValue) { var formater = this._engine.ServiceProvider.GetRequiredService <IValueFormater>(); var ft = formater.Format(value); if (ft != null) { this._engine.ServiceProvider.GetRequiredService <IOutputer>() .WriteLine(OutputLevel.Normal, formater.Format(value)); } } return(new Executor(this._engine, value)); } catch (TerminationException) { /* ignore. */ } catch (CliException e) { if (e.Message.Length > 0) { this._engine.ServiceProvider.GetRequiredService <IOutputer>() .WriteLine(OutputLevel.Error, e.Message); } session.DrawUsage(); } catch (NotImplementedException e) { this._engine.ServiceProvider.GetRequiredService <IOutputer>() .WriteLine(OutputLevel.Error, e.ToString()); } catch (InvalidOperationException e) { this._engine.ServiceProvider.GetRequiredService <IOutputer>() .WriteLine(OutputLevel.Error, e.Message); } catch (Exception e) { this._engine.ServiceProvider.GetRequiredService <IOutputer>() .WriteLine(OutputLevel.Error, e.ToString()); } } } return(new Executor(this._engine, null)); }
public ExecutionResult ExecuteSql(string sql, ExecuteMode executeMode, Hashtable htValues) { ExecutionResult execRes = new ExecutionResult(); bool designMode = string.IsNullOrEmpty(CliUtils.fLoginDB); if (designMode) { return ExecuteSqlDesign(sql, executeMode, htValues); } string database = designMode ? report.EEPAlias : CliUtils.fLoginDB; CliUtils.fLoginDB = database; ClientType clientType = CliUtils.GetDataBaseType(database); DBParameter dbParameter = new DBParameter(clientType); try { ArrayList parameters = new ArrayList(); if (htValues != null) { foreach (DictionaryEntry de in htValues) { IDbDataParameter dbParam = dbParameter.CreateParameter(); dbParam.ParameterName = dbParameter.ParamTag + de.Key; dbParam.Value = de.Value; if (de.Value != null) { if (de.Value.GetType().Name == "Byte[]") { if (dbParam is OleDbParameter) (dbParam as OleDbParameter).OleDbType = OleDbType.LongVarBinary; else dbParam.DbType = DbType.Binary; } else { if (dbParam is OleDbParameter) (dbParam as OleDbParameter).OleDbType = OleDbType.VarChar; else dbParam.DbType = DbType.String; } } else { if (dbParam is OleDbParameter) (dbParam as OleDbParameter).OleDbType = OleDbType.VarChar; else dbParam.DbType = DbType.String; dbParam.Value = ""; } parameters.Add(dbParam); } } DataSet ds = CliUtils.ExecuteSql("GLModule", "cmdRefValUse", sql, database, executeMode == ExecuteMode.Select, CliUtils.fCurrentProject, null, parameters); if (executeMode == ExecuteMode.Select) { execRes.Anything = ds.Tables[0]; } //if (executeMode == ExecuteMode.Select) //{ // iDbDataAdapter = DBUtils.CreateDbDataAdapter(iDbCommand); // if (iDbCommand.Connection is OleDbConnection) // { // DataTable dt = new DataTable(); // (iDbDataAdapter as OleDbDataAdapter).Fill(dt); // ds.Tables.Add(dt); // } // else // iDbDataAdapter.Fill(ds); // //iDbDataAdapter.Fill(ds); // execRes.Anything = ds.Tables[0]; //} //else //{ // iDbCommand.ExecuteNonQuery(); //} execRes.Status = true; } catch (Exception ex) { throw ex; } finally { if (designMode) { CliUtils.fLoginDB = string.Empty; } } return execRes; }
public ExecutionResult ExecuteSql(string sql, ExecuteMode executeMode) { return this.ExecuteSql(sql, executeMode, null); }
public ExecutionResult ExecuteSqlDesign(string sql, ExecuteMode executeMode, Hashtable htValues) { IDbConnection iDbConn = GetConnection(report.EEPAlias); #region Variable Definition ExecutionResult execRes = new ExecutionResult(); //IDbConnection iDbConn = null; IDbCommand iDbCommand = null; IDbDataAdapter iDbDataAdapter = null; DataSet ds = new DataSet(); IDbDataParameter dbParam = null; #endregion DBParameter dbParameter = new DBParameter(DBUtils.GetDatabaseType(iDbConn)); try { if (iDbConn.State == ConnectionState.Closed) { iDbConn.Open(); } iDbCommand = iDbConn.CreateCommand(); iDbCommand.CommandText = sql; if (htValues != null) { foreach (DictionaryEntry de in htValues) { dbParam = iDbCommand.CreateParameter(); dbParam.ParameterName = dbParameter.ParamTag + de.Key; dbParam.Value = de.Value; if (de.Value != null) { if (de.Value.GetType().Name == "Byte[]") { if (iDbCommand.Connection is OleDbConnection) (dbParam as OleDbParameter).OleDbType = OleDbType.LongVarBinary; else dbParam.DbType = DbType.Binary; } else { if (iDbCommand.Connection is OleDbConnection) (dbParam as OleDbParameter).OleDbType = OleDbType.VarChar; else dbParam.DbType = DbType.String; } } else { if (iDbCommand.Connection is OleDbConnection) (dbParam as OleDbParameter).OleDbType = OleDbType.VarChar; else dbParam.DbType = DbType.String; dbParam.Value = ""; } iDbCommand.Parameters.Add(dbParam); } } if (executeMode == ExecuteMode.Select) { iDbDataAdapter = DBUtils.CreateDbDataAdapter(iDbCommand); DataTable dt = new DataTable(); if (iDbCommand.Connection is OleDbConnection) { (iDbDataAdapter as OleDbDataAdapter).Fill(dt); ds.Tables.Add(dt); } else iDbDataAdapter.Fill(ds); //iDbDataAdapter.Fill(ds); execRes.Anything = ds.Tables[0]; } else { iDbCommand.ExecuteNonQuery(); } execRes.Status = true; } catch (Exception ex) { throw ex; } finally { iDbConn.Close(); //iDbConn.Dispose(); } return execRes; }
public bool Execute(ExecuteMode mode) { string action = "SLDY"; TransactionDTO SLDY = getDTO(action); #if TroposDesktop || TroposWebService using (Transactions trans = new Transactions()) { #else using (TDK.Common.Helper.Transactions trans = new TDK.Common.Helper.Transactions()) { #endif trans.DataValid += Trans_DataValid; trans.AddTransaction(SLDY); _results = trans.ExecuteTransaction(out _errors, mode); if (Results.Count > 0) { //Use reflection to populate each property with the transaction results Dictionary <string, object> f = Results[0].Fields; _ActionFields = new Dictionary <string, string>(); foreach (string key in f.Keys) { string property = key.Replace("$", "_").Replace("-", "_"); if (this.GetType().GetProperty(property) != null) { this.GetType().GetProperty(property).SetValue(this, f[key], null); } if (key.StartsWith("i", System.StringComparison.Ordinal) || key.StartsWith("v", System.StringComparison.Ordinal)) { _ActionFields.Add(key, f[key].ToString()); } } } } if (_results[0].ScrollLines.Rows.Count > 0) { _ScrollLines = new Collection <string>(); foreach (DataRow Row in _results[0].ScrollLines.Rows) { ScrollLines.Add(Row["ScrollLine"].ToString()); } } #if TroposWebService this.WaitefReturn = _results[0].WaitefReturn; #endif int nonErrors = 0; if (_errors.Count > 0) { //Count the non-errors foreach (TransactionError te in _errors) { if (te.Severity == TroposErrorSeverity.Severe || te.Severity == TroposErrorSeverity.Validation) { break; } else { nonErrors++; } } } //Return true if no errors or all the errors are not severe or validation (warnings, none, informational) return(_errors.Count == nonErrors); }
/// <summary> /// 根据 Record内容、执行模式生成相应的执行语句 /// </summary> /// <param name="record"></param> /// <param name="execMode"></param> /// <returns></returns> public string General(Record record, ExecuteMode execMode) { DBType dbType = record.Connection.ConnectionType; string sqlInsert = @"insert into {0}({1}) values({2})"; string sqlUpdate = @"update {0} set {1} where {2}"; string sqlDelete = @"delete from {0} where {1}"; string sqlCheck = @"select count(*) from {0} where {1}"; StringBuilder sbSQL = new StringBuilder(); string sql = string.Empty; List <Field> keyFields = GetKeyFields(record); if (keyFields.Count == 0 && execMode != ExecuteMode.Insert) { throw new Exception(string.Format(@"表{0}没有设置主键字段", record.TableName)); } FieldCollection fc = record.FieldCollection; switch (execMode) { case ExecuteMode.Insert: StringBuilder sbFields = new StringBuilder(); StringBuilder sbValues = new StringBuilder(); foreach (Field field in fc) { //if (field.FieldType == FieldType.DateTime && dbType == DBType.Oracle) //{ // sbFields.Append(string.Format(@"{0},", field.Name)); // sbValues.Append(string.Format(@"to_date('{0}','yyyy-mm-dd HH24:mi:ss'),", field.Value)); //} //else //{ // sbFields.Append(string.Format(@"{0},", field.Name)); // sbValues.Append(string.Format(@"'{0}',", field.Value)); //} sbFields.Append(string.Format(@"{0},", field.Name)); sbValues.Append(string.Format(@"{0},", _formatFieldValue(field, dbType))); } sql = string.Format(sqlInsert, record.TableName, sbFields.ToString().TrimEnd(','), sbValues.ToString().TrimEnd(',')); break; case ExecuteMode.Update: StringBuilder sbUpdate = new StringBuilder(); StringBuilder sbUpdateCondition = new StringBuilder(); foreach (Field field in fc) { if (!field.IsKey) { //if (field.FieldType == FieldType.DateTime && dbType == DBType.Oracle) //{ // sbUpdate.Append(string.Format(@"{0}=to_date('{1}','yyyy-mm-dd HH24:mi:ss'),", field.Name, field.Value)); //} //else //{ // sbUpdate.Append(string.Format(@"{0}='{1}',", field.Name, field.Value)); //} sbUpdate.Append(string.Format(@"{0}={1},", field.Name, _formatFieldValue(field, dbType))); } else { //if (field.FieldType == FieldType.DateTime && dbType == DBType.Oracle) //{ // sbUpdateCondition.Append(string.Format(@"{0}=to_date('{1}','yyyy-mm-dd HH24:mi:ss') and ", field.Name, field.Value)); //} //else //{ // sbUpdateCondition.Append(string.Format(@"{0}='{1}' and ", field.Name, field.Value)); //} sbUpdateCondition.Append(string.Format(@"{0}={1} and ", field.Name, _formatFieldValue(field, dbType))); } } sbUpdateCondition = sbUpdateCondition.Remove(sbUpdateCondition.Length - 4, 4); sql = string.Format(sqlUpdate, record.TableName, sbUpdate.ToString().TrimEnd(','), sbUpdateCondition.ToString()); break; case ExecuteMode.Delete: StringBuilder sbDelCondition = new StringBuilder(); foreach (Field field in keyFields) { //if (field.FieldType == FieldType.DateTime && dbType == DBType.Oracle) //{ // sbDelCondition.Append(string.Format(@"{0}=to_date('{1}','yyyy-mm-dd HH24:mi:ss') and ", field.Name, field.Value)); //} //else //{ // sbDelCondition.Append(string.Format(@"{0}='{1}' and ", field.Name, field.Value)); //} sbDelCondition.Append(string.Format(@"{0}={1} and ", field.Name, _formatFieldValue(field, dbType))); } sbDelCondition = sbDelCondition.Remove(sbDelCondition.Length - 4, 4); sql = string.Format(sqlDelete, record.TableName, sbDelCondition.ToString()); break; case ExecuteMode.Check: StringBuilder sbChkCondition = new StringBuilder(); foreach (Field field in keyFields) { //if (field.FieldType == FieldType.DateTime && dbType == DBType.Oracle) //{ // sbChkCondition.Append(string.Format(@"{0}=to_date('{1}','yyyy-mm-dd HH24:mi:ss') and ", field.Name, field.Value)); //} //else //{ // sbChkCondition.Append(string.Format(@"{0}='{1}' and ", field.Name, field.Value)); //} sbChkCondition.Append(string.Format(@"{0}={1} and ", field.Name, _formatFieldValue(field, dbType))); } sbChkCondition = sbChkCondition.Remove(sbChkCondition.Length - 4, 4); sql = string.Format(sqlCheck, record.TableName, sbChkCondition.ToString()); break; } return(sql); }
public static SeacClient.SeacRuntime.ExecuteMode Raw(this ExecuteMode executeMode) => (SeacClient.SeacRuntime.ExecuteMode)executeMode;