URL/Webpage Memory Leak and Error

When using the dashboard we find the first two have no issues but the “GOLD Documents” throws an error after clicking the “download” control.

We initially tried the browser within a customization but found that it created a memory leak. I’ve also noticed that the “download” control actually functions as intended displaying the ability to ‘Open’ or ‘Save’ the item. Preferred is the customization route but open to using the dashboard if we can get past the errors.

// **************************************************
// Custom code for PartAdvisorForm
// Created: 3/2/2022 10:15:38 AM
// **************************************************

extern alias Erp_Contracts_BO_PartAdvisor;
extern alias Erp_Contracts_BO_Part;
extern alias Ice_Core_Session;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
               // ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
               // Begin Wizard Added Module Level Variables **

               // End Wizard Added Module Level Variables **

               // Add Custom Module Level Variables Here **

               private System.Windows.Forms.WebBrowser wbSite;   
               private EpiDataView edvPartView;

               private System.Windows.Forms.WebBrowser wbSite2; 
               private EpiDataView edvPartView2;

               private System.Windows.Forms.WebBrowser wbSite3; 
               private EpiDataView edvPartView3;
               
               public void InitializeCustomCode()
               {
                               // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
                               // Begin Wizard Added Variable Initialization

                               // End Wizard Added Variable Initialization

                               // Begin Wizard Added Custom Method Calls

                               // End Wizard Added Custom Method Calls

                               this.edvPartView = ((EpiDataView)(this.oTrans.EpiDataViews["PartView"]));
                               this.edvPartView.EpiViewNotification += new EpiViewNotification(this.edvPartView_EpiViewNotification);

                               this.edvPartView2 = ((EpiDataView)(this.oTrans.EpiDataViews["PartView"]));
                               this.edvPartView2.EpiViewNotification += new EpiViewNotification(this.edvPartView_EpiViewNotification);

                               this.edvPartView3 = ((EpiDataView)(this.oTrans.EpiDataViews["PartView"]));
                               this.edvPartView3.EpiViewNotification += new EpiViewNotification(this.edvPartView_EpiViewNotification);

               }

               public void SetupBrowser(string partNum)
               {
                               grpBrws.Controls.Remove(wbSite);
                               grpBrws.Dock = System.Windows.Forms.DockStyle.Fill;
                               wbSite = new System.Windows.Forms.WebBrowser();
                               wbSite.Dock = System.Windows.Forms.DockStyle.Fill;
                               wbSite.Location = new System.Drawing.Point(0,0);
                               wbSite.MinimumSize = new System.Drawing.Size(20,20);
                               wbSite.Name = "wbSite";
                               wbSite.Size = new System.Drawing.Size(560,323);
                               wbSite.TabIndex = 0;
                               wbSite.ScriptErrorsSuppressed = true;
                               grpBrws.Controls.Add(wbSite);
                               wbSite.Navigate("http://gold/ExternalPages/External_DocumentExplorer.aspx?Part=" + partNum);
               }

               public void SetupBrowser2(string partNum)
               {
                               grpBrws2.Controls.Remove(wbSite2);
                               grpBrws2.Dock = System.Windows.Forms.DockStyle.Fill;
                               wbSite2 = new System.Windows.Forms.WebBrowser();
                               wbSite2.Dock = System.Windows.Forms.DockStyle.Fill;
                               wbSite2.Location = new System.Drawing.Point(0,0);
                               wbSite2.MinimumSize = new System.Drawing.Size(20,20);
                               wbSite2.Name = "wbSite2";
                               wbSite2.Size = new System.Drawing.Size(560,323);
                               wbSite2.TabIndex = 0;
                               wbSite2.ScriptErrorsSuppressed = true;
                               grpBrws2.Controls.Add(wbSite2);

                               Ice.Core.Session ss=(Ice.Core.Session)PartAdvisorForm.Session;
                               string user = ss.EmployeeID;

                               wbSite2.Navigate("http://gold/ExternalPages/External_DocumentUploader.aspx?Part=" + partNum + "&UserID=" + user);
               }

               public void SetupBrowser3(string partNum)
               {
                               grpBrws3.Controls.Remove(wbSite3);
                               grpBrws3.Dock = System.Windows.Forms.DockStyle.Fill;
                               wbSite3 = new System.Windows.Forms.WebBrowser();
                               wbSite3.Dock = System.Windows.Forms.DockStyle.Fill;
                               wbSite3.Location = new System.Drawing.Point(0,0);
                               wbSite3.MinimumSize = new System.Drawing.Size(20,20);
                               wbSite3.Name = "wbSite3";
                               wbSite3.Size = new System.Drawing.Size(560,323);
                               wbSite3.TabIndex = 0;
                               wbSite3.ScriptErrorsSuppressed = true;
                               grpBrws3.Controls.Add(wbSite3);

                               Ice.Core.Session ss=(Ice.Core.Session)PartAdvisorForm.Session;
                               string user = ss.EmployeeID;

                               wbSite3.Navigate("http://gold/ExternalPages/External_ChangeRequest.aspx?Part=" + partNum + "&UserID=" + user);
               }

               private void edvPartView_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
               {
                               // ** Argument Properties and Uses **
                               // view.dataView[args.Row]["FieldName"]
                               // args.Row, args.Column, args.Sender, args.NotifyType
                               // NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView,     NotifyType.InitAndResetTreeNodes
                               if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
                               {
                                               if ((args.Row > -1))
                                               {              
                                                               string partNum = view.dataView[view.Row]["PartNum"].ToString();
                                                               SetupBrowser(partNum);
                                                               SetupBrowser2(partNum);
                                                               SetupBrowser3(partNum);
                                               }
                               }
               }
                               

               public void DestroyCustomCode()
               {
                               // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
                               // Begin Wizard Added Object Disposal

                               // End Wizard Added Object Disposal

                               // Begin Custom Code Disposal

                               // End Custom Code Disposal
               }

}


Dashboard Error2
Dashboard Error1

Beginner level user, relying heavily on Epiwidgets in BAQs and BPMs. I do have a programming duo that helps me out quite a bit but we seem to have no luck on this one. Hoping one of you can help guide us in the right direction. Thank you in advance for your time!

@Chris_Conn, @josecgomez, @Mark_Wonsil, @timshuwy, @ckrusen, @Banderson, @NateS

I am not very versed in using the dyn webbrowser.

I am a little confused as to why we pulled 3 different instances of the same edv though.
Seems like you just wired 3 identical events to the same edv.

Also, is it intended to apply EmpID as UserID?

Each edv leads to a different webpage (wbSite, wbSite2, wbSite3). We need EmpID for the webpage and the user action (on the webpage) gets recorded in another database separate from Epicor.

But each edv is the same edv. The code above ran for each part view, just gets the same part view reference.

It just feels like initialize isnt the ideal place to set those browsers up. Is that actually loading webpages on row init? Just a half-cocked idea, I think I would prefer to use a single edv ref. Add a column for those 3 actions that is an icon and then handle the webpage stuff on click.

2 Likes

Thank you @Chris_Conn. I will give that a shot!