Vantage 8.03.409C: System.Threading and BO

I am not understanding how to utilize this bit of code. I used your suggestion of the free internet C#toVB converter tools and got back this, obviously replacing the YOURFORM with UD01Form:

YOURFORM.Invoke(DirectCast(Function() Do

' CD 7/11/2012

' Changed rows to 5 for testing.

' TODO: Set rows=grdJobs.Rows.Count after testing is done.

pbProgress.Maximum = rows
pbProgress.Minimum = 0
pbProgress.Value = 0
pbProgress.[Step] = 1
End Function, ThreadStart))

So am I suppose to take my function that I want the Thread.Start to be associated with and place it in the location that covers "Function()" through to "End Function"? It is not working for me. I am getting a number of errors.



-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Wednesday, August 15, 2012 11:12 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

You can update the UI you just have to do it Thread Safe

YOURFORM.Invoke((ThreadStart)delegate()
{

// CD 7/11/2012

// Changed rows to 5 for testing.

// TODO: Set rows=grdJobs.Rows.Count after testing is done.

pbProgress.Maximum=rows;
pbProgress.Minimum=0;
pbProgress.Value=0;
pbProgress.Step=1;
});


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*
Has anyone used threading with Business Objects? I am trying to use it to spawn a thread for a method that takes 5 minutes. I am utilizing the DynamicQueryAdapter in my method.

the strange thing is that I can call the BOConnect(), GetByID(), AddWhereItem() and Update methods, but when I try to call the Execute method it crashes.

Does anyone have any thoughts and/or ideas on this?

Dan
I've done it several times, how are you doing it? You can't update UI items
from a thread, so if its updating UI that's where your crash is happening
your best bet is to instanciate a new BO do your stuff and then refresh the
UI once its donre.l

*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...> wrote:

> **
>
>
> Has anyone used threading with Business Objects? I am trying to use it to
> spawn a thread for a method that takes 5 minutes. I am utilizing the
> DynamicQueryAdapter in my method.
>
> the strange thing is that I can call the BOConnect(), GetByID(),
> AddWhereItem() and Update methods, but when I try to call the Execute
> method it crashes.
>
> Does anyone have any thoughts and/or ideas on this?
>
> Dan
>
>
>


[Non-text portions of this message have been removed]
What I am doing is calling a BAQ and then adding two where clauses for the PartNum and RevisionNum. I then execute the BAQ. This is all done with local parameters inside of the method that I delegate for the thread. Should I set the DynamicQueryAdapter object as global so that it is owned by the Form?

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Tuesday, August 14, 2012 2:39 PM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

I've done it several times, how are you doing it? You can't update UI items from a thread, so if its updating UI that's where your crash is happening your best bet is to instanciate a new BO do your stuff and then refresh the UI once its donre.l

*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...> wrote:

> **
>
>
> Has anyone used threading with Business Objects? I am trying to use it
> to spawn a thread for a method that takes 5 minutes. I am utilizing
> the DynamicQueryAdapter in my method.
>
> the strange thing is that I can call the BOConnect(), GetByID(),
> AddWhereItem() and Update methods, but when I try to call the Execute
> method it crashes.
>
> Does anyone have any thoughts and/or ideas on this?
>
> Dan
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
You shouldn't need to. What is the error you're receiving? If you stick
your code up here it will likely help a lot.

On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> What I am doing is calling a BAQ and then adding two where clauses for the
> PartNum and RevisionNum. I then execute the BAQ. This is all done with
> local parameters inside of the method that I delegate for the thread.
> Should I set the DynamicQueryAdapter object as global so that it is owned
> by the Form?
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of Jose Gomez
> Sent: Tuesday, August 14, 2012 2:39 PM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> I've done it several times, how are you doing it? You can't update UI
> items from a thread, so if its updating UI that's where your crash is
> happening your best bet is to instanciate a new BO do your stuff and then
> refresh the UI once its donre.l
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez
> >
> <http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
> On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...> wrote:
>
> > **
> >
> >
> > Has anyone used threading with Business Objects? I am trying to use it
> > to spawn a thread for a method that takes 5 minutes. I am utilizing
> > the DynamicQueryAdapter in my method.
> >
> > the strange thing is that I can call the BOConnect(), GetByID(),
> > AddWhereItem() and Update methods, but when I try to call the Execute
> > method it crashes.
> >
> > Does anyone have any thoughts and/or ideas on this?
> >
> > Dan
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
> already linked your email address to a yahoo id to enable access. )
> (1) To access the Files Section of our Yahoo!Group for Report Builder and
> Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]
Here is the code, thanks ahead of time if you guys can help me out on this.

Dan

'//**************************************************
'// Custom VB.NET code for UD01Form
'// Created: 6/5/2008 1:06:23 PM
'//**************************************************
Imports System
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic
Imports Epicor.Mfg.UI
Imports Epicor.Mfg.UI.FrameWork
Imports Epicor.Mfg.UI.ExtendedProps
Imports Epicor.Mfg.UI.FormFunctions
Imports Epicor.Mfg.UI.Customization
Imports Epicor.Mfg.UI.Adapters
Imports Epicor.Mfg.UI.Searches
IMPORTS System.IO
Imports Epicor.Mfg.BO
Imports Infragistics.Win
Imports Infragistics.Shared
Imports Infragistics.Win.UltraWinGrid
Imports System.Reflection
Imports Infragistics.Win.UltraWinToolBars
Imports System.Threading


Module 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 WithEvents timephasAdapter As TimePhasAdapter
Private WithEvents edvTimePhas As EpiDataView
Private dsAvailability AS System.Data.DataSet
Private dsTimePhase AS System.Data.DataSet
Private nAvailabilityDataColumns AS Integer = 0
Private nTimePhaseDataColumns AS Integer = 0
Private Const sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
Private bDeveloperLoggedIn AS Boolean = False
Private bGridSizeSet AS Boolean = False
Private Const nGridID_ComponentAvailability AS Integer = 1
Private Const nGridID_TimePhase AS Integer = 2
Private bFormLoaded AS Boolean = False
Private baseToolbarsManager As Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
Private sCurrentPartNum AS String = String.Empty
Private dteShortageDate AS Date
Private nAvailableQty AS Decimal = 0
Private bCancelRetrieve AS Boolean = False
Private thrdSpawnNewThread AS Thread
'Private dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)


Sub InitializeCustomCode()


'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Intialization' lines **
'// Begin Wizard Added Variable Intialization

'// End Wizard Added Variable Intialization
'// Begin Custom Method Calls
If Thread.CurrentThread.Name = Nothing Then
thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
End If

'dynQryAD = New DynamicQueryAdapter(UD01Form)
'dynQryAD.BOconnect()


dsAvailability = New System.Data.DataSet("Results")
dsTimePhase = New System.Data.DataSet("Results")
timephasAdapter = New timephasAdapter(oTrans)
timephasAdapter.BOConnect()

edvTimePhas = new EpiDataView()
edvTimePhas.dataView = New DataView(timephasAdapter.TimePhasData.TimePhas)

If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
oTrans.Add("TimePhasView",edvTimePhas)
End If

dim obj as Object = GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolbarsManager", BindingFlags.Instance Or BindingFlags.GetField Or BindingFlags.NonPublic, Nothing, UD01Form, Nothing)
BaseToolbarsManager = ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
AddHandler baseToolbarsManager.ToolClick, AddressOf baseToolbarsManager_ToolClick


'// End Custom Method Calls
End Sub

Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object, ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
Select case args.tool.key
Case "ClearTool"
ClearData(False)
'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly, "baseToolbarsManager.ToolClick")
End Select
End Sub


Sub 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
releaseObject(edvTimePhas)

timephasAdapter.Dispose()
releaseObject(timephasAdapter)

dsTimePhase.Dispose()
releaseObject(dsTimePhase)

dsAvailability.Dispose()
releaseObject(dsAvailability)

'dynQryAD.Dispose()
'releaseObject(dynQryAD)

End Sub


Private Sub UD01Form_Load(ByVal sender As object, ByVal args As EventArgs) Handles UD01Form.Load
'//
'// Add Event Handler Code
'//
Dim userID As String = UD01Form.Session.UserID
bFormLoaded = False
bDeveloperLoggedIn = False
Select userID
Case "dgodfrey"
bDeveloperLoggedIn = True
Case Else
bDeveloperLoggedIn = False
End Select
AddingDataColumns(dsAvailability, ugdBOMGrid, nGridID_ComponentAvailability)

'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)

ugdBOMGrid.Width = 1070
ugdBOMGrid.Height = 165

ugdBOMGrid.Width = 1070
ugdBOMGrid.Height = 250

grpFilters.Show()
chkExceptionsOnly.Show()
lblExceptionsOnly.Show()
chkExceptionsOnly.Checked = False
chkExcludeConsignments.Show()
chkExcludeConsignments.Show()
chkExcludeConsignments.Checked = False

grpTimePhaseFilters.Show()
chkSuggestions.Show()
lblSuggestions.Show()
chkSuggestions.Checked = False
chkForecasting.Checked = False

IF(bDeveloperLoggedIn) Then
btnShowSize.Show()
ChkForecasting.Show()
lblForecasting.Show()
btnCancelRetrieve.Show()
Else
ChkForecasting.Hide()
lblForecasting.Hide()
btnShowSize.Hide()
btnCancelRetrieve.Hide()
End If

Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel = CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57fb7a6"), Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel = CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e274b"), Epicor.Mfg.UI.App.UD01Entry.MainPanel)
myTreeViewPanel.Dispose()
myMainPanel.Dispose()
bFormLoaded = True
otrans.pushstatustext("Ready!", False)
End Sub



'/********************************************************************/
'/********************************************************************/
'/**************** Start of Generic Function *************************/
'/********************************************************************/
'/********************************************************************/
Private Sub ClearData(ByVal bGridOnly AS Boolean)
IF(bGridOnly = False) Then
txtBOMPartNum.Text = String.Empty
txtPartDescription.Text = String.Empty
txtBOMRevisionNum.text = String.Empty
txtProductionQty.Text = String.Empty
End If
dsAvailability.Tables(0).Rows.Clear()
ugdBOMGrid.Text = "BOM Components"
ugdTimePhase.Text = "Time Phase Inquiry"

timephasAdapter.clearData()
edvTimePhas.EpiDataChanged()
End Sub

Private Sub ShowSize()
DIM msg AS String = String.Empty
msg = msg & "Form Size:" & chr(13) & chr(10)
msg = msg & "Bottom = " & ugdBOMGrid.FindForm().Bottom & ", Top = " & ugdBOMGrid.FindForm().Top & ", Width = " & ugdBOMGrid.FindForm().Width & ", Height = " & ugdBOMGrid.FindForm().Height & chr(13) & chr(10)
msg = msg & "ugdBOMGrid Size:" & chr(13) & chr(10)
msg = msg & "Bottom = " & ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top & ", Width = " & ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height & chr(13) & chr(10)
msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10)
msg = msg & "Bottom = " & ugdTimePhase.Bottom & ", Top = " & ugdTimePhase.Top & ", Width = " & ugdTimePhase.Width & ", Height = " & ugdTimePhase.Height & chr(13) & chr(10)
MyMessageBox(msg, bDeveloperLoggedIn, MsgBoxStyle.OKOnly, "Grid Sizes")

End Sub

Private Sub ValidateGridSize()
Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width
Dim nHeight AS Integer = ugdBOMGrid.FindForm().Height
DIM nCriteriaAreaPlusFooting AS Integer = 250
Dim nSpaceBtwnGrids AS Integer = 5

ugdBOMGrid.Width = (nWidth - 50)
ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4

ugdTimePhase.Left = ugdBOMGrid.Left
ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height + nSpaceBtwnGrids
ugdTimePhase.Width = ugdBOMGrid.Width
ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6


btnShowSize.Left = ugdBOMGrid.Left
btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height + nSpaceBtwnGrids
ugdBOMGrid.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
bGridSizeSet = True

'ShowSize()
End Sub

Private Sub GridCustomization(ByRef Collection AS Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier AS Integer)
Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
IF(GridIdentifier = nGridID_ComponentAvailability) Then
For each column in Collection
Select column.Header.Caption
Case "Rev", "Part Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
column.Hidden = True
Case "Lvl"
column.Width = 30
column.CellAppearance.TextHAlign = HAlign.Right
Case "MtlSeq", "Lead"
column.Width = 50
column.CellAppearance.TextHAlign = HAlign.Right
Case "Material Part"
column.Width = 150
Case "PartDescription"
column.Width = 250
Case "Type"
column.Width = 50
Case "RequiredQty"
column.Width = 75
column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
column.CellAppearance.TextHAlign = HAlign.Right
Case "ClassID"
column.Width = 50
Case "TotalQtyOnHand", "AvailableQty"
column.Width = 125
column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
column.CellAppearance.TextHAlign = HAlign.Right
Case Else
'column.Hidden = True

End Select
Next Column
Else'nGridID_TimePhase
Dim nOrdinal AS Integer = 0
For each column in Collection
Select column.Header.Caption
Case "Due"
'column.Ordinal = 0
Case "Receipts"
'column.Ordinal = 1
Case "Job"
'column.Ordinal = 2
Case "Order"
'column.Ordinal = 3
Case "RequiredQty"
'column.Ordinal = 4
Case "PO"
'column.Ordinal = 5
Case "Lead"
'column.Ordinal = 6
Case "Balance"
'column.Ordinal = 7
Case "Exception"
'column.Ordinal = 8
Case "Order By"
'column.Ordinal = 9
Case "Source"
'column.Ordinal = 10
Case "JobStatus"
'column.Ordinal = 11
'nOrdinal = 11
Case Else
'column.Ordinal = 11
'nOrdinal = nOrdinal + 1
'column.Hidden = True
End Select
Next Column
End IF

End Sub 'GridCustomization(ByRef Collection AS Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier AS Integer)

Private Sub TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal nFirstColumnIndex AS Integer, ByVal nColumnCnt AS Integer, ByVal SrcRow AS DataRow)
' Instantiate a new row using the NewRow method.
Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
Dim i AS Integer = 0
'Insert code to fill the row with values.
For i = nFirstColumnIndex To nColumnCnt
newRow.Item(i) = SrcRow.Item(i)
Next i
'Add the row to the DataRowCollection.
myDataSet.Tables("Results").Rows.Add(newRow)
myDataSet.Tables("Results").AcceptChanges()
End Sub 'TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal nFirstColumnIndex, ByVal nColumnCnt AS Integer, ByVal SrcRow AS DataRow)

Private Sub AddingDataColumns(ByRef myDataSet AS System.Data.DataSet, ByRef myGrid AS Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal GridIdentifier AS Integer)

IF(myDataSet.Tables.Count <= 0)Then
myDataSet.Tables.Add("Results")
End If
'// ** Place Event Handling Code Here **
otrans.pushstatustext("Retrieving Data ...", False)
'Dim sStatusString as String = String.Empty

IF(GridIdentifier = nGridID_ComponentAvailability) Then
Dim sStatusString AS String = String.EMpty
Dim nColumns AS Integer = 0
Dim dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
Dim sBaqID AS String = sAvailabilityBAQID
sBaqID = sAvailabilityBAQID

dynQryAD.BOconnect()
dynQryAD.GetByID(sBaqID)

For Each DR AS DataRow in dynQryAD.QueryDesignData.Tables("SelectedField").Rows
nColumns = nColumns + 1
sStatusString = "AddingDataColumns function: Adding " & nColumns & "/" & dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & " ColumnName: " & DR.Item("FieldLabel") & " is " & DR.Item("DataType").ToString().ToUpper()
WriteToLogFile(sStatusString)
Select DR.Item("DataType").ToString().ToUpper()
Case "CHARACTER"
myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"), Type.GetType("System.String"))
Case "INTEGER"
myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"), Type.GetType("System.Int32"))
Case "DECIMAL"
myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"), Type.GetType("System.Decimal"))
Case "LOGICAL"
myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"), Type.GetType("System.Boolean"))
Case "DATE"
myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"), Type.GetType("System.DateTime"))
Case Else
myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"), Type.GetType("System.String"))
End Select
myDataSet.Tables(0).AcceptChanges()
Next
nAvailabilityDataColumns = nColumns - 1
dynQryAD.Dispose()
releaseObject(dynQryAD)
Else'nGridID_TimePhase
End If

myGrid.DataSource = myDataSet
GridCustomization(myGrid.DisplayLayout.Bands(0).Columns, GridIdentifier)

End Sub 'AddingDataColumns()

Private Function ShowDebugInformation() AS String
Dim sRet AS String
'& Chr(13) & Chr(10)
sRet = "Debug Data:" & Chr(13) & Chr(10)
sRet = sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13) & Chr(10)
sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail & Chr(13) & Chr(10)
sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName & Chr(13) & Chr(10)
sRet = sRet & "- ProductCode = " & UD01Form.Session.ProductCode & Chr(13) & Chr(10)
WriteToLogFile(sRet)

Return sRet
End Function 'ShowDebugInformation() AS String

Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS String
Dim sRet AS String = String.Empty
sRet = "INSIDE ShowDataSet:" & chr(13) & chr(10)
WriteToLogFile(sRet)
sRet = String.Empty
For each Table as DataTable in myDataSet.Tables
sRet = sRet & "Table: " & Table.TableName & chr(13) & chr(10)
For Each DR AS DataRow in Table.Rows
For Each DC as DataColumn in Table.Columns
IF(DC.ColumnName = "RowIdent") Then
Exit For
End If
sRet = sRet & DC.ColumnName & ":" & DR(DC.ColumnName)& ", "
Next'For Each DC as DataColumn in Table.Columns
sRet = sRet & chr(13) & chr(10)
Next'For Each DR AS DataRow in Table.Rows
Next'For each Table
WriteToLogFile(sRet)
Return sRet
End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS String

Private Function GetDataColumnInformation(ByVal myDataTable AS DataTable) AS String
Dim sRet AS String = String.Empty

sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
WriteToLogFile(sRet)
sRet = String.Empty
For Each DC as DataColumn in myDataTable.Columns
sRet = sRet & DC.ColumnName & ", "
Next'For Each DC as DataColumn in Table.Columns
sRet = sRet & chr(13) & chr(10)
WriteToLogFile(sRet)

Return sRet
End Function 'GetDataColumnInformation(ByVal myDataTable AS DataTable) AS String

''' <summary>
''' Copies the the specified number of rows from the top of the specified table.
''' </summary>
''' <param name="table">
''' The table containing the original rows.
''' </param>
''' <param name="rowCount">
''' The number of rows to copy.
''' </param>
''' <param name="useView">
''' Indicates whether the row order should be based on the DefaultView or not.
''' </param>
''' <returns>
''' A DataTable containing the copied rows.
''' </returns>
Private Function GetTopRows(ByVal table As DataTable, _
ByVal rowCount As Integer, _
ByVal useDefaultView As Boolean) As DataTable
'You can't get more rows than exist.
If useDefaultView Then
rowCount = Math.Min(rowCount, table.DefaultView.Count)
Else
rowCount = Math.Min(rowCount, table.Rows.Count)
End If
'Copy the table schema.
Dim topTable As DataTable = table.Clone()
'Copy the specified number of rows.
For rowIndex As Integer = 0 To rowCount - 1 Step 1
If useDefaultView Then
'Take the top rows from the DeafultView.
topTable.ImportRow(table.DefaultView(rowIndex).Row)
Else
'Take the top rows from the original table.
topTable.ImportRow(table.Rows(rowIndex))
End If
Next rowIndex
Return topTable
End Function

Private Function WriteToLogFile(ByVal TextString AS String) as Boolean
Dim bResults AS Boolean = False

Dim sInputString AS String = TextString & Chr(13) & Chr(10)
Dim sPath AS String = "C:\BOM_CAR_log.txt"


IF(File.Exists(sPath) = False) Then
' Create a file to write to.
File.WriteAllText(sPath, sInputString)
bResults = True
Else
' This text is always added, making the file longer over time
' if it is not deleted.
File.AppendAllText(sPath, sInputString)
bResults = True
End If
return bResults
End Function 'WriteToLogFile(ByVal TextString AS String) as Boolean

Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String = Nothing) As MsgBoxResult
Dim results As MsgBoxResult
If(FYI = True) Then
If Not String.IsNullOrEmpty(Title) Then
results = MsgBox(Msg, Button, Title)
Else
results = MsgBox(Msg, Button)
End If
End If
return results
End Function 'MyMessageBox( ByVal Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String = Nothing) As MsgBoxResult

Private Function FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As Object) As Integer
Dim retVal As Integer = 0
Dim myArray As Array = DirectCast(Values, Array)
If Array.IndexOf(myArray, valueToSearch) <> -1 Then
retVal = Array.IndexOf(myArray, valueToSearch)
Else
retVal = -1
End If
Return retVal
End Function 'FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As Object) As Integer

Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub 'releaseObject(ByVal obj As Object)
'/********************************************************************/
'/********************************************************************/
'/**************** End of Generic Function ***************************/
'/********************************************************************/
'/********************************************************************/


'/********************************************************************/
'/********************************************************************/
'/**************** Start of BOM_CAR Function *************************/
'/********************************************************************/
'/********************************************************************/

Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnCancelRetrieve.Click
'// ** Place Event Handling Code Here **
IF(btnRetrieve.Enabled = False) Then
bCancelRetrieve = True
'thrdSpawnNewThread.Abort
'ClearData(True)
End If
End Sub

Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles ugdBOMGrid.Resize
'// ** Place Event Handling Code Here **
ValidateGridSize()
End Sub

Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnRetrieve.Click
btnRetrieve.Enabled = False
thrdSpawnNewThread = new Thread(AddressOf RetrieveAvailabilityData)
thrdSpawnNewThread.Start
'RetrieveAvailabilityData()
IF(bGridSizeSet = False) Then
ValidateGridSize()
End If
btnRetrieve.Enabled = True
End Sub

Private Function GetShortageQtyANDDate(ByVal sPartNum AS String, ByVal nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity AS Decimal) AS Boolean

Dim blTimePhas As Boolean = timephasAdapter.GoProcessTimePhase(sPartNum, "MfgSys", chkSuggestions.Checked, False)
'ShowDataSet(timephasAdapter.TimePhasData)
IF(blTimePhas = True) Then
For Each drRow as DataRow in timephasAdapter.TimePhasData.Tables("TimePhas").Rows
drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
Quantity = drRow.Item("BalanceQty")
IF(Quantity <= 0) then
blTimePhas = True
IF(drRow.Item("DueDate").ToString() <> "") then
sDate = drRow.Item("DueDate").Date
End If
Exit For
Else
blTimePhas = False
End If

Next
timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
End If

Return blTimePhas
End Function

Private Sub RetrieveTimePhaseInquiry()

IF(ugdBOMGrid.Text <> "") Then
otrans.pushstatustext("Retrieving TimePhase Data ...", True)

timephasAdapter.clearData()
Dim blTimePhas As Boolean = GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Material Part")), ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("RequiredQty")), dteShortageDate, nAvailableQty)
edvTimePhas.EpiDataChanged()
ugdTimePhase.Text = "Time Phase Inquiry: Part: " & ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Material Part")) & " Description: " & ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("PartDescription"))

otrans.pushstatustext("Ready!", False)
End IF
End Sub


Private Sub RetrieveAvailabilityData()
'// ** Place Event Handling Code Here **
Dim dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
Dim pcTable As String = "PartRev"
Dim pcField As String = "PartNum"
Dim pbIsConst As Boolean = TRUE
Dim pcCondition As String = "="
Dim pcToValue as String = txtBOMPartNum.Text
Dim pcToTable As String = String.Empty
Dim pcToField As String = String.Empty
Dim pcRightParentheses as String = String.Empty
Dim pcLeftParentheses as String = String.Empty
Dim pcAndOr as String = String.Empty
Dim pbNeg as Boolean = False
Try
WriteToLogFile("Retrieving Availability Data ...")
otrans.pushstatustext("Retrieving Availability Data ...", True)

dynQryAD.BOconnect()

dsAvailability.Tables(0).Rows.Clear()
ugdBOMGrid.DataSource.Tables(0).Rows.Clear()

dynQryAD.GetByID(sAvailabilityBAQID)

dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID, pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable, pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
dynQryAD.Update
pcField = "RevisionNum"
pcToValue = txtBOMRevisionNum.Text.ToString()
pcAndOr = "AND"
dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID, pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable, pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
dynQryAD.Update

ugdBOMGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True

WriteToLogFile("copy all data from QueryDesignData tables to DynamicQueryData tables (only for tables that exist in both datasets)")
'//copy all data from QueryDesignData tables to DynamicQueryData tables (only
'for tables that exist in both datasets

Dim targetRow as DataRow
For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
If Table.Rows.Count = 0 Then
For Each sourceRow as DataRow in dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
targetRow = Table.NewRow()
targetRow.ItemArray = sourceRow.ItemArray
Table.Rows.Add(targetRow)
Next
End If
Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables

WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
dynQryAD.Execute(dynQryAD.DynamicQueryData)

WriteToLogFile("Processing " & dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query records.")
otrans.pushstatustext("Processing " & dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query records.", True)
Dim RecCnt AS Integer = 0
Dim AddToGrid AS Boolean = True
Dim bNegAvail AS boolean = False
WriteToLogFile("Pre-Filtered DataSet")
ShowDataSet(dynQryAD.QueryResults)

For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
'myDataSet has records
IF(bCancelRetrieve = True) Then
ClearData(True)
Exit For
End If
AddToGrid = True

ORow.Item("RequiredQty") = ORow.Item("RequiredQty") * txtProductionQty.Value
nAvailableQty = ORow.Item("PartPlant.Number01") - ORow.Item("RequiredQty")
dteShortageDate = Today()
IF(nAvailableQty > 0) then
bNegAvail = GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"), ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty)
Else
bNegAvail = True
End If

IF(bCancelRetrieve = True) Then
ClearData(True)
Exit For
End If

ORow.Item("ShortageDate") = dteShortageDate.Date
ORow.Item("AvailableQty") = nAvailableQty

IF(chkExceptionsOnly.Checked = True) Then
AddToGrid = bNegAvail
End If
IF(chkExcludeConsignments.Checked) Then
Select ORow.Item("Part.ClassID")
Case "CARR"
AddToGrid = False
Case "CTTI"
AddToGrid = False
Case "CAVN"
AddToGrid = False
Case Else
AddToGrid = AddToGrid
End Select
End If

IF(bCancelRetrieve = True) Then
ClearData(True)
Exit For
End If

If(AddToGrid) then
RecCnt = RecCnt + 1
TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow)
End If
Next'For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
IF(bCancelRetrieve = True) Then
bCancelRetrieve = False
Else
otrans.pushstatustext("Processed " & RecCnt & " Component records.", True)
WriteToLogFile("Processed " & RecCnt & " Component records.")
WriteToLogFile("Grid-Filtered DataSet")
ShowDataSet(dsAvailability)

dsAvailability.Tables("Results").Columns("Material Part").ExtendedProperties("Like") = "Part.PartNum"
dsAvailability.Tables("Results").AcceptChanges()
IF(RecCnt > 0) Then
ugdBOMGrid.Text = dsAvailability.Tables(0).Rows(0).Item("RevDescription")
txtPartdescription.Text = dsAvailability.Tables(0).Rows(0).Item("RevDescription")
ugdBOMGrid.DataSource = dsAvailability
GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns, nGridID_ComponentAvailability)
Else
MyMessageBox("There was no exceptions found.", True, MsgBoxStyle.OKOnly, "Availability Report")
timephasAdapter.clearData()
edvTimePhas.EpiDataChanged()

End If

ugdBOMGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False
End If
Catch abortException As ThreadAbortException
MyMessageBox(abortException.Message & ": " & CType(abortException.ExceptionState, String), True, MsgBoxStyle.OKOnly, "Availability Report")
finally
dynQryAD.Dispose()
releaseObject(dynQryAD)
End Try
End Sub 'RetrieveSalesData()

Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnPartRevSearch.Click
'// ** Place Event Handling Code Here **
Dim recordSelected As Boolean
Dim sPart AS String = txtBOMPartNum.Text
Dim wClause AS String = "PartNum >= '" + sPart + "'"

IF(sPart.length() <= 0) Then
wClause = String.Empty
End If
Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form, "PartRevSearchAdapter", recordSelected, True, wClause, False)

If( recordSelected) Then
txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
End If
End Sub


Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnShowSize.Click
'// ** Place Event Handling Code Here **
ShowSize()
End Sub

Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate
'// ** Place Event Handling Code Here **
RetrieveTimePhaseInquiry()
End Sub


Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles chkSuggestions.AfterCheckStateChanged
'// ** Place Event Handling Code Here **
IF(bFormLoaded) Then
RetrieveTimePhaseInquiry()
End If
End Sub


Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles txtBOMPartNum.Leave
'// ** Place Event Handling Code Here **
IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
sCurrentPartNum = txtBOMPartNum.Text
End If

End Sub

Private Function GetLatestPartRev (ByVal sPartNum As string) As string

Dim sPartRev As String = String.Empty
Dim recSelected As Boolean = False
Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"

Dim dsSearch As DataSet
dsSearch = SearchFunctions.listLookup(oTrans, "PartRevSearchAdapter", recSelected, False, swhereClause, True)
If recSelected Then
sPartRev = dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() - 1).Item("RevisionNum")
Else
MyMessageBox("The PartNum you entered does not have a valid Revision Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number")
End If
Return sPartRev
End Function

End Module

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of John Driggers
Sent: Wednesday, August 15, 2012 7:35 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

You shouldn't need to. What is the error you're receiving? If you stick your code up here it will likely help a lot.

On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> What I am doing is calling a BAQ and then adding two where clauses for
> the PartNum and RevisionNum. I then execute the BAQ. This is all done
> with local parameters inside of the method that I delegate for the thread.
> Should I set the DynamicQueryAdapter object as global so that it is
> owned by the Form?
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of Jose Gomez
> Sent: Tuesday, August 14, 2012 2:39 PM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> I've done it several times, how are you doing it? You can't update UI
> items from a thread, so if its updating UI that's where your crash is
> happening your best bet is to instanciate a new BO do your stuff and
> then refresh the UI once its donre.l
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez>
> <http://www.facebook.com/josegomez
> >
> <http://www.google.com/profiles/jose.gomez>
> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
> On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...> wrote:
>
> > **
> >
> >
> > Has anyone used threading with Business Objects? I am trying to use
> > it to spawn a thread for a method that takes 5 minutes. I am
> > utilizing the DynamicQueryAdapter in my method.
> >
> > the strange thing is that I can call the BOConnect(), GetByID(),
> > AddWhereItem() and Update methods, but when I try to call the
> > Execute method it crashes.
> >
> > Does anyone have any thoughts and/or ideas on this?
> >
> > Dan
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
WOW ok that's a lot of code, but anything in RetrieveAvailabilityData
which touches the UI has got to go


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Wed, Aug 15, 2012 at 11:07 AM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> Here is the code, thanks ahead of time if you guys can help me out on this.
>
> Dan
>
> '//**************************************************
> '// Custom VB.NET code for UD01Form
> '// Created: 6/5/2008 1:06:23 PM
> '//**************************************************
> Imports System
> Imports System.Data
> Imports System.Diagnostics
> Imports System.Windows.Forms
> Imports System.ComponentModel
> Imports Microsoft.VisualBasic
> Imports Epicor.Mfg.UI
> Imports Epicor.Mfg.UI.FrameWork
> Imports Epicor.Mfg.UI.ExtendedProps
> Imports Epicor.Mfg.UI.FormFunctions
> Imports Epicor.Mfg.UI.Customization
> Imports Epicor.Mfg.UI.Adapters
> Imports Epicor.Mfg.UI.Searches
> IMPORTS System.IO
> Imports Epicor.Mfg.BO
> Imports Infragistics.Win
> Imports Infragistics.Shared
> Imports Infragistics.Win.UltraWinGrid
> Imports System.Reflection
> Imports Infragistics.Win.UltraWinToolBars
> Imports System.Threading
>
> Module 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 WithEvents timephasAdapter As TimePhasAdapter
> Private WithEvents edvTimePhas As EpiDataView
> Private dsAvailability AS System.Data.DataSet
> Private dsTimePhase AS System.Data.DataSet
> Private nAvailabilityDataColumns AS Integer = 0
> Private nTimePhaseDataColumns AS Integer = 0
> Private Const sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
> Private bDeveloperLoggedIn AS Boolean = False
> Private bGridSizeSet AS Boolean = False
> Private Const nGridID_ComponentAvailability AS Integer = 1
> Private Const nGridID_TimePhase AS Integer = 2
> Private bFormLoaded AS Boolean = False
> Private baseToolbarsManager As
> Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
> Private sCurrentPartNum AS String = String.Empty
> Private dteShortageDate AS Date
> Private nAvailableQty AS Decimal = 0
> Private bCancelRetrieve AS Boolean = False
> Private thrdSpawnNewThread AS Thread
> 'Private dynQryAD As DynamicQueryAdapter = New
> DynamicQueryAdapter(UD01Form)
>
> Sub InitializeCustomCode()
>
> '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added
> Variable Intialization' lines **
> '// Begin Wizard Added Variable Intialization
>
> '// End Wizard Added Variable Intialization
> '// Begin Custom Method Calls
> If Thread.CurrentThread.Name = Nothing Then
> thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
> End If
>
> 'dynQryAD = New DynamicQueryAdapter(UD01Form)
> 'dynQryAD.BOconnect()
>
> dsAvailability = New System.Data.DataSet("Results")
> dsTimePhase = New System.Data.DataSet("Results")
> timephasAdapter = New timephasAdapter(oTrans)
> timephasAdapter.BOConnect()
>
> edvTimePhas = new EpiDataView()
> edvTimePhas.dataView = New DataView(timephasAdapter.TimePhasData.TimePhas)
>
> If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
> oTrans.Add("TimePhasView",edvTimePhas)
> End If
>
> dim obj as Object =
> GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolbarsManager",
> BindingFlags.Instance Or BindingFlags.GetField Or BindingFlags.NonPublic,
> Nothing, UD01Form, Nothing)
> BaseToolbarsManager =
> ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
> AddHandler baseToolbarsManager.ToolClick, AddressOf
> baseToolbarsManager_ToolClick
>
>
> '// End Custom Method Calls
> End Sub
>
> Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object, ByVal
> args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
> Select case args.tool.key
> Case "ClearTool"
> ClearData(False)
> 'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly,
> "baseToolbarsManager.ToolClick")
> End Select
> End Sub
>
> Sub 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
> releaseObject(edvTimePhas)
>
> timephasAdapter.Dispose()
> releaseObject(timephasAdapter)
>
> dsTimePhase.Dispose()
> releaseObject(dsTimePhase)
>
> dsAvailability.Dispose()
> releaseObject(dsAvailability)
>
> 'dynQryAD.Dispose()
> 'releaseObject(dynQryAD)
>
> End Sub
>
> Private Sub UD01Form_Load(ByVal sender As object, ByVal args As EventArgs)
> Handles UD01Form.Load
> '//
> '// Add Event Handler Code
> '//
> Dim userID As String = UD01Form.Session.UserID
> bFormLoaded = False
> bDeveloperLoggedIn = False
> Select userID
> Case "dgodfrey"
> bDeveloperLoggedIn = True
> Case Else
> bDeveloperLoggedIn = False
> End Select
> AddingDataColumns(dsAvailability, ugdBOMGrid,
> nGridID_ComponentAvailability)
>
> 'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)
>
> ugdBOMGrid.Width = 1070
> ugdBOMGrid.Height = 165
>
> ugdBOMGrid.Width = 1070
> ugdBOMGrid.Height = 250
>
> grpFilters.Show()
> chkExceptionsOnly.Show()
> lblExceptionsOnly.Show()
> chkExceptionsOnly.Checked = False
> chkExcludeConsignments.Show()
> chkExcludeConsignments.Show()
> chkExcludeConsignments.Checked = False
>
> grpTimePhaseFilters.Show()
> chkSuggestions.Show()
> lblSuggestions.Show()
> chkSuggestions.Checked = False
> chkForecasting.Checked = False
>
> IF(bDeveloperLoggedIn) Then
> btnShowSize.Show()
> ChkForecasting.Show()
> lblForecasting.Show()
> btnCancelRetrieve.Show()
> Else
> ChkForecasting.Hide()
> lblForecasting.Hide()
> btnShowSize.Hide()
> btnCancelRetrieve.Hide()
> End If
>
> Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel =
> CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57fb7a6"),
> Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
> Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel =
> CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e274b"),
> Epicor.Mfg.UI.App.UD01Entry.MainPanel)
> myTreeViewPanel.Dispose()
> myMainPanel.Dispose()
> bFormLoaded = True
> otrans.pushstatustext("Ready!", False)
> End Sub
>
> '/********************************************************************/
> '/********************************************************************/
> '/**************** Start of Generic Function *************************/
> '/********************************************************************/
> '/********************************************************************/
> Private Sub ClearData(ByVal bGridOnly AS Boolean)
> IF(bGridOnly = False) Then
> txtBOMPartNum.Text = String.Empty
> txtPartDescription.Text = String.Empty
> txtBOMRevisionNum.text = String.Empty
> txtProductionQty.Text = String.Empty
> End If
> dsAvailability.Tables(0).Rows.Clear()
> ugdBOMGrid.Text = "BOM Components"
> ugdTimePhase.Text = "Time Phase Inquiry"
>
> timephasAdapter.clearData()
> edvTimePhas.EpiDataChanged()
> End Sub
>
> Private Sub ShowSize()
> DIM msg AS String = String.Empty
> msg = msg & "Form Size:" & chr(13) & chr(10)
> msg = msg & "Bottom = " & ugdBOMGrid.FindForm().Bottom & ", Top = " &
> ugdBOMGrid.FindForm().Top & ", Width = " & ugdBOMGrid.FindForm().Width & ",
> Height = " & ugdBOMGrid.FindForm().Height & chr(13) & chr(10)
> msg = msg & "ugdBOMGrid Size:" & chr(13) & chr(10)
> msg = msg & "Bottom = " & ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top
> & ", Width = " & ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height &
> chr(13) & chr(10)
> msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10)
> msg = msg & "Bottom = " & ugdTimePhase.Bottom & ", Top = " &
> ugdTimePhase.Top & ", Width = " & ugdTimePhase.Width & ", Height = " &
> ugdTimePhase.Height & chr(13) & chr(10)
> MyMessageBox(msg, bDeveloperLoggedIn, MsgBoxStyle.OKOnly, "Grid Sizes")
>
> End Sub
>
> Private Sub ValidateGridSize()
> Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width
> Dim nHeight AS Integer = ugdBOMGrid.FindForm().Height
> DIM nCriteriaAreaPlusFooting AS Integer = 250
> Dim nSpaceBtwnGrids AS Integer = 5
>
> ugdBOMGrid.Width = (nWidth - 50)
> ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4
>
> ugdTimePhase.Left = ugdBOMGrid.Left
> ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height + nSpaceBtwnGrids
> ugdTimePhase.Width = ugdBOMGrid.Width
> ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6
>
>
> btnShowSize.Left = ugdBOMGrid.Left
> btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height + nSpaceBtwnGrids
> ugdBOMGrid.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> AnchorStyles.Left Or AnchorStyles.Top
> 'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> AnchorStyles.Left Or AnchorStyles.Top
> bGridSizeSet = True
>
> 'ShowSize()
> End Sub
>
> Private Sub GridCustomization(ByRef Collection AS
> Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier AS
> Integer)
> Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
> IF(GridIdentifier = nGridID_ComponentAvailability) Then
> For each column in Collection
> Select column.Header.Caption
> Case "Rev", "Part Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
> column.Hidden = True
> Case "Lvl"
> column.Width = 30
> column.CellAppearance.TextHAlign = HAlign.Right
> Case "MtlSeq", "Lead"
> column.Width = 50
> column.CellAppearance.TextHAlign = HAlign.Right
> Case "Material Part"
> column.Width = 150
> Case "PartDescription"
> column.Width = 250
> Case "Type"
> column.Width = 50
> Case "RequiredQty"
> column.Width = 75
> column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> column.CellAppearance.TextHAlign = HAlign.Right
> Case "ClassID"
> column.Width = 50
> Case "TotalQtyOnHand", "AvailableQty"
> column.Width = 125
> column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> column.CellAppearance.TextHAlign = HAlign.Right
> Case Else
> 'column.Hidden = True
>
> End Select
> Next Column
> Else'nGridID_TimePhase
> Dim nOrdinal AS Integer = 0
> For each column in Collection
> Select column.Header.Caption
> Case "Due"
> 'column.Ordinal = 0
> Case "Receipts"
> 'column.Ordinal = 1
> Case "Job"
> 'column.Ordinal = 2
> Case "Order"
> 'column.Ordinal = 3
> Case "RequiredQty"
> 'column.Ordinal = 4
> Case "PO"
> 'column.Ordinal = 5
> Case "Lead"
> 'column.Ordinal = 6
> Case "Balance"
> 'column.Ordinal = 7
> Case "Exception"
> 'column.Ordinal = 8
> Case "Order By"
> 'column.Ordinal = 9
> Case "Source"
> 'column.Ordinal = 10
> Case "JobStatus"
> 'column.Ordinal = 11
> 'nOrdinal = 11
> Case Else
> 'column.Ordinal = 11
> 'nOrdinal = nOrdinal + 1
> 'column.Hidden = True
> End Select
> Next Column
> End IF
>
> End Sub 'GridCustomization(ByRef Collection AS
> Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier AS
> Integer)
>
> Private Sub TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal
> nFirstColumnIndex AS Integer, ByVal nColumnCnt AS Integer, ByVal SrcRow AS
> DataRow)
> ' Instantiate a new row using the NewRow method.
> Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
> Dim i AS Integer = 0
> 'Insert code to fill the row with values.
> For i = nFirstColumnIndex To nColumnCnt
> newRow.Item(i) = SrcRow.Item(i)
> Next i
> 'Add the row to the DataRowCollection.
> myDataSet.Tables("Results").Rows.Add(newRow)
> myDataSet.Tables("Results").AcceptChanges()
> End Sub 'TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal
> nFirstColumnIndex, ByVal nColumnCnt AS Integer, ByVal SrcRow AS DataRow)
>
> Private Sub AddingDataColumns(ByRef myDataSet AS System.Data.DataSet,
> ByRef myGrid AS Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal GridIdentifier
> AS Integer)
>
> IF(myDataSet.Tables.Count <= 0)Then
> myDataSet.Tables.Add("Results")
> End If
> '// ** Place Event Handling Code Here **
> otrans.pushstatustext("Retrieving Data ...", False)
> 'Dim sStatusString as String = String.Empty
>
> IF(GridIdentifier = nGridID_ComponentAvailability) Then
> Dim sStatusString AS String = String.EMpty
> Dim nColumns AS Integer = 0
> Dim dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
> Dim sBaqID AS String = sAvailabilityBAQID
> sBaqID = sAvailabilityBAQID
>
> dynQryAD.BOconnect()
> dynQryAD.GetByID(sBaqID)
>
> For Each DR AS DataRow in
> dynQryAD.QueryDesignData.Tables("SelectedField").Rows
> nColumns = nColumns + 1
> sStatusString = "AddingDataColumns function: Adding " & nColumns & "/" &
> dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & " ColumnName:
> " & DR.Item("FieldLabel") & " is " &
> DR.Item("DataType").ToString().ToUpper()
> WriteToLogFile(sStatusString)
> Select DR.Item("DataType").ToString().ToUpper()
> Case "CHARACTER"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.String"))
> Case "INTEGER"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Int32"))
> Case "DECIMAL"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Decimal"))
> Case "LOGICAL"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Boolean"))
> Case "DATE"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.DateTime"))
> Case Else
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.String"))
> End Select
> myDataSet.Tables(0).AcceptChanges()
> Next
> nAvailabilityDataColumns = nColumns - 1
> dynQryAD.Dispose()
> releaseObject(dynQryAD)
> Else'nGridID_TimePhase
> End If
>
> myGrid.DataSource = myDataSet
> GridCustomization(myGrid.DisplayLayout.Bands(0).Columns, GridIdentifier)
>
> End Sub 'AddingDataColumns()
>
> Private Function ShowDebugInformation() AS String
> Dim sRet AS String
> '& Chr(13) & Chr(10)
> sRet = "Debug Data:" & Chr(13) & Chr(10)
> sRet = sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
> sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13) &
> Chr(10)
> sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail & Chr(13) &
> Chr(10)
> sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName & Chr(13)
> & Chr(10)
> sRet = sRet & "- ProductCode = " & UD01Form.Session.ProductCode & Chr(13)
> & Chr(10)
> WriteToLogFile(sRet)
>
> Return sRet
> End Function 'ShowDebugInformation() AS String
>
> Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS
> String
> Dim sRet AS String = String.Empty
> sRet = "INSIDE ShowDataSet:" & chr(13) & chr(10)
> WriteToLogFile(sRet)
> sRet = String.Empty
> For each Table as DataTable in myDataSet.Tables
> sRet = sRet & "Table: " & Table.TableName & chr(13) & chr(10)
> For Each DR AS DataRow in Table.Rows
> For Each DC as DataColumn in Table.Columns
> IF(DC.ColumnName = "RowIdent") Then
> Exit For
> End If
> sRet = sRet & DC.ColumnName & ":" & DR(DC.ColumnName)& ", "
> Next'For Each DC as DataColumn in Table.Columns
> sRet = sRet & chr(13) & chr(10)
> Next'For Each DR AS DataRow in Table.Rows
> Next'For each Table
> WriteToLogFile(sRet)
> Return sRet
> End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS String
>
> Private Function GetDataColumnInformation(ByVal myDataTable AS DataTable)
> AS String
> Dim sRet AS String = String.Empty
>
> sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
> WriteToLogFile(sRet)
> sRet = String.Empty
> For Each DC as DataColumn in myDataTable.Columns
> sRet = sRet & DC.ColumnName & ", "
> Next'For Each DC as DataColumn in Table.Columns
> sRet = sRet & chr(13) & chr(10)
> WriteToLogFile(sRet)
>
> Return sRet
> End Function 'GetDataColumnInformation(ByVal myDataTable AS DataTable) AS
> String
>
> ''' <summary>
> ''' Copies the the specified number of rows from the top of the specified
> table.
> ''' </summary>
> ''' <param name="table">
> ''' The table containing the original rows.
> ''' </param>
> ''' <param name="rowCount">
> ''' The number of rows to copy.
> ''' </param>
> ''' <param name="useView">
> ''' Indicates whether the row order should be based on the DefaultView or
> not.
> ''' </param>
> ''' <returns>
> ''' A DataTable containing the copied rows.
> ''' </returns>
> Private Function GetTopRows(ByVal table As DataTable, _
> ByVal rowCount As Integer, _
> ByVal useDefaultView As Boolean) As DataTable
> 'You can't get more rows than exist.
> If useDefaultView Then
> rowCount = Math.Min(rowCount, table.DefaultView.Count)
> Else
> rowCount = Math.Min(rowCount, table.Rows.Count)
> End If
> 'Copy the table schema.
> Dim topTable As DataTable = table.Clone()
> 'Copy the specified number of rows.
> For rowIndex As Integer = 0 To rowCount - 1 Step 1
> If useDefaultView Then
> 'Take the top rows from the DeafultView.
> topTable.ImportRow(table.DefaultView(rowIndex).Row)
> Else
> 'Take the top rows from the original table.
> topTable.ImportRow(table.Rows(rowIndex))
> End If
> Next rowIndex
> Return topTable
> End Function
>
> Private Function WriteToLogFile(ByVal TextString AS String) as Boolean
> Dim bResults AS Boolean = False
>
> Dim sInputString AS String = TextString & Chr(13) & Chr(10)
> Dim sPath AS String = "C:\BOM_CAR_log.txt"
>
>
> IF(File.Exists(sPath) = False) Then
> ' Create a file to write to.
> File.WriteAllText(sPath, sInputString)
> bResults = True
> Else
> ' This text is always added, making the file longer over time
> ' if it is not deleted.
> File.AppendAllText(sPath, sInputString)
> bResults = True
> End If
> return bResults
> End Function 'WriteToLogFile(ByVal TextString AS String) as Boolean
>
> Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly, Optional
> ByVal Title As String = Nothing) As MsgBoxResult
> Dim results As MsgBoxResult
> If(FYI = True) Then
> If Not String.IsNullOrEmpty(Title) Then
> results = MsgBox(Msg, Button, Title)
> Else
> results = MsgBox(Msg, Button)
> End If
> End If
> return results
> End Function 'MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly, Optional
> ByVal Title As String = Nothing) As MsgBoxResult
>
> Private Function FindValueFromArray(ByVal Values As Object(), ByVal
> valueToSearch As Object) As Integer
> Dim retVal As Integer = 0
> Dim myArray As Array = DirectCast(Values, Array)
> If Array.IndexOf(myArray, valueToSearch) <> -1 Then
> retVal = Array.IndexOf(myArray, valueToSearch)
> Else
> retVal = -1
> End If
> Return retVal
> End Function 'FindValueFromArray(ByVal Values As Object(), ByVal
> valueToSearch As Object) As Integer
>
> Private Sub releaseObject(ByVal obj As Object)
> Try
> System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
> obj = Nothing
> Catch ex As Exception
> obj = Nothing
> Finally
> GC.Collect()
> End Try
> End Sub 'releaseObject(ByVal obj As Object)
> '/********************************************************************/
> '/********************************************************************/
> '/**************** End of Generic Function ***************************/
> '/********************************************************************/
> '/********************************************************************/
>
> '/********************************************************************/
> '/********************************************************************/
> '/**************** Start of BOM_CAR Function *************************/
> '/********************************************************************/
> '/********************************************************************/
>
> Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnCancelRetrieve.Click
> '// ** Place Event Handling Code Here **
> IF(btnRetrieve.Enabled = False) Then
> bCancelRetrieve = True
> 'thrdSpawnNewThread.Abort
> 'ClearData(True)
> End If
> End Sub
>
> Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles ugdBOMGrid.Resize
> '// ** Place Event Handling Code Here **
> ValidateGridSize()
> End Sub
>
> Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnRetrieve.Click
> btnRetrieve.Enabled = False
> thrdSpawnNewThread = new Thread(AddressOf RetrieveAvailabilityData)
> thrdSpawnNewThread.Start
> 'RetrieveAvailabilityData()
> IF(bGridSizeSet = False) Then
> ValidateGridSize()
> End If
> btnRetrieve.Enabled = True
> End Sub
>
> Private Function GetShortageQtyANDDate(ByVal sPartNum AS String, ByVal
> nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity AS Decimal) AS
> Boolean
>
> Dim blTimePhas As Boolean = timephasAdapter.GoProcessTimePhase(sPartNum,
> "MfgSys", chkSuggestions.Checked, False)
> 'ShowDataSet(timephasAdapter.TimePhasData)
> IF(blTimePhas = True) Then
> For Each drRow as DataRow in
> timephasAdapter.TimePhasData.Tables("TimePhas").Rows
> drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
> Quantity = drRow.Item("BalanceQty")
> IF(Quantity <= 0) then
> blTimePhas = True
> IF(drRow.Item("DueDate").ToString() <> "") then
> sDate = drRow.Item("DueDate").Date
> End If
> Exit For
> Else
> blTimePhas = False
> End If
>
> Next
> timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
> End If
>
> Return blTimePhas
> End Function
>
> Private Sub RetrieveTimePhaseInquiry()
>
> IF(ugdBOMGrid.Text <> "") Then
> otrans.pushstatustext("Retrieving TimePhase Data ...", True)
>
> timephasAdapter.clearData()
> Dim blTimePhas As Boolean =
> GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Material
> Part")),
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("RequiredQty")),
> dteShortageDate, nAvailableQty)
> edvTimePhas.EpiDataChanged()
> ugdTimePhase.Text = "Time Phase Inquiry: Part: " &
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Material
> Part")) & " Description: " &
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("PartDescription"))
>
> otrans.pushstatustext("Ready!", False)
> End IF
> End Sub
>
> Private Sub RetrieveAvailabilityData()
> '// ** Place Event Handling Code Here **
> Dim dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
> Dim pcTable As String = "PartRev"
> Dim pcField As String = "PartNum"
> Dim pbIsConst As Boolean = TRUE
> Dim pcCondition As String = "="
> Dim pcToValue as String = txtBOMPartNum.Text
> Dim pcToTable As String = String.Empty
> Dim pcToField As String = String.Empty
> Dim pcRightParentheses as String = String.Empty
> Dim pcLeftParentheses as String = String.Empty
> Dim pcAndOr as String = String.Empty
> Dim pbNeg as Boolean = False
> Try
> WriteToLogFile("Retrieving Availability Data ...")
> otrans.pushstatustext("Retrieving Availability Data ...", True)
>
> dynQryAD.BOconnect()
>
> dsAvailability.Tables(0).Rows.Clear()
> ugdBOMGrid.DataSource.Tables(0).Rows.Clear()
>
> dynQryAD.GetByID(sAvailabilityBAQID)
>
> dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable, pcToField,
> pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> dynQryAD.Update
> pcField = "RevisionNum"
> pcToValue = txtBOMRevisionNum.Text.ToString()
> pcAndOr = "AND"
> dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable, pcToField,
> pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> dynQryAD.Update
>
> ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> Infragistics.Win.DefaultableBoolean.True
>
> WriteToLogFile("copy all data from QueryDesignData tables to
> DynamicQueryData tables (only for tables that exist in both datasets)")
> '//copy all data from QueryDesignData tables to DynamicQueryData tables
> (only
> 'for tables that exist in both datasets
>
> Dim targetRow as DataRow
> For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
> If Table.Rows.Count = 0 Then
> For Each sourceRow as DataRow in
> dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
> targetRow = Table.NewRow()
> targetRow.ItemArray = sourceRow.ItemArray
> Table.Rows.Add(targetRow)
> Next
> End If
> Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
>
> WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
> dynQryAD.Execute(dynQryAD.DynamicQueryData)
>
> WriteToLogFile("Processing " &
> dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query records.")
> otrans.pushstatustext("Processing " &
> dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query records.",
> True)
> Dim RecCnt AS Integer = 0
> Dim AddToGrid AS Boolean = True
> Dim bNegAvail AS boolean = False
> WriteToLogFile("Pre-Filtered DataSet")
> ShowDataSet(dynQryAD.QueryResults)
>
> For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> 'myDataSet has records
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
> AddToGrid = True
>
> ORow.Item("RequiredQty") = ORow.Item("RequiredQty") *
> txtProductionQty.Value
> nAvailableQty = ORow.Item("PartPlant.Number01") - ORow.Item("RequiredQty")
> dteShortageDate = Today()
> IF(nAvailableQty > 0) then
> bNegAvail = GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"),
> ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty)
> Else
> bNegAvail = True
> End If
>
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
>
> ORow.Item("ShortageDate") = dteShortageDate.Date
> ORow.Item("AvailableQty") = nAvailableQty
>
> IF(chkExceptionsOnly.Checked = True) Then
> AddToGrid = bNegAvail
> End If
> IF(chkExcludeConsignments.Checked) Then
> Select ORow.Item("Part.ClassID")
> Case "CARR"
> AddToGrid = False
> Case "CTTI"
> AddToGrid = False
> Case "CAVN"
> AddToGrid = False
> Case Else
> AddToGrid = AddToGrid
> End Select
> End If
>
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
>
> If(AddToGrid) then
> RecCnt = RecCnt + 1
> TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow)
> End If
> Next'For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> IF(bCancelRetrieve = True) Then
> bCancelRetrieve = False
> Else
> otrans.pushstatustext("Processed " & RecCnt & " Component records.", True)
> WriteToLogFile("Processed " & RecCnt & " Component records.")
> WriteToLogFile("Grid-Filtered DataSet")
> ShowDataSet(dsAvailability)
>
> dsAvailability.Tables("Results").Columns("Material
> Part").ExtendedProperties("Like") = "Part.PartNum"
> dsAvailability.Tables("Results").AcceptChanges()
> IF(RecCnt > 0) Then
> ugdBOMGrid.Text = dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> txtPartdescription.Text =
> dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> ugdBOMGrid.DataSource = dsAvailability
> GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns,
> nGridID_ComponentAvailability)
> Else
> MyMessageBox("There was no exceptions found.", True, MsgBoxStyle.OKOnly,
> "Availability Report")
> timephasAdapter.clearData()
> edvTimePhas.EpiDataChanged()
>
> End If
>
> ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> Infragistics.Win.DefaultableBoolean.False
> End If
> Catch abortException As ThreadAbortException
> MyMessageBox(abortException.Message & ": " &
> CType(abortException.ExceptionState, String), True, MsgBoxStyle.OKOnly,
> "Availability Report")
> finally
> dynQryAD.Dispose()
> releaseObject(dynQryAD)
> End Try
> End Sub 'RetrieveSalesData()
>
> Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnPartRevSearch.Click
> '// ** Place Event Handling Code Here **
> Dim recordSelected As Boolean
> Dim sPart AS String = txtBOMPartNum.Text
> Dim wClause AS String = "PartNum >= '" + sPart + "'"
>
> IF(sPart.length() <= 0) Then
> wClause = String.Empty
> End If
> Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form,
> "PartRevSearchAdapter", recordSelected, True, wClause, False)
>
> If( recordSelected) Then
> txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
> txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
> End If
> End Sub
>
> Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnShowSize.Click
> '// ** Place Event Handling Code Here **
> ShowSize()
> End Sub
>
> Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object, ByVal Args
> As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate
> '// ** Place Event Handling Code Here **
> RetrieveTimePhaseInquiry()
> End Sub
>
> Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As Object,
> ByVal Args As System.EventArgs) Handles
> chkSuggestions.AfterCheckStateChanged
> '// ** Place Event Handling Code Here **
> IF(bFormLoaded) Then
> RetrieveTimePhaseInquiry()
> End If
> End Sub
>
> Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles txtBOMPartNum.Leave
> '// ** Place Event Handling Code Here **
> IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
> txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
> sCurrentPartNum = txtBOMPartNum.Text
> End If
>
> End Sub
>
> Private Function GetLatestPartRev (ByVal sPartNum As string) As string
>
> Dim sPartRev As String = String.Empty
> Dim recSelected As Boolean = False
> Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"
>
> Dim dsSearch As DataSet
> dsSearch = SearchFunctions.listLookup(oTrans, "PartRevSearchAdapter",
> recSelected, False, swhereClause, True)
> If recSelected Then
> sPartRev = dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() -
> 1).Item("RevisionNum")
> Else
> MyMessageBox("The PartNum you entered does not have a valid Revision
> Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number")
> End If
> Return sPartRev
> End Function
>
> End Module
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of John Driggers
> Sent: Wednesday, August 15, 2012 7:35 AM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> You shouldn't need to. What is the error you're receiving? If you stick
> your code up here it will likely help a lot.
>
> On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:
>
> > **
> >
> >
> > What I am doing is calling a BAQ and then adding two where clauses for
> > the PartNum and RevisionNum. I then execute the BAQ. This is all done
> > with local parameters inside of the method that I delegate for the
> thread.
> > Should I set the DynamicQueryAdapter object as global so that it is
> > owned by the Form?
> >
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > Behalf Of Jose Gomez
> > Sent: Tuesday, August 14, 2012 2:39 PM
> > To: vantage@yahoogroups.com
> > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> >
> > I've done it several times, how are you doing it? You can't update UI
> > items from a thread, so if its updating UI that's where your crash is
> > happening your best bet is to instanciate a new BO do your stuff and
> > then refresh the UI once its donre.l
> >
> > *Jose C Gomez*
> > *Software Engineer*
> > *
> > *
> > *
> > *T: 904.469.1524 mobile
> > E: jose@...
> > http://www.josecgomez.com
> > <http://www.linkedin.com/in/josecgomez>
> > <http://www.facebook.com/josegomez
> > >
> > <http://www.google.com/profiles/jose.gomez>
> > <http://www.twitter.com/joc85>
> > <http://www.josecgomez.com/professional-resume/>
> > <http://www.josecgomez.com/feed/>
> > <http://www.usdoingstuff.com>
> >
> > *Quis custodiet ipsos custodes?*
> >
> > On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...>
> wrote:
> >
> > > **
> > >
> > >
> > > Has anyone used threading with Business Objects? I am trying to use
> > > it to spawn a thread for a method that takes 5 minutes. I am
> > > utilizing the DynamicQueryAdapter in my method.
> > >
> > > the strange thing is that I can call the BOConnect(), GetByID(),
> > > AddWhereItem() and Update methods, but when I try to call the
> > > Execute method it crashes.
> > >
> > > Does anyone have any thoughts and/or ideas on this?
> > >
> > > Dan
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> > have already linked your email address to a yahoo id to enable access.
> > )
> > (1) To access the Files Section of our Yahoo!Group for Report Builder
> > and Crystal Reports and other 'goodies', please goto:
> > http://groups.yahoo.com/group/vantage/files/.
> > (2) To search through old msg's goto:
> > http://groups.yahoo.com/group/vantage/messages
> > (3) To view links to Vendors that provide Vantage services goto:
> > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
> already linked your email address to a yahoo id to enable access. )
> (1) To access the Files Section of our Yahoo!Group for Report Builder and
> Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]
Ok, I will work on that, thanks.

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Wednesday, August 15, 2012 8:36 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

WOW ok that's a lot of code, but anything in RetrieveAvailabilityData which touches the UI has got to go


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Wed, Aug 15, 2012 at 11:07 AM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> Here is the code, thanks ahead of time if you guys can help me out on this.
>
> Dan
>
> '//**************************************************
> '// Custom VB.NET code for UD01Form
> '// Created: 6/5/2008 1:06:23 PM
> '//**************************************************
> Imports System
> Imports System.Data
> Imports System.Diagnostics
> Imports System.Windows.Forms
> Imports System.ComponentModel
> Imports Microsoft.VisualBasic
> Imports Epicor.Mfg.UI
> Imports Epicor.Mfg.UI.FrameWork
> Imports Epicor.Mfg.UI.ExtendedProps
> Imports Epicor.Mfg.UI.FormFunctions
> Imports Epicor.Mfg.UI.Customization
> Imports Epicor.Mfg.UI.Adapters
> Imports Epicor.Mfg.UI.Searches
> IMPORTS System.IO
> Imports Epicor.Mfg.BO
> Imports Infragistics.Win
> Imports Infragistics.Shared
> Imports Infragistics.Win.UltraWinGrid
> Imports System.Reflection
> Imports Infragistics.Win.UltraWinToolBars Imports System.Threading
>
> Module 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 WithEvents
> timephasAdapter As TimePhasAdapter Private WithEvents edvTimePhas As
> EpiDataView Private dsAvailability AS System.Data.DataSet Private
> dsTimePhase AS System.Data.DataSet Private nAvailabilityDataColumns AS
> Integer = 0 Private nTimePhaseDataColumns AS Integer = 0 Private Const
> sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
> Private bDeveloperLoggedIn AS Boolean = False Private bGridSizeSet AS
> Boolean = False Private Const nGridID_ComponentAvailability AS Integer
> = 1 Private Const nGridID_TimePhase AS Integer = 2 Private bFormLoaded
> AS Boolean = False Private baseToolbarsManager As
> Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
> Private sCurrentPartNum AS String = String.Empty Private
> dteShortageDate AS Date Private nAvailableQty AS Decimal = 0 Private
> bCancelRetrieve AS Boolean = False Private thrdSpawnNewThread AS
> Thread 'Private dynQryAD As DynamicQueryAdapter = New
> DynamicQueryAdapter(UD01Form)
>
> Sub InitializeCustomCode()
>
> '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added
> Variable Intialization' lines ** '// Begin Wizard Added Variable
> Intialization
>
> '// End Wizard Added Variable Intialization '// Begin Custom Method
> Calls If Thread.CurrentThread.Name = Nothing Then
> thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
> End If
>
> 'dynQryAD = New DynamicQueryAdapter(UD01Form)
> 'dynQryAD.BOconnect()
>
> dsAvailability = New System.Data.DataSet("Results") dsTimePhase = New
> System.Data.DataSet("Results") timephasAdapter = New
> timephasAdapter(oTrans)
> timephasAdapter.BOConnect()
>
> edvTimePhas = new EpiDataView()
> edvTimePhas.dataView = New
> DataView(timephasAdapter.TimePhasData.TimePhas)
>
> If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
> oTrans.Add("TimePhasView",edvTimePhas)
> End If
>
> dim obj as Object =
> GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolba
> rsManager", BindingFlags.Instance Or BindingFlags.GetField Or
> BindingFlags.NonPublic, Nothing, UD01Form, Nothing)
> BaseToolbarsManager =
> ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
> AddHandler baseToolbarsManager.ToolClick, AddressOf
> baseToolbarsManager_ToolClick
>
>
> '// End Custom Method Calls
> End Sub
>
> Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object,
> ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
> Select case args.tool.key
> Case "ClearTool"
> ClearData(False)
> 'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly,
> "baseToolbarsManager.ToolClick")
> End Select
> End Sub
>
> Sub 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
> releaseObject(edvTimePhas)
>
> timephasAdapter.Dispose()
> releaseObject(timephasAdapter)
>
> dsTimePhase.Dispose()
> releaseObject(dsTimePhase)
>
> dsAvailability.Dispose()
> releaseObject(dsAvailability)
>
> 'dynQryAD.Dispose()
> 'releaseObject(dynQryAD)
>
> End Sub
>
> Private Sub UD01Form_Load(ByVal sender As object, ByVal args As
> EventArgs) Handles UD01Form.Load '// '// Add Event Handler Code '//
> Dim userID As String = UD01Form.Session.UserID bFormLoaded = False
> bDeveloperLoggedIn = False Select userID Case "dgodfrey"
> bDeveloperLoggedIn = True
> Case Else
> bDeveloperLoggedIn = False
> End Select
> AddingDataColumns(dsAvailability, ugdBOMGrid,
> nGridID_ComponentAvailability)
>
> 'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)
>
> ugdBOMGrid.Width = 1070
> ugdBOMGrid.Height = 165
>
> ugdBOMGrid.Width = 1070
> ugdBOMGrid.Height = 250
>
> grpFilters.Show()
> chkExceptionsOnly.Show()
> lblExceptionsOnly.Show()
> chkExceptionsOnly.Checked = False
> chkExcludeConsignments.Show()
> chkExcludeConsignments.Show()
> chkExcludeConsignments.Checked = False
>
> grpTimePhaseFilters.Show()
> chkSuggestions.Show()
> lblSuggestions.Show()
> chkSuggestions.Checked = False
> chkForecasting.Checked = False
>
> IF(bDeveloperLoggedIn) Then
> btnShowSize.Show()
> ChkForecasting.Show()
> lblForecasting.Show()
> btnCancelRetrieve.Show()
> Else
> ChkForecasting.Hide()
> lblForecasting.Hide()
> btnShowSize.Hide()
> btnCancelRetrieve.Hide()
> End If
>
> Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel =
> CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57fb
> 7a6"),
> Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
> Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel =
> CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e2
> 74b"),
> Epicor.Mfg.UI.App.UD01Entry.MainPanel)
> myTreeViewPanel.Dispose()
> myMainPanel.Dispose()
> bFormLoaded = True
> otrans.pushstatustext("Ready!", False) End Sub
>
> '/********************************************************************
> /
> '/********************************************************************
> /
> '/**************** Start of Generic Function
> *************************/
> '/********************************************************************
> /
> '/********************************************************************
> / Private Sub ClearData(ByVal bGridOnly AS Boolean) IF(bGridOnly =
> False) Then txtBOMPartNum.Text = String.Empty txtPartDescription.Text
> = String.Empty txtBOMRevisionNum.text = String.Empty
> txtProductionQty.Text = String.Empty End If
> dsAvailability.Tables(0).Rows.Clear()
> ugdBOMGrid.Text = "BOM Components"
> ugdTimePhase.Text = "Time Phase Inquiry"
>
> timephasAdapter.clearData()
> edvTimePhas.EpiDataChanged()
> End Sub
>
> Private Sub ShowSize()
> DIM msg AS String = String.Empty
> msg = msg & "Form Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> ugdBOMGrid.FindForm().Bottom & ", Top = " & ugdBOMGrid.FindForm().Top
> & ", Width = " & ugdBOMGrid.FindForm().Width & ", Height = " &
> ugdBOMGrid.FindForm().Height & chr(13) & chr(10) msg = msg &
> "ugdBOMGrid Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top & ", Width = " &
> ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height &
> chr(13) & chr(10)
> msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10) msg = msg &
> "Bottom = " & ugdTimePhase.Bottom & ", Top = " & ugdTimePhase.Top & ",
> Width = " & ugdTimePhase.Width & ", Height = " & ugdTimePhase.Height &
> chr(13) & chr(10) MyMessageBox(msg, bDeveloperLoggedIn,
> MsgBoxStyle.OKOnly, "Grid Sizes")
>
> End Sub
>
> Private Sub ValidateGridSize()
> Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width Dim nHeight AS
> Integer = ugdBOMGrid.FindForm().Height DIM nCriteriaAreaPlusFooting AS
> Integer = 250 Dim nSpaceBtwnGrids AS Integer = 5
>
> ugdBOMGrid.Width = (nWidth - 50)
> ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4
>
> ugdTimePhase.Left = ugdBOMGrid.Left
> ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height +
> nSpaceBtwnGrids ugdTimePhase.Width = ugdBOMGrid.Width
> ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6
>
>
> btnShowSize.Left = ugdBOMGrid.Left
> btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height +
> nSpaceBtwnGrids ugdBOMGrid.Anchor = AnchorStyles.Bottom Or
> AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
> 'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> AnchorStyles.Left Or AnchorStyles.Top bGridSizeSet = True
>
> 'ShowSize()
> End Sub
>
> Private Sub GridCustomization(ByRef Collection AS
> Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier
> AS
> Integer)
> Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
> IF(GridIdentifier = nGridID_ComponentAvailability) Then For each
> column in Collection Select column.Header.Caption Case "Rev", "Part
> Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
> column.Hidden = True
> Case "Lvl"
> column.Width = 30
> column.CellAppearance.TextHAlign = HAlign.Right Case "MtlSeq", "Lead"
> column.Width = 50
> column.CellAppearance.TextHAlign = HAlign.Right Case "Material Part"
> column.Width = 150
> Case "PartDescription"
> column.Width = 250
> Case "Type"
> column.Width = 50
> Case "RequiredQty"
> column.Width = 75
> column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> column.CellAppearance.TextHAlign = HAlign.Right Case "ClassID"
> column.Width = 50
> Case "TotalQtyOnHand", "AvailableQty"
> column.Width = 125
> column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> column.CellAppearance.TextHAlign = HAlign.Right Case Else
> 'column.Hidden = True
>
> End Select
> Next Column
> Else'nGridID_TimePhase
> Dim nOrdinal AS Integer = 0
> For each column in Collection
> Select column.Header.Caption
> Case "Due"
> 'column.Ordinal = 0
> Case "Receipts"
> 'column.Ordinal = 1
> Case "Job"
> 'column.Ordinal = 2
> Case "Order"
> 'column.Ordinal = 3
> Case "RequiredQty"
> 'column.Ordinal = 4
> Case "PO"
> 'column.Ordinal = 5
> Case "Lead"
> 'column.Ordinal = 6
> Case "Balance"
> 'column.Ordinal = 7
> Case "Exception"
> 'column.Ordinal = 8
> Case "Order By"
> 'column.Ordinal = 9
> Case "Source"
> 'column.Ordinal = 10
> Case "JobStatus"
> 'column.Ordinal = 11
> 'nOrdinal = 11
> Case Else
> 'column.Ordinal = 11
> 'nOrdinal = nOrdinal + 1
> 'column.Hidden = True
> End Select
> Next Column
> End IF
>
> End Sub 'GridCustomization(ByRef Collection AS
> Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier
> AS
> Integer)
>
> Private Sub TransferDataRow(ByRef myDataSet AS
> System.Data.DataSet,ByVal nFirstColumnIndex AS Integer, ByVal
> nColumnCnt AS Integer, ByVal SrcRow AS
> DataRow)
> ' Instantiate a new row using the NewRow method.
> Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
> Dim i AS Integer = 0
> 'Insert code to fill the row with values.
> For i = nFirstColumnIndex To nColumnCnt
> newRow.Item(i) = SrcRow.Item(i)
> Next i
> 'Add the row to the DataRowCollection.
> myDataSet.Tables("Results").Rows.Add(newRow)
> myDataSet.Tables("Results").AcceptChanges()
> End Sub 'TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal
> nFirstColumnIndex, ByVal nColumnCnt AS Integer, ByVal SrcRow AS
> DataRow)
>
> Private Sub AddingDataColumns(ByRef myDataSet AS System.Data.DataSet,
> ByRef myGrid AS Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal
> GridIdentifier AS Integer)
>
> IF(myDataSet.Tables.Count <= 0)Then
> myDataSet.Tables.Add("Results")
> End If
> '// ** Place Event Handling Code Here **
> otrans.pushstatustext("Retrieving Data ...", False) 'Dim sStatusString
> as String = String.Empty
>
> IF(GridIdentifier = nGridID_ComponentAvailability) Then Dim
> sStatusString AS String = String.EMpty Dim nColumns AS Integer = 0 Dim
> dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
> Dim sBaqID AS String = sAvailabilityBAQID sBaqID = sAvailabilityBAQID
>
> dynQryAD.BOconnect()
> dynQryAD.GetByID(sBaqID)
>
> For Each DR AS DataRow in
> dynQryAD.QueryDesignData.Tables("SelectedField").Rows
> nColumns = nColumns + 1
> sStatusString = "AddingDataColumns function: Adding " & nColumns & "/"
> & dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & " ColumnName:
> " & DR.Item("FieldLabel") & " is " &
> DR.Item("DataType").ToString().ToUpper()
> WriteToLogFile(sStatusString)
> Select DR.Item("DataType").ToString().ToUpper()
> Case "CHARACTER"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.String"))
> Case "INTEGER"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Int32"))
> Case "DECIMAL"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Decimal"))
> Case "LOGICAL"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Boolean"))
> Case "DATE"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.DateTime"))
> Case Else
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.String"))
> End Select
> myDataSet.Tables(0).AcceptChanges()
> Next
> nAvailabilityDataColumns = nColumns - 1
> dynQryAD.Dispose()
> releaseObject(dynQryAD)
> Else'nGridID_TimePhase
> End If
>
> myGrid.DataSource = myDataSet
> GridCustomization(myGrid.DisplayLayout.Bands(0).Columns,
> GridIdentifier)
>
> End Sub 'AddingDataColumns()
>
> Private Function ShowDebugInformation() AS String Dim sRet AS String
> '& Chr(13) & Chr(10) sRet = "Debug Data:" & Chr(13) & Chr(10) sRet =
> sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
> sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13) &
> Chr(10)
> sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail & Chr(13)
> &
> Chr(10)
> sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName &
> Chr(13) & Chr(10) sRet = sRet & "- ProductCode = " &
> UD01Form.Session.ProductCode & Chr(13) & Chr(10)
> WriteToLogFile(sRet)
>
> Return sRet
> End Function 'ShowDebugInformation() AS String
>
> Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet)
> AS String Dim sRet AS String = String.Empty sRet = "INSIDE
> ShowDataSet:" & chr(13) & chr(10)
> WriteToLogFile(sRet)
> sRet = String.Empty
> For each Table as DataTable in myDataSet.Tables sRet = sRet & "Table:
> " & Table.TableName & chr(13) & chr(10) For Each DR AS DataRow in
> Table.Rows For Each DC as DataColumn in Table.Columns IF(DC.ColumnName
> = "RowIdent") Then Exit For End If sRet = sRet & DC.ColumnName & ":" &
> DR(DC.ColumnName)& ", "
> Next'For Each DC as DataColumn in Table.Columns sRet = sRet & chr(13)
> & chr(10) Next'For Each DR AS DataRow in Table.Rows Next'For each
> Table
> WriteToLogFile(sRet)
> Return sRet
> End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS
> String
>
> Private Function GetDataColumnInformation(ByVal myDataTable AS
> DataTable) AS String Dim sRet AS String = String.Empty
>
> sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
> WriteToLogFile(sRet)
> sRet = String.Empty
> For Each DC as DataColumn in myDataTable.Columns sRet = sRet &
> DC.ColumnName & ", "
> Next'For Each DC as DataColumn in Table.Columns sRet = sRet & chr(13)
> & chr(10)
> WriteToLogFile(sRet)
>
> Return sRet
> End Function 'GetDataColumnInformation(ByVal myDataTable AS DataTable)
> AS String
>
> ''' <summary>
> ''' Copies the the specified number of rows from the top of the
> specified table.
> ''' </summary>
> ''' <param name="table">
> ''' The table containing the original rows.
> ''' </param>
> ''' <param name="rowCount">
> ''' The number of rows to copy.
> ''' </param>
> ''' <param name="useView">
> ''' Indicates whether the row order should be based on the DefaultView
> or not.
> ''' </param>
> ''' <returns>
> ''' A DataTable containing the copied rows.
> ''' </returns>
> Private Function GetTopRows(ByVal table As DataTable, _ ByVal rowCount
> As Integer, _ ByVal useDefaultView As Boolean) As DataTable 'You can't
> get more rows than exist.
> If useDefaultView Then
> rowCount = Math.Min(rowCount, table.DefaultView.Count) Else rowCount =
> Math.Min(rowCount, table.Rows.Count) End If 'Copy the table schema.
> Dim topTable As DataTable = table.Clone() 'Copy the specified number
> of rows.
> For rowIndex As Integer = 0 To rowCount - 1 Step 1 If useDefaultView
> Then 'Take the top rows from the DeafultView.
> topTable.ImportRow(table.DefaultView(rowIndex).Row)
> Else
> 'Take the top rows from the original table.
> topTable.ImportRow(table.Rows(rowIndex))
> End If
> Next rowIndex
> Return topTable
> End Function
>
> Private Function WriteToLogFile(ByVal TextString AS String) as Boolean
> Dim bResults AS Boolean = False
>
> Dim sInputString AS String = TextString & Chr(13) & Chr(10) Dim sPath
> AS String = "C:\BOM_CAR_log.txt"
>
>
> IF(File.Exists(sPath) = False) Then
> ' Create a file to write to.
> File.WriteAllText(sPath, sInputString) bResults = True Else ' This
> text is always added, making the file longer over time ' if it is not
> deleted.
> File.AppendAllText(sPath, sInputString) bResults = True End If return
> bResults End Function 'WriteToLogFile(ByVal TextString AS String) as
> Boolean
>
> Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly,
> Optional ByVal Title As String = Nothing) As MsgBoxResult Dim results
> As MsgBoxResult If(FYI = True) Then If Not String.IsNullOrEmpty(Title)
> Then results = MsgBox(Msg, Button, Title) Else results = MsgBox(Msg,
> Button) End If End If return results End Function 'MyMessageBox( ByVal
> Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As
> MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String =
> Nothing) As MsgBoxResult
>
> Private Function FindValueFromArray(ByVal Values As Object(), ByVal
> valueToSearch As Object) As Integer Dim retVal As Integer = 0 Dim
> myArray As Array = DirectCast(Values, Array) If Array.IndexOf(myArray,
> valueToSearch) <> -1 Then retVal = Array.IndexOf(myArray,
> valueToSearch) Else retVal = -1 End If Return retVal End Function
> 'FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As
> Object) As Integer
>
> Private Sub releaseObject(ByVal obj As Object) Try
> System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
> obj = Nothing
> Catch ex As Exception
> obj = Nothing
> Finally
> GC.Collect()
> End Try
> End Sub 'releaseObject(ByVal obj As Object)
> '/********************************************************************
> /
> '/********************************************************************
> /
> '/**************** End of Generic Function
> ***************************/
> '/********************************************************************
> /
> '/********************************************************************
> /
>
> '/********************************************************************
> /
> '/********************************************************************
> /
> '/**************** Start of BOM_CAR Function
> *************************/
> '/********************************************************************
> /
> '/********************************************************************
> /
>
> Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal Args
> As
> System.EventArgs) Handles btnCancelRetrieve.Click '// ** Place Event
> Handling Code Here ** IF(btnRetrieve.Enabled = False) Then
> bCancelRetrieve = True 'thrdSpawnNewThread.Abort
> 'ClearData(True)
> End If
> End Sub
>
> Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles ugdBOMGrid.Resize '// ** Place Event
> Handling Code Here **
> ValidateGridSize()
> End Sub
>
> Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnRetrieve.Click btnRetrieve.Enabled =
> False thrdSpawnNewThread = new Thread(AddressOf
> RetrieveAvailabilityData) thrdSpawnNewThread.Start
> 'RetrieveAvailabilityData()
> IF(bGridSizeSet = False) Then
> ValidateGridSize()
> End If
> btnRetrieve.Enabled = True
> End Sub
>
> Private Function GetShortageQtyANDDate(ByVal sPartNum AS String, ByVal
> nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity AS
> Decimal) AS Boolean
>
> Dim blTimePhas As Boolean =
> timephasAdapter.GoProcessTimePhase(sPartNum,
> "MfgSys", chkSuggestions.Checked, False)
> 'ShowDataSet(timephasAdapter.TimePhasData)
> IF(blTimePhas = True) Then
> For Each drRow as DataRow in
> timephasAdapter.TimePhasData.Tables("TimePhas").Rows
> drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
> Quantity = drRow.Item("BalanceQty") IF(Quantity <= 0) then blTimePhas
> = True
> IF(drRow.Item("DueDate").ToString() <> "") then sDate =
> drRow.Item("DueDate").Date End If Exit For Else blTimePhas = False End
> If
>
> Next
> timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
> End If
>
> Return blTimePhas
> End Function
>
> Private Sub RetrieveTimePhaseInquiry()
>
> IF(ugdBOMGrid.Text <> "") Then
> otrans.pushstatustext("Retrieving TimePhase Data ...", True)
>
> timephasAdapter.clearData()
> Dim blTimePhas As Boolean =
> GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.Acti
> veRow.Band.Columns("Material
> Part")),
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Re
> quiredQty")),
> dteShortageDate, nAvailableQty)
> edvTimePhas.EpiDataChanged()
> ugdTimePhase.Text = "Time Phase Inquiry: Part: " &
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Ma
> terial
> Part")) & " Description: " &
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Pa
> rtDescription"))
>
> otrans.pushstatustext("Ready!", False) End IF End Sub
>
> Private Sub RetrieveAvailabilityData() '// ** Place Event Handling
> Code Here ** Dim dynQryAD As DynamicQueryAdapter = New
> DynamicQueryAdapter(UD01Form) Dim pcTable As String = "PartRev"
> Dim pcField As String = "PartNum"
> Dim pbIsConst As Boolean = TRUE
> Dim pcCondition As String = "="
> Dim pcToValue as String = txtBOMPartNum.Text Dim pcToTable As String =
> String.Empty Dim pcToField As String = String.Empty Dim
> pcRightParentheses as String = String.Empty Dim pcLeftParentheses as
> String = String.Empty Dim pcAndOr as String = String.Empty Dim pbNeg
> as Boolean = False Try WriteToLogFile("Retrieving Availability Data
> ...") otrans.pushstatustext("Retrieving Availability Data ...", True)
>
> dynQryAD.BOconnect()
>
> dsAvailability.Tables(0).Rows.Clear()
> ugdBOMGrid.DataSource.Tables(0).Rows.Clear()
>
> dynQryAD.GetByID(sAvailabilityBAQID)
>
> dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> dynQryAD.Update pcField = "RevisionNum"
> pcToValue = txtBOMRevisionNum.Text.ToString() pcAndOr = "AND"
> dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> dynQryAD.Update
>
> ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> Infragistics.Win.DefaultableBoolean.True
>
> WriteToLogFile("copy all data from QueryDesignData tables to
> DynamicQueryData tables (only for tables that exist in both
> datasets)") '//copy all data from QueryDesignData tables to
> DynamicQueryData tables (only 'for tables that exist in both datasets
>
> Dim targetRow as DataRow
> For each Table as DataTable in dynQryAD.DynamicQueryData.Tables If
> Table.Rows.Count = 0 Then For Each sourceRow as DataRow in
> dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
> targetRow = Table.NewRow()
> targetRow.ItemArray = sourceRow.ItemArray
> Table.Rows.Add(targetRow)
> Next
> End If
> Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
>
> WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
> dynQryAD.Execute(dynQryAD.DynamicQueryData)
>
> WriteToLogFile("Processing " &
> dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> records.") otrans.pushstatustext("Processing " &
> dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> records.",
> True)
> Dim RecCnt AS Integer = 0
> Dim AddToGrid AS Boolean = True
> Dim bNegAvail AS boolean = False
> WriteToLogFile("Pre-Filtered DataSet")
> ShowDataSet(dynQryAD.QueryResults)
>
> For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> 'myDataSet has records
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
> AddToGrid = True
>
> ORow.Item("RequiredQty") = ORow.Item("RequiredQty") *
> txtProductionQty.Value nAvailableQty = ORow.Item("PartPlant.Number01")
> - ORow.Item("RequiredQty") dteShortageDate = Today() IF(nAvailableQty
> > 0) then bNegAvail =
> GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"),
> ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty) Else
> bNegAvail = True End If
>
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
>
> ORow.Item("ShortageDate") = dteShortageDate.Date
> ORow.Item("AvailableQty") = nAvailableQty
>
> IF(chkExceptionsOnly.Checked = True) Then AddToGrid = bNegAvail End If
> IF(chkExcludeConsignments.Checked) Then Select
> ORow.Item("Part.ClassID") Case "CARR"
> AddToGrid = False
> Case "CTTI"
> AddToGrid = False
> Case "CAVN"
> AddToGrid = False
> Case Else
> AddToGrid = AddToGrid
> End Select
> End If
>
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
>
> If(AddToGrid) then
> RecCnt = RecCnt + 1
> TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow) End
> If Next'For Each ORow as DataRow in
> dynQryAD.QueryResults.Tables(0).Rows
> IF(bCancelRetrieve = True) Then
> bCancelRetrieve = False
> Else
> otrans.pushstatustext("Processed " & RecCnt & " Component records.",
> True) WriteToLogFile("Processed " & RecCnt & " Component records.")
> WriteToLogFile("Grid-Filtered DataSet")
> ShowDataSet(dsAvailability)
>
> dsAvailability.Tables("Results").Columns("Material
> Part").ExtendedProperties("Like") = "Part.PartNum"
> dsAvailability.Tables("Results").AcceptChanges()
> IF(RecCnt > 0) Then
> ugdBOMGrid.Text =
> dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> txtPartdescription.Text =
> dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> ugdBOMGrid.DataSource = dsAvailability
> GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns,
> nGridID_ComponentAvailability)
> Else
> MyMessageBox("There was no exceptions found.", True,
> MsgBoxStyle.OKOnly, "Availability Report")
> timephasAdapter.clearData()
> edvTimePhas.EpiDataChanged()
>
> End If
>
> ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> Infragistics.Win.DefaultableBoolean.False
> End If
> Catch abortException As ThreadAbortException
> MyMessageBox(abortException.Message & ": " &
> CType(abortException.ExceptionState, String), True,
> MsgBoxStyle.OKOnly, "Availability Report") finally
> dynQryAD.Dispose()
> releaseObject(dynQryAD)
> End Try
> End Sub 'RetrieveSalesData()
>
> Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal Args
> As
> System.EventArgs) Handles btnPartRevSearch.Click '// ** Place Event
> Handling Code Here ** Dim recordSelected As Boolean Dim sPart AS
> String = txtBOMPartNum.Text Dim wClause AS String = "PartNum >= '" +
> sPart + "'"
>
> IF(sPart.length() <= 0) Then
> wClause = String.Empty
> End If
> Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form,
> "PartRevSearchAdapter", recordSelected, True, wClause, False)
>
> If( recordSelected) Then
> txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
> txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
> End If
> End Sub
>
> Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnShowSize.Click '// ** Place Event
> Handling Code Here **
> ShowSize()
> End Sub
>
> Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object, ByVal
> Args As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate '// **
> Place Event Handling Code Here **
> RetrieveTimePhaseInquiry()
> End Sub
>
> Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As
> Object, ByVal Args As System.EventArgs) Handles
> chkSuggestions.AfterCheckStateChanged
> '// ** Place Event Handling Code Here **
> IF(bFormLoaded) Then
> RetrieveTimePhaseInquiry()
> End If
> End Sub
>
> Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles txtBOMPartNum.Leave '// ** Place Event
> Handling Code Here ** IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
> txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
> sCurrentPartNum = txtBOMPartNum.Text
> End If
>
> End Sub
>
> Private Function GetLatestPartRev (ByVal sPartNum As string) As string
>
> Dim sPartRev As String = String.Empty
> Dim recSelected As Boolean = False
> Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"
>
> Dim dsSearch As DataSet
> dsSearch = SearchFunctions.listLookup(oTrans, "PartRevSearchAdapter",
> recSelected, False, swhereClause, True) If recSelected Then sPartRev =
> dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() -
> 1).Item("RevisionNum")
> Else
> MyMessageBox("The PartNum you entered does not have a valid Revision
> Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number") End If
> Return sPartRev End Function
>
> End Module
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of John Driggers
> Sent: Wednesday, August 15, 2012 7:35 AM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> You shouldn't need to. What is the error you're receiving? If you
> stick your code up here it will likely help a lot.
>
> On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:
>
> > **
> >
> >
> > What I am doing is calling a BAQ and then adding two where clauses
> > for the PartNum and RevisionNum. I then execute the BAQ. This is all
> > done with local parameters inside of the method that I delegate for
> > the
> thread.
> > Should I set the DynamicQueryAdapter object as global so that it is
> > owned by the Form?
> >
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > Behalf Of Jose Gomez
> > Sent: Tuesday, August 14, 2012 2:39 PM
> > To: vantage@yahoogroups.com
> > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> >
> > I've done it several times, how are you doing it? You can't update
> > UI items from a thread, so if its updating UI that's where your
> > crash is happening your best bet is to instanciate a new BO do your
> > stuff and then refresh the UI once its donre.l
> >
> > *Jose C Gomez*
> > *Software Engineer*
> > *
> > *
> > *
> > *T: 904.469.1524 mobile
> > E: jose@...
> > http://www.josecgomez.com
> > <http://www.linkedin.com/in/josecgomez>
> > <http://www.facebook.com/josegomez
> > >
> > <http://www.google.com/profiles/jose.gomez>
> > <http://www.twitter.com/joc85>
> > <http://www.josecgomez.com/professional-resume/>
> > <http://www.josecgomez.com/feed/>
> > <http://www.usdoingstuff.com>
> >
> > *Quis custodiet ipsos custodes?*
> >
> > On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...>
> wrote:
> >
> > > **
> > >
> > >
> > > Has anyone used threading with Business Objects? I am trying to
> > > use it to spawn a thread for a method that takes 5 minutes. I am
> > > utilizing the DynamicQueryAdapter in my method.
> > >
> > > the strange thing is that I can call the BOConnect(), GetByID(),
> > > AddWhereItem() and Update methods, but when I try to call the
> > > Execute method it crashes.
> > >
> > > Does anyone have any thoughts and/or ideas on this?
> > >
> > > Dan
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > must have already linked your email address to a yahoo id to enable access.
> > )
> > (1) To access the Files Section of our Yahoo!Group for Report
> > Builder and Crystal Reports and other 'goodies', please goto:
> > http://groups.yahoo.com/group/vantage/files/.
> > (2) To search through old msg's goto:
> > http://groups.yahoo.com/group/vantage/messages
> > (3) To view links to Vendors that provide Vantage services goto:
> > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
I am having a problem. I need to update the grids with the data that was processed on that extra thread. The purpose was that because the data processing potentially covers 5 minutes of time, which during that whole time Vantage would be useless, and the users need to be able to continue with other things IN Vantage during that time.

With knowing the purpose of the threading, is there any other way to accomplish this?

Is it possible to kick-off a timer to monitor a variable (Boolean) change that would update the UI. I then could set the timer when I start the thread and then set a boolean change variable inside the data processing function when it is complete. That would then kick-off the timer function to update the UI.

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Dan Godfrey
Sent: Wednesday, August 15, 2012 8:56 AM
To: vantage@yahoogroups.com
Subject: RE: [Vantage] Vantage 8.03.409C: System.Threading and BO

Ok, I will work on that, thanks.

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Wednesday, August 15, 2012 8:36 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

WOW ok that's a lot of code, but anything in RetrieveAvailabilityData which touches the UI has got to go


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Wed, Aug 15, 2012 at 11:07 AM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> Here is the code, thanks ahead of time if you guys can help me out on this.
>
> Dan
>
> '//**************************************************
> '// Custom VB.NET code for UD01Form
> '// Created: 6/5/2008 1:06:23 PM
> '//**************************************************
> Imports System
> Imports System.Data
> Imports System.Diagnostics
> Imports System.Windows.Forms
> Imports System.ComponentModel
> Imports Microsoft.VisualBasic
> Imports Epicor.Mfg.UI
> Imports Epicor.Mfg.UI.FrameWork
> Imports Epicor.Mfg.UI.ExtendedProps
> Imports Epicor.Mfg.UI.FormFunctions
> Imports Epicor.Mfg.UI.Customization
> Imports Epicor.Mfg.UI.Adapters
> Imports Epicor.Mfg.UI.Searches
> IMPORTS System.IO
> Imports Epicor.Mfg.BO
> Imports Infragistics.Win
> Imports Infragistics.Shared
> Imports Infragistics.Win.UltraWinGrid
> Imports System.Reflection
> Imports Infragistics.Win.UltraWinToolBars Imports System.Threading
>
> Module 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 WithEvents
> timephasAdapter As TimePhasAdapter Private WithEvents edvTimePhas As
> EpiDataView Private dsAvailability AS System.Data.DataSet Private
> dsTimePhase AS System.Data.DataSet Private nAvailabilityDataColumns AS
> Integer = 0 Private nTimePhaseDataColumns AS Integer = 0 Private Const
> sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
> Private bDeveloperLoggedIn AS Boolean = False Private bGridSizeSet AS
> Boolean = False Private Const nGridID_ComponentAvailability AS Integer
> = 1 Private Const nGridID_TimePhase AS Integer = 2 Private bFormLoaded
> AS Boolean = False Private baseToolbarsManager As
> Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
> Private sCurrentPartNum AS String = String.Empty Private
> dteShortageDate AS Date Private nAvailableQty AS Decimal = 0 Private
> bCancelRetrieve AS Boolean = False Private thrdSpawnNewThread AS
> Thread 'Private dynQryAD As DynamicQueryAdapter = New
> DynamicQueryAdapter(UD01Form)
>
> Sub InitializeCustomCode()
>
> '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added
> Variable Intialization' lines ** '// Begin Wizard Added Variable
> Intialization
>
> '// End Wizard Added Variable Intialization '// Begin Custom Method
> Calls If Thread.CurrentThread.Name = Nothing Then
> thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
> End If
>
> 'dynQryAD = New DynamicQueryAdapter(UD01Form)
> 'dynQryAD.BOconnect()
>
> dsAvailability = New System.Data.DataSet("Results") dsTimePhase = New
> System.Data.DataSet("Results") timephasAdapter = New
> timephasAdapter(oTrans)
> timephasAdapter.BOConnect()
>
> edvTimePhas = new EpiDataView()
> edvTimePhas.dataView = New
> DataView(timephasAdapter.TimePhasData.TimePhas)
>
> If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
> oTrans.Add("TimePhasView",edvTimePhas)
> End If
>
> dim obj as Object =
> GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolba
> rsManager", BindingFlags.Instance Or BindingFlags.GetField Or
> BindingFlags.NonPublic, Nothing, UD01Form, Nothing)
> BaseToolbarsManager =
> ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
> AddHandler baseToolbarsManager.ToolClick, AddressOf
> baseToolbarsManager_ToolClick
>
>
> '// End Custom Method Calls
> End Sub
>
> Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object,
> ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
> Select case args.tool.key
> Case "ClearTool"
> ClearData(False)
> 'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly,
> "baseToolbarsManager.ToolClick")
> End Select
> End Sub
>
> Sub 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
> releaseObject(edvTimePhas)
>
> timephasAdapter.Dispose()
> releaseObject(timephasAdapter)
>
> dsTimePhase.Dispose()
> releaseObject(dsTimePhase)
>
> dsAvailability.Dispose()
> releaseObject(dsAvailability)
>
> 'dynQryAD.Dispose()
> 'releaseObject(dynQryAD)
>
> End Sub
>
> Private Sub UD01Form_Load(ByVal sender As object, ByVal args As
> EventArgs) Handles UD01Form.Load '// '// Add Event Handler Code '//
> Dim userID As String = UD01Form.Session.UserID bFormLoaded = False
> bDeveloperLoggedIn = False Select userID Case "dgodfrey"
> bDeveloperLoggedIn = True
> Case Else
> bDeveloperLoggedIn = False
> End Select
> AddingDataColumns(dsAvailability, ugdBOMGrid,
> nGridID_ComponentAvailability)
>
> 'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)
>
> ugdBOMGrid.Width = 1070
> ugdBOMGrid.Height = 165
>
> ugdBOMGrid.Width = 1070
> ugdBOMGrid.Height = 250
>
> grpFilters.Show()
> chkExceptionsOnly.Show()
> lblExceptionsOnly.Show()
> chkExceptionsOnly.Checked = False
> chkExcludeConsignments.Show()
> chkExcludeConsignments.Show()
> chkExcludeConsignments.Checked = False
>
> grpTimePhaseFilters.Show()
> chkSuggestions.Show()
> lblSuggestions.Show()
> chkSuggestions.Checked = False
> chkForecasting.Checked = False
>
> IF(bDeveloperLoggedIn) Then
> btnShowSize.Show()
> ChkForecasting.Show()
> lblForecasting.Show()
> btnCancelRetrieve.Show()
> Else
> ChkForecasting.Hide()
> lblForecasting.Hide()
> btnShowSize.Hide()
> btnCancelRetrieve.Hide()
> End If
>
> Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel =
> CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57fb
> 7a6"),
> Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
> Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel =
> CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e2
> 74b"),
> Epicor.Mfg.UI.App.UD01Entry.MainPanel)
> myTreeViewPanel.Dispose()
> myMainPanel.Dispose()
> bFormLoaded = True
> otrans.pushstatustext("Ready!", False) End Sub
>
> '/********************************************************************
> /
> '/********************************************************************
> /
> '/**************** Start of Generic Function
> *************************/
> '/********************************************************************
> /
> '/********************************************************************
> / Private Sub ClearData(ByVal bGridOnly AS Boolean) IF(bGridOnly =
> False) Then txtBOMPartNum.Text = String.Empty txtPartDescription.Text
> = String.Empty txtBOMRevisionNum.text = String.Empty
> txtProductionQty.Text = String.Empty End If
> dsAvailability.Tables(0).Rows.Clear()
> ugdBOMGrid.Text = "BOM Components"
> ugdTimePhase.Text = "Time Phase Inquiry"
>
> timephasAdapter.clearData()
> edvTimePhas.EpiDataChanged()
> End Sub
>
> Private Sub ShowSize()
> DIM msg AS String = String.Empty
> msg = msg & "Form Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> ugdBOMGrid.FindForm().Bottom & ", Top = " & ugdBOMGrid.FindForm().Top
> & ", Width = " & ugdBOMGrid.FindForm().Width & ", Height = " &
> ugdBOMGrid.FindForm().Height & chr(13) & chr(10) msg = msg &
> "ugdBOMGrid Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top & ", Width = " &
> ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height &
> chr(13) & chr(10)
> msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10) msg = msg &
> "Bottom = " & ugdTimePhase.Bottom & ", Top = " & ugdTimePhase.Top & ",
> Width = " & ugdTimePhase.Width & ", Height = " & ugdTimePhase.Height &
> chr(13) & chr(10) MyMessageBox(msg, bDeveloperLoggedIn,
> MsgBoxStyle.OKOnly, "Grid Sizes")
>
> End Sub
>
> Private Sub ValidateGridSize()
> Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width Dim nHeight AS
> Integer = ugdBOMGrid.FindForm().Height DIM nCriteriaAreaPlusFooting AS
> Integer = 250 Dim nSpaceBtwnGrids AS Integer = 5
>
> ugdBOMGrid.Width = (nWidth - 50)
> ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4
>
> ugdTimePhase.Left = ugdBOMGrid.Left
> ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height +
> nSpaceBtwnGrids ugdTimePhase.Width = ugdBOMGrid.Width
> ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6
>
>
> btnShowSize.Left = ugdBOMGrid.Left
> btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height +
> nSpaceBtwnGrids ugdBOMGrid.Anchor = AnchorStyles.Bottom Or
> AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
> 'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> AnchorStyles.Left Or AnchorStyles.Top bGridSizeSet = True
>
> 'ShowSize()
> End Sub
>
> Private Sub GridCustomization(ByRef Collection AS
> Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier
> AS
> Integer)
> Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
> IF(GridIdentifier = nGridID_ComponentAvailability) Then For each
> column in Collection Select column.Header.Caption Case "Rev", "Part
> Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
> column.Hidden = True
> Case "Lvl"
> column.Width = 30
> column.CellAppearance.TextHAlign = HAlign.Right Case "MtlSeq", "Lead"
> column.Width = 50
> column.CellAppearance.TextHAlign = HAlign.Right Case "Material Part"
> column.Width = 150
> Case "PartDescription"
> column.Width = 250
> Case "Type"
> column.Width = 50
> Case "RequiredQty"
> column.Width = 75
> column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> column.CellAppearance.TextHAlign = HAlign.Right Case "ClassID"
> column.Width = 50
> Case "TotalQtyOnHand", "AvailableQty"
> column.Width = 125
> column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> column.CellAppearance.TextHAlign = HAlign.Right Case Else
> 'column.Hidden = True
>
> End Select
> Next Column
> Else'nGridID_TimePhase
> Dim nOrdinal AS Integer = 0
> For each column in Collection
> Select column.Header.Caption
> Case "Due"
> 'column.Ordinal = 0
> Case "Receipts"
> 'column.Ordinal = 1
> Case "Job"
> 'column.Ordinal = 2
> Case "Order"
> 'column.Ordinal = 3
> Case "RequiredQty"
> 'column.Ordinal = 4
> Case "PO"
> 'column.Ordinal = 5
> Case "Lead"
> 'column.Ordinal = 6
> Case "Balance"
> 'column.Ordinal = 7
> Case "Exception"
> 'column.Ordinal = 8
> Case "Order By"
> 'column.Ordinal = 9
> Case "Source"
> 'column.Ordinal = 10
> Case "JobStatus"
> 'column.Ordinal = 11
> 'nOrdinal = 11
> Case Else
> 'column.Ordinal = 11
> 'nOrdinal = nOrdinal + 1
> 'column.Hidden = True
> End Select
> Next Column
> End IF
>
> End Sub 'GridCustomization(ByRef Collection AS
> Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier
> AS
> Integer)
>
> Private Sub TransferDataRow(ByRef myDataSet AS
> System.Data.DataSet,ByVal nFirstColumnIndex AS Integer, ByVal
> nColumnCnt AS Integer, ByVal SrcRow AS
> DataRow)
> ' Instantiate a new row using the NewRow method.
> Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
> Dim i AS Integer = 0
> 'Insert code to fill the row with values.
> For i = nFirstColumnIndex To nColumnCnt
> newRow.Item(i) = SrcRow.Item(i)
> Next i
> 'Add the row to the DataRowCollection.
> myDataSet.Tables("Results").Rows.Add(newRow)
> myDataSet.Tables("Results").AcceptChanges()
> End Sub 'TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal
> nFirstColumnIndex, ByVal nColumnCnt AS Integer, ByVal SrcRow AS
> DataRow)
>
> Private Sub AddingDataColumns(ByRef myDataSet AS System.Data.DataSet,
> ByRef myGrid AS Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal
> GridIdentifier AS Integer)
>
> IF(myDataSet.Tables.Count <= 0)Then
> myDataSet.Tables.Add("Results")
> End If
> '// ** Place Event Handling Code Here **
> otrans.pushstatustext("Retrieving Data ...", False) 'Dim sStatusString
> as String = String.Empty
>
> IF(GridIdentifier = nGridID_ComponentAvailability) Then Dim
> sStatusString AS String = String.EMpty Dim nColumns AS Integer = 0 Dim
> dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
> Dim sBaqID AS String = sAvailabilityBAQID sBaqID = sAvailabilityBAQID
>
> dynQryAD.BOconnect()
> dynQryAD.GetByID(sBaqID)
>
> For Each DR AS DataRow in
> dynQryAD.QueryDesignData.Tables("SelectedField").Rows
> nColumns = nColumns + 1
> sStatusString = "AddingDataColumns function: Adding " & nColumns & "/"
> & dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & " ColumnName:
> " & DR.Item("FieldLabel") & " is " &
> DR.Item("DataType").ToString().ToUpper()
> WriteToLogFile(sStatusString)
> Select DR.Item("DataType").ToString().ToUpper()
> Case "CHARACTER"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.String"))
> Case "INTEGER"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Int32"))
> Case "DECIMAL"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Decimal"))
> Case "LOGICAL"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.Boolean"))
> Case "DATE"
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.DateTime"))
> Case Else
> myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> Type.GetType("System.String"))
> End Select
> myDataSet.Tables(0).AcceptChanges()
> Next
> nAvailabilityDataColumns = nColumns - 1
> dynQryAD.Dispose()
> releaseObject(dynQryAD)
> Else'nGridID_TimePhase
> End If
>
> myGrid.DataSource = myDataSet
> GridCustomization(myGrid.DisplayLayout.Bands(0).Columns,
> GridIdentifier)
>
> End Sub 'AddingDataColumns()
>
> Private Function ShowDebugInformation() AS String Dim sRet AS String
> '& Chr(13) & Chr(10) sRet = "Debug Data:" & Chr(13) & Chr(10) sRet =
> sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
> sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13) &
> Chr(10)
> sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail & Chr(13)
> &
> Chr(10)
> sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName &
> Chr(13) & Chr(10) sRet = sRet & "- ProductCode = " &
> UD01Form.Session.ProductCode & Chr(13) & Chr(10)
> WriteToLogFile(sRet)
>
> Return sRet
> End Function 'ShowDebugInformation() AS String
>
> Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet)
> AS String Dim sRet AS String = String.Empty sRet = "INSIDE
> ShowDataSet:" & chr(13) & chr(10)
> WriteToLogFile(sRet)
> sRet = String.Empty
> For each Table as DataTable in myDataSet.Tables sRet = sRet & "Table:
> " & Table.TableName & chr(13) & chr(10) For Each DR AS DataRow in
> Table.Rows For Each DC as DataColumn in Table.Columns IF(DC.ColumnName
> = "RowIdent") Then Exit For End If sRet = sRet & DC.ColumnName & ":" &
> DR(DC.ColumnName)& ", "
> Next'For Each DC as DataColumn in Table.Columns sRet = sRet & chr(13)
> & chr(10) Next'For Each DR AS DataRow in Table.Rows Next'For each
> Table
> WriteToLogFile(sRet)
> Return sRet
> End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS
> String
>
> Private Function GetDataColumnInformation(ByVal myDataTable AS
> DataTable) AS String Dim sRet AS String = String.Empty
>
> sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
> WriteToLogFile(sRet)
> sRet = String.Empty
> For Each DC as DataColumn in myDataTable.Columns sRet = sRet &
> DC.ColumnName & ", "
> Next'For Each DC as DataColumn in Table.Columns sRet = sRet & chr(13)
> & chr(10)
> WriteToLogFile(sRet)
>
> Return sRet
> End Function 'GetDataColumnInformation(ByVal myDataTable AS DataTable)
> AS String
>
> ''' <summary>
> ''' Copies the the specified number of rows from the top of the
> specified table.
> ''' </summary>
> ''' <param name="table">
> ''' The table containing the original rows.
> ''' </param>
> ''' <param name="rowCount">
> ''' The number of rows to copy.
> ''' </param>
> ''' <param name="useView">
> ''' Indicates whether the row order should be based on the DefaultView
> or not.
> ''' </param>
> ''' <returns>
> ''' A DataTable containing the copied rows.
> ''' </returns>
> Private Function GetTopRows(ByVal table As DataTable, _ ByVal rowCount
> As Integer, _ ByVal useDefaultView As Boolean) As DataTable 'You can't
> get more rows than exist.
> If useDefaultView Then
> rowCount = Math.Min(rowCount, table.DefaultView.Count) Else rowCount =
> Math.Min(rowCount, table.Rows.Count) End If 'Copy the table schema.
> Dim topTable As DataTable = table.Clone() 'Copy the specified number
> of rows.
> For rowIndex As Integer = 0 To rowCount - 1 Step 1 If useDefaultView
> Then 'Take the top rows from the DeafultView.
> topTable.ImportRow(table.DefaultView(rowIndex).Row)
> Else
> 'Take the top rows from the original table.
> topTable.ImportRow(table.Rows(rowIndex))
> End If
> Next rowIndex
> Return topTable
> End Function
>
> Private Function WriteToLogFile(ByVal TextString AS String) as Boolean
> Dim bResults AS Boolean = False
>
> Dim sInputString AS String = TextString & Chr(13) & Chr(10) Dim sPath
> AS String = "C:\BOM_CAR_log.txt"
>
>
> IF(File.Exists(sPath) = False) Then
> ' Create a file to write to.
> File.WriteAllText(sPath, sInputString) bResults = True Else ' This
> text is always added, making the file longer over time ' if it is not
> deleted.
> File.AppendAllText(sPath, sInputString) bResults = True End If return
> bResults End Function 'WriteToLogFile(ByVal TextString AS String) as
> Boolean
>
> Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly,
> Optional ByVal Title As String = Nothing) As MsgBoxResult Dim results
> As MsgBoxResult If(FYI = True) Then If Not String.IsNullOrEmpty(Title)
> Then results = MsgBox(Msg, Button, Title) Else results = MsgBox(Msg,
> Button) End If End If return results End Function 'MyMessageBox( ByVal
> Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As
> MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String =
> Nothing) As MsgBoxResult
>
> Private Function FindValueFromArray(ByVal Values As Object(), ByVal
> valueToSearch As Object) As Integer Dim retVal As Integer = 0 Dim
> myArray As Array = DirectCast(Values, Array) If Array.IndexOf(myArray,
> valueToSearch) <> -1 Then retVal = Array.IndexOf(myArray,
> valueToSearch) Else retVal = -1 End If Return retVal End Function
> 'FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As
> Object) As Integer
>
> Private Sub releaseObject(ByVal obj As Object) Try
> System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
> obj = Nothing
> Catch ex As Exception
> obj = Nothing
> Finally
> GC.Collect()
> End Try
> End Sub 'releaseObject(ByVal obj As Object)
> '/********************************************************************
> /
> '/********************************************************************
> /
> '/**************** End of Generic Function
> ***************************/
> '/********************************************************************
> /
> '/********************************************************************
> /
>
> '/********************************************************************
> /
> '/********************************************************************
> /
> '/**************** Start of BOM_CAR Function
> *************************/
> '/********************************************************************
> /
> '/********************************************************************
> /
>
> Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal Args
> As
> System.EventArgs) Handles btnCancelRetrieve.Click '// ** Place Event
> Handling Code Here ** IF(btnRetrieve.Enabled = False) Then
> bCancelRetrieve = True 'thrdSpawnNewThread.Abort
> 'ClearData(True)
> End If
> End Sub
>
> Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles ugdBOMGrid.Resize '// ** Place Event
> Handling Code Here **
> ValidateGridSize()
> End Sub
>
> Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnRetrieve.Click btnRetrieve.Enabled =
> False thrdSpawnNewThread = new Thread(AddressOf
> RetrieveAvailabilityData) thrdSpawnNewThread.Start
> 'RetrieveAvailabilityData()
> IF(bGridSizeSet = False) Then
> ValidateGridSize()
> End If
> btnRetrieve.Enabled = True
> End Sub
>
> Private Function GetShortageQtyANDDate(ByVal sPartNum AS String, ByVal
> nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity AS
> Decimal) AS Boolean
>
> Dim blTimePhas As Boolean =
> timephasAdapter.GoProcessTimePhase(sPartNum,
> "MfgSys", chkSuggestions.Checked, False)
> 'ShowDataSet(timephasAdapter.TimePhasData)
> IF(blTimePhas = True) Then
> For Each drRow as DataRow in
> timephasAdapter.TimePhasData.Tables("TimePhas").Rows
> drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
> Quantity = drRow.Item("BalanceQty") IF(Quantity <= 0) then blTimePhas
> = True
> IF(drRow.Item("DueDate").ToString() <> "") then sDate =
> drRow.Item("DueDate").Date End If Exit For Else blTimePhas = False End
> If
>
> Next
> timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
> End If
>
> Return blTimePhas
> End Function
>
> Private Sub RetrieveTimePhaseInquiry()
>
> IF(ugdBOMGrid.Text <> "") Then
> otrans.pushstatustext("Retrieving TimePhase Data ...", True)
>
> timephasAdapter.clearData()
> Dim blTimePhas As Boolean =
> GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.Acti
> veRow.Band.Columns("Material
> Part")),
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Re
> quiredQty")),
> dteShortageDate, nAvailableQty)
> edvTimePhas.EpiDataChanged()
> ugdTimePhase.Text = "Time Phase Inquiry: Part: " &
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Ma
> terial
> Part")) & " Description: " &
> ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Pa
> rtDescription"))
>
> otrans.pushstatustext("Ready!", False) End IF End Sub
>
> Private Sub RetrieveAvailabilityData() '// ** Place Event Handling
> Code Here ** Dim dynQryAD As DynamicQueryAdapter = New
> DynamicQueryAdapter(UD01Form) Dim pcTable As String = "PartRev"
> Dim pcField As String = "PartNum"
> Dim pbIsConst As Boolean = TRUE
> Dim pcCondition As String = "="
> Dim pcToValue as String = txtBOMPartNum.Text Dim pcToTable As String =
> String.Empty Dim pcToField As String = String.Empty Dim
> pcRightParentheses as String = String.Empty Dim pcLeftParentheses as
> String = String.Empty Dim pcAndOr as String = String.Empty Dim pbNeg
> as Boolean = False Try WriteToLogFile("Retrieving Availability Data
> ...") otrans.pushstatustext("Retrieving Availability Data ...", True)
>
> dynQryAD.BOconnect()
>
> dsAvailability.Tables(0).Rows.Clear()
> ugdBOMGrid.DataSource.Tables(0).Rows.Clear()
>
> dynQryAD.GetByID(sAvailabilityBAQID)
>
> dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> dynQryAD.Update pcField = "RevisionNum"
> pcToValue = txtBOMRevisionNum.Text.ToString() pcAndOr = "AND"
> dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> dynQryAD.Update
>
> ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> Infragistics.Win.DefaultableBoolean.True
>
> WriteToLogFile("copy all data from QueryDesignData tables to
> DynamicQueryData tables (only for tables that exist in both
> datasets)") '//copy all data from QueryDesignData tables to
> DynamicQueryData tables (only 'for tables that exist in both datasets
>
> Dim targetRow as DataRow
> For each Table as DataTable in dynQryAD.DynamicQueryData.Tables If
> Table.Rows.Count = 0 Then For Each sourceRow as DataRow in
> dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
> targetRow = Table.NewRow()
> targetRow.ItemArray = sourceRow.ItemArray
> Table.Rows.Add(targetRow)
> Next
> End If
> Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
>
> WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
> dynQryAD.Execute(dynQryAD.DynamicQueryData)
>
> WriteToLogFile("Processing " &
> dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> records.") otrans.pushstatustext("Processing " &
> dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> records.",
> True)
> Dim RecCnt AS Integer = 0
> Dim AddToGrid AS Boolean = True
> Dim bNegAvail AS boolean = False
> WriteToLogFile("Pre-Filtered DataSet")
> ShowDataSet(dynQryAD.QueryResults)
>
> For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> 'myDataSet has records
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
> AddToGrid = True
>
> ORow.Item("RequiredQty") = ORow.Item("RequiredQty") *
> txtProductionQty.Value nAvailableQty = ORow.Item("PartPlant.Number01")
> - ORow.Item("RequiredQty") dteShortageDate = Today() IF(nAvailableQty
> > 0) then bNegAvail =
> GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"),
> ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty) Else
> bNegAvail = True End If
>
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
>
> ORow.Item("ShortageDate") = dteShortageDate.Date
> ORow.Item("AvailableQty") = nAvailableQty
>
> IF(chkExceptionsOnly.Checked = True) Then AddToGrid = bNegAvail End If
> IF(chkExcludeConsignments.Checked) Then Select
> ORow.Item("Part.ClassID") Case "CARR"
> AddToGrid = False
> Case "CTTI"
> AddToGrid = False
> Case "CAVN"
> AddToGrid = False
> Case Else
> AddToGrid = AddToGrid
> End Select
> End If
>
> IF(bCancelRetrieve = True) Then
> ClearData(True)
> Exit For
> End If
>
> If(AddToGrid) then
> RecCnt = RecCnt + 1
> TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow) End
> If Next'For Each ORow as DataRow in
> dynQryAD.QueryResults.Tables(0).Rows
> IF(bCancelRetrieve = True) Then
> bCancelRetrieve = False
> Else
> otrans.pushstatustext("Processed " & RecCnt & " Component records.",
> True) WriteToLogFile("Processed " & RecCnt & " Component records.")
> WriteToLogFile("Grid-Filtered DataSet")
> ShowDataSet(dsAvailability)
>
> dsAvailability.Tables("Results").Columns("Material
> Part").ExtendedProperties("Like") = "Part.PartNum"
> dsAvailability.Tables("Results").AcceptChanges()
> IF(RecCnt > 0) Then
> ugdBOMGrid.Text =
> dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> txtPartdescription.Text =
> dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> ugdBOMGrid.DataSource = dsAvailability
> GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns,
> nGridID_ComponentAvailability)
> Else
> MyMessageBox("There was no exceptions found.", True,
> MsgBoxStyle.OKOnly, "Availability Report")
> timephasAdapter.clearData()
> edvTimePhas.EpiDataChanged()
>
> End If
>
> ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> Infragistics.Win.DefaultableBoolean.False
> End If
> Catch abortException As ThreadAbortException
> MyMessageBox(abortException.Message & ": " &
> CType(abortException.ExceptionState, String), True,
> MsgBoxStyle.OKOnly, "Availability Report") finally
> dynQryAD.Dispose()
> releaseObject(dynQryAD)
> End Try
> End Sub 'RetrieveSalesData()
>
> Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal Args
> As
> System.EventArgs) Handles btnPartRevSearch.Click '// ** Place Event
> Handling Code Here ** Dim recordSelected As Boolean Dim sPart AS
> String = txtBOMPartNum.Text Dim wClause AS String = "PartNum >= '" +
> sPart + "'"
>
> IF(sPart.length() <= 0) Then
> wClause = String.Empty
> End If
> Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form,
> "PartRevSearchAdapter", recordSelected, True, wClause, False)
>
> If( recordSelected) Then
> txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
> txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
> End If
> End Sub
>
> Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles btnShowSize.Click '// ** Place Event
> Handling Code Here **
> ShowSize()
> End Sub
>
> Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object, ByVal
> Args As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate '// **
> Place Event Handling Code Here **
> RetrieveTimePhaseInquiry()
> End Sub
>
> Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As
> Object, ByVal Args As System.EventArgs) Handles
> chkSuggestions.AfterCheckStateChanged
> '// ** Place Event Handling Code Here **
> IF(bFormLoaded) Then
> RetrieveTimePhaseInquiry()
> End If
> End Sub
>
> Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args As
> System.EventArgs) Handles txtBOMPartNum.Leave '// ** Place Event
> Handling Code Here ** IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
> txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
> sCurrentPartNum = txtBOMPartNum.Text
> End If
>
> End Sub
>
> Private Function GetLatestPartRev (ByVal sPartNum As string) As string
>
> Dim sPartRev As String = String.Empty
> Dim recSelected As Boolean = False
> Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"
>
> Dim dsSearch As DataSet
> dsSearch = SearchFunctions.listLookup(oTrans, "PartRevSearchAdapter",
> recSelected, False, swhereClause, True) If recSelected Then sPartRev =
> dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() -
> 1).Item("RevisionNum")
> Else
> MyMessageBox("The PartNum you entered does not have a valid Revision
> Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number") End If
> Return sPartRev End Function
>
> End Module
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of John Driggers
> Sent: Wednesday, August 15, 2012 7:35 AM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> You shouldn't need to. What is the error you're receiving? If you
> stick your code up here it will likely help a lot.
>
> On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:
>
> > **
> >
> >
> > What I am doing is calling a BAQ and then adding two where clauses
> > for the PartNum and RevisionNum. I then execute the BAQ. This is all
> > done with local parameters inside of the method that I delegate for
> > the
> thread.
> > Should I set the DynamicQueryAdapter object as global so that it is
> > owned by the Form?
> >
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > Behalf Of Jose Gomez
> > Sent: Tuesday, August 14, 2012 2:39 PM
> > To: vantage@yahoogroups.com
> > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> >
> > I've done it several times, how are you doing it? You can't update
> > UI items from a thread, so if its updating UI that's where your
> > crash is happening your best bet is to instanciate a new BO do your
> > stuff and then refresh the UI once its donre.l
> >
> > *Jose C Gomez*
> > *Software Engineer*
> > *
> > *
> > *
> > *T: 904.469.1524 mobile
> > E: jose@...
> > http://www.josecgomez.com
> > <http://www.linkedin.com/in/josecgomez>
> > <http://www.facebook.com/josegomez
> > >
> > <http://www.google.com/profiles/jose.gomez>
> > <http://www.twitter.com/joc85>
> > <http://www.josecgomez.com/professional-resume/>
> > <http://www.josecgomez.com/feed/>
> > <http://www.usdoingstuff.com>
> >
> > *Quis custodiet ipsos custodes?*
> >
> > On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...>
> wrote:
> >
> > > **
> > >
> > >
> > > Has anyone used threading with Business Objects? I am trying to
> > > use it to spawn a thread for a method that takes 5 minutes. I am
> > > utilizing the DynamicQueryAdapter in my method.
> > >
> > > the strange thing is that I can call the BOConnect(), GetByID(),
> > > AddWhereItem() and Update methods, but when I try to call the
> > > Execute method it crashes.
> > >
> > > Does anyone have any thoughts and/or ideas on this?
> > >
> > > Dan
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > must have already linked your email address to a yahoo id to enable access.
> > )
> > (1) To access the Files Section of our Yahoo!Group for Report
> > Builder and Crystal Reports and other 'goodies', please goto:
> > http://groups.yahoo.com/group/vantage/files/.
> > (2) To search through old msg's goto:
> > http://groups.yahoo.com/group/vantage/messages
> > (3) To view links to Vendors that provide Vantage services goto:
> > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links





------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
You can update the UI you just have to do it Thread Safe

YOURFORM.Invoke((ThreadStart)delegate()
{

// CD 7/11/2012

// Changed rows to 5 for testing.

// TODO: Set rows=grdJobs.Rows.Count after testing is done.

pbProgress.Maximum=rows;
pbProgress.Minimum=0;
pbProgress.Value=0;
pbProgress.Step=1;
});


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Wed, Aug 15, 2012 at 1:32 PM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> I am having a problem. I need to update the grids with the data that was
> processed on that extra thread. The purpose was that because the data
> processing potentially covers 5 minutes of time, which during that whole
> time Vantage would be useless, and the users need to be able to continue
> with other things IN Vantage during that time.
>
> With knowing the purpose of the threading, is there any other way to
> accomplish this?
>
> Is it possible to kick-off a timer to monitor a variable (Boolean) change
> that would update the UI. I then could set the timer when I start the
> thread and then set a boolean change variable inside the data processing
> function when it is complete. That would then kick-off the timer function
> to update the UI.
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of Dan Godfrey
> Sent: Wednesday, August 15, 2012 8:56 AM
> To: vantage@yahoogroups.com
> Subject: RE: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> Ok, I will work on that, thanks.
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of Jose Gomez
> Sent: Wednesday, August 15, 2012 8:36 AM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> WOW ok that's a lot of code, but anything in RetrieveAvailabilityData
> which touches the UI has got to go
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez
> >
> <http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
> On Wed, Aug 15, 2012 at 11:07 AM, Dan Godfrey <dgodfrey@...> wrote:
>
> > **
> >
> >
> > Here is the code, thanks ahead of time if you guys can help me out on
> this.
> >
> > Dan
> >
> > '//**************************************************
> > '// Custom VB.NET code for UD01Form
> > '// Created: 6/5/2008 1:06:23 PM
> > '//**************************************************
> > Imports System
> > Imports System.Data
> > Imports System.Diagnostics
> > Imports System.Windows.Forms
> > Imports System.ComponentModel
> > Imports Microsoft.VisualBasic
> > Imports Epicor.Mfg.UI
> > Imports Epicor.Mfg.UI.FrameWork
> > Imports Epicor.Mfg.UI.ExtendedProps
> > Imports Epicor.Mfg.UI.FormFunctions
> > Imports Epicor.Mfg.UI.Customization
> > Imports Epicor.Mfg.UI.Adapters
> > Imports Epicor.Mfg.UI.Searches
> > IMPORTS System.IO
> > Imports Epicor.Mfg.BO
> > Imports Infragistics.Win
> > Imports Infragistics.Shared
> > Imports Infragistics.Win.UltraWinGrid
> > Imports System.Reflection
> > Imports Infragistics.Win.UltraWinToolBars Imports System.Threading
> >
> > Module 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 WithEvents
> > timephasAdapter As TimePhasAdapter Private WithEvents edvTimePhas As
> > EpiDataView Private dsAvailability AS System.Data.DataSet Private
> > dsTimePhase AS System.Data.DataSet Private nAvailabilityDataColumns AS
> > Integer = 0 Private nTimePhaseDataColumns AS Integer = 0 Private Const
> > sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
> > Private bDeveloperLoggedIn AS Boolean = False Private bGridSizeSet AS
> > Boolean = False Private Const nGridID_ComponentAvailability AS Integer
> > = 1 Private Const nGridID_TimePhase AS Integer = 2 Private bFormLoaded
> > AS Boolean = False Private baseToolbarsManager As
> > Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
> > Private sCurrentPartNum AS String = String.Empty Private
> > dteShortageDate AS Date Private nAvailableQty AS Decimal = 0 Private
> > bCancelRetrieve AS Boolean = False Private thrdSpawnNewThread AS
> > Thread 'Private dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form)
> >
> > Sub InitializeCustomCode()
> >
> > '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added
> > Variable Intialization' lines ** '// Begin Wizard Added Variable
> > Intialization
> >
> > '// End Wizard Added Variable Intialization '// Begin Custom Method
> > Calls If Thread.CurrentThread.Name = Nothing Then
> > thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
> > End If
> >
> > 'dynQryAD = New DynamicQueryAdapter(UD01Form)
> > 'dynQryAD.BOconnect()
> >
> > dsAvailability = New System.Data.DataSet("Results") dsTimePhase = New
> > System.Data.DataSet("Results") timephasAdapter = New
> > timephasAdapter(oTrans)
> > timephasAdapter.BOConnect()
> >
> > edvTimePhas = new EpiDataView()
> > edvTimePhas.dataView = New
> > DataView(timephasAdapter.TimePhasData.TimePhas)
> >
> > If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
> > oTrans.Add("TimePhasView",edvTimePhas)
> > End If
> >
> > dim obj as Object =
> > GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolba
> > rsManager", BindingFlags.Instance Or BindingFlags.GetField Or
> > BindingFlags.NonPublic, Nothing, UD01Form, Nothing)
> > BaseToolbarsManager =
> > ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
> > AddHandler baseToolbarsManager.ToolClick, AddressOf
> > baseToolbarsManager_ToolClick
> >
> >
> > '// End Custom Method Calls
> > End Sub
> >
> > Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object,
> > ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
> > Select case args.tool.key
> > Case "ClearTool"
> > ClearData(False)
> > 'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly,
> > "baseToolbarsManager.ToolClick")
> > End Select
> > End Sub
> >
> > Sub 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
> > releaseObject(edvTimePhas)
> >
> > timephasAdapter.Dispose()
> > releaseObject(timephasAdapter)
> >
> > dsTimePhase.Dispose()
> > releaseObject(dsTimePhase)
> >
> > dsAvailability.Dispose()
> > releaseObject(dsAvailability)
> >
> > 'dynQryAD.Dispose()
> > 'releaseObject(dynQryAD)
> >
> > End Sub
> >
> > Private Sub UD01Form_Load(ByVal sender As object, ByVal args As
> > EventArgs) Handles UD01Form.Load '// '// Add Event Handler Code '//
> > Dim userID As String = UD01Form.Session.UserID bFormLoaded = False
> > bDeveloperLoggedIn = False Select userID Case "dgodfrey"
> > bDeveloperLoggedIn = True
> > Case Else
> > bDeveloperLoggedIn = False
> > End Select
> > AddingDataColumns(dsAvailability, ugdBOMGrid,
> > nGridID_ComponentAvailability)
> >
> > 'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)
> >
> > ugdBOMGrid.Width = 1070
> > ugdBOMGrid.Height = 165
> >
> > ugdBOMGrid.Width = 1070
> > ugdBOMGrid.Height = 250
> >
> > grpFilters.Show()
> > chkExceptionsOnly.Show()
> > lblExceptionsOnly.Show()
> > chkExceptionsOnly.Checked = False
> > chkExcludeConsignments.Show()
> > chkExcludeConsignments.Show()
> > chkExcludeConsignments.Checked = False
> >
> > grpTimePhaseFilters.Show()
> > chkSuggestions.Show()
> > lblSuggestions.Show()
> > chkSuggestions.Checked = False
> > chkForecasting.Checked = False
> >
> > IF(bDeveloperLoggedIn) Then
> > btnShowSize.Show()
> > ChkForecasting.Show()
> > lblForecasting.Show()
> > btnCancelRetrieve.Show()
> > Else
> > ChkForecasting.Hide()
> > lblForecasting.Hide()
> > btnShowSize.Hide()
> > btnCancelRetrieve.Hide()
> > End If
> >
> > Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel =
> > CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57fb
> > 7a6"),
> > Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
> > Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel =
> > CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e2
> > 74b"),
> > Epicor.Mfg.UI.App.UD01Entry.MainPanel)
> > myTreeViewPanel.Dispose()
> > myMainPanel.Dispose()
> > bFormLoaded = True
> > otrans.pushstatustext("Ready!", False) End Sub
> >
> > '/********************************************************************
> > /
> > '/********************************************************************
> > /
> > '/**************** Start of Generic Function
> > *************************/
> > '/********************************************************************
> > /
> > '/********************************************************************
> > / Private Sub ClearData(ByVal bGridOnly AS Boolean) IF(bGridOnly =
> > False) Then txtBOMPartNum.Text = String.Empty txtPartDescription.Text
> > = String.Empty txtBOMRevisionNum.text = String.Empty
> > txtProductionQty.Text = String.Empty End If
> > dsAvailability.Tables(0).Rows.Clear()
> > ugdBOMGrid.Text = "BOM Components"
> > ugdTimePhase.Text = "Time Phase Inquiry"
> >
> > timephasAdapter.clearData()
> > edvTimePhas.EpiDataChanged()
> > End Sub
> >
> > Private Sub ShowSize()
> > DIM msg AS String = String.Empty
> > msg = msg & "Form Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> > ugdBOMGrid.FindForm().Bottom & ", Top = " & ugdBOMGrid.FindForm().Top
> > & ", Width = " & ugdBOMGrid.FindForm().Width & ", Height = " &
> > ugdBOMGrid.FindForm().Height & chr(13) & chr(10) msg = msg &
> > "ugdBOMGrid Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> > ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top & ", Width = " &
> > ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height &
> > chr(13) & chr(10)
> > msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10) msg = msg &
> > "Bottom = " & ugdTimePhase.Bottom & ", Top = " & ugdTimePhase.Top & ",
> > Width = " & ugdTimePhase.Width & ", Height = " & ugdTimePhase.Height &
> > chr(13) & chr(10) MyMessageBox(msg, bDeveloperLoggedIn,
> > MsgBoxStyle.OKOnly, "Grid Sizes")
> >
> > End Sub
> >
> > Private Sub ValidateGridSize()
> > Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width Dim nHeight AS
> > Integer = ugdBOMGrid.FindForm().Height DIM nCriteriaAreaPlusFooting AS
> > Integer = 250 Dim nSpaceBtwnGrids AS Integer = 5
> >
> > ugdBOMGrid.Width = (nWidth - 50)
> > ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4
> >
> > ugdTimePhase.Left = ugdBOMGrid.Left
> > ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height +
> > nSpaceBtwnGrids ugdTimePhase.Width = ugdBOMGrid.Width
> > ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6
> >
> >
> > btnShowSize.Left = ugdBOMGrid.Left
> > btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height +
> > nSpaceBtwnGrids ugdBOMGrid.Anchor = AnchorStyles.Bottom Or
> > AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
> > 'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> > AnchorStyles.Left Or AnchorStyles.Top bGridSizeSet = True
> >
> > 'ShowSize()
> > End Sub
> >
> > Private Sub GridCustomization(ByRef Collection AS
> > Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier
> > AS
> > Integer)
> > Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
> > IF(GridIdentifier = nGridID_ComponentAvailability) Then For each
> > column in Collection Select column.Header.Caption Case "Rev", "Part
> > Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
> > column.Hidden = True
> > Case "Lvl"
> > column.Width = 30
> > column.CellAppearance.TextHAlign = HAlign.Right Case "MtlSeq", "Lead"
> > column.Width = 50
> > column.CellAppearance.TextHAlign = HAlign.Right Case "Material Part"
> > column.Width = 150
> > Case "PartDescription"
> > column.Width = 250
> > Case "Type"
> > column.Width = 50
> > Case "RequiredQty"
> > column.Width = 75
> > column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> > column.CellAppearance.TextHAlign = HAlign.Right Case "ClassID"
> > column.Width = 50
> > Case "TotalQtyOnHand", "AvailableQty"
> > column.Width = 125
> > column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> > column.CellAppearance.TextHAlign = HAlign.Right Case Else
> > 'column.Hidden = True
> >
> > End Select
> > Next Column
> > Else'nGridID_TimePhase
> > Dim nOrdinal AS Integer = 0
> > For each column in Collection
> > Select column.Header.Caption
> > Case "Due"
> > 'column.Ordinal = 0
> > Case "Receipts"
> > 'column.Ordinal = 1
> > Case "Job"
> > 'column.Ordinal = 2
> > Case "Order"
> > 'column.Ordinal = 3
> > Case "RequiredQty"
> > 'column.Ordinal = 4
> > Case "PO"
> > 'column.Ordinal = 5
> > Case "Lead"
> > 'column.Ordinal = 6
> > Case "Balance"
> > 'column.Ordinal = 7
> > Case "Exception"
> > 'column.Ordinal = 8
> > Case "Order By"
> > 'column.Ordinal = 9
> > Case "Source"
> > 'column.Ordinal = 10
> > Case "JobStatus"
> > 'column.Ordinal = 11
> > 'nOrdinal = 11
> > Case Else
> > 'column.Ordinal = 11
> > 'nOrdinal = nOrdinal + 1
> > 'column.Hidden = True
> > End Select
> > Next Column
> > End IF
> >
> > End Sub 'GridCustomization(ByRef Collection AS
> > Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal GridIdentifier
> > AS
> > Integer)
> >
> > Private Sub TransferDataRow(ByRef myDataSet AS
> > System.Data.DataSet,ByVal nFirstColumnIndex AS Integer, ByVal
> > nColumnCnt AS Integer, ByVal SrcRow AS
> > DataRow)
> > ' Instantiate a new row using the NewRow method.
> > Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
> > Dim i AS Integer = 0
> > 'Insert code to fill the row with values.
> > For i = nFirstColumnIndex To nColumnCnt
> > newRow.Item(i) = SrcRow.Item(i)
> > Next i
> > 'Add the row to the DataRowCollection.
> > myDataSet.Tables("Results").Rows.Add(newRow)
> > myDataSet.Tables("Results").AcceptChanges()
> > End Sub 'TransferDataRow(ByRef myDataSet AS System.Data.DataSet,ByVal
> > nFirstColumnIndex, ByVal nColumnCnt AS Integer, ByVal SrcRow AS
> > DataRow)
> >
> > Private Sub AddingDataColumns(ByRef myDataSet AS System.Data.DataSet,
> > ByRef myGrid AS Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal
> > GridIdentifier AS Integer)
> >
> > IF(myDataSet.Tables.Count <= 0)Then
> > myDataSet.Tables.Add("Results")
> > End If
> > '// ** Place Event Handling Code Here **
> > otrans.pushstatustext("Retrieving Data ...", False) 'Dim sStatusString
> > as String = String.Empty
> >
> > IF(GridIdentifier = nGridID_ComponentAvailability) Then Dim
> > sStatusString AS String = String.EMpty Dim nColumns AS Integer = 0 Dim
> > dynQryAD As DynamicQueryAdapter = New DynamicQueryAdapter(UD01Form)
> > Dim sBaqID AS String = sAvailabilityBAQID sBaqID = sAvailabilityBAQID
> >
> > dynQryAD.BOconnect()
> > dynQryAD.GetByID(sBaqID)
> >
> > For Each DR AS DataRow in
> > dynQryAD.QueryDesignData.Tables("SelectedField").Rows
> > nColumns = nColumns + 1
> > sStatusString = "AddingDataColumns function: Adding " & nColumns & "/"
> > & dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & "
> ColumnName:
> > " & DR.Item("FieldLabel") & " is " &
> > DR.Item("DataType").ToString().ToUpper()
> > WriteToLogFile(sStatusString)
> > Select DR.Item("DataType").ToString().ToUpper()
> > Case "CHARACTER"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.String"))
> > Case "INTEGER"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Int32"))
> > Case "DECIMAL"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Decimal"))
> > Case "LOGICAL"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Boolean"))
> > Case "DATE"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.DateTime"))
> > Case Else
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.String"))
> > End Select
> > myDataSet.Tables(0).AcceptChanges()
> > Next
> > nAvailabilityDataColumns = nColumns - 1
> > dynQryAD.Dispose()
> > releaseObject(dynQryAD)
> > Else'nGridID_TimePhase
> > End If
> >
> > myGrid.DataSource = myDataSet
> > GridCustomization(myGrid.DisplayLayout.Bands(0).Columns,
> > GridIdentifier)
> >
> > End Sub 'AddingDataColumns()
> >
> > Private Function ShowDebugInformation() AS String Dim sRet AS String
> > '& Chr(13) & Chr(10) sRet = "Debug Data:" & Chr(13) & Chr(10) sRet =
> > sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
> > sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13) &
> > Chr(10)
> > sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail & Chr(13)
> > &
> > Chr(10)
> > sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName &
> > Chr(13) & Chr(10) sRet = sRet & "- ProductCode = " &
> > UD01Form.Session.ProductCode & Chr(13) & Chr(10)
> > WriteToLogFile(sRet)
> >
> > Return sRet
> > End Function 'ShowDebugInformation() AS String
> >
> > Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet)
> > AS String Dim sRet AS String = String.Empty sRet = "INSIDE
> > ShowDataSet:" & chr(13) & chr(10)
> > WriteToLogFile(sRet)
> > sRet = String.Empty
> > For each Table as DataTable in myDataSet.Tables sRet = sRet & "Table:
> > " & Table.TableName & chr(13) & chr(10) For Each DR AS DataRow in
> > Table.Rows For Each DC as DataColumn in Table.Columns IF(DC.ColumnName
> > = "RowIdent") Then Exit For End If sRet = sRet & DC.ColumnName & ":" &
> > DR(DC.ColumnName)& ", "
> > Next'For Each DC as DataColumn in Table.Columns sRet = sRet & chr(13)
> > & chr(10) Next'For Each DR AS DataRow in Table.Rows Next'For each
> > Table
> > WriteToLogFile(sRet)
> > Return sRet
> > End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS
> > String
> >
> > Private Function GetDataColumnInformation(ByVal myDataTable AS
> > DataTable) AS String Dim sRet AS String = String.Empty
> >
> > sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
> > WriteToLogFile(sRet)
> > sRet = String.Empty
> > For Each DC as DataColumn in myDataTable.Columns sRet = sRet &
> > DC.ColumnName & ", "
> > Next'For Each DC as DataColumn in Table.Columns sRet = sRet & chr(13)
> > & chr(10)
> > WriteToLogFile(sRet)
> >
> > Return sRet
> > End Function 'GetDataColumnInformation(ByVal myDataTable AS DataTable)
> > AS String
> >
> > ''' <summary>
> > ''' Copies the the specified number of rows from the top of the
> > specified table.
> > ''' </summary>
> > ''' <param name="table">
> > ''' The table containing the original rows.
> > ''' </param>
> > ''' <param name="rowCount">
> > ''' The number of rows to copy.
> > ''' </param>
> > ''' <param name="useView">
> > ''' Indicates whether the row order should be based on the DefaultView
> > or not.
> > ''' </param>
> > ''' <returns>
> > ''' A DataTable containing the copied rows.
> > ''' </returns>
> > Private Function GetTopRows(ByVal table As DataTable, _ ByVal rowCount
> > As Integer, _ ByVal useDefaultView As Boolean) As DataTable 'You can't
> > get more rows than exist.
> > If useDefaultView Then
> > rowCount = Math.Min(rowCount, table.DefaultView.Count) Else rowCount =
> > Math.Min(rowCount, table.Rows.Count) End If 'Copy the table schema.
> > Dim topTable As DataTable = table.Clone() 'Copy the specified number
> > of rows.
> > For rowIndex As Integer = 0 To rowCount - 1 Step 1 If useDefaultView
> > Then 'Take the top rows from the DeafultView.
> > topTable.ImportRow(table.DefaultView(rowIndex).Row)
> > Else
> > 'Take the top rows from the original table.
> > topTable.ImportRow(table.Rows(rowIndex))
> > End If
> > Next rowIndex
> > Return topTable
> > End Function
> >
> > Private Function WriteToLogFile(ByVal TextString AS String) as Boolean
> > Dim bResults AS Boolean = False
> >
> > Dim sInputString AS String = TextString & Chr(13) & Chr(10) Dim sPath
> > AS String = "C:\BOM_CAR_log.txt"
> >
> >
> > IF(File.Exists(sPath) = False) Then
> > ' Create a file to write to.
> > File.WriteAllText(sPath, sInputString) bResults = True Else ' This
> > text is always added, making the file longer over time ' if it is not
> > deleted.
> > File.AppendAllText(sPath, sInputString) bResults = True End If return
> > bResults End Function 'WriteToLogFile(ByVal TextString AS String) as
> > Boolean
> >
> > Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> > Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly,
> > Optional ByVal Title As String = Nothing) As MsgBoxResult Dim results
> > As MsgBoxResult If(FYI = True) Then If Not String.IsNullOrEmpty(Title)
> > Then results = MsgBox(Msg, Button, Title) Else results = MsgBox(Msg,
> > Button) End If End If return results End Function 'MyMessageBox( ByVal
> > Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As
> > MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String =
> > Nothing) As MsgBoxResult
> >
> > Private Function FindValueFromArray(ByVal Values As Object(), ByVal
> > valueToSearch As Object) As Integer Dim retVal As Integer = 0 Dim
> > myArray As Array = DirectCast(Values, Array) If Array.IndexOf(myArray,
> > valueToSearch) <> -1 Then retVal = Array.IndexOf(myArray,
> > valueToSearch) Else retVal = -1 End If Return retVal End Function
> > 'FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As
> > Object) As Integer
> >
> > Private Sub releaseObject(ByVal obj As Object) Try
> > System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
> > obj = Nothing
> > Catch ex As Exception
> > obj = Nothing
> > Finally
> > GC.Collect()
> > End Try
> > End Sub 'releaseObject(ByVal obj As Object)
> > '/********************************************************************
> > /
> > '/********************************************************************
> > /
> > '/**************** End of Generic Function
> > ***************************/
> > '/********************************************************************
> > /
> > '/********************************************************************
> > /
> >
> > '/********************************************************************
> > /
> > '/********************************************************************
> > /
> > '/**************** Start of BOM_CAR Function
> > *************************/
> > '/********************************************************************
> > /
> > '/********************************************************************
> > /
> >
> > Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal Args
> > As
> > System.EventArgs) Handles btnCancelRetrieve.Click '// ** Place Event
> > Handling Code Here ** IF(btnRetrieve.Enabled = False) Then
> > bCancelRetrieve = True 'thrdSpawnNewThread.Abort
> > 'ClearData(True)
> > End If
> > End Sub
> >
> > Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles ugdBOMGrid.Resize '// ** Place Event
> > Handling Code Here **
> > ValidateGridSize()
> > End Sub
> >
> > Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles btnRetrieve.Click btnRetrieve.Enabled =
> > False thrdSpawnNewThread = new Thread(AddressOf
> > RetrieveAvailabilityData) thrdSpawnNewThread.Start
> > 'RetrieveAvailabilityData()
> > IF(bGridSizeSet = False) Then
> > ValidateGridSize()
> > End If
> > btnRetrieve.Enabled = True
> > End Sub
> >
> > Private Function GetShortageQtyANDDate(ByVal sPartNum AS String, ByVal
> > nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity AS
> > Decimal) AS Boolean
> >
> > Dim blTimePhas As Boolean =
> > timephasAdapter.GoProcessTimePhase(sPartNum,
> > "MfgSys", chkSuggestions.Checked, False)
> > 'ShowDataSet(timephasAdapter.TimePhasData)
> > IF(blTimePhas = True) Then
> > For Each drRow as DataRow in
> > timephasAdapter.TimePhasData.Tables("TimePhas").Rows
> > drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
> > Quantity = drRow.Item("BalanceQty") IF(Quantity <= 0) then blTimePhas
> > = True
> > IF(drRow.Item("DueDate").ToString() <> "") then sDate =
> > drRow.Item("DueDate").Date End If Exit For Else blTimePhas = False End
> > If
> >
> > Next
> > timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
> > End If
> >
> > Return blTimePhas
> > End Function
> >
> > Private Sub RetrieveTimePhaseInquiry()
> >
> > IF(ugdBOMGrid.Text <> "") Then
> > otrans.pushstatustext("Retrieving TimePhase Data ...", True)
> >
> > timephasAdapter.clearData()
> > Dim blTimePhas As Boolean =
> > GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.Acti
> > veRow.Band.Columns("Material
> > Part")),
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Re
> > quiredQty")),
> > dteShortageDate, nAvailableQty)
> > edvTimePhas.EpiDataChanged()
> > ugdTimePhase.Text = "Time Phase Inquiry: Part: " &
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Ma
> > terial
> > Part")) & " Description: " &
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("Pa
> > rtDescription"))
> >
> > otrans.pushstatustext("Ready!", False) End IF End Sub
> >
> > Private Sub RetrieveAvailabilityData() '// ** Place Event Handling
> > Code Here ** Dim dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form) Dim pcTable As String = "PartRev"
> > Dim pcField As String = "PartNum"
> > Dim pbIsConst As Boolean = TRUE
> > Dim pcCondition As String = "="
> > Dim pcToValue as String = txtBOMPartNum.Text Dim pcToTable As String =
> > String.Empty Dim pcToField As String = String.Empty Dim
> > pcRightParentheses as String = String.Empty Dim pcLeftParentheses as
> > String = String.Empty Dim pcAndOr as String = String.Empty Dim pbNeg
> > as Boolean = False Try WriteToLogFile("Retrieving Availability Data
> > ...") otrans.pushstatustext("Retrieving Availability Data ...", True)
> >
> > dynQryAD.BOconnect()
> >
> > dsAvailability.Tables(0).Rows.Clear()
> > ugdBOMGrid.DataSource.Tables(0).Rows.Clear()
> >
> > dynQryAD.GetByID(sAvailabilityBAQID)
> >
> > dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> > pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> > pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> > dynQryAD.Update pcField = "RevisionNum"
> > pcToValue = txtBOMRevisionNum.Text.ToString() pcAndOr = "AND"
> > dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> > pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> > pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> > dynQryAD.Update
> >
> > ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> > Infragistics.Win.DefaultableBoolean.True
> >
> > WriteToLogFile("copy all data from QueryDesignData tables to
> > DynamicQueryData tables (only for tables that exist in both
> > datasets)") '//copy all data from QueryDesignData tables to
> > DynamicQueryData tables (only 'for tables that exist in both datasets
> >
> > Dim targetRow as DataRow
> > For each Table as DataTable in dynQryAD.DynamicQueryData.Tables If
> > Table.Rows.Count = 0 Then For Each sourceRow as DataRow in
> > dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
> > targetRow = Table.NewRow()
> > targetRow.ItemArray = sourceRow.ItemArray
> > Table.Rows.Add(targetRow)
> > Next
> > End If
> > Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
> >
> > WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
> > dynQryAD.Execute(dynQryAD.DynamicQueryData)
> >
> > WriteToLogFile("Processing " &
> > dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> > records.") otrans.pushstatustext("Processing " &
> > dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> > records.",
> > True)
> > Dim RecCnt AS Integer = 0
> > Dim AddToGrid AS Boolean = True
> > Dim bNegAvail AS boolean = False
> > WriteToLogFile("Pre-Filtered DataSet")
> > ShowDataSet(dynQryAD.QueryResults)
> >
> > For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> > 'myDataSet has records
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> > AddToGrid = True
> >
> > ORow.Item("RequiredQty") = ORow.Item("RequiredQty") *
> > txtProductionQty.Value nAvailableQty = ORow.Item("PartPlant.Number01")
> > - ORow.Item("RequiredQty") dteShortageDate = Today() IF(nAvailableQty
> > > 0) then bNegAvail =
> > GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"),
> > ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty) Else
> > bNegAvail = True End If
> >
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> >
> > ORow.Item("ShortageDate") = dteShortageDate.Date
> > ORow.Item("AvailableQty") = nAvailableQty
> >
> > IF(chkExceptionsOnly.Checked = True) Then AddToGrid = bNegAvail End If
> > IF(chkExcludeConsignments.Checked) Then Select
> > ORow.Item("Part.ClassID") Case "CARR"
> > AddToGrid = False
> > Case "CTTI"
> > AddToGrid = False
> > Case "CAVN"
> > AddToGrid = False
> > Case Else
> > AddToGrid = AddToGrid
> > End Select
> > End If
> >
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> >
> > If(AddToGrid) then
> > RecCnt = RecCnt + 1
> > TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow) End
> > If Next'For Each ORow as DataRow in
> > dynQryAD.QueryResults.Tables(0).Rows
> > IF(bCancelRetrieve = True) Then
> > bCancelRetrieve = False
> > Else
> > otrans.pushstatustext("Processed " & RecCnt & " Component records.",
> > True) WriteToLogFile("Processed " & RecCnt & " Component records.")
> > WriteToLogFile("Grid-Filtered DataSet")
> > ShowDataSet(dsAvailability)
> >
> > dsAvailability.Tables("Results").Columns("Material
> > Part").ExtendedProperties("Like") = "Part.PartNum"
> > dsAvailability.Tables("Results").AcceptChanges()
> > IF(RecCnt > 0) Then
> > ugdBOMGrid.Text =
> > dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> > txtPartdescription.Text =
> > dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> > ugdBOMGrid.DataSource = dsAvailability
> > GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns,
> > nGridID_ComponentAvailability)
> > Else
> > MyMessageBox("There was no exceptions found.", True,
> > MsgBoxStyle.OKOnly, "Availability Report")
> > timephasAdapter.clearData()
> > edvTimePhas.EpiDataChanged()
> >
> > End If
> >
> > ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> > Infragistics.Win.DefaultableBoolean.False
> > End If
> > Catch abortException As ThreadAbortException
> > MyMessageBox(abortException.Message & ": " &
> > CType(abortException.ExceptionState, String), True,
> > MsgBoxStyle.OKOnly, "Availability Report") finally
> > dynQryAD.Dispose()
> > releaseObject(dynQryAD)
> > End Try
> > End Sub 'RetrieveSalesData()
> >
> > Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal Args
> > As
> > System.EventArgs) Handles btnPartRevSearch.Click '// ** Place Event
> > Handling Code Here ** Dim recordSelected As Boolean Dim sPart AS
> > String = txtBOMPartNum.Text Dim wClause AS String = "PartNum >= '" +
> > sPart + "'"
> >
> > IF(sPart.length() <= 0) Then
> > wClause = String.Empty
> > End If
> > Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form,
> > "PartRevSearchAdapter", recordSelected, True, wClause, False)
> >
> > If( recordSelected) Then
> > txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
> > txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
> > End If
> > End Sub
> >
> > Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles btnShowSize.Click '// ** Place Event
> > Handling Code Here **
> > ShowSize()
> > End Sub
> >
> > Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object, ByVal
> > Args As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate '// **
> > Place Event Handling Code Here **
> > RetrieveTimePhaseInquiry()
> > End Sub
> >
> > Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As
> > Object, ByVal Args As System.EventArgs) Handles
> > chkSuggestions.AfterCheckStateChanged
> > '// ** Place Event Handling Code Here **
> > IF(bFormLoaded) Then
> > RetrieveTimePhaseInquiry()
> > End If
> > End Sub
> >
> > Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles txtBOMPartNum.Leave '// ** Place Event
> > Handling Code Here ** IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
> > txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
> > sCurrentPartNum = txtBOMPartNum.Text
> > End If
> >
> > End Sub
> >
> > Private Function GetLatestPartRev (ByVal sPartNum As string) As string
> >
> > Dim sPartRev As String = String.Empty
> > Dim recSelected As Boolean = False
> > Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"
> >
> > Dim dsSearch As DataSet
> > dsSearch = SearchFunctions.listLookup(oTrans, "PartRevSearchAdapter",
> > recSelected, False, swhereClause, True) If recSelected Then sPartRev =
> > dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() -
> > 1).Item("RevisionNum")
> > Else
> > MyMessageBox("The PartNum you entered does not have a valid Revision
> > Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number") End If
> > Return sPartRev End Function
> >
> > End Module
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > Behalf Of John Driggers
> > Sent: Wednesday, August 15, 2012 7:35 AM
> > To: vantage@yahoogroups.com
> > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> >
> > You shouldn't need to. What is the error you're receiving? If you
> > stick your code up here it will likely help a lot.
> >
> > On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:
> >
> > > **
> > >
> > >
> > > What I am doing is calling a BAQ and then adding two where clauses
> > > for the PartNum and RevisionNum. I then execute the BAQ. This is all
> > > done with local parameters inside of the method that I delegate for
> > > the
> > thread.
> > > Should I set the DynamicQueryAdapter object as global so that it is
> > > owned by the Form?
> > >
> > >
> > > -----Original Message-----
> > > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > > Behalf Of Jose Gomez
> > > Sent: Tuesday, August 14, 2012 2:39 PM
> > > To: vantage@yahoogroups.com
> > > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> > >
> > > I've done it several times, how are you doing it? You can't update
> > > UI items from a thread, so if its updating UI that's where your
> > > crash is happening your best bet is to instanciate a new BO do your
> > > stuff and then refresh the UI once its donre.l
> > >
> > > *Jose C Gomez*
> > > *Software Engineer*
> > > *
> > > *
> > > *
> > > *T: 904.469.1524 mobile
> > > E: jose@...
> > > http://www.josecgomez.com
> > > <http://www.linkedin.com/in/josecgomez>
> > > <http://www.facebook.com/josegomez
> > > >
> > > <http://www.google.com/profiles/jose.gomez>
> > > <http://www.twitter.com/joc85>
> > > <http://www.josecgomez.com/professional-resume/>
> > > <http://www.josecgomez.com/feed/>
> > > <http://www.usdoingstuff.com>
> > >
> > > *Quis custodiet ipsos custodes?*
> > >
> > > On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...>
> > wrote:
> > >
> > > > **
> > > >
> > > >
> > > > Has anyone used threading with Business Objects? I am trying to
> > > > use it to spawn a thread for a method that takes 5 minutes. I am
> > > > utilizing the DynamicQueryAdapter in my method.
> > > >
> > > > the strange thing is that I can call the BOConnect(), GetByID(),
> > > > AddWhereItem() and Update methods, but when I try to call the
> > > > Execute method it crashes.
> > > >
> > > > Does anyone have any thoughts and/or ideas on this?
> > > >
> > > > Dan
> > > >
> > > >
> > > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> > > ------------------------------------
> > >
> > > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > > must have already linked your email address to a yahoo id to enable
> access.
> > > )
> > > (1) To access the Files Section of our Yahoo!Group for Report
> > > Builder and Crystal Reports and other 'goodies', please goto:
> > > http://groups.yahoo.com/group/vantage/files/.
> > > (2) To search through old msg's goto:
> > > http://groups.yahoo.com/group/vantage/messages
> > > (3) To view links to Vendors that provide Vantage services goto:
> > > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> > have already linked your email address to a yahoo id to enable access.
> > )
> > (1) To access the Files Section of our Yahoo!Group for Report Builder
> > and Crystal Reports and other 'goodies', please goto:
> > http://groups.yahoo.com/group/vantage/files/.
> > (2) To search through old msg's goto:
> > http://groups.yahoo.com/group/vantage/messages
> > (3) To view links to Vendors that provide Vantage services goto:
> > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
> already linked your email address to a yahoo id to enable access. )
> (1) To access the Files Section of our Yahoo!Group for Report Builder and
> Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
> already linked your email address to a yahoo id to enable access. )
> (1) To access the Files Section of our Yahoo!Group for Report Builder and
> Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]
How would that look in VB?

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Wednesday, August 15, 2012 11:12 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

You can update the UI you just have to do it Thread Safe

YOURFORM.Invoke((ThreadStart)delegate()
{

// CD 7/11/2012

// Changed rows to 5 for testing.

// TODO: Set rows=grdJobs.Rows.Count after testing is done.

pbProgress.Maximum=rows;
pbProgress.Minimum=0;
pbProgress.Value=0;
pbProgress.Step=1;
});


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Wed, Aug 15, 2012 at 1:32 PM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> I am having a problem. I need to update the grids with the data that
> was processed on that extra thread. The purpose was that because the
> data processing potentially covers 5 minutes of time, which during
> that whole time Vantage would be useless, and the users need to be
> able to continue with other things IN Vantage during that time.
>
> With knowing the purpose of the threading, is there any other way to
> accomplish this?
>
> Is it possible to kick-off a timer to monitor a variable (Boolean)
> change that would update the UI. I then could set the timer when I
> start the thread and then set a boolean change variable inside the
> data processing function when it is complete. That would then kick-off
> the timer function to update the UI.
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of Dan Godfrey
> Sent: Wednesday, August 15, 2012 8:56 AM
> To: vantage@yahoogroups.com
> Subject: RE: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> Ok, I will work on that, thanks.
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of Jose Gomez
> Sent: Wednesday, August 15, 2012 8:36 AM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> WOW ok that's a lot of code, but anything in RetrieveAvailabilityData
> which touches the UI has got to go
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez>
> <http://www.facebook.com/josegomez
> >
> <http://www.google.com/profiles/jose.gomez>
> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
> On Wed, Aug 15, 2012 at 11:07 AM, Dan Godfrey <dgodfrey@...> wrote:
>
> > **
> >
> >
> > Here is the code, thanks ahead of time if you guys can help me out
> > on
> this.
> >
> > Dan
> >
> > '//**************************************************
> > '// Custom VB.NET code for UD01Form
> > '// Created: 6/5/2008 1:06:23 PM
> > '//**************************************************
> > Imports System
> > Imports System.Data
> > Imports System.Diagnostics
> > Imports System.Windows.Forms
> > Imports System.ComponentModel
> > Imports Microsoft.VisualBasic
> > Imports Epicor.Mfg.UI
> > Imports Epicor.Mfg.UI.FrameWork
> > Imports Epicor.Mfg.UI.ExtendedProps
> > Imports Epicor.Mfg.UI.FormFunctions
> > Imports Epicor.Mfg.UI.Customization
> > Imports Epicor.Mfg.UI.Adapters
> > Imports Epicor.Mfg.UI.Searches
> > IMPORTS System.IO
> > Imports Epicor.Mfg.BO
> > Imports Infragistics.Win
> > Imports Infragistics.Shared
> > Imports Infragistics.Win.UltraWinGrid Imports System.Reflection
> > Imports Infragistics.Win.UltraWinToolBars Imports System.Threading
> >
> > Module 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 WithEvents
> > timephasAdapter As TimePhasAdapter Private WithEvents edvTimePhas As
> > EpiDataView Private dsAvailability AS System.Data.DataSet Private
> > dsTimePhase AS System.Data.DataSet Private nAvailabilityDataColumns
> > AS Integer = 0 Private nTimePhaseDataColumns AS Integer = 0 Private
> > Const sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
> > Private bDeveloperLoggedIn AS Boolean = False Private bGridSizeSet
> > AS Boolean = False Private Const nGridID_ComponentAvailability AS
> > Integer = 1 Private Const nGridID_TimePhase AS Integer = 2 Private
> > bFormLoaded AS Boolean = False Private baseToolbarsManager As
> > Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
> > Private sCurrentPartNum AS String = String.Empty Private
> > dteShortageDate AS Date Private nAvailableQty AS Decimal = 0 Private
> > bCancelRetrieve AS Boolean = False Private thrdSpawnNewThread AS
> > Thread 'Private dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form)
> >
> > Sub InitializeCustomCode()
> >
> > '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard
> > Added Variable Intialization' lines ** '// Begin Wizard Added
> > Variable Intialization
> >
> > '// End Wizard Added Variable Intialization '// Begin Custom Method
> > Calls If Thread.CurrentThread.Name = Nothing Then
> > thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
> > End If
> >
> > 'dynQryAD = New DynamicQueryAdapter(UD01Form)
> > 'dynQryAD.BOconnect()
> >
> > dsAvailability = New System.Data.DataSet("Results") dsTimePhase =
> > New
> > System.Data.DataSet("Results") timephasAdapter = New
> > timephasAdapter(oTrans)
> > timephasAdapter.BOConnect()
> >
> > edvTimePhas = new EpiDataView()
> > edvTimePhas.dataView = New
> > DataView(timephasAdapter.TimePhasData.TimePhas)
> >
> > If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
> > oTrans.Add("TimePhasView",edvTimePhas)
> > End If
> >
> > dim obj as Object =
> > GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseTool
> > ba rsManager", BindingFlags.Instance Or BindingFlags.GetField Or
> > BindingFlags.NonPublic, Nothing, UD01Form, Nothing)
> > BaseToolbarsManager =
> > ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
> > AddHandler baseToolbarsManager.ToolClick, AddressOf
> > baseToolbarsManager_ToolClick
> >
> >
> > '// End Custom Method Calls
> > End Sub
> >
> > Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object,
> > ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
> > Select case args.tool.key
> > Case "ClearTool"
> > ClearData(False)
> > 'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly,
> > "baseToolbarsManager.ToolClick")
> > End Select
> > End Sub
> >
> > Sub 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
> > releaseObject(edvTimePhas)
> >
> > timephasAdapter.Dispose()
> > releaseObject(timephasAdapter)
> >
> > dsTimePhase.Dispose()
> > releaseObject(dsTimePhase)
> >
> > dsAvailability.Dispose()
> > releaseObject(dsAvailability)
> >
> > 'dynQryAD.Dispose()
> > 'releaseObject(dynQryAD)
> >
> > End Sub
> >
> > Private Sub UD01Form_Load(ByVal sender As object, ByVal args As
> > EventArgs) Handles UD01Form.Load '// '// Add Event Handler Code '//
> > Dim userID As String = UD01Form.Session.UserID bFormLoaded = False
> > bDeveloperLoggedIn = False Select userID Case "dgodfrey"
> > bDeveloperLoggedIn = True
> > Case Else
> > bDeveloperLoggedIn = False
> > End Select
> > AddingDataColumns(dsAvailability, ugdBOMGrid,
> > nGridID_ComponentAvailability)
> >
> > 'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)
> >
> > ugdBOMGrid.Width = 1070
> > ugdBOMGrid.Height = 165
> >
> > ugdBOMGrid.Width = 1070
> > ugdBOMGrid.Height = 250
> >
> > grpFilters.Show()
> > chkExceptionsOnly.Show()
> > lblExceptionsOnly.Show()
> > chkExceptionsOnly.Checked = False
> > chkExcludeConsignments.Show()
> > chkExcludeConsignments.Show()
> > chkExcludeConsignments.Checked = False
> >
> > grpTimePhaseFilters.Show()
> > chkSuggestions.Show()
> > lblSuggestions.Show()
> > chkSuggestions.Checked = False
> > chkForecasting.Checked = False
> >
> > IF(bDeveloperLoggedIn) Then
> > btnShowSize.Show()
> > ChkForecasting.Show()
> > lblForecasting.Show()
> > btnCancelRetrieve.Show()
> > Else
> > ChkForecasting.Hide()
> > lblForecasting.Hide()
> > btnShowSize.Hide()
> > btnCancelRetrieve.Hide()
> > End If
> >
> > Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel =
> > CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57
> > fb
> > 7a6"),
> > Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
> > Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel =
> > CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287
> > e2
> > 74b"),
> > Epicor.Mfg.UI.App.UD01Entry.MainPanel)
> > myTreeViewPanel.Dispose()
> > myMainPanel.Dispose()
> > bFormLoaded = True
> > otrans.pushstatustext("Ready!", False) End Sub
> >
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> > '/**************** Start of Generic Function
> > *************************/
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > ** / Private Sub ClearData(ByVal bGridOnly AS Boolean) IF(bGridOnly
> > =
> > False) Then txtBOMPartNum.Text = String.Empty
> > txtPartDescription.Text = String.Empty txtBOMRevisionNum.text =
> > String.Empty txtProductionQty.Text = String.Empty End If
> > dsAvailability.Tables(0).Rows.Clear()
> > ugdBOMGrid.Text = "BOM Components"
> > ugdTimePhase.Text = "Time Phase Inquiry"
> >
> > timephasAdapter.clearData()
> > edvTimePhas.EpiDataChanged()
> > End Sub
> >
> > Private Sub ShowSize()
> > DIM msg AS String = String.Empty
> > msg = msg & "Form Size:" & chr(13) & chr(10) msg = msg & "Bottom = "
> > & ugdBOMGrid.FindForm().Bottom & ", Top = " &
> > ugdBOMGrid.FindForm().Top & ", Width = " &
> > ugdBOMGrid.FindForm().Width & ", Height = " &
> > ugdBOMGrid.FindForm().Height & chr(13) & chr(10) msg = msg &
> > "ugdBOMGrid Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> > ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top & ", Width = " &
> > ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height &
> > chr(13) & chr(10)
> > msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10) msg = msg &
> > "Bottom = " & ugdTimePhase.Bottom & ", Top = " & ugdTimePhase.Top &
> > ", Width = " & ugdTimePhase.Width & ", Height = " &
> > ugdTimePhase.Height &
> > chr(13) & chr(10) MyMessageBox(msg, bDeveloperLoggedIn,
> > MsgBoxStyle.OKOnly, "Grid Sizes")
> >
> > End Sub
> >
> > Private Sub ValidateGridSize()
> > Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width Dim nHeight AS
> > Integer = ugdBOMGrid.FindForm().Height DIM nCriteriaAreaPlusFooting
> > AS Integer = 250 Dim nSpaceBtwnGrids AS Integer = 5
> >
> > ugdBOMGrid.Width = (nWidth - 50)
> > ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4
> >
> > ugdTimePhase.Left = ugdBOMGrid.Left
> > ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height +
> > nSpaceBtwnGrids ugdTimePhase.Width = ugdBOMGrid.Width
> > ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6
> >
> >
> > btnShowSize.Left = ugdBOMGrid.Left
> > btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height +
> > nSpaceBtwnGrids ugdBOMGrid.Anchor = AnchorStyles.Bottom Or
> > AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
> > 'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> > AnchorStyles.Left Or AnchorStyles.Top bGridSizeSet = True
> >
> > 'ShowSize()
> > End Sub
> >
> > Private Sub GridCustomization(ByRef Collection AS
> > Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal
> > GridIdentifier AS
> > Integer)
> > Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
> > IF(GridIdentifier = nGridID_ComponentAvailability) Then For each
> > column in Collection Select column.Header.Caption Case "Rev", "Part
> > Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
> > column.Hidden = True
> > Case "Lvl"
> > column.Width = 30
> > column.CellAppearance.TextHAlign = HAlign.Right Case "MtlSeq", "Lead"
> > column.Width = 50
> > column.CellAppearance.TextHAlign = HAlign.Right Case "Material Part"
> > column.Width = 150
> > Case "PartDescription"
> > column.Width = 250
> > Case "Type"
> > column.Width = 50
> > Case "RequiredQty"
> > column.Width = 75
> > column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> > column.CellAppearance.TextHAlign = HAlign.Right Case "ClassID"
> > column.Width = 50
> > Case "TotalQtyOnHand", "AvailableQty"
> > column.Width = 125
> > column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> > column.CellAppearance.TextHAlign = HAlign.Right Case Else
> > 'column.Hidden = True
> >
> > End Select
> > Next Column
> > Else'nGridID_TimePhase
> > Dim nOrdinal AS Integer = 0
> > For each column in Collection
> > Select column.Header.Caption
> > Case "Due"
> > 'column.Ordinal = 0
> > Case "Receipts"
> > 'column.Ordinal = 1
> > Case "Job"
> > 'column.Ordinal = 2
> > Case "Order"
> > 'column.Ordinal = 3
> > Case "RequiredQty"
> > 'column.Ordinal = 4
> > Case "PO"
> > 'column.Ordinal = 5
> > Case "Lead"
> > 'column.Ordinal = 6
> > Case "Balance"
> > 'column.Ordinal = 7
> > Case "Exception"
> > 'column.Ordinal = 8
> > Case "Order By"
> > 'column.Ordinal = 9
> > Case "Source"
> > 'column.Ordinal = 10
> > Case "JobStatus"
> > 'column.Ordinal = 11
> > 'nOrdinal = 11
> > Case Else
> > 'column.Ordinal = 11
> > 'nOrdinal = nOrdinal + 1
> > 'column.Hidden = True
> > End Select
> > Next Column
> > End IF
> >
> > End Sub 'GridCustomization(ByRef Collection AS
> > Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal
> > GridIdentifier AS
> > Integer)
> >
> > Private Sub TransferDataRow(ByRef myDataSet AS
> > System.Data.DataSet,ByVal nFirstColumnIndex AS Integer, ByVal
> > nColumnCnt AS Integer, ByVal SrcRow AS
> > DataRow)
> > ' Instantiate a new row using the NewRow method.
> > Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
> > Dim i AS Integer = 0
> > 'Insert code to fill the row with values.
> > For i = nFirstColumnIndex To nColumnCnt
> > newRow.Item(i) = SrcRow.Item(i)
> > Next i
> > 'Add the row to the DataRowCollection.
> > myDataSet.Tables("Results").Rows.Add(newRow)
> > myDataSet.Tables("Results").AcceptChanges()
> > End Sub 'TransferDataRow(ByRef myDataSet AS
> > System.Data.DataSet,ByVal nFirstColumnIndex, ByVal nColumnCnt AS
> > Integer, ByVal SrcRow AS
> > DataRow)
> >
> > Private Sub AddingDataColumns(ByRef myDataSet AS
> > System.Data.DataSet, ByRef myGrid AS
> > Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal GridIdentifier AS
> > Integer)
> >
> > IF(myDataSet.Tables.Count <= 0)Then
> > myDataSet.Tables.Add("Results")
> > End If
> > '// ** Place Event Handling Code Here **
> > otrans.pushstatustext("Retrieving Data ...", False) 'Dim
> > sStatusString as String = String.Empty
> >
> > IF(GridIdentifier = nGridID_ComponentAvailability) Then Dim
> > sStatusString AS String = String.EMpty Dim nColumns AS Integer = 0
> > Dim dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form) Dim sBaqID AS String =
> > sAvailabilityBAQID sBaqID = sAvailabilityBAQID
> >
> > dynQryAD.BOconnect()
> > dynQryAD.GetByID(sBaqID)
> >
> > For Each DR AS DataRow in
> > dynQryAD.QueryDesignData.Tables("SelectedField").Rows
> > nColumns = nColumns + 1
> > sStatusString = "AddingDataColumns function: Adding " & nColumns & "/"
> > & dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & "
> ColumnName:
> > " & DR.Item("FieldLabel") & " is " &
> > DR.Item("DataType").ToString().ToUpper()
> > WriteToLogFile(sStatusString)
> > Select DR.Item("DataType").ToString().ToUpper()
> > Case "CHARACTER"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.String"))
> > Case "INTEGER"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Int32"))
> > Case "DECIMAL"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Decimal"))
> > Case "LOGICAL"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Boolean"))
> > Case "DATE"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.DateTime"))
> > Case Else
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.String"))
> > End Select
> > myDataSet.Tables(0).AcceptChanges()
> > Next
> > nAvailabilityDataColumns = nColumns - 1
> > dynQryAD.Dispose()
> > releaseObject(dynQryAD)
> > Else'nGridID_TimePhase
> > End If
> >
> > myGrid.DataSource = myDataSet
> > GridCustomization(myGrid.DisplayLayout.Bands(0).Columns,
> > GridIdentifier)
> >
> > End Sub 'AddingDataColumns()
> >
> > Private Function ShowDebugInformation() AS String Dim sRet AS String
> > '& Chr(13) & Chr(10) sRet = "Debug Data:" & Chr(13) & Chr(10) sRet =
> > sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
> > sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13)
> > &
> > Chr(10)
> > sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail &
> > Chr(13) &
> > Chr(10)
> > sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName &
> > Chr(13) & Chr(10) sRet = sRet & "- ProductCode = " &
> > UD01Form.Session.ProductCode & Chr(13) & Chr(10)
> > WriteToLogFile(sRet)
> >
> > Return sRet
> > End Function 'ShowDebugInformation() AS String
> >
> > Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet)
> > AS String Dim sRet AS String = String.Empty sRet = "INSIDE
> > ShowDataSet:" & chr(13) & chr(10)
> > WriteToLogFile(sRet)
> > sRet = String.Empty
> > For each Table as DataTable in myDataSet.Tables sRet = sRet & "Table:
> > " & Table.TableName & chr(13) & chr(10) For Each DR AS DataRow in
> > Table.Rows For Each DC as DataColumn in Table.Columns
> > IF(DC.ColumnName = "RowIdent") Then Exit For End If sRet = sRet &
> > DC.ColumnName & ":" & DR(DC.ColumnName)& ", "
> > Next'For Each DC as DataColumn in Table.Columns sRet = sRet &
> > chr(13) & chr(10) Next'For Each DR AS DataRow in Table.Rows Next'For
> > each Table
> > WriteToLogFile(sRet)
> > Return sRet
> > End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS
> > String
> >
> > Private Function GetDataColumnInformation(ByVal myDataTable AS
> > DataTable) AS String Dim sRet AS String = String.Empty
> >
> > sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
> > WriteToLogFile(sRet)
> > sRet = String.Empty
> > For Each DC as DataColumn in myDataTable.Columns sRet = sRet &
> > DC.ColumnName & ", "
> > Next'For Each DC as DataColumn in Table.Columns sRet = sRet &
> > chr(13) & chr(10)
> > WriteToLogFile(sRet)
> >
> > Return sRet
> > End Function 'GetDataColumnInformation(ByVal myDataTable AS
> > DataTable) AS String
> >
> > ''' <summary>
> > ''' Copies the the specified number of rows from the top of the
> > specified table.
> > ''' </summary>
> > ''' <param name="table">
> > ''' The table containing the original rows.
> > ''' </param>
> > ''' <param name="rowCount">
> > ''' The number of rows to copy.
> > ''' </param>
> > ''' <param name="useView">
> > ''' Indicates whether the row order should be based on the
> > DefaultView or not.
> > ''' </param>
> > ''' <returns>
> > ''' A DataTable containing the copied rows.
> > ''' </returns>
> > Private Function GetTopRows(ByVal table As DataTable, _ ByVal
> > rowCount As Integer, _ ByVal useDefaultView As Boolean) As DataTable
> > 'You can't get more rows than exist.
> > If useDefaultView Then
> > rowCount = Math.Min(rowCount, table.DefaultView.Count) Else rowCount
> > = Math.Min(rowCount, table.Rows.Count) End If 'Copy the table schema.
> > Dim topTable As DataTable = table.Clone() 'Copy the specified number
> > of rows.
> > For rowIndex As Integer = 0 To rowCount - 1 Step 1 If useDefaultView
> > Then 'Take the top rows from the DeafultView.
> > topTable.ImportRow(table.DefaultView(rowIndex).Row)
> > Else
> > 'Take the top rows from the original table.
> > topTable.ImportRow(table.Rows(rowIndex))
> > End If
> > Next rowIndex
> > Return topTable
> > End Function
> >
> > Private Function WriteToLogFile(ByVal TextString AS String) as
> > Boolean Dim bResults AS Boolean = False
> >
> > Dim sInputString AS String = TextString & Chr(13) & Chr(10) Dim
> > sPath AS String = "C:\BOM_CAR_log.txt"
> >
> >
> > IF(File.Exists(sPath) = False) Then
> > ' Create a file to write to.
> > File.WriteAllText(sPath, sInputString) bResults = True Else ' This
> > text is always added, making the file longer over time ' if it is
> > not deleted.
> > File.AppendAllText(sPath, sInputString) bResults = True End If
> > return bResults End Function 'WriteToLogFile(ByVal TextString AS
> > String) as Boolean
> >
> > Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> > Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly,
> > Optional ByVal Title As String = Nothing) As MsgBoxResult Dim
> > results As MsgBoxResult If(FYI = True) Then If Not
> > String.IsNullOrEmpty(Title) Then results = MsgBox(Msg, Button,
> > Title) Else results = MsgBox(Msg,
> > Button) End If End If return results End Function 'MyMessageBox(
> > ByVal Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As
> > MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String =
> > Nothing) As MsgBoxResult
> >
> > Private Function FindValueFromArray(ByVal Values As Object(), ByVal
> > valueToSearch As Object) As Integer Dim retVal As Integer = 0 Dim
> > myArray As Array = DirectCast(Values, Array) If
> > Array.IndexOf(myArray,
> > valueToSearch) <> -1 Then retVal = Array.IndexOf(myArray,
> > valueToSearch) Else retVal = -1 End If Return retVal End Function
> > 'FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As
> > Object) As Integer
> >
> > Private Sub releaseObject(ByVal obj As Object) Try
> > System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
> > obj = Nothing
> > Catch ex As Exception
> > obj = Nothing
> > Finally
> > GC.Collect()
> > End Try
> > End Sub 'releaseObject(ByVal obj As Object)
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> > '/**************** End of Generic Function
> > ***************************/
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> >
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> > '/**************** Start of BOM_CAR Function
> > *************************/
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> >
> > Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal
> > Args As
> > System.EventArgs) Handles btnCancelRetrieve.Click '// ** Place Event
> > Handling Code Here ** IF(btnRetrieve.Enabled = False) Then
> > bCancelRetrieve = True 'thrdSpawnNewThread.Abort
> > 'ClearData(True)
> > End If
> > End Sub
> >
> > Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles ugdBOMGrid.Resize '// ** Place Event
> > Handling Code Here **
> > ValidateGridSize()
> > End Sub
> >
> > Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles btnRetrieve.Click btnRetrieve.Enabled =
> > False thrdSpawnNewThread = new Thread(AddressOf
> > RetrieveAvailabilityData) thrdSpawnNewThread.Start
> > 'RetrieveAvailabilityData()
> > IF(bGridSizeSet = False) Then
> > ValidateGridSize()
> > End If
> > btnRetrieve.Enabled = True
> > End Sub
> >
> > Private Function GetShortageQtyANDDate(ByVal sPartNum AS String,
> > ByVal nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity
> > AS
> > Decimal) AS Boolean
> >
> > Dim blTimePhas As Boolean =
> > timephasAdapter.GoProcessTimePhase(sPartNum,
> > "MfgSys", chkSuggestions.Checked, False)
> > 'ShowDataSet(timephasAdapter.TimePhasData)
> > IF(blTimePhas = True) Then
> > For Each drRow as DataRow in
> > timephasAdapter.TimePhasData.Tables("TimePhas").Rows
> > drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
> > Quantity = drRow.Item("BalanceQty") IF(Quantity <= 0) then
> > blTimePhas = True
> > IF(drRow.Item("DueDate").ToString() <> "") then sDate =
> > drRow.Item("DueDate").Date End If Exit For Else blTimePhas = False
> > End If
> >
> > Next
> > timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
> > End If
> >
> > Return blTimePhas
> > End Function
> >
> > Private Sub RetrieveTimePhaseInquiry()
> >
> > IF(ugdBOMGrid.Text <> "") Then
> > otrans.pushstatustext("Retrieving TimePhase Data ...", True)
> >
> > timephasAdapter.clearData()
> > Dim blTimePhas As Boolean =
> > GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.Ac
> > ti
> > veRow.Band.Columns("Material
> > Part")),
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("
> > Re
> > quiredQty")),
> > dteShortageDate, nAvailableQty)
> > edvTimePhas.EpiDataChanged()
> > ugdTimePhase.Text = "Time Phase Inquiry: Part: " &
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("
> > Ma
> > terial
> > Part")) & " Description: " &
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("
> > Pa
> > rtDescription"))
> >
> > otrans.pushstatustext("Ready!", False) End IF End Sub
> >
> > Private Sub RetrieveAvailabilityData() '// ** Place Event Handling
> > Code Here ** Dim dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form) Dim pcTable As String = "PartRev"
> > Dim pcField As String = "PartNum"
> > Dim pbIsConst As Boolean = TRUE
> > Dim pcCondition As String = "="
> > Dim pcToValue as String = txtBOMPartNum.Text Dim pcToTable As String
> > = String.Empty Dim pcToField As String = String.Empty Dim
> > pcRightParentheses as String = String.Empty Dim pcLeftParentheses as
> > String = String.Empty Dim pcAndOr as String = String.Empty Dim pbNeg
> > as Boolean = False Try WriteToLogFile("Retrieving Availability Data
> > ...") otrans.pushstatustext("Retrieving Availability Data ...",
> > True)
> >
> > dynQryAD.BOconnect()
> >
> > dsAvailability.Tables(0).Rows.Clear()
> > ugdBOMGrid.DataSource.Tables(0).Rows.Clear()
> >
> > dynQryAD.GetByID(sAvailabilityBAQID)
> >
> > dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> > pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> > pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> > dynQryAD.Update pcField = "RevisionNum"
> > pcToValue = txtBOMRevisionNum.Text.ToString() pcAndOr = "AND"
> > dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> > pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> > pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> > dynQryAD.Update
> >
> > ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> > Infragistics.Win.DefaultableBoolean.True
> >
> > WriteToLogFile("copy all data from QueryDesignData tables to
> > DynamicQueryData tables (only for tables that exist in both
> > datasets)") '//copy all data from QueryDesignData tables to
> > DynamicQueryData tables (only 'for tables that exist in both
> > datasets
> >
> > Dim targetRow as DataRow
> > For each Table as DataTable in dynQryAD.DynamicQueryData.Tables If
> > Table.Rows.Count = 0 Then For Each sourceRow as DataRow in
> > dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
> > targetRow = Table.NewRow()
> > targetRow.ItemArray = sourceRow.ItemArray
> > Table.Rows.Add(targetRow)
> > Next
> > End If
> > Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
> >
> > WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
> > dynQryAD.Execute(dynQryAD.DynamicQueryData)
> >
> > WriteToLogFile("Processing " &
> > dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> > records.") otrans.pushstatustext("Processing " &
> > dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> > records.",
> > True)
> > Dim RecCnt AS Integer = 0
> > Dim AddToGrid AS Boolean = True
> > Dim bNegAvail AS boolean = False
> > WriteToLogFile("Pre-Filtered DataSet")
> > ShowDataSet(dynQryAD.QueryResults)
> >
> > For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> > 'myDataSet has records
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> > AddToGrid = True
> >
> > ORow.Item("RequiredQty") = ORow.Item("RequiredQty") *
> > txtProductionQty.Value nAvailableQty =
> > ORow.Item("PartPlant.Number01")
> > - ORow.Item("RequiredQty") dteShortageDate = Today()
> > IF(nAvailableQty
> > > 0) then bNegAvail =
> > GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"),
> > ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty) Else
> > bNegAvail = True End If
> >
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> >
> > ORow.Item("ShortageDate") = dteShortageDate.Date
> > ORow.Item("AvailableQty") = nAvailableQty
> >
> > IF(chkExceptionsOnly.Checked = True) Then AddToGrid = bNegAvail End
> > If
> > IF(chkExcludeConsignments.Checked) Then Select
> > ORow.Item("Part.ClassID") Case "CARR"
> > AddToGrid = False
> > Case "CTTI"
> > AddToGrid = False
> > Case "CAVN"
> > AddToGrid = False
> > Case Else
> > AddToGrid = AddToGrid
> > End Select
> > End If
> >
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> >
> > If(AddToGrid) then
> > RecCnt = RecCnt + 1
> > TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow)
> > End If Next'For Each ORow as DataRow in
> > dynQryAD.QueryResults.Tables(0).Rows
> > IF(bCancelRetrieve = True) Then
> > bCancelRetrieve = False
> > Else
> > otrans.pushstatustext("Processed " & RecCnt & " Component records.",
> > True) WriteToLogFile("Processed " & RecCnt & " Component records.")
> > WriteToLogFile("Grid-Filtered DataSet")
> > ShowDataSet(dsAvailability)
> >
> > dsAvailability.Tables("Results").Columns("Material
> > Part").ExtendedProperties("Like") = "Part.PartNum"
> > dsAvailability.Tables("Results").AcceptChanges()
> > IF(RecCnt > 0) Then
> > ugdBOMGrid.Text =
> > dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> > txtPartdescription.Text =
> > dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> > ugdBOMGrid.DataSource = dsAvailability
> > GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns,
> > nGridID_ComponentAvailability)
> > Else
> > MyMessageBox("There was no exceptions found.", True,
> > MsgBoxStyle.OKOnly, "Availability Report")
> > timephasAdapter.clearData()
> > edvTimePhas.EpiDataChanged()
> >
> > End If
> >
> > ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> > Infragistics.Win.DefaultableBoolean.False
> > End If
> > Catch abortException As ThreadAbortException
> > MyMessageBox(abortException.Message & ": " &
> > CType(abortException.ExceptionState, String), True,
> > MsgBoxStyle.OKOnly, "Availability Report") finally
> > dynQryAD.Dispose()
> > releaseObject(dynQryAD)
> > End Try
> > End Sub 'RetrieveSalesData()
> >
> > Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal
> > Args As
> > System.EventArgs) Handles btnPartRevSearch.Click '// ** Place Event
> > Handling Code Here ** Dim recordSelected As Boolean Dim sPart AS
> > String = txtBOMPartNum.Text Dim wClause AS String = "PartNum >= '" +
> > sPart + "'"
> >
> > IF(sPart.length() <= 0) Then
> > wClause = String.Empty
> > End If
> > Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form,
> > "PartRevSearchAdapter", recordSelected, True, wClause, False)
> >
> > If( recordSelected) Then
> > txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
> > txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
> > End If
> > End Sub
> >
> > Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles btnShowSize.Click '// ** Place Event
> > Handling Code Here **
> > ShowSize()
> > End Sub
> >
> > Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object,
> > ByVal Args As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate
> > '// ** Place Event Handling Code Here **
> > RetrieveTimePhaseInquiry()
> > End Sub
> >
> > Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As
> > Object, ByVal Args As System.EventArgs) Handles
> > chkSuggestions.AfterCheckStateChanged
> > '// ** Place Event Handling Code Here **
> > IF(bFormLoaded) Then
> > RetrieveTimePhaseInquiry()
> > End If
> > End Sub
> >
> > Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args
> > As
> > System.EventArgs) Handles txtBOMPartNum.Leave '// ** Place Event
> > Handling Code Here ** IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
> > txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
> > sCurrentPartNum = txtBOMPartNum.Text End If
> >
> > End Sub
> >
> > Private Function GetLatestPartRev (ByVal sPartNum As string) As
> > string
> >
> > Dim sPartRev As String = String.Empty Dim recSelected As Boolean =
> > False Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"
> >
> > Dim dsSearch As DataSet
> > dsSearch = SearchFunctions.listLookup(oTrans,
> > "PartRevSearchAdapter", recSelected, False, swhereClause, True) If
> > recSelected Then sPartRev =
> > dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() -
> > 1).Item("RevisionNum")
> > Else
> > MyMessageBox("The PartNum you entered does not have a valid Revision
> > Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number") End If
> > Return sPartRev End Function
> >
> > End Module
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > Behalf Of John Driggers
> > Sent: Wednesday, August 15, 2012 7:35 AM
> > To: vantage@yahoogroups.com
> > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> >
> > You shouldn't need to. What is the error you're receiving? If you
> > stick your code up here it will likely help a lot.
> >
> > On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:
> >
> > > **
> > >
> > >
> > > What I am doing is calling a BAQ and then adding two where clauses
> > > for the PartNum and RevisionNum. I then execute the BAQ. This is
> > > all done with local parameters inside of the method that I
> > > delegate for the
> > thread.
> > > Should I set the DynamicQueryAdapter object as global so that it
> > > is owned by the Form?
> > >
> > >
> > > -----Original Message-----
> > > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > > Behalf Of Jose Gomez
> > > Sent: Tuesday, August 14, 2012 2:39 PM
> > > To: vantage@yahoogroups.com
> > > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> > >
> > > I've done it several times, how are you doing it? You can't update
> > > UI items from a thread, so if its updating UI that's where your
> > > crash is happening your best bet is to instanciate a new BO do
> > > your stuff and then refresh the UI once its donre.l
> > >
> > > *Jose C Gomez*
> > > *Software Engineer*
> > > *
> > > *
> > > *
> > > *T: 904.469.1524 mobile
> > > E: jose@...
> > > http://www.josecgomez.com
> > > <http://www.linkedin.com/in/josecgomez>
> > > <http://www.facebook.com/josegomez
> > > >
> > > <http://www.google.com/profiles/jose.gomez>
> > > <http://www.twitter.com/joc85>
> > > <http://www.josecgomez.com/professional-resume/>
> > > <http://www.josecgomez.com/feed/>
> > > <http://www.usdoingstuff.com>
> > >
> > > *Quis custodiet ipsos custodes?*
> > >
> > > On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...>
> > wrote:
> > >
> > > > **
> > > >
> > > >
> > > > Has anyone used threading with Business Objects? I am trying to
> > > > use it to spawn a thread for a method that takes 5 minutes. I am
> > > > utilizing the DynamicQueryAdapter in my method.
> > > >
> > > > the strange thing is that I can call the BOConnect(), GetByID(),
> > > > AddWhereItem() and Update methods, but when I try to call the
> > > > Execute method it crashes.
> > > >
> > > > Does anyone have any thoughts and/or ideas on this?
> > > >
> > > > Dan
> > > >
> > > >
> > > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> > > ------------------------------------
> > >
> > > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > > must have already linked your email address to a yahoo id to
> > > enable
> access.
> > > )
> > > (1) To access the Files Section of our Yahoo!Group for Report
> > > Builder and Crystal Reports and other 'goodies', please goto:
> > > http://groups.yahoo.com/group/vantage/files/.
> > > (2) To search through old msg's goto:
> > > http://groups.yahoo.com/group/vantage/messages
> > > (3) To view links to Vendors that provide Vantage services goto:
> > > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > must have already linked your email address to a yahoo id to enable access.
> > )
> > (1) To access the Files Section of our Yahoo!Group for Report
> > Builder and Crystal Reports and other 'goodies', please goto:
> > http://groups.yahoo.com/group/vantage/files/.
> > (2) To search through old msg's goto:
> > http://groups.yahoo.com/group/vantage/messages
> > (3) To view links to Vendors that provide Vantage services goto:
> > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
One thing I can't figure out is why will it crash on the DynamicQueryAdapter.Execute but not the GetByID or BOConnect, or the Update.

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Dan Godfrey
Sent: Wednesday, August 15, 2012 12:35 PM
To: vantage@yahoogroups.com
Subject: RE: [Vantage] Vantage 8.03.409C: System.Threading and BO

How would that look in VB?

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Wednesday, August 15, 2012 11:12 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO

You can update the UI you just have to do it Thread Safe

YOURFORM.Invoke((ThreadStart)delegate()
{

// CD 7/11/2012

// Changed rows to 5 for testing.

// TODO: Set rows=grdJobs.Rows.Count after testing is done.

pbProgress.Maximum=rows;
pbProgress.Minimum=0;
pbProgress.Value=0;
pbProgress.Step=1;
});


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Wed, Aug 15, 2012 at 1:32 PM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> I am having a problem. I need to update the grids with the data that
> was processed on that extra thread. The purpose was that because the
> data processing potentially covers 5 minutes of time, which during
> that whole time Vantage would be useless, and the users need to be
> able to continue with other things IN Vantage during that time.
>
> With knowing the purpose of the threading, is there any other way to
> accomplish this?
>
> Is it possible to kick-off a timer to monitor a variable (Boolean)
> change that would update the UI. I then could set the timer when I
> start the thread and then set a boolean change variable inside the
> data processing function when it is complete. That would then kick-off
> the timer function to update the UI.
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of Dan Godfrey
> Sent: Wednesday, August 15, 2012 8:56 AM
> To: vantage@yahoogroups.com
> Subject: RE: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> Ok, I will work on that, thanks.
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of Jose Gomez
> Sent: Wednesday, August 15, 2012 8:36 AM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
>
> WOW ok that's a lot of code, but anything in RetrieveAvailabilityData
> which touches the UI has got to go
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez>
> <http://www.facebook.com/josegomez
> >
> <http://www.google.com/profiles/jose.gomez>
> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
> On Wed, Aug 15, 2012 at 11:07 AM, Dan Godfrey <dgodfrey@...> wrote:
>
> > **
> >
> >
> > Here is the code, thanks ahead of time if you guys can help me out
> > on
> this.
> >
> > Dan
> >
> > '//**************************************************
> > '// Custom VB.NET code for UD01Form
> > '// Created: 6/5/2008 1:06:23 PM
> > '//**************************************************
> > Imports System
> > Imports System.Data
> > Imports System.Diagnostics
> > Imports System.Windows.Forms
> > Imports System.ComponentModel
> > Imports Microsoft.VisualBasic
> > Imports Epicor.Mfg.UI
> > Imports Epicor.Mfg.UI.FrameWork
> > Imports Epicor.Mfg.UI.ExtendedProps
> > Imports Epicor.Mfg.UI.FormFunctions
> > Imports Epicor.Mfg.UI.Customization
> > Imports Epicor.Mfg.UI.Adapters
> > Imports Epicor.Mfg.UI.Searches
> > IMPORTS System.IO
> > Imports Epicor.Mfg.BO
> > Imports Infragistics.Win
> > Imports Infragistics.Shared
> > Imports Infragistics.Win.UltraWinGrid Imports System.Reflection
> > Imports Infragistics.Win.UltraWinToolBars Imports System.Threading
> >
> > Module 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 WithEvents
> > timephasAdapter As TimePhasAdapter Private WithEvents edvTimePhas As
> > EpiDataView Private dsAvailability AS System.Data.DataSet Private
> > dsTimePhase AS System.Data.DataSet Private nAvailabilityDataColumns
> > AS Integer = 0 Private nTimePhaseDataColumns AS Integer = 0 Private
> > Const sAvailabilityBAQID AS String = "AMC-AVAILABILITY02"
> > Private bDeveloperLoggedIn AS Boolean = False Private bGridSizeSet
> > AS Boolean = False Private Const nGridID_ComponentAvailability AS
> > Integer = 1 Private Const nGridID_TimePhase AS Integer = 2 Private
> > bFormLoaded AS Boolean = False Private baseToolbarsManager As
> > Infragistics.Win.UltraWinToolbars.UltraToolbarsManager
> > Private sCurrentPartNum AS String = String.Empty Private
> > dteShortageDate AS Date Private nAvailableQty AS Decimal = 0 Private
> > bCancelRetrieve AS Boolean = False Private thrdSpawnNewThread AS
> > Thread 'Private dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form)
> >
> > Sub InitializeCustomCode()
> >
> > '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard
> > Added Variable Intialization' lines ** '// Begin Wizard Added
> > Variable Intialization
> >
> > '// End Wizard Added Variable Intialization '// Begin Custom Method
> > Calls If Thread.CurrentThread.Name = Nothing Then
> > thrdSpawnNewThread.CurrentThread.Name = "RetrieveAvailabilityData"
> > End If
> >
> > 'dynQryAD = New DynamicQueryAdapter(UD01Form)
> > 'dynQryAD.BOconnect()
> >
> > dsAvailability = New System.Data.DataSet("Results") dsTimePhase =
> > New
> > System.Data.DataSet("Results") timephasAdapter = New
> > timephasAdapter(oTrans)
> > timephasAdapter.BOConnect()
> >
> > edvTimePhas = new EpiDataView()
> > edvTimePhas.dataView = New
> > DataView(timephasAdapter.TimePhasData.TimePhas)
> >
> > If Not (oTrans.EpiDataViews.ContainsKey("TimePhasView")) Then
> > oTrans.Add("TimePhasView",edvTimePhas)
> > End If
> >
> > dim obj as Object =
> > GetType(Epicor.Mfg.UI.App.UD01Entry.UD01Form).InvokeMember("baseTool
> > ba rsManager", BindingFlags.Instance Or BindingFlags.GetField Or
> > BindingFlags.NonPublic, Nothing, UD01Form, Nothing)
> > BaseToolbarsManager =
> > ctype(obj,Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)
> > AddHandler baseToolbarsManager.ToolClick, AddressOf
> > baseToolbarsManager_ToolClick
> >
> >
> > '// End Custom Method Calls
> > End Sub
> >
> > Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object,
> > ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
> > Select case args.tool.key
> > Case "ClearTool"
> > ClearData(False)
> > 'MyMessageBox("ClearTool.Click", True, MsgBoxStyle.OKOnly,
> > "baseToolbarsManager.ToolClick")
> > End Select
> > End Sub
> >
> > Sub 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
> > releaseObject(edvTimePhas)
> >
> > timephasAdapter.Dispose()
> > releaseObject(timephasAdapter)
> >
> > dsTimePhase.Dispose()
> > releaseObject(dsTimePhase)
> >
> > dsAvailability.Dispose()
> > releaseObject(dsAvailability)
> >
> > 'dynQryAD.Dispose()
> > 'releaseObject(dynQryAD)
> >
> > End Sub
> >
> > Private Sub UD01Form_Load(ByVal sender As object, ByVal args As
> > EventArgs) Handles UD01Form.Load '// '// Add Event Handler Code '//
> > Dim userID As String = UD01Form.Session.UserID bFormLoaded = False
> > bDeveloperLoggedIn = False Select userID Case "dgodfrey"
> > bDeveloperLoggedIn = True
> > Case Else
> > bDeveloperLoggedIn = False
> > End Select
> > AddingDataColumns(dsAvailability, ugdBOMGrid,
> > nGridID_ComponentAvailability)
> >
> > 'AddingDataColumns(dsTimePhase, ugdTimePhase, nGridID_TimePhase)
> >
> > ugdBOMGrid.Width = 1070
> > ugdBOMGrid.Height = 165
> >
> > ugdBOMGrid.Width = 1070
> > ugdBOMGrid.Height = 250
> >
> > grpFilters.Show()
> > chkExceptionsOnly.Show()
> > lblExceptionsOnly.Show()
> > chkExceptionsOnly.Checked = False
> > chkExcludeConsignments.Show()
> > chkExcludeConsignments.Show()
> > chkExcludeConsignments.Checked = False
> >
> > grpTimePhaseFilters.Show()
> > chkSuggestions.Show()
> > lblSuggestions.Show()
> > chkSuggestions.Checked = False
> > chkForecasting.Checked = False
> >
> > IF(bDeveloperLoggedIn) Then
> > btnShowSize.Show()
> > ChkForecasting.Show()
> > lblForecasting.Show()
> > btnCancelRetrieve.Show()
> > Else
> > ChkForecasting.Hide()
> > lblForecasting.Hide()
> > btnShowSize.Hide()
> > btnCancelRetrieve.Hide()
> > End If
> >
> > Dim myTreeViewPanel as Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel =
> > CType(csm.GetNativeControlReference("ff47e708-60d7-4586-9708-91a5d57
> > fb
> > 7a6"),
> > Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)
> > Dim myMainPanel as Epicor.Mfg.UI.App.UD01Entry.MainPanel =
> > CType(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287
> > e2
> > 74b"),
> > Epicor.Mfg.UI.App.UD01Entry.MainPanel)
> > myTreeViewPanel.Dispose()
> > myMainPanel.Dispose()
> > bFormLoaded = True
> > otrans.pushstatustext("Ready!", False) End Sub
> >
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> > '/**************** Start of Generic Function
> > *************************/
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > ** / Private Sub ClearData(ByVal bGridOnly AS Boolean) IF(bGridOnly
> > =
> > False) Then txtBOMPartNum.Text = String.Empty
> > txtPartDescription.Text = String.Empty txtBOMRevisionNum.text =
> > String.Empty txtProductionQty.Text = String.Empty End If
> > dsAvailability.Tables(0).Rows.Clear()
> > ugdBOMGrid.Text = "BOM Components"
> > ugdTimePhase.Text = "Time Phase Inquiry"
> >
> > timephasAdapter.clearData()
> > edvTimePhas.EpiDataChanged()
> > End Sub
> >
> > Private Sub ShowSize()
> > DIM msg AS String = String.Empty
> > msg = msg & "Form Size:" & chr(13) & chr(10) msg = msg & "Bottom = "
> > & ugdBOMGrid.FindForm().Bottom & ", Top = " &
> > ugdBOMGrid.FindForm().Top & ", Width = " &
> > ugdBOMGrid.FindForm().Width & ", Height = " &
> > ugdBOMGrid.FindForm().Height & chr(13) & chr(10) msg = msg &
> > "ugdBOMGrid Size:" & chr(13) & chr(10) msg = msg & "Bottom = " &
> > ugdBOMGrid.Bottom & ", Top = " & ugdBOMGrid.Top & ", Width = " &
> > ugdBOMGrid.Width & ", Height = " & ugdBOMGrid.Height &
> > chr(13) & chr(10)
> > msg = msg & "ugdTimePhase Size:" & chr(13) & chr(10) msg = msg &
> > "Bottom = " & ugdTimePhase.Bottom & ", Top = " & ugdTimePhase.Top &
> > ", Width = " & ugdTimePhase.Width & ", Height = " &
> > ugdTimePhase.Height &
> > chr(13) & chr(10) MyMessageBox(msg, bDeveloperLoggedIn,
> > MsgBoxStyle.OKOnly, "Grid Sizes")
> >
> > End Sub
> >
> > Private Sub ValidateGridSize()
> > Dim nWidth AS Integer = ugdBOMGrid.FindForm().Width Dim nHeight AS
> > Integer = ugdBOMGrid.FindForm().Height DIM nCriteriaAreaPlusFooting
> > AS Integer = 250 Dim nSpaceBtwnGrids AS Integer = 5
> >
> > ugdBOMGrid.Width = (nWidth - 50)
> > ugdBOMGrid.Height = (nHeight - nCriteriaAreaPlusFooting) *.4
> >
> > ugdTimePhase.Left = ugdBOMGrid.Left
> > ugdTimePhase.Top = ugdBOMGrid.Top + ugdBOMGrid.Height +
> > nSpaceBtwnGrids ugdTimePhase.Width = ugdBOMGrid.Width
> > ugdTimePhase.Height = (nHeight - nCriteriaAreaPlusFooting) *.6
> >
> >
> > btnShowSize.Left = ugdBOMGrid.Left
> > btnShowSize.Top = ugdTimePhase.Top + ugdTimePhase.Height +
> > nSpaceBtwnGrids ugdBOMGrid.Anchor = AnchorStyles.Bottom Or
> > AnchorStyles.Right Or AnchorStyles.Left Or AnchorStyles.Top
> > 'ugdTimePhase.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or
> > AnchorStyles.Left Or AnchorStyles.Top bGridSizeSet = True
> >
> > 'ShowSize()
> > End Sub
> >
> > Private Sub GridCustomization(ByRef Collection AS
> > Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal
> > GridIdentifier AS
> > Integer)
> > Dim column AS Infragistics.Win.UltraWinGrid.UltraGridColumn
> > IF(GridIdentifier = nGridID_ComponentAvailability) Then For each
> > column in Collection Select column.Header.Caption Case "Rev", "Part
> > Number", "RevDescription", "Rel Opr.", "TotalDemandQty"
> > column.Hidden = True
> > Case "Lvl"
> > column.Width = 30
> > column.CellAppearance.TextHAlign = HAlign.Right Case "MtlSeq", "Lead"
> > column.Width = 50
> > column.CellAppearance.TextHAlign = HAlign.Right Case "Material Part"
> > column.Width = 150
> > Case "PartDescription"
> > column.Width = 250
> > Case "Type"
> > column.Width = 50
> > Case "RequiredQty"
> > column.Width = 75
> > column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> > column.CellAppearance.TextHAlign = HAlign.Right Case "ClassID"
> > column.Width = 50
> > Case "TotalQtyOnHand", "AvailableQty"
> > column.Width = 125
> > column.MaskInput = "-nnnn,nnn,nnn,nnn.nn"
> > column.CellAppearance.TextHAlign = HAlign.Right Case Else
> > 'column.Hidden = True
> >
> > End Select
> > Next Column
> > Else'nGridID_TimePhase
> > Dim nOrdinal AS Integer = 0
> > For each column in Collection
> > Select column.Header.Caption
> > Case "Due"
> > 'column.Ordinal = 0
> > Case "Receipts"
> > 'column.Ordinal = 1
> > Case "Job"
> > 'column.Ordinal = 2
> > Case "Order"
> > 'column.Ordinal = 3
> > Case "RequiredQty"
> > 'column.Ordinal = 4
> > Case "PO"
> > 'column.Ordinal = 5
> > Case "Lead"
> > 'column.Ordinal = 6
> > Case "Balance"
> > 'column.Ordinal = 7
> > Case "Exception"
> > 'column.Ordinal = 8
> > Case "Order By"
> > 'column.Ordinal = 9
> > Case "Source"
> > 'column.Ordinal = 10
> > Case "JobStatus"
> > 'column.Ordinal = 11
> > 'nOrdinal = 11
> > Case Else
> > 'column.Ordinal = 11
> > 'nOrdinal = nOrdinal + 1
> > 'column.Hidden = True
> > End Select
> > Next Column
> > End IF
> >
> > End Sub 'GridCustomization(ByRef Collection AS
> > Infragistics.Win.UltraWinGrid.ColumnsCollection, ByVal
> > GridIdentifier AS
> > Integer)
> >
> > Private Sub TransferDataRow(ByRef myDataSet AS
> > System.Data.DataSet,ByVal nFirstColumnIndex AS Integer, ByVal
> > nColumnCnt AS Integer, ByVal SrcRow AS
> > DataRow)
> > ' Instantiate a new row using the NewRow method.
> > Dim newRow As DataRow = myDataSet.Tables("Results").NewRow()
> > Dim i AS Integer = 0
> > 'Insert code to fill the row with values.
> > For i = nFirstColumnIndex To nColumnCnt
> > newRow.Item(i) = SrcRow.Item(i)
> > Next i
> > 'Add the row to the DataRowCollection.
> > myDataSet.Tables("Results").Rows.Add(newRow)
> > myDataSet.Tables("Results").AcceptChanges()
> > End Sub 'TransferDataRow(ByRef myDataSet AS
> > System.Data.DataSet,ByVal nFirstColumnIndex, ByVal nColumnCnt AS
> > Integer, ByVal SrcRow AS
> > DataRow)
> >
> > Private Sub AddingDataColumns(ByRef myDataSet AS
> > System.Data.DataSet, ByRef myGrid AS
> > Epicor.Mfg.UI.FrameWork.EpiUltraGrid, ByVal GridIdentifier AS
> > Integer)
> >
> > IF(myDataSet.Tables.Count <= 0)Then
> > myDataSet.Tables.Add("Results")
> > End If
> > '// ** Place Event Handling Code Here **
> > otrans.pushstatustext("Retrieving Data ...", False) 'Dim
> > sStatusString as String = String.Empty
> >
> > IF(GridIdentifier = nGridID_ComponentAvailability) Then Dim
> > sStatusString AS String = String.EMpty Dim nColumns AS Integer = 0
> > Dim dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form) Dim sBaqID AS String =
> > sAvailabilityBAQID sBaqID = sAvailabilityBAQID
> >
> > dynQryAD.BOconnect()
> > dynQryAD.GetByID(sBaqID)
> >
> > For Each DR AS DataRow in
> > dynQryAD.QueryDesignData.Tables("SelectedField").Rows
> > nColumns = nColumns + 1
> > sStatusString = "AddingDataColumns function: Adding " & nColumns & "/"
> > & dynQryAD.QueryDesignData.Tables("SelectedField").Rows.Count & "
> ColumnName:
> > " & DR.Item("FieldLabel") & " is " &
> > DR.Item("DataType").ToString().ToUpper()
> > WriteToLogFile(sStatusString)
> > Select DR.Item("DataType").ToString().ToUpper()
> > Case "CHARACTER"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.String"))
> > Case "INTEGER"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Int32"))
> > Case "DECIMAL"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Decimal"))
> > Case "LOGICAL"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.Boolean"))
> > Case "DATE"
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.DateTime"))
> > Case Else
> > myDataSet.Tables("Results").Columns.Add(DR.Item("FieldLabel"),
> > Type.GetType("System.String"))
> > End Select
> > myDataSet.Tables(0).AcceptChanges()
> > Next
> > nAvailabilityDataColumns = nColumns - 1
> > dynQryAD.Dispose()
> > releaseObject(dynQryAD)
> > Else'nGridID_TimePhase
> > End If
> >
> > myGrid.DataSource = myDataSet
> > GridCustomization(myGrid.DisplayLayout.Bands(0).Columns,
> > GridIdentifier)
> >
> > End Sub 'AddingDataColumns()
> >
> > Private Function ShowDebugInformation() AS String Dim sRet AS String
> > '& Chr(13) & Chr(10) sRet = "Debug Data:" & Chr(13) & Chr(10) sRet =
> > sRet & "- UserID = " & UD01Form.Session.UserID & Chr(13) & Chr(10)
> > sRet = sRet & "- UserName = " & UD01Form.Session.UserName & Chr(13)
> > &
> > Chr(10)
> > sRet = sRet & "- UserEmail = " & UD01Form.Session.UserEmail &
> > Chr(13) &
> > Chr(10)
> > sRet = sRet & "- ProductName = " & UD01Form.Session.ProductName &
> > Chr(13) & Chr(10) sRet = sRet & "- ProductCode = " &
> > UD01Form.Session.ProductCode & Chr(13) & Chr(10)
> > WriteToLogFile(sRet)
> >
> > Return sRet
> > End Function 'ShowDebugInformation() AS String
> >
> > Private Function ShowDataSet(ByVal myDataSet AS System.Data.DataSet)
> > AS String Dim sRet AS String = String.Empty sRet = "INSIDE
> > ShowDataSet:" & chr(13) & chr(10)
> > WriteToLogFile(sRet)
> > sRet = String.Empty
> > For each Table as DataTable in myDataSet.Tables sRet = sRet & "Table:
> > " & Table.TableName & chr(13) & chr(10) For Each DR AS DataRow in
> > Table.Rows For Each DC as DataColumn in Table.Columns
> > IF(DC.ColumnName = "RowIdent") Then Exit For End If sRet = sRet &
> > DC.ColumnName & ":" & DR(DC.ColumnName)& ", "
> > Next'For Each DC as DataColumn in Table.Columns sRet = sRet &
> > chr(13) & chr(10) Next'For Each DR AS DataRow in Table.Rows Next'For
> > each Table
> > WriteToLogFile(sRet)
> > Return sRet
> > End Function 'ShowDataSet(ByVal myDataSet AS System.Data.DataSet) AS
> > String
> >
> > Private Function GetDataColumnInformation(ByVal myDataTable AS
> > DataTable) AS String Dim sRet AS String = String.Empty
> >
> > sRet = "INSIDE GetDataColumnInformation:" & chr(13) & chr(10)
> > WriteToLogFile(sRet)
> > sRet = String.Empty
> > For Each DC as DataColumn in myDataTable.Columns sRet = sRet &
> > DC.ColumnName & ", "
> > Next'For Each DC as DataColumn in Table.Columns sRet = sRet &
> > chr(13) & chr(10)
> > WriteToLogFile(sRet)
> >
> > Return sRet
> > End Function 'GetDataColumnInformation(ByVal myDataTable AS
> > DataTable) AS String
> >
> > ''' <summary>
> > ''' Copies the the specified number of rows from the top of the
> > specified table.
> > ''' </summary>
> > ''' <param name="table">
> > ''' The table containing the original rows.
> > ''' </param>
> > ''' <param name="rowCount">
> > ''' The number of rows to copy.
> > ''' </param>
> > ''' <param name="useView">
> > ''' Indicates whether the row order should be based on the
> > DefaultView or not.
> > ''' </param>
> > ''' <returns>
> > ''' A DataTable containing the copied rows.
> > ''' </returns>
> > Private Function GetTopRows(ByVal table As DataTable, _ ByVal
> > rowCount As Integer, _ ByVal useDefaultView As Boolean) As DataTable
> > 'You can't get more rows than exist.
> > If useDefaultView Then
> > rowCount = Math.Min(rowCount, table.DefaultView.Count) Else rowCount
> > = Math.Min(rowCount, table.Rows.Count) End If 'Copy the table schema.
> > Dim topTable As DataTable = table.Clone() 'Copy the specified number
> > of rows.
> > For rowIndex As Integer = 0 To rowCount - 1 Step 1 If useDefaultView
> > Then 'Take the top rows from the DeafultView.
> > topTable.ImportRow(table.DefaultView(rowIndex).Row)
> > Else
> > 'Take the top rows from the original table.
> > topTable.ImportRow(table.Rows(rowIndex))
> > End If
> > Next rowIndex
> > Return topTable
> > End Function
> >
> > Private Function WriteToLogFile(ByVal TextString AS String) as
> > Boolean Dim bResults AS Boolean = False
> >
> > Dim sInputString AS String = TextString & Chr(13) & Chr(10) Dim
> > sPath AS String = "C:\BOM_CAR_log.txt"
> >
> >
> > IF(File.Exists(sPath) = False) Then
> > ' Create a file to write to.
> > File.WriteAllText(sPath, sInputString) bResults = True Else ' This
> > text is always added, making the file longer over time ' if it is
> > not deleted.
> > File.AppendAllText(sPath, sInputString) bResults = True End If
> > return bResults End Function 'WriteToLogFile(ByVal TextString AS
> > String) as Boolean
> >
> > Private Function MyMessageBox( ByVal Msg AS String, ByVal FYI AS
> > Boolean,Optional ByVal Button As MsgBoxStyle = MsgBoxStyle.OKOnly,
> > Optional ByVal Title As String = Nothing) As MsgBoxResult Dim
> > results As MsgBoxResult If(FYI = True) Then If Not
> > String.IsNullOrEmpty(Title) Then results = MsgBox(Msg, Button,
> > Title) Else results = MsgBox(Msg,
> > Button) End If End If return results End Function 'MyMessageBox(
> > ByVal Msg AS String, ByVal FYI AS Boolean,Optional ByVal Button As
> > MsgBoxStyle = MsgBoxStyle.OKOnly, Optional ByVal Title As String =
> > Nothing) As MsgBoxResult
> >
> > Private Function FindValueFromArray(ByVal Values As Object(), ByVal
> > valueToSearch As Object) As Integer Dim retVal As Integer = 0 Dim
> > myArray As Array = DirectCast(Values, Array) If
> > Array.IndexOf(myArray,
> > valueToSearch) <> -1 Then retVal = Array.IndexOf(myArray,
> > valueToSearch) Else retVal = -1 End If Return retVal End Function
> > 'FindValueFromArray(ByVal Values As Object(), ByVal valueToSearch As
> > Object) As Integer
> >
> > Private Sub releaseObject(ByVal obj As Object) Try
> > System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
> > obj = Nothing
> > Catch ex As Exception
> > obj = Nothing
> > Finally
> > GC.Collect()
> > End Try
> > End Sub 'releaseObject(ByVal obj As Object)
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> > '/**************** End of Generic Function
> > ***************************/
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> >
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> > '/**************** Start of BOM_CAR Function
> > *************************/
> > '/******************************************************************
> > **
> > /
> > '/******************************************************************
> > **
> > /
> >
> > Private Sub btnCancelRetrieve_Click(ByVal Sender As Object, ByVal
> > Args As
> > System.EventArgs) Handles btnCancelRetrieve.Click '// ** Place Event
> > Handling Code Here ** IF(btnRetrieve.Enabled = False) Then
> > bCancelRetrieve = True 'thrdSpawnNewThread.Abort
> > 'ClearData(True)
> > End If
> > End Sub
> >
> > Private Sub ugdBOMGrid_Resize(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles ugdBOMGrid.Resize '// ** Place Event
> > Handling Code Here **
> > ValidateGridSize()
> > End Sub
> >
> > Private Sub btnRetrieve_Click(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles btnRetrieve.Click btnRetrieve.Enabled =
> > False thrdSpawnNewThread = new Thread(AddressOf
> > RetrieveAvailabilityData) thrdSpawnNewThread.Start
> > 'RetrieveAvailabilityData()
> > IF(bGridSizeSet = False) Then
> > ValidateGridSize()
> > End If
> > btnRetrieve.Enabled = True
> > End Sub
> >
> > Private Function GetShortageQtyANDDate(ByVal sPartNum AS String,
> > ByVal nRequiredQty AS Decimal, ByRef sDate AS Date, ByRef Quantity
> > AS
> > Decimal) AS Boolean
> >
> > Dim blTimePhas As Boolean =
> > timephasAdapter.GoProcessTimePhase(sPartNum,
> > "MfgSys", chkSuggestions.Checked, False)
> > 'ShowDataSet(timephasAdapter.TimePhasData)
> > IF(blTimePhas = True) Then
> > For Each drRow as DataRow in
> > timephasAdapter.TimePhasData.Tables("TimePhas").Rows
> > drRow.Item("BalanceQty") = drRow.Item("BalanceQty") - nRequiredQty
> > Quantity = drRow.Item("BalanceQty") IF(Quantity <= 0) then
> > blTimePhas = True
> > IF(drRow.Item("DueDate").ToString() <> "") then sDate =
> > drRow.Item("DueDate").Date End If Exit For Else blTimePhas = False
> > End If
> >
> > Next
> > timephasAdapter.TimePhasData.Tables("TimePhas").AcceptChanges()
> > End If
> >
> > Return blTimePhas
> > End Function
> >
> > Private Sub RetrieveTimePhaseInquiry()
> >
> > IF(ugdBOMGrid.Text <> "") Then
> > otrans.pushstatustext("Retrieving TimePhase Data ...", True)
> >
> > timephasAdapter.clearData()
> > Dim blTimePhas As Boolean =
> > GetShortageQtyANDDate(ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.Ac
> > ti
> > veRow.Band.Columns("Material
> > Part")),
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("
> > Re
> > quiredQty")),
> > dteShortageDate, nAvailableQty)
> > edvTimePhas.EpiDataChanged()
> > ugdTimePhase.Text = "Time Phase Inquiry: Part: " &
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("
> > Ma
> > terial
> > Part")) & " Description: " &
> > ugdBOMGrid.ActiveRow.GetCellText(ugdBOMGrid.ActiveRow.Band.Columns("
> > Pa
> > rtDescription"))
> >
> > otrans.pushstatustext("Ready!", False) End IF End Sub
> >
> > Private Sub RetrieveAvailabilityData() '// ** Place Event Handling
> > Code Here ** Dim dynQryAD As DynamicQueryAdapter = New
> > DynamicQueryAdapter(UD01Form) Dim pcTable As String = "PartRev"
> > Dim pcField As String = "PartNum"
> > Dim pbIsConst As Boolean = TRUE
> > Dim pcCondition As String = "="
> > Dim pcToValue as String = txtBOMPartNum.Text Dim pcToTable As String
> > = String.Empty Dim pcToField As String = String.Empty Dim
> > pcRightParentheses as String = String.Empty Dim pcLeftParentheses as
> > String = String.Empty Dim pcAndOr as String = String.Empty Dim pbNeg
> > as Boolean = False Try WriteToLogFile("Retrieving Availability Data
> > ...") otrans.pushstatustext("Retrieving Availability Data ...",
> > True)
> >
> > dynQryAD.BOconnect()
> >
> > dsAvailability.Tables(0).Rows.Clear()
> > ugdBOMGrid.DataSource.Tables(0).Rows.Clear()
> >
> > dynQryAD.GetByID(sAvailabilityBAQID)
> >
> > dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> > pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> > pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> > dynQryAD.Update pcField = "RevisionNum"
> > pcToValue = txtBOMRevisionNum.Text.ToString() pcAndOr = "AND"
> > dynQryAD.AddWhereItem(dynQryAD.QueryDesignData, sAvailabilityBAQID,
> > pcTable, pcField, pcCondition, pbIsConst, pcToValue, pcToTable,
> > pcToField, pcLeftParentheses, pcRightParentheses, pcAndOr, pbNeg)
> > dynQryAD.Update
> >
> > ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> > Infragistics.Win.DefaultableBoolean.True
> >
> > WriteToLogFile("copy all data from QueryDesignData tables to
> > DynamicQueryData tables (only for tables that exist in both
> > datasets)") '//copy all data from QueryDesignData tables to
> > DynamicQueryData tables (only 'for tables that exist in both
> > datasets
> >
> > Dim targetRow as DataRow
> > For each Table as DataTable in dynQryAD.DynamicQueryData.Tables If
> > Table.Rows.Count = 0 Then For Each sourceRow as DataRow in
> > dynQryAD.QueryDesignData.Tables(Table.ToString()).Rows
> > targetRow = Table.NewRow()
> > targetRow.ItemArray = sourceRow.ItemArray
> > Table.Rows.Add(targetRow)
> > Next
> > End If
> > Next'For each Table as DataTable in dynQryAD.DynamicQueryData.Tables
> >
> > WriteToLogFile("dynQryAD.Execute(dynQryAD.DynamicQueryData)")
> > dynQryAD.Execute(dynQryAD.DynamicQueryData)
> >
> > WriteToLogFile("Processing " &
> > dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> > records.") otrans.pushstatustext("Processing " &
> > dynQryAD.QueryResults.Tables("Results").Rows.Count & " Query
> > records.",
> > True)
> > Dim RecCnt AS Integer = 0
> > Dim AddToGrid AS Boolean = True
> > Dim bNegAvail AS boolean = False
> > WriteToLogFile("Pre-Filtered DataSet")
> > ShowDataSet(dynQryAD.QueryResults)
> >
> > For Each ORow as DataRow in dynQryAD.QueryResults.Tables(0).Rows
> > 'myDataSet has records
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> > AddToGrid = True
> >
> > ORow.Item("RequiredQty") = ORow.Item("RequiredQty") *
> > txtProductionQty.Value nAvailableQty =
> > ORow.Item("PartPlant.Number01")
> > - ORow.Item("RequiredQty") dteShortageDate = Today()
> > IF(nAvailableQty
> > > 0) then bNegAvail =
> > GetShortageQtyANDDate(ORow.Item("ECOMtl.MtlPartNum"),
> > ORow.Item("RequiredQty"), dteShortageDate, nAvailableQty) Else
> > bNegAvail = True End If
> >
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> >
> > ORow.Item("ShortageDate") = dteShortageDate.Date
> > ORow.Item("AvailableQty") = nAvailableQty
> >
> > IF(chkExceptionsOnly.Checked = True) Then AddToGrid = bNegAvail End
> > If
> > IF(chkExcludeConsignments.Checked) Then Select
> > ORow.Item("Part.ClassID") Case "CARR"
> > AddToGrid = False
> > Case "CTTI"
> > AddToGrid = False
> > Case "CAVN"
> > AddToGrid = False
> > Case Else
> > AddToGrid = AddToGrid
> > End Select
> > End If
> >
> > IF(bCancelRetrieve = True) Then
> > ClearData(True)
> > Exit For
> > End If
> >
> > If(AddToGrid) then
> > RecCnt = RecCnt + 1
> > TransferDataRow(dsAvailability, 0, nAvailabilityDataColumns, ORow)
> > End If Next'For Each ORow as DataRow in
> > dynQryAD.QueryResults.Tables(0).Rows
> > IF(bCancelRetrieve = True) Then
> > bCancelRetrieve = False
> > Else
> > otrans.pushstatustext("Processed " & RecCnt & " Component records.",
> > True) WriteToLogFile("Processed " & RecCnt & " Component records.")
> > WriteToLogFile("Grid-Filtered DataSet")
> > ShowDataSet(dsAvailability)
> >
> > dsAvailability.Tables("Results").Columns("Material
> > Part").ExtendedProperties("Like") = "Part.PartNum"
> > dsAvailability.Tables("Results").AcceptChanges()
> > IF(RecCnt > 0) Then
> > ugdBOMGrid.Text =
> > dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> > txtPartdescription.Text =
> > dsAvailability.Tables(0).Rows(0).Item("RevDescription")
> > ugdBOMGrid.DataSource = dsAvailability
> > GridCustomization(ugdBOMGrid.DisplayLayout.Bands(0).Columns,
> > nGridID_ComponentAvailability)
> > Else
> > MyMessageBox("There was no exceptions found.", True,
> > MsgBoxStyle.OKOnly, "Availability Report")
> > timephasAdapter.clearData()
> > edvTimePhas.EpiDataChanged()
> >
> > End If
> >
> > ugdBOMGrid.DisplayLayout.Override.AllowUpdate =
> > Infragistics.Win.DefaultableBoolean.False
> > End If
> > Catch abortException As ThreadAbortException
> > MyMessageBox(abortException.Message & ": " &
> > CType(abortException.ExceptionState, String), True,
> > MsgBoxStyle.OKOnly, "Availability Report") finally
> > dynQryAD.Dispose()
> > releaseObject(dynQryAD)
> > End Try
> > End Sub 'RetrieveSalesData()
> >
> > Private Sub btnPartRevSearch_Click(ByVal Sender As Object, ByVal
> > Args As
> > System.EventArgs) Handles btnPartRevSearch.Click '// ** Place Event
> > Handling Code Here ** Dim recordSelected As Boolean Dim sPart AS
> > String = txtBOMPartNum.Text Dim wClause AS String = "PartNum >= '" +
> > sPart + "'"
> >
> > IF(sPart.length() <= 0) Then
> > wClause = String.Empty
> > End If
> > Dim dsSearch As DataSet = SearchFunctions.listLookup(UD01Form,
> > "PartRevSearchAdapter", recordSelected, True, wClause, False)
> >
> > If( recordSelected) Then
> > txtBOMPartNum.Text = dsSearch.Tables(0).Rows(0)("PartNum")
> > txtBOMRevisionNum.Text = dsSearch.Tables(0).Rows(0)("RevisionNum")
> > End If
> > End Sub
> >
> > Private Sub btnShowSize_Click(ByVal Sender As Object, ByVal Args As
> > System.EventArgs) Handles btnShowSize.Click '// ** Place Event
> > Handling Code Here **
> > ShowSize()
> > End Sub
> >
> > Private Sub ugdBOMGrid_AfterRowActivate(ByVal Sender As Object,
> > ByVal Args As System.EventArgs) Handles ugdBOMGrid.AfterRowActivate
> > '// ** Place Event Handling Code Here **
> > RetrieveTimePhaseInquiry()
> > End Sub
> >
> > Private Sub chkSuggestions_AfterCheckStateChanged(ByVal Sender As
> > Object, ByVal Args As System.EventArgs) Handles
> > chkSuggestions.AfterCheckStateChanged
> > '// ** Place Event Handling Code Here **
> > IF(bFormLoaded) Then
> > RetrieveTimePhaseInquiry()
> > End If
> > End Sub
> >
> > Private Sub txtBOMPartNum_Leave(ByVal Sender As Object, ByVal Args
> > As
> > System.EventArgs) Handles txtBOMPartNum.Leave '// ** Place Event
> > Handling Code Here ** IF(txtBOMPartNum.Text <> sCurrentPartNum) Then
> > txtBOMRevisionNum.Text = GetLatestPartRev(txtBOMPartNum.Text)
> > sCurrentPartNum = txtBOMPartNum.Text End If
> >
> > End Sub
> >
> > Private Function GetLatestPartRev (ByVal sPartNum As string) As
> > string
> >
> > Dim sPartRev As String = String.Empty Dim recSelected As Boolean =
> > False Dim swhereClause AS String = "PartNum = '" & sPartNum & "'"
> >
> > Dim dsSearch As DataSet
> > dsSearch = SearchFunctions.listLookup(oTrans,
> > "PartRevSearchAdapter", recSelected, False, swhereClause, True) If
> > recSelected Then sPartRev =
> > dsSearch.Tables(0).Rows(dsSearch.Tables(0).Rows.Count() -
> > 1).Item("RevisionNum")
> > Else
> > MyMessageBox("The PartNum you entered does not have a valid Revision
> > Number.", True, MsgBoxStyle.OKOnly, "Invalid Part Number") End If
> > Return sPartRev End Function
> >
> > End Module
> >
> > -----Original Message-----
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > Behalf Of John Driggers
> > Sent: Wednesday, August 15, 2012 7:35 AM
> > To: vantage@yahoogroups.com
> > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> >
> > You shouldn't need to. What is the error you're receiving? If you
> > stick your code up here it will likely help a lot.
> >
> > On Tue, Aug 14, 2012 at 6:17 PM, Dan Godfrey <dgodfrey@...> wrote:
> >
> > > **
> > >
> > >
> > > What I am doing is calling a BAQ and then adding two where clauses
> > > for the PartNum and RevisionNum. I then execute the BAQ. This is
> > > all done with local parameters inside of the method that I
> > > delegate for the
> > thread.
> > > Should I set the DynamicQueryAdapter object as global so that it
> > > is owned by the Form?
> > >
> > >
> > > -----Original Message-----
> > > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> > > Behalf Of Jose Gomez
> > > Sent: Tuesday, August 14, 2012 2:39 PM
> > > To: vantage@yahoogroups.com
> > > Subject: Re: [Vantage] Vantage 8.03.409C: System.Threading and BO
> > >
> > > I've done it several times, how are you doing it? You can't update
> > > UI items from a thread, so if its updating UI that's where your
> > > crash is happening your best bet is to instanciate a new BO do
> > > your stuff and then refresh the UI once its donre.l
> > >
> > > *Jose C Gomez*
> > > *Software Engineer*
> > > *
> > > *
> > > *
> > > *T: 904.469.1524 mobile
> > > E: jose@...
> > > http://www.josecgomez.com
> > > <http://www.linkedin.com/in/josecgomez>
> > > <http://www.facebook.com/josegomez
> > > >
> > > <http://www.google.com/profiles/jose.gomez>
> > > <http://www.twitter.com/joc85>
> > > <http://www.josecgomez.com/professional-resume/>
> > > <http://www.josecgomez.com/feed/>
> > > <http://www.usdoingstuff.com>
> > >
> > > *Quis custodiet ipsos custodes?*
> > >
> > > On Tue, Aug 14, 2012 at 4:39 PM, dgodfrey_amc <dgodfrey@...>
> > wrote:
> > >
> > > > **
> > > >
> > > >
> > > > Has anyone used threading with Business Objects? I am trying to
> > > > use it to spawn a thread for a method that takes 5 minutes. I am
> > > > utilizing the DynamicQueryAdapter in my method.
> > > >
> > > > the strange thing is that I can call the BOConnect(), GetByID(),
> > > > AddWhereItem() and Update methods, but when I try to call the
> > > > Execute method it crashes.
> > > >
> > > > Does anyone have any thoughts and/or ideas on this?
> > > >
> > > > Dan
> > > >
> > > >
> > > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> > > ------------------------------------
> > >
> > > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > > must have already linked your email address to a yahoo id to
> > > enable
> access.
> > > )
> > > (1) To access the Files Section of our Yahoo!Group for Report
> > > Builder and Crystal Reports and other 'goodies', please goto:
> > > http://groups.yahoo.com/group/vantage/files/.
> > > (2) To search through old msg's goto:
> > > http://groups.yahoo.com/group/vantage/messages
> > > (3) To view links to Vendors that provide Vantage services goto:
> > > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Useful links for the Yahoo!Groups Vantage Board are: ( Note: You
> > must have already linked your email address to a yahoo id to enable access.
> > )
> > (1) To access the Files Section of our Yahoo!Group for Report
> > Builder and Crystal Reports and other 'goodies', please goto:
> > http://groups.yahoo.com/group/vantage/files/.
> > (2) To search through old msg's goto:
> > http://groups.yahoo.com/group/vantage/messages
> > (3) To view links to Vendors that provide Vantage services goto:
> > http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
> ------------------------------------
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access.
> )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links





------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links