/// <summary> /// Main entry point for the application. /// </summary> /// <param name="dbp">The Diagram Buildin g Properties.</param> /// <param name="worker">The worker.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> /// <returns></returns> //public string GenerateDiagram(string connectionName, List<string> entities, RetrieveAllEntitiesResponse response, int selectedDiagramEntityLabelIndex, BackgroundWorker worker, DoWorkEventArgs e) public string GenerateDiagram(DiagramBuildingProperties dbp, BackgroundWorker worker, DoWorkEventArgs e) { String filename = String.Empty; VisioApi.Application application; VisioApi.Document document; DiagramBuilder builder = new DiagramBuilder(); try { // Load Visio and create a new document. application = new VisioApi.Application(); application.Visible = false; // Not showing the UI increases rendering speed builder.VersionName = application.Version; document = application.Documents.Add(String.Empty); builder._application = application; builder._document = document; builder._metadataResponse = dbp.environmentStructure; builder.selectedEntitiesNames = dbp.entities; builder.dbp = dbp; // Diagram all entities if given no command-line parameters, otherwise diagram // those entered as command-line parameters. builder.BuildDiagram(dbp.entities, worker, e); filename = "EntitesStructure\\Diagrams.vsd"; // Save the diagram in the current directory using the name of the first // entity argument or "AllEntities" if none were given. Close the Visio application. document.SaveAs(Directory.GetCurrentDirectory() + "\\" + filename); application.Quit(); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } catch (System.Exception) { throw; } return(filename); }
/// <summary> /// Main entry point for the application. /// </summary> /// <param name="connectionName">Name of the connection.</param> /// <param name="entities">The entities.</param> /// <param name="response">The response.</param> /// <param name="worker">The worker.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> /// <returns></returns> public string GenerateDiagram(string connectionName, List<string> entities, RetrieveAllEntitiesResponse response, BackgroundWorker worker, DoWorkEventArgs e) { String filename = String.Empty; VisioApi.Application application; VisioApi.Document document; DiagramBuilder builder = new DiagramBuilder(); try { // Load Visio and create a new document. application = new VisioApi.Application(); application.Visible = false; // Not showing the UI increases rendering speed document = application.Documents.Add(String.Empty); builder._application = application; builder._document = document; builder._metadataResponse = response; builder.selectedEntitiesNames = entities; // Diagram all entities if given no command-line parameters, otherwise diagram // those entered as command-line parameters. builder.BuildDiagram(entities, String.Join(", ", entities), worker, e); filename = "EntitesStructure\\Diagrams.vsd"; // Save the diagram in the current directory using the name of the first // entity argument or "AllEntities" if none were given. Close the Visio application. document.SaveAs(Directory.GetCurrentDirectory() + "\\" + filename); application.Quit(); } catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { throw; } catch (System.Exception) { throw; } return filename; }