/// <summary> /// 构造通用最终用的sql语句 /// </summary> /// <returns></returns> public String CreateGeneralSelectSQL(Expression expression) { #region if (expression.SqlConditions != null) { addCondition(expression.SqlConditions); } string endsql = expression.SqlBusiness; if (!string.IsNullOrEmpty(_condition)) { endsql = String.Format("{0} where {1} {2}", endsql, _condition, getOrderby(expression)); } else { endsql = String.Format("{0} {1}", endsql, getOrderby(expression)); } ExtConsole.WriteWithColor(endsql); return(endsql); #endregion }
/// <summary> /// /// </summary> /// <param name="expression"></param> /// <returns></returns> public String CreateSelectSQLWithoutPage(Expression expression) { #region if (expression.SqlConditions != null) { addCondition(expression.SqlConditions); } string returnfields = "*"; if (expression.SqlConditions != null) { if (!string.IsNullOrEmpty(expression.SqlConditions.ReturnFields)) { returnfields = expression.SqlConditions.ReturnFields; } } string format = @"select {0} from ({1}) as a {2} {3}"; object[] argument = new object[4]; argument[0] = returnfields; argument[1] = expression.SqlBusiness; argument[2] = string.IsNullOrEmpty(_condition) ? "" : string.Format("where {0}", _condition); argument[3] = getOrderby(expression); format = string.Format(format, argument); ExtConsole.WriteWithColor(format); return(format); #endregion }
/// <summary> /// /// </summary> /// <param name="index"></param> public void Remove(int index) { if (index > Count - 1 || index < 0) { ExtConsole.WriteWithColor("往事务中添加Action时,索引出错!"); } else { this.subtractCount(((Expression)List[index]).EnumReturn); List.RemoveAt(index); } }
/// <summary> /// 写日志 /// </summary> /// <param name="error"></param> public static void Write(string error) { #region lock (LogLockObject) { LogBusiness log = new LogBusiness( CustomConfig.LogDirectoryName, LogFileName); string logTemplate = "错误发生在:{0}\r\n{1}"; string logContent = String.Format(logTemplate, DateTime.Now.ToString(), error); log.writefile(logContent); ExtConsole.WriteWithColor(logContent); //if(_viewConsole) // MainView.AsyncAppendContent(error+"\r\n\r\n"); } #endregion }
/// <summary> /// /// </summary> /// <param name="expression"></param> /// <returns></returns> public String CreateTopSelectSQL(Expression expression) { #region if (expression.SqlConditions != null) { addCondition(expression.SqlConditions); } int pagesize = int.MaxValue; int pageindex = 1; string returnfields = "*"; string businesssql = expression.SqlBusiness; if (expression.SqlConditions != null) { pagesize = expression.SqlConditions.PageSize; pageindex = expression.SqlConditions.PageIndex; if (!string.IsNullOrEmpty(expression.SqlConditions.ReturnFields)) { returnfields = expression.SqlConditions.ReturnFields; } } string key = getAllKeys(expression); string format = @"select top {0} {2} from ({4}) as a where {3} not in (select top ({0}*({1}-1)) {3} from ({4}) as b {5}) {5} "; object[] argument = new object[6]; argument[0] = pagesize; argument[1] = pageindex; argument[2] = returnfields; argument[3] = key; argument[4] = string.IsNullOrEmpty(_condition) ? businesssql : string.Format("{0} where {1}", businesssql, _condition); argument[5] = getOrderby(expression); format = string.Format(format, argument); ExtConsole.WriteWithColor(format); return(format); #endregion }
/// <summary> /// /// </summary> /// <param name="callback"></param> /// <param name="state"></param> /// <returns></returns> public static WaitCallback Wrap(WaitCallback callback, object state) { #region return(new WaitCallback( delegate { try { callback(state); } catch (Exception ex) { ThreadsCustom._threadSuccessful[(int)state] = false; ExtConsole.WriteWithColor(ex.ToString()); } })); #endregion }
/// <summary> /// 构造存储过程最终用的sql语句 /// </summary> /// <returns></returns> public String CreateSelectSQL(Expression expression) { #region if (expression.SqlConditions != null) { addCondition(expression.SqlConditions); } string endsql = ""; if (!string.IsNullOrEmpty(_condition)) { _condition = string.Format("where {0}", _condition); } endsql = String.Format("({0} {2}) as {1}", expression.SqlBusiness, GetViewTablename(expression), _condition); ExtConsole.WriteWithColor(endsql); return(endsql); #endregion }
private void socketErrorHandler(object sender, ErrorEventArgs e) { ExtConsole.WriteWithColor(e.SocketException.ToString()); }