public override int BindDataTableManager(IDataTableManager dtm, string bindPath) { IReportExpressionEngine expEngin = (this as IBindReportExpressionEngine).ExpressionEngine; bool newFlag = false; // 计算显示值 if (null == expEngin) { expEngin = (this as IBindReportExpressionEngine).ExpressionEngine = new ReportExpressionEngine(); newFlag = true; } object obj = null; if (!string.IsNullOrEmpty(Expression) && Expression.Trim().StartsWith("=")) { // 启用表达式 obj = expEngin.Execute(Expression.Trim().TrimStart("=".ToCharArray()), dtm, bindPath); } else if (!string.IsNullOrEmpty(DbField)) { // 替换显示 obj = expEngin.ExcuteBindObj(DbField, dtm, bindPath); if (null == obj) { obj = expEngin.ExcuteBindText(DbField, dtm, bindPath); } } if (null != obj) { if (obj is byte[]) { obj = GetImageBytesFromOLEField(obj as byte[]); // 二进制图片数据 RealText = Convert.ToBase64String(obj as byte[]); } else if (obj is string) { string path = obj.ToString(); if (File.Exists(path)) { try { Image = System.Drawing.Image.FromFile(path); } catch (System.Exception ex) { Image = null; } } } } if (newFlag) { expEngin.Dispose(); } return(0); }
public override int BindDataTableManager(IDataTableManager dtm, string bindPath) { IReportExpressionEngine expEngin = (this as IBindReportExpressionEngine).ExpressionEngine; bool newFlag = false; // 计算显示值 if (null == expEngin) { expEngin = (this as IBindReportExpressionEngine).ExpressionEngine = new ReportExpressionEngine(); newFlag = true; } RealText = expEngin.Execute(Expression, Text, dtm, this as IPMSFormate, this as IDataMapping, bindPath); //object oValue = null; //if (!string.IsNullOrEmpty(Expression) && Expression.StartsWith("=")) //{ // // 启用表达式 // oValue = expEngin.Excute(Expression.TrimStart("=".ToCharArray()), dtm, bindPath); //} //else if (!string.IsNullOrEmpty(Text)) //{ // // 替换显示 // oValue = expEngin.ExcuteBindText(Text, dtm, bindPath); //} //// format //if (null != oValue) //{ // RealText = oValue.ToString(); // if (!string.IsNullOrEmpty(StrFormate)) // { // RealText = FormateToString(oValue); // } //} ////mapping //if (EnableMapping) //{ // string result = GetMapValue(RealText); // if (null != result) // { // RealText = result; // } //} if (newFlag) { expEngin.Dispose(); } return(0); }
/// <summary> /// 根据表达式计算出实际值 /// </summary> /// <param name="expression">表达式</param> /// <param name="text">Text</param> /// <param name="dtm">数据源</param> /// <param name="bindPath">绑定路径</param> /// <returns>计算后的实际值</returns> public string ExpressionExecute(string expression, string text, IDataTableManager dtm, string bindPath) { IReportExpressionEngine expEngin = (this as IBindReportExpressionEngine).ExpressionEngine; bool newFlag = false; if (null == expEngin) { expEngin = (this as IBindReportExpressionEngine).ExpressionEngine = new ReportExpressionEngine(); newFlag = true; } string RealText = expEngin.Execute(expression, text, dtm, this as PMS.Libraries.ToolControls.Report.IPMSFormate, this as IDataMapping, bindPath); if (newFlag) { expEngin.Dispose(); } return(RealText); }
public override int BindDataTableManager(IDataTableManager dtm, string bindPath) { IReportExpressionEngine expEngin = (this as IBindReportExpressionEngine).ExpressionEngine; bool newFlag = false; // 计算显示值 if (null == expEngin) { expEngin = (this as IBindReportExpressionEngine).ExpressionEngine = new ReportExpressionEngine(); newFlag = true; } RealText = expEngin.Execute(Expression, Text, dtm, this as IPMSFormate, this as IDataMapping, bindPath); if (newFlag) { expEngin.Dispose(); } return(0); }