コード例 #1
0
        private void _designer_DesignerCompileSupport(object sender, DesignerCompilerArgs e)
        {
            if (e.EditType != ExpressionDesigner.ExpressionDesigner.EditType.Script)
            {
                return;
            }
            ScriptHelper sh                     = null;
            Report       report                 = null;
            string       reportinitstring       = null;
            string       reportrowfiltermapkeys = null;

            if (_object is Report)
            {
                report           = _object as Report;
                reportinitstring = report.InitEvent;
                report.InitEvent = e.ResultString;
                sh = new ScriptHelper(report);
            }
            else if (_object is RowFilter)
            {
                report = (_object as RowFilter).Parent;
                sh     = new ScriptHelper(report);
                reportrowfiltermapkeys         = (_object as RowFilter).MapKeys;
                (_object as RowFilter).MapKeys = e.ResultString;
            }
            else
            {
                #region cell
                (_object as Cell).GetReport();
                report = (_object as Cell).Report;

                foreach (Section section in report.Sections)
                {
                    foreach (Cell cell in section.Cells)
                    {
                        if (cell is IMapName)
                        {
                            IMapName map = cell as IMapName;
                            if (!report.DataSources.Contains(map.MapName.Trim()))
                            {
                                DataType dt = DataType.String;
                                if (map is IDecimal)
                                {
                                    dt = DataType.Decimal;
                                }
                                else if (map is IDateTime)
                                {
                                    dt = DataType.DateTime;
                                }

                                report.DataSources.Add(new DataSource(map.MapName.Trim(), dt));
                            }
                        }
                    }
                }

                sh = new ScriptHelper(report);
                string cellstring = sh.CellString(_object as Cell, e.ResultString, _type);

                AddScriptKey(e.ResultString, report, sh);

                foreach (string name in sh.DSFunctions.Keys)
                {
                    cellstring = cellstring.Replace("current." + name, "current." + sh.DSFunctions.GetString(name).ToString());
                    cellstring = cellstring.Replace("previous." + name, "previous." + sh.DSFunctions.GetString(name).ToString());
                }
                sh.AddScript(cellstring);
                #endregion
            }

            sh.References.Add(ExecutePath + "UFIDA.U8.UAP.Services.ReportData.dll");
            sh.References.Add(ExecutePath + "UFIDA.U8.UAP.Services.ReportElements.dll");
            sh.References.Add(ExecutePath + "UFIDA.U8.UAP.Services.ReportFilterService.dll");
            //sh.References.Add(ExecutePath + "UFSoft.U8.Report.Exhibition.dll");
            //sh.References.Add(ExecutePath + "UFSoft.U8.Ex.Filter.dll");
            sh.OutputAssembly = null;
            CompilerResults cr = sh.Compile();

            if (cr.Errors.Count > 0)
            {
                e.IsCompileSucceed = false;
                for (int i = 0; i < cr.Errors.Count; i++)
                {
                    cr.Errors[i].Line -= 18;
                }
                e.Error = cr.Errors;
            }
            else
            {
                e.IsCompileSucceed = true;
            }
            if (reportinitstring != null)
            {
                (_object as Report).InitEvent = reportinitstring;
            }
            if (reportrowfiltermapkeys != null)
            {
                (_object as RowFilter).MapKeys = reportrowfiltermapkeys;
            }
        }