// Loads and shows the report. private void MainForm_Load(object sender, EventArgs e) { var rptPath = new FileInfo(@"..\..\OleDBReport.rdlx"); var pageReport = new PageReport(rptPath); reportPreview.LoadDocument(pageReport.Document); }
// GET api/values/5 public string Get(string id) { var fileName = "BarCode.rdlx"; try { //GrapeCity.ActiveReports.Viewer.Win.Viewer arvMain = new GrapeCity.ActiveReports.Viewer.Win.Viewer(); var reportFile = new FileInfo(HttpContext.Current.Server.MapPath("~/") + fileName); PageReport report = new PageReport(reportFile); var doc = new PageDocument(report); doc.Parameters["ReportParameter1"].CurrentValue = id; doc.Print(false, false, false); return("value = " + id); } catch (Exception e) { return(e.Message); } }
protected override object OnCreateReportHandler(string reportPath) { SectionReport rptOrders; switch (reportPath) { case "Reports/BillingInvoice.rdlx": case "Reports/Orders.rdlx": PageReport rptPageRDL = new PageReport(); rptPageRDL.Load(new FileInfo(Server.MapPath(reportPath))); rptPageRDL.Report.DataSources[0].ConnectionProperties.ConnectString = "data source=" + Server.MapPath("~/App_Data/NWind.mdb") + ";provider=Microsoft.Jet.OLEDB.4.0;"; return(rptPageRDL); case "Reports/Invoice.rpx": rptOrders = new SectionReport(); XmlTextReader xtr = new XmlTextReader(Server.MapPath(reportPath)); rptOrders.LoadLayout(xtr); (rptOrders.DataSource as OleDBDataSource).ConnectionString = "data source=" + Server.MapPath("~/App_Data/NWind.mdb") + ";provider=Microsoft.Jet.OLEDB.4.0;"; return(rptOrders); default: return(base.OnCreateReportHandler(reportPath)); } }
protected override object OnCreateReportHandler(string reportPath) { var data = reportPath.Split(';'); if (data.Length != 2) { return(base.OnCreateReportHandler(reportPath)); } switch (data[0]) { case "Section": return(new OrderReport { DataSource = Repository.GetOrders(data[1]) }); case "Page": var report = new PageReport(new FileInfo(Server.MapPath("~/Reports/OrderDetailsReport.rdlx"))); report.Document.LocateDataSource += delegate(object sender, LocateDataSourceEventArgs args) { args.Data = Repository.GetDetails(data[1]); }; return(report); } return(base.OnCreateReportHandler(reportPath)); }
//This section adds the datasource to be used by the report //It adds the dataset for the report,adds the query,the Fields and their expression public static PageReport AddDataSetDataSource(PageReport report) { // create DataSource for the report DataSource dataSource = new DataSource(); dataSource.Name = "Reels Database"; dataSource.ConnectionProperties.DataProvider = "OLEDB"; dataSource.ConnectionProperties.ConnectString = ExpressionInfo.FromString(Properties.Resources.ConnectionString); //Create DataSet with specified query and load database fields to the DataSet DataSet dataSet = new DataSet(); Query query = new Query(); dataSet.Name = "Sample DataSet"; query.DataSourceName = "Reels Database"; query.CommandType = QueryCommandType.Text; query.CommandText = ExpressionInfo.FromString(Constants.cmdText); dataSet.Query = query; String[] fieldsList = new String[] { "MoviedID", "Title", "YearReleased", "MPAA" }; foreach (string fieldName in fieldsList) { Field field = new Field(fieldName, fieldName, null); dataSet.Fields.Add(field); } //create report definition with specified DataSet and DataSource report.Report.DataSources.Add(dataSource); report.Report.DataSets.Add(dataSet); return(report); }
protected override object OnCreateReportHandler(string reportPath) { var data = reportPath.Split(';'); if (data.Length != 2) { return(base.OnCreateReportHandler(reportPath)); } switch (data[0]) { case "Section": var sectionReport = new SectionReport(); sectionReport.LoadLayout(XmlReader.Create(Server.MapPath("~/Reports/OrderReport.rpx"))); sectionReport.DataSource = Repository.GetOrders(data[1]); var xvalues = new List <string>(); var yvalues = new List <double>(); foreach (Order order in Repository.GetOrders(data[1])) { xvalues.Add(order.ShippedDate); yvalues.Add((double)order.Freight); } ((SectionReportModel.ChartControl)sectionReport.Sections["reportFooter1"].Controls[0]).Series[0].Points.DataBindXY(xvalues.ToArray(), yvalues.ToArray()); return(sectionReport); case "Page": var pageReport = new PageReport(new FileInfo(Server.MapPath("~/Reports/OrderDetailsReport.rdlx"))); pageReport.Document.LocateDataSource += delegate(object sender, LocateDataSourceEventArgs args) { args.Data = Repository.GetDetails(data[1]); }; return(pageReport); } return(base.OnCreateReportHandler(reportPath)); }
private void DisplayErrorCollection(PageReport report) { StringBuilder sb = new StringBuilder(); string fmt = Resources.GetString(ResourceTokens.ExportErrorsInPage); string shapeFmt = Resources.GetString(ResourceTokens.ExportShapeError); sb.AppendFormat(fmt, report.Errors.Count, report.Page.Name); foreach (ShapeError e in report.Errors) { if (null != e.ShapeHandler) { sb.AppendFormat(shapeFmt, Truncate(e.ShapeHandler.Text.Replace('\n', ' ')), e.Message); } else { sb.Append(e.Message); sb.Append("\n\r"); } } ESIMessageBox.ShowError(sb.ToString()); }
private void ShowReport(PageReport report, bool isExporting) { if (report.Processed == false) { string s = Resources.GetString(ResourceTokens.ExportPageNotMidgard); ESIMessageBox.ShowError(s); } else if (report.Errors.Count == 0) { string s; if (isExporting) { s = Resources.GetString(ResourceTokens.ExportPageOk); } else { s = Resources.GetString(ResourceTokens.ValidatePageOk); } ESIMessageBox.Show(s); } else { DisplayErrorCollection(report); } }
private void RenderPdf(StreamProvider streams, Action <StreamProvider> postAction) { var reportPath = Path.Combine(ReportsPath, (string)reports.SelectedItem); var pdfSettings = (ISettings)propertyGrid.SelectedObject; var export = radioButton1.Checked ? _arPdf : _sharpPdf; Cursor = Cursors.WaitCursor; Enabled = false; var thread = new Thread(_ => { try { using (var report = new PageReport(new FileInfo(reportPath))) report.Document.Render(export, streams, pdfSettings.GetSettings()); postAction(streams); } catch (Exception ex) { BeginInvoke( new MethodInvoker(() => { MessageBox.Show(this, string.Format(Resources.ErrorMessage, ex.Message), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); })); } finally { BeginInvoke(new MethodInvoker(() => { Enabled = true; })); BeginInvoke(new MethodInvoker(() => { Cursor = Cursors.Default; })); } }); thread.Start(); }
private void PrintBarcode(int repid) { try { PageReport rpt = new PageReport(); rpt.Load(new FileInfo("reg\\doc\\barcode.rdlx")); rpt.Report.DataSources[0].ConnectionProperties.ConnectString = KontoGlobals.sqlConnectionString.ConnectionString; GrapeCity.ActiveReports.Document.PageDocument doc = new GrapeCity.ActiveReports.Document.PageDocument(rpt); doc.Parameters["reportid"].CurrentValue = repid; var frm = new KontoRepViewer(doc); frm.Text = "Print"; var _tab = this.Parent.Parent as TabControlAdv; if (_tab == null) { return; } var pg1 = new TabPageAdv(); pg1.Text = "Barcode Print"; _tab.TabPages.Add(pg1); _tab.SelectedTab = pg1; frm.TopLevel = false; frm.Parent = pg1; frm.Location = new System.Drawing.Point(pg1.Location.X + pg1.Width / 2 - frm.Width / 2, pg1.Location.Y + pg1.Height / 2 - frm.Height / 2); frm.Show();// = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); Log.Error(ex, "print barcode"); } }
// Loads and shows the report. private void btnCSV_Click(object sender, EventArgs e) { const string settingForNoHeaderDelimited = "ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued"; var connectionString = string.Empty; if (rbtnNoHeaderComma.Checked) { connectionString = string.Format(@"Path={0};Encoding={1};TextQualifier="";ColumnsSeparator=,;RowsSeparator=\r\n;Columns={2}", Properties.Resources.PathToFileNoHeaderComma, Properties.Resources.CSVEncoding, settingForNoHeaderDelimited); } else if (rbtnHeaderTab.Checked) { connectionString = string.Format(@"Path={0};Encoding={1};TextQualifier="";ColumnsSeparator= ;RowsSeparator=\r\n;HasHeaders=True", Properties.Resources.PathToFileHeaderTab, Properties.Resources.CSVEncoding); } else if (rbtnHeader.Checked) { connectionString = string.Format(@"Path={0};Encoding={1};Columns={2};HasHeaders=True", Properties.Resources.PathToFileHeader, Properties.Resources.CSVEncoding, _settingForHeaderExistsFixed); } else if (rbtnNoHeader.Checked) { connectionString = string.Format(@"Path={0};Encoding={1};Columns={2}", Properties.Resources.PathToFileNoHeader, Properties.Resources.CSVEncoding, _settingForNoHeaderFixed); } var report = new PageReport(new FileInfo(@"..\..\Reports\StockList.rdlx")); var connectionProps = report.Report.DataSources[0].ConnectionProperties; connectionProps.DataProvider = "CSV"; connectionProps.ConnectString = connectionString; arvMain.ReportViewer.LoadDocument(report.Document); }
/// <summary> /// </summary> /// <param name="fromDateTime"></param> /// <param name="toDateTime"></param> private void ImportDataByTime(DateTime?fromDateTime, DateTime toDateTime) { IList <PageReport> PageReportLogs = new List <PageReport>(); var predicate = PredicateBuilder.True <UserBehavior>(); predicate = predicate.And(x => x.CreatedTime <= toDateTime && x.CreatedTime > fromDateTime); //predicate = predicate.And(x =>x.Url!=""&& x.Url!=null); //predicate = predicate.And(x => x.ContentType != 9); predicate = predicate.And(x => x.ContentType == 0); var logs = userBehaviorService.Repository.Entities.Where(predicate).ToList();//.AsParallel(); logs.GroupBy(x => x.FunctionId).ToList().ForEach( appGroup => appGroup.GroupBy(x => x.CreatedTime.Date).ToList().ForEach(appAccess => { var appAccessAction = appAccess.FirstOrDefault(); if (appAccessAction == null) { return; } var entity = new PageReport { Appid = appAccessAction.AppId, PageUrl = appAccessAction.FunctionId, AccessDate = appAccessAction.CreatedTime.Date, CreatedDate = DateTime.Now, VisitTimes = appAccess.Count(), VisitorCount = appAccess.GroupBy(x => x.UserId).Count() }; PageReportLogs.Add(entity); })); PageReportService.Repository.Insert(PageReportLogs.AsEnumerable()); }
//This section creates the Layout of the PageReport //It adds a Table to the report body //It adds the TableRows and TableColumns and TableCells //It adds Textbox reportitems to the TaleCells public static PageReport BuildReportLayout() { PageReport report = new PageReport(); report.Report.Body.Height = "5cm"; report.Report.Width = "20cm"; //Creating a Table reportitem Table table = new Table(); table.Name = "Table1"; //Creating the rows,columns as well as TableCells for the table as well as TextBoxes to be placed within the Table Cells TextBox[] tableTextBoxes = new TextBox[6]; TableCell[] tableCells = new TableCell[6]; TableRow[] tableRows = new TableRow[2]; TableColumn[] tableColumns = new TableColumn[3]; String[] textBoxValues = new String[] { Properties.Resources.TitleValue, Properties.Resources.YearReleasedValue, Properties.Resources.MPAAValue, Properties.Resources.TitleField, Properties.Resources.YearReleasedField, Properties.Resources.MPAAField }; String[] columnsWidth = new String[] { "9cm", "4.6cm", "5.3cm" }; String[] rowsHeight = new String[] { "1.5cm", "1.5cm" }; //Setting properties for the Textboxes to be placed in the TableCells for (int i = 0; i < tableTextBoxes.Length; i++) { tableTextBoxes.SetValue(new TextBox(), i); tableTextBoxes[i].Name = "textBox" + (i + 1); tableTextBoxes[i].Value = ExpressionInfo.FromString(textBoxValues[i]); tableTextBoxes[i].Style.PaddingBottom = tableTextBoxes[i].Style.PaddingLeft = tableTextBoxes[i].Style.PaddingRight = tableTextBoxes[i].Style.PaddingTop = ExpressionInfo.FromString("2pt"); tableTextBoxes[i].Style.TextAlign = ExpressionInfo.FromString("Left"); tableCells.SetValue(new TableCell(), i); tableCells[i].ReportItems.Add(tableTextBoxes[i]); //Adding the TextBoxes to the TableCells if (i < rowsHeight.Length) { tableRows.SetValue(new TableRow(), i); tableRows[i].Height = "1.25cm"; table.Height += "1.25cm"; } if (i < columnsWidth.Length) { tableColumns.SetValue(new TableColumn(), i); tableColumns[i].Width = columnsWidth[i]; table.Width += columnsWidth[i]; table.TableColumns.Add(tableColumns[i]); tableCells[i].ReportItems[0].Style.BackgroundColor = ExpressionInfo.FromString("LightBlue"); tableRows[0].TableCells.Add(tableCells[i]); } else { tableCells[i].ReportItems[0].Style.BackgroundColor = ExpressionInfo.FromString("=Choose((RowNumber(\"Table1\") +1) mod 2, \"PaleGreen\",)"); tableRows[1].TableCells.Add(tableCells[i]); } } table.Header.TableRows.Add(tableRows[0]); table.Details.TableRows.Add(tableRows[1]); table.Top = "1cm"; table.Left = "0.635cm"; report.Report.Body.ReportItems.Add(table); return(report); }
// Loads and shows the report. private void MainForm_Load(object sender, EventArgs e) { FileInfo rptPath = new FileInfo(@"..\..\ObjectsReport.rdlx"); PageReport pageReport = new PageReport(rptPath); pageReport.Document.LocateDataSource += new LocateDataSourceEventHandler(OnLocateDataSource); reportPreview.LoadDocument(pageReport.Document); }
// Loads and shows the report. private void ViewerForm_Load(object sender, EventArgs e) { var rptPath = new FileInfo(@"..\..\Invoice2.rdlx"); var definition = new PageReport(rptPath); definition.Document.LocateDataSource += new LocateDataSourceEventHandler(OnLocateDataSource); arvMain.LoadDocument(definition.Document); }
private Report(PageReport report) { _report = report ?? throw new ArgumentNullException(nameof(report)); //_report.Document.LocateDataSource += Document_LocateDataSource; //_report.Document.LocateCredentials += Document_LocateCredentials; this.Parameters = new ReportParameterCollection(_report.Report.ReportParameters); this.Type = report.Report.Body.ReportItems.Count > 0 && report.Report.Body.ReportItems[0].GetReportItemTypeName() == "FixedPage" ? "FPL" : "CPL"; }
// Loads and shows the report. private void MainForm_Load(object sender, EventArgs e) { var rptPath = new FileInfo(@"..\..\testReport.rdlx"); var definition = new PageReport(rptPath); definition.Document.LocateDataSource += OnLocateDataSource; reportPreview.ReportViewer.LoadDocument(definition.Document); }
public MainForm() { InitializeComponent(); var rptPath = new FileInfo(_path); _pageReport = new PageReport(rptPath); _pageReport.Document.LocateDataSource += OnLocateDataSource; comboBox1.SelectedIndex = 0; }
//This section loads the PageReport object created earlier to a Stream public static MemoryStream LoadReportToStream(PageReport report) { string rpt = report.ToRdlString(); byte[] data = Encoding.UTF8.GetBytes(rpt); MemoryStream stream = new MemoryStream(data); return(stream); }
private void Setting_CheckedChanged(object sender, EventArgs e) { RadioButton rbtn = sender as RadioButton; if (rbtn.Checked == true) { if (m_LastSettingPage != null) { this.tlpSettingBase.Controls.RemoveAt(2); m_LastSettingPage.Dispose(); m_LastSettingPage = null; } switch (rbtn.Name) { case string rbtnName when rbtnMachine.Name == rbtnName: PageMachine pMachine = new PageMachine(); pMachine.Setup(); m_LastSettingPage = pMachine; break; case string rbtnName when rbtnCar.Name == rbtnName: PageCars pCars = new PageCars(); pCars.Setup(); m_LastSettingPage = pCars; break; case string rbtnName when rbtnUser.Name == rbtnName: PageUser pUser = new PageUser(); pUser.Setup(); m_LastSettingPage = pUser; break; case string rbtnName when rbtnBackup.Name == rbtnName: PageBackup pBackup = new PageBackup(); pBackup.Setup(); m_LastSettingPage = pBackup; break; case string rbtnName when rbtnReport.Name == rbtnName: PageReport pReport = new PageReport(m_Machine); pReport.Setup(); m_LastSettingPage = pReport; break; case string rbtnName when rbtnPrinter.Name == rbtnName: PagePrinterSetting pPrinter = new PagePrinterSetting(); pPrinter.Setup(); m_LastSettingPage = pPrinter; break; } tlpSettingBase.Controls.Add(m_LastSettingPage, 2, 0); m_LastSettingPage.Dock = DockStyle.Fill; } }
public ImageLocatorService(IReport parentReport) { if (parentReport == null) { Debug.Fail("Unable to get the parent report for calendar report item"); return; } _parentPageReport = parentReport.GetService(typeof(PageReport)) as PageReport; InitializeServices(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var reportFile = new FileInfo(@"..\..\..\..\Report\Svg.rdlx"); var report = new PageReport(reportFile); var document = new PageDocument(report); viewer1.LoadDocument(document); }
private void PDFDigitalSignature_Load(object sender, EventArgs e) { //Set the default for in the 'Signature Format' combo box. cmbVisibilityType.SelectedIndex = 3; var pageReport = new PageReport(); _pageDocument = pageReport.Document; pageReport.Load(new FileInfo("..//..//..//..//Report//Catalog.rdlx")); arvMain.LoadDocument(_pageDocument); }
/// <summary> /// 功能:导出Excel非表格 /// 作者:付强 /// 日期:2013年7月9日 /// </summary> /// <param name="fileName">要保存的文件路径及名称</param> /// <param name="reportSource">数据源</param> private void ExportExcel(string fileName, PageReport reportSource) { Microsoft.Office.Interop.Excel._Application xlsApp = new ApplicationClass(); if (xlsApp == null) { return; } Workbook xlsBook = xlsApp.Workbooks.Add(true); Worksheet xlSheet = (Worksheet)xlsBook.Worksheets[1]; xlSheet.Cells[1, 1] = reportSource.ReportName; Range range = xlSheet.get_Range(xlsApp.Cells[1, 1], xlsApp.Cells[1, 11]); range.MergeCells = true; range.Font.Size = 24; range.Font.Bold = true; range.HorizontalAlignment = XlHAlign.xlHAlignCenter; for (int i = 0; i < reportSource.RowReports.Length; i++) { RowReport item = reportSource.RowReports[i] as RowReport; if (!string.IsNullOrEmpty(item.Field)) { xlSheet.Cells[(i + 1) * 2, 1] = reportSource.RowReports[i].ToString(); range = (Microsoft.Office.Interop.Excel.Range)xlSheet.Cells[i + 2, 1]; range.Interior.ColorIndex = 15; range.Font.Bold = true; range.HorizontalAlignment = XlHAlign.xlHAlignRight; range.Borders.LineStyle = XlLineStyle.xlLineStyleNone; range = xlSheet.get_Range(xlsApp.Cells[(i + 1) * 2, 1], xlsApp.Cells[(i + 2) * 2 - 1, 1]); range.MergeCells = true; range = xlSheet.get_Range(xlsApp.Cells[i + 2, 2], xlsApp.Cells[i + 2, 11]); range.MergeCells = true; range.Font.Underline = true; range = xlSheet.get_Range(xlsApp.Cells[(i + 1) * 2, 2], xlsApp.Cells[(i + 2) * 2 - 1, 11]); range.MergeCells = true; range.Font.Underline = true; if (!string.IsNullOrEmpty(item.RightContent)) { xlSheet.Cells[(i + 1) * 2, 12] = item.RightContent; range = xlSheet.get_Range(xlsApp.Cells[(i + 1) * 2, 12], xlsApp.Cells[(i + 2) * 2 - 1, 13]); range.HorizontalAlignment = item.ContentAlignment; } } } xlsBook.Saved = true; xlsBook.SaveCopyAs(fileName); }
private static Stream SaveReportToStream(PageReport def) { MemoryStream stream = new MemoryStream(); using (XmlWriter writer = XmlWriter.Create(stream)) { def.Save(writer); } stream.Position = 0; return(stream); }
/// <summary> /// Loads and returns a <see cref="PageReport"/> for the specified rdl filename. /// </summary> /// <param name="rdlFileName">The name of the rdl file. The filename should be relative to the <see cref="TestSettings.RDLDirectory"/>.</param> /// <returns>The specified <see cref="PageReport"/>.</returns> public static PageReport GetPageReport(string rdlFileName) { FileInfo rdlFile = GetRdlFile(rdlFileName); if (rdlFile != null) { PageReport reportDef = new PageReport(rdlFile); return(reportDef); } return(null); }
private bool IsFpl(string reportFile) { using (var pageReport = new PageReport(new FileInfo(Path.Combine(ReportsPath, reportFile)))) { var report = pageReport.Report; if (report == null || report.Body == null) { return(false); } var items = report.Body.ReportItems; return(items != null && items.Count == 1 && items[0] is FixedPage); } }
public void ProcessRequest(HttpContext context) { if (!context.Request.Url.AbsolutePath.EndsWith(HandlerExtension)) { if (!context.Request.Url.AbsolutePath.EndsWith(HandlerCacheExtension)) { return; } // return image var keyName = Path.GetFileName(context.Request.FilePath); var cacheItem = context.Cache[keyName]; context.Response.BinaryWrite((byte[])cacheItem); return; } context.Response.ContentType = "text/html"; var streams = new HtmlStreamProvider(); try { using (var report = new PageReport(new FileInfo(context.Server.MapPath(context.Request.Url.LocalPath)))) { var html = new HtmlRenderingExtension(); var settings = (Settings)html.GetSupportedSettings(); settings.StyleStream = false; settings.OutputTOC = false; settings.Mode = RenderMode.Paginated; report.Document.Render(html, streams, ((ISettings)settings).GetSettings()); } foreach (var secondaryStreamInfo in streams.GetSecondaryStreams()) { var secondaryStream = (MemoryStream)secondaryStreamInfo.OpenStream(); // 30 seconds should be enough to load all images context.Cache.Insert(secondaryStreamInfo.Uri.OriginalString, secondaryStream.ToArray(), null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, 30)); } } catch (ReportException eRunReport) { // Failure running report, just report the error to the user. context.Response.Write(Properties.Resource.Error); context.Response.Write(eRunReport.ToString()); return; } var primaryStream = (MemoryStream)streams.GetPrimaryStream().OpenStream(); context.Response.BinaryWrite(primaryStream.ToArray()); }
private void ReportsForm_Load(object sender, EventArgs e) { PageReport report = LayoutBuilder.BuildReportLayout(); //Loading the layout to a PageReport object report = LayoutBuilder.AddDataSetDataSource(report); //Adding DataSources to the PageReport object MemoryStream reportStream = LayoutBuilder.LoadReportToStream(report); //Loading the PageReport object to a stream reportStream.Position = 0; //Loading the stream to the designer via a XmlReader reportDesigner.LoadReport(XmlReader.Create(reportStream), DesignerReportType.Page);//Loading the stream to the designer report.Dispose(); reportStream.Dispose(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SetupTemplates(); WizardDialog wizard = CreateWizard(); Application.Run(wizard); if (wizard.DialogResult == DialogResult.OK) { PageReport def = LayoutBuilder.BuildReport(state); ReportsForm frm = new ReportsForm(def); Application.Run(frm); } }
private PageReport DoPageValidation(Page page, string mode, out Dictionary<IShapeHandler, Shape> mapping, out List<IShapeHandler> webPages, out List<IShapeHandler> transitions) { PageReport report = new PageReport(page); Hashtable shapeHandlers = new Hashtable(); Hashtable fromConns = new Hashtable(); Hashtable toConns = new Hashtable(); mapping = new Dictionary<IShapeHandler, Shape>(); webPages = new List<IShapeHandler>(); transitions = new List<IShapeHandler>(); try { int processedShapes = 0; /* * Iterate through all the shapes in the current page, generating * the overall graph of the shapes. This effectively preloads all * of the information into memory. */ #region Preloading, Construct Graph foreach (Shape shape in page.Shapes) { string progressMessage = string.Format("Page: {0}, Shape: {1}, scanning...", page.Name, shape.Name); OnStartStep(progressMessage); string shapeName = VisioUtils.GetProperty(shape, "User", "Midgard"); if (shapeName == null) { OnEndStep("skip"); continue; } processedShapes++; IShapeHandler shapeHandler = GetShapeHandler(shapeHandlers, shape, shapeName, mode); mapping.Add(shapeHandler, shape); if ("transition" == shapeHandler.Element && 2 <= shape.Connects.Count) { SetShapeConn(fromConns, shape.Connects[1].ToCell.Shape, shapeHandler); SetShapeConn(toConns, shape.Connects[2].ToCell.Shape, shapeHandler); } OnEndStep("ok."); } /* * If no processable shapes have been encountered, then reset the * processed bit to false and quit early... */ if (processedShapes == 0) { report.Processed = false; _currentStep += page.Shapes.Count; return report; } #endregion #region Connections Validation (client side) foreach (IShapeHandler h in shapeHandlers.Values) { ShapeError error; OnStartStep(string.Format("A validar localmente a shape {0}", h.Text.Replace('\n', ' '))); switch (h.Element) { case "transition": error = h.Validate(shapeHandlers); transitions.Add(h); break; default: ArrayList from = (ArrayList)fromConns[h.VisioShape]; ArrayList to = (ArrayList)toConns[h.VisioShape]; error = h.Validate(new object[] { from, to }); webPages.Add(h); break; } if (error != null) report.Errors.Add(error); } /* * Contains errors: abort! || only clientValidation */ if (report.Errors.Count > 0) { _currentStep += page.Shapes.Count; return report; } if (0 == shapeHandlers.Count) { report.Errors.Add(new ShapeError(Resources.GetString(ResourceTokens.NoDiagram))); return report; } #endregion Connections Validation (client side) #region Data Validation (server side) if (report.Errors.Count > 0) { _currentStep += page.Shapes.Count; return report; } #endregion Data Validation (server side) } catch (Exception e) { report.Errors.Add(new ShapeError(e.StackTrace)); } finally { /* * Avoid maintaining a reference to Interop COM objects. Release * all of the content of the graph to avoid memory leaks. */ foreach (IShapeHandler h in shapeHandlers.Values) { (h as IDisposable).Dispose(); } shapeHandlers.Clear(); fromConns.Clear(); toConns.Clear(); } return report; }