View Single Post
 
Old 04-25-2022, 07:27 AM
sytec sytec is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2022
Posts: 6
sytec is on a distinguished road
Default Why Visio VSTO can't add DataRecordsets after 10 sec. of execution?

Hello.
Why Visio VSTO can't add DataRecordsets after 10 sec. of execution?
I have this method in Visio VSTO:
private void btnDrawStructure_Click(object sender, EventArgs e)
{
Application.DoEvents();
this.Hide();
Application.DoEvents();
this.DialogResult = DialogResult.Cancel;
Application.DoEvents();
ThisAddIn.dontShowTasks = chbDontShowTasks.Checked;
Utils.GetProjSite(ThisAddIn.selectedProjectGuid.To String().ToUpper());
byte[] FileContent = Utils.GenerateExcelFromData();
string uploadedFileToSharePointPath = Utils.UploadFileToSharePoint(Consts.SiteBaseUrl + ThisAddIn.projectSite + @"/", Consts.DocumentLibrary, Consts.ClientSubFolder, Consts.FileName, FileContent);
Utils.DrawStructure();
}
and all methods before last (DrawStructure) execute about 9.5 secs. (I can add DataRecordsets in Utils.DrawStructure),
but if i add one method after Utils.GetProjSite (about 1 sec of execution), all methods before last (DrawStructure) execute about 10.5 secs and I can't add DataRecordsets in Utils.DrawStructure method
The problem is if I have this code:
private void btnDrawStructure_Click(object sender, EventArgs e)
{
Application.DoEvents();
this.Hide();
Application.DoEvents();
this.DialogResult = DialogResult.Cancel;
Application.DoEvents();
ThisAddIn.dontShowTasks = chbDontShowTasks.Checked;
Utils.GetProjSite(ThisAddIn.selectedProjectGuid.To String().ToUpper());
Utils.GetProjManager(ThisAddIn.selectedProjectGuid .ToString().ToUpper());
byte[] FileContent = Utils.GenerateExcelFromData();
string uploadedFileToSharePointPath = Utils.UploadFileToSharePoint(Consts.SiteBaseUrl + ThisAddIn.projectSite + @"/", Consts.DocumentLibrary, Consts.ClientSubFolder, Consts.FileName, FileContent);
Utils.DrawStructure();
}
The method DrawStructure constant in both cases:
public static void DrawStructure()
{
try
{
Globals.ThisAddIn.Application.ActiveWindow.Close() ;
Globals.ThisAddIn.Application.Documents.Add("ORGCH _M.VSTX");
Visio.Document visioStencil = Globals.ThisAddIn.Application.Documents.OpenEx("WB S 2.0.VSSX", (short)Visio.VisOpenSaveArgs.visOpenDocked);
Visio.Documents visioDocs = Globals.ThisAddIn.Application.Documents;
Visio.Page visioPage = Globals.ThisAddIn.Application.ActivePage;
SetOrientationToLandscape(visioPage);
Visio.DataRecordset vsoDataRecordset;
string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" +
@"Data Source=\" + Consts.projectServer + @"@SSL\DavWWWRoot\PWA" + ThisAddIn.projectSite.Replace(@"PWA/", @"") + @"\Shared Documents" + Consts.ClientSubFolder + @"" + Consts.FileName + @";" +
@"Extended Properties=""Excel 12.0 Xml; HDR = YES"";" +
@"Persist Security Info=False;";
string strCommand = "SELECT * FROM [Sheet1$]";
vsoDataRecordset = Globals.ThisAddIn.Application.ActiveDocument.DataR ecordsets.Add(strConnection, strCommand, 0, "PrjStruct");
...
Reply With Quote