protected internal virtual string scanParameter() { int num = this.string_0.Length; while (this.int_0 < num) { if (!char.IsWhiteSpace(this.string_0[this.int_0])) { break; } this.int_0++; } if (this.int_0 == num) { throw new ReportError("函数缺少参数"); } if (this.string_0[this.int_0] != '(') { throw new ReportError("函数缺少参数"); } int num2 = ExpString.scanParenthesis(this.string_0, this.int_0); if (num2 == -1) { throw new ReportError("函数括号不匹配"); } string str = this.string_0.Substring(this.int_0 + 1, num2 - (this.int_0 + 1)); this.int_0 = num2 + 1; return(str); }
public override object calculate() { if (base.paramList.Count < 3) { throw new ReportError("repstr函数参数需要至少三个参数,源字符串、将要被替换的字符串、替换后的字符串,引号里的字符是否要替换"); } object obj2 = ConvertTool.getValue(((ExpParse)base.paramList[0]).calculate()); if (obj2 == null) { return(obj2); } if (!(obj2 is string)) { throw new ReportError("repstr函数参数1应为字符串"); } object obj3 = ConvertTool.getValue(((ExpParse)base.paramList[1]).calculate()); if (obj3 == null) { return(obj3); } if (!(obj3 is string)) { throw new ReportError("repstr函数参数2应为字符串"); } object obj4 = ConvertTool.getValue(((ExpParse)base.paramList[2]).calculate()); if (obj4 == null) { return(obj4); } if (!(obj4 is string)) { throw new ReportError("repstr函数参数3应为字符串"); } object obj5 = ConvertTool.getValue(((ExpParse)base.paramList[3]).calculate()); if (obj5 == null) { return(obj5); } if (!(obj5 is bool)) { throw new ReportError("repstr函数参数4应为字符串"); } if (!(bool)obj5) { return(ExpString.replace((string)obj2, 0, (string)obj3, (string)obj4, 0)); } return(ExpString.replace((string)obj2, 0, (string)obj3, (string)obj4, 16)); }
public Macros(string macrosStr) { this.string_0 = new string[8]; this.string_1 = new string[8]; this.string_2 = new string[8]; this.int_0 = 0; int index = 0; ArgToken token = new ArgToken(macrosStr.Trim(), ';'); while (token.hasNext()) { string str4 = token.next(); string str = ""; string str2 = ""; string str3 = ""; int num2 = str4.IndexOf('='); if (num2 >= 0) { str = str4.Substring(0, num2); if (num2 < (str4.Length - 1)) { int num3 = ExpString.indexOf(str4, ",", num2 + 1, 0); if (num3 >= 0) { str2 = Escape.remove(str4.Substring(num2 + 1, num3 - (num2 + 1))); str3 = Escape.remove(str4.Substring(num3 + 1)); } else { str2 = Escape.remove(str4.Substring(num2 + 1)); } } } else { str = str4; } str = str.Trim(); if (str.Length != 0) { this.vmethod_0(index + 1); this.string_0[index] = str; this.string_1[index] = str2; this.string_2[index] = str3; index++; this.int_0++; } } }
private void method_0(Field field_0, CellSet cellSet_1, int int_3) { if (field_0 != null) { int startRow = field_0.StartRow; int endRow = field_0.EndRow; int num3 = this.Int32_0; for (int i = startRow; i <= endRow; i++) { for (int j = 1; j < cellSet_1.Column; j++) { object obj2 = cellSet_1.getPropertyValue(i, j, 302); if ((obj2 != null) && (obj2 is string)) { string str = (string)obj2; str = ExpString.replace(ExpString.replace(ExpString.replace(ExpString.replace(str, "{page_cn}", StringUtils.toChinese((long)int_3, true, false), 19), "{pages_cn}", StringUtils.toChinese((long)num3, true, false), 19), "{page}", int_3.ToString(), 19), "{pages}", num3.ToString(), 19); cellSet_1.setPropertyValue(i, j, 302, str); } } } } }
protected internal virtual Unit createNode() { char ch = this.string_0[this.int_0]; int num = -1; switch (ch) { case '"': case '\'': { num = ExpString.scanQuotation(this.string_0, this.int_0); if (num == -1) { throw new ReportError("引号不匹配"); } string str3 = this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1)); this.int_0 = num + 1; return(new Constant(str3)); } } if ((this.cellExt1_0 != null) && (ch == '{')) { num = ExpString.scanBrace(this.string_0, this.int_0); if (num == -1) { throw new ReportError("大括号不匹配"); } FunctionUnit unit7 = LoadFunction.newFunction("select", this.env_0, this.cellExt1_0, this.dataSet_0); unit7.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1))); this.int_0 = num + 1; return(unit7); } if ((this.cellExt1_0 != null) && (ch == '[')) { FunctionUnit unit6; num = ExpString.scanBracket(this.string_0, this.int_0); if (num == -1) { throw new ReportError("中括号不匹配"); } if ((this.unit_1 != null) && !this.unit_1.Operator) { if (this.unit_1 is CSVar) { unit6 = LoadFunction.newFunction("move", this.env_0, this.cellExt1_0, this.dataSet_0); unit6.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1))); } else { unit6 = LoadFunction.newFunction("offset", this.env_0, this.cellExt1_0, this.dataSet_0); unit6.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1))); } } else { unit6 = LoadFunction.newFunction("list", this.env_0, this.cellExt1_0, this.dataSet_0); unit6.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1))); } this.int_0 = num + 1; return(unit6); } string id = this.scanId(); if (id.ToUpper().Equals("and".ToUpper())) { return(new And()); } if (id.ToUpper().Equals("or".ToUpper())) { return(new Or()); } if (id.ToUpper().Equals("not".ToUpper())) { return(new Not()); } if (id.ToUpper().Equals("in".ToUpper())) { return(new In()); } if (id.ToUpper().Equals("to".ToUpper())) { return(new To()); } if (id.ToUpper().Equals("like".ToUpper())) { return(new Like()); } DataSet ds = this.dataSet_0; int index = id.IndexOf('.'); if ((index > 0) && !char.IsDigit(id[0])) { string str2 = id.Substring(0, index); if (this.env_0.isDataSetName(str2)) { ds = this.env_0.getDataSet(str2); id = id.Substring(index + 1); Unit unit5 = this.createDSNode(ds, id, true); if (unit5 == null) { throw new ReportError("有不可识别的数据集函数" + id.ToString().ToString()); } return(unit5); } } if (this.dataSet_0 != null) { Unit unit4 = this.createDSNode(this.dataSet_0, id, true); if (unit4 != null) { return(unit4); } } if (this.unit_1 is DSMember) { Unit unit3 = this.createDSNode(this.dataSet_0, id, false); if (unit3 != null) { return(unit3); } } bool isSaved = false; if (id[0] != '@') { if (id[0] == '$') { id = id.Substring(1); isSaved = true; } } else { id = id.Substring(1); } if ((this.cellExt1_0 != null) && id.ToUpper().Equals("value".ToUpper())) { return(new CSCurrent(this.cellExt1_0)); } if (this.env_0.isParamName(id)) { return(new Constant(this.env_0.getParam(id))); } if ((this.cellExt1_0 != null) && this.cellExt1_0.isSource(id.ToLower())) { id = id.ToLower(); if (this.cellExt1_0.getSource(id) != null) { return(new CSVar(this.cellExt1_0.getSource(id), isSaved)); } return(new CSVar(this.cellExt1_0, id)); } if (!this.Boolean_0) { return(new Constant(ConvertTool.parse(id))); } if (!LoadFunction.isFunName(id)) { throw new ReportError("未知的函数" + id.ToString().ToString()); } FunctionUnit unit2 = LoadFunction.newFunction(id, this.env_0, this.cellExt1_0, this.dataSet_0); unit2.setParameter(this.scanParameter()); return(unit2); }
private void method_13(ShortMap shortMap_0, int int_0, int int_1, int int_2, int int_3, int int_4, int int_5) { if (shortMap_0 != null) { for (int i = 0; i < shortMap_0.size(); i++) { int num3; int num5; char ch; short num2 = shortMap_0.getKey(i); string str = (string)method_15(int_0, int_1, num2); if (((str == null) || (str.Trim().Length == 0)) || (str.StartsWith("#REF!") || str.StartsWith("#ERR!"))) { continue; } StringBuilder builder = null; int num6 = str.Length; bool flag = false; int num4 = 0; goto Label_0188; Label_0075: ch = str[num4]; switch (ch) { case '\'': case '"': goto Label_015A; default: if (method_10(ch)) { goto Label_0146; } num3 = method_11(str, num4); num5 = num4; while (num5 < num3) { if (str[num5] == '.') { break; } num5++; } break; } if (!method_9(str, num4, num5)) { if (builder != null) { builder.Append(str.Substring(num4, num5 - num4)); } } else { if (builder == null) { builder = new StringBuilder(64); builder.Append(str.Substring(0, num4)); } if (!method_14(str, num4, num5, int_2, int_3, int_5, int_4, builder)) { goto Label_0193; } } if ((num5 < num3) && (builder != null)) { builder.Append(str.Substring(num5, num3 - num5)); } num4 = num3; goto Label_0188; Label_0146: if (builder != null) { builder.Append(ch); } num4++; goto Label_0188; Label_015A: num3 = ExpString.scanQuotation(str, num4, '\\'); if (num3 < 0) { goto Label_01E0; } if (builder != null) { builder.Append(str.Substring(num4, (num3 + 1) - num4)); } num4 = num3 + 1; Label_0188: if (num4 >= num6) { goto Label_0202; } goto Label_0075; Label_0193: if (_relativeList == null) { _relativeList = new ArrayList(10); } _relativeList.Add(new RelativeFix(int_0, int_1, num2)); method_16(int_0, int_1, num2, "#REF!" + str.ToString().ToString()); flag = true; goto Label_0202; Label_01E0: method_16(int_0, int_1, num2, "#ERR!" + str.ToString().ToString()); flag = true; Label_0202: if (!flag && (builder != null)) { method_16(int_0, int_1, num2, builder.ToString()); } } } }
public virtual DataSet getDataSet(Env env) { DataSet set3; DataSetConfig config = (DataSetConfig)this.hashtable_0["dsc"]; CellExt1 cs = (CellExt1)this.hashtable_0["ecs"]; string name = config.Name; IDbCommand pst = null; IDataReader rs = null; IDbConnection connection = null; try { bool flag; bool flag2; string dataSourceName = config.DataSourceName; if (dataSourceName != null) { connection = env.getConnection(dataSourceName); if (connection == null) { connection = env.getConnection(); } } else { connection = env.getConnection(); dataSourceName = ""; } if ((connection == null) || (connection.State == null)) { return(null); } if ((dataSourceName != null) && (dataSourceName.Trim().Length != 0)) { flag = env.getIsEncoding(dataSourceName); } else { flag = env.getIsEncoding(); } string dbCharset = env.getDBCharset(dataSourceName); if ((dbCharset == null) || (dbCharset.Trim().Length == 0)) { dbCharset = env.getDBCharset(); } string str = MacroCalc.replaceMacros(config.SQL, env.MacrosMap); if ((dataSourceName != null) && (dataSourceName.Trim().Length != 0)) { flag2 = env.getNeedTransSQLcode(dataSourceName); } else { flag2 = env.getNeedTransSQLcode(); } if (flag2) { str = Encoding.GetEncoding(dbCharset).GetString(Encoding.Default.GetBytes(str)); } string[] sqlArguments = config.SqlArguments; string[] sqlArgumentsName = config.SqlArgumentsName; int[] argumentTypes = config.ArgumentTypes; object[] objArray = null; if (sqlArguments != null) { objArray = new object[sqlArguments.Length]; int num7 = 0; for (int i = 0; i < sqlArguments.Length; i++) { num7 = ExpString.indexOf(str, "?", num7 + 1, 18); if ((sqlArguments[i] != null) && sqlArguments[i].ToLower().Equals("@@result")) { objArray[i] = "@@result"; } else { objArray[i] = ConvertTool.getValue(new ExpParse(cs, sqlArguments[i]).calculate()); if ((objArray[i] != null) && (objArray[i] is ArrayList)) { objArray[i] = ((ArrayList)objArray[i]).ToArray(); if (((((object[])objArray[i]).Length > 0) && (((object[])objArray[i])[0] is string)) && flag2) { for (int j = 0; j < ((object[])objArray[i]).Length; j++) { ((object[])objArray[i])[j] = Convert.ToString(Encoding.GetEncoding(dbCharset).GetBytes((string)((object[])objArray[i])[0])); } } } else if ((objArray[i] is string) && flag2) { objArray[i] = Convert.ToString(Encoding.GetEncoding(dbCharset).GetBytes((string)objArray[i])); } if ((objArray[i] != null) && objArray[i].GetType().IsArray) { int length = ((object[])objArray[i]).Length; StringBuilder builder = new StringBuilder(2 * length); for (int k = 0; k < length; k++) { builder.Append("?,"); } if ((builder.Length > 0) && (builder[builder.Length - 1] == ',')) { builder.Remove(builder.Length - 1, 1); } if (builder.Length > 1) { str = new StringBuilder(str.Substring(0, num7).ToString().ToString()).Append(builder.ToString()).Append(str.Substring(num7 + 1)).ToString().ToString(); } num7 += builder.Length; } } } } Logger.debug("下面开始打出sql"); int num6 = 0; if ((3 != config.SQLType) || (connection is OleDbConnection)) { try { Logger.debug(new StringBuilder(name.ToString().ToString()).Append("=").Append(str).ToString().ToString()); pst = SupportClass.TransactionManager.manager.PrepareStatement(connection, str); goto Label_0472; } catch (Exception exception3) { throw new ReportError(new StringBuilder("数据集").Append(name).Append(" sql异常:").Append(exception3.Message).ToString().ToString(), exception3); } } try { pst = SupportClass.TransactionManager.manager.PrepareCall(connection, str); } catch (Exception exception4) { throw new ReportError(new StringBuilder("数据集").Append(name).Append(" sql异常:").Append(exception4.Message).ToString().ToString(), exception4); } Label_0472: if ((objArray == null) || (objArray.Length <= 0)) { goto Label_06A2; } int index = 0; int num3 = 0; Label_048F: if (num3 >= objArray.Length) { goto Label_06A2; } index++; if ((sqlArguments[num3] == null) || !sqlArguments[num3].ToLower().Equals("@@result")) { goto Label_050E; } if (!(pst is OracleCommand)) { goto Label_0698; } try { OracleParameter parameter = new OracleParameter(); parameter.ParameterName = (sqlArgumentsName[num3]); parameter.OracleType = (OracleType)(5); parameter.Direction = (ParameterDirection)(2); pst.Parameters.Add(parameter); goto Label_0698; } catch (Exception) { goto Label_0698; } Label_0504: num6 = index; goto Label_068D; Label_050E: try { if ((objArray[num3] != null) && objArray[num3].GetType().IsArray) { string msg = new StringBuilder("第").Append(num3).Append("个参数组: ").ToString().ToString(); for (int m = 0; m < ((object[])objArray[num3]).Length; m++) { msg = (msg.ToString() + ((object[])objArray[num3])[m].ToString()).ToString().ToString() + ","; SQLTool.setObject(pst, index, ((object[])objArray[num3])[m], argumentTypes[num3], sqlArgumentsName[num3]); index++; } Logger.debug(msg); index--; } else { Logger.debug(new StringBuilder("第").Append(num3).Append("个参数: ").Append(objArray[num3]).ToString().ToString()); if ((6 == argumentTypes[num3]) && (objArray[num3] == null)) { objArray[num3] = ""; } SQLTool.setObject(pst, index, objArray[num3], argumentTypes[num3], sqlArgumentsName[num3]); } } catch (Exception exception2) { throw new ReportError(new StringBuilder("数据集").Append(name).Append("的sql第").Append(num3 + 1).Append("个参数异常:").Append(exception2.Message).ToString().ToString(), exception2); } Label_068D: num3++; goto Label_048F; Label_0698: if (num6 == 0) { goto Label_0504; } goto Label_068D; Label_06A2: try { rs = pst.ExecuteReader(); } catch (Exception exception) { throw new ReportError(new StringBuilder("数据集").Append(name).Append("的 sql异常:").Append(exception.Message).ToString().ToString(), exception); } string beginRow = config.BeginRow; string endRow = config.EndRow; if (((beginRow == null) || (beginRow.Trim().Length == 0)) || beginRow.Trim().ToUpper().Equals("null".ToUpper())) { beginRow = "0"; } if (((endRow == null) || (endRow.Trim().Length == 0)) || endRow.Trim().ToUpper().Equals("null".ToUpper())) { endRow = "0"; } beginRow = MacroCalc.replaceMacros(beginRow, env.MacrosMap); endRow = MacroCalc.replaceMacros(endRow, env.MacrosMap); int num = 0; int num2 = 0; try { object obj2 = ConvertTool.getValue(new ExpParse(env, beginRow).calculate()); object obj3 = ConvertTool.getValue(new ExpParse(env, endRow).calculate()); if ((obj2 is int) && (obj3 is int)) { num = (int)obj2; num2 = (int)obj3; } } catch (Exception) { throw new ReportError("数据集的起始行或者结束行设置有误。"); } ArrayList fieldText = config.getFieldTextList(); RecordCheck oRecordCheck = new RecordCheck(new ConnectionConfig().getDBOperator(), env.Request, env.Session); DataSet set = DataSetTool.populate(null, rs, num, num2, dbCharset, fieldText, false, flag, oRecordCheck); if ((config.IndexCols != null) && (config.IndexCols.Length > 0)) { set.createIndex(config.IndexCols, config.IndexSorted); } set3 = set; } catch (ReportError error) { throw error; } catch (Exception exception5) { throw new ReportError(exception5.Message, exception5); } finally { try { if (rs != null) { rs.Close(); } if (pst != null) { pst.Dispose(); } } catch (Exception exception6) { throw new ReportError(exception6.Message, exception6); } } return(set3); }