APM (doc-link) indexing through VB

Wicked

Sent from my Verizon Wireless Droid


-----Original message-----
From: bw2868bond <bwalker@...>
To: "vantage@yahoogroups.com" <vantage@yahoogroups.com>
Sent: Thu, Mar 1, 2012 12:21:42 GMT+00:00
Subject: [Vantage] Re: APM (doc-link) indexing through VB



Our APM documents are stored in SQL db not in File Store.
We Generate a Legal Number at receipt entry.
We attach a barcode label to the receipt which contains the Legal Number
We scan Vendor pack slips (and Certs) which are indexed into DocLink using the Legal Number
As components are used on jobs, the barcodes are scanned and the job number / legal number is stored in a UD table
When QA wants to gather component documents for a job, they enter the job number in a customized Vantage form and all of the scanned vendor documents are dumped into a folder on their PC. (the SQL server storing our documents is "VANTAGE-APM" - you would need to change that to what is relevant in your environment)

The Customization:

'//**************************************************
'// Custom VB.NET code for UD04Form
'// Created: 6/30/2011 10:28:05 AM
'//**************************************************
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Diagnostics
Imports System.IO
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 Epicor.Mfg.BO

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 **

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

'// End Custom Method Calls
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
End Sub

Private Sub btnEpiCustom1_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom1.Click
'// ** Place Event Handling Code Here **
Dim myPath As string
Dim intDocuments as integer = 0
Dim opts As New SearchOptions(Epicor.Mfg.UI.Searches.SearchMode.AutoSearch)
opts.DataSetMode = DataSetMode.ListDataSet
opts.PreLoadSearchFilter = "Key1 = '" + txtEpiCustom1.Text + "' AND ShortChar03 MATCHES '*RR*'"
Dim callResult As Object = ProcessCaller.LaunchSearch(UD04Form,"UD04Adapter",opts)
If(TypeOf callResult Is System.Data.Dataset) AndAlso (DirectCast(callResult,DataSet).Tables(0).Rows.Count > 0) Then
Dim dtToFind As DataTable = DirectCast(callResult,DataSet).Tables(0).DefaultView.ToTable(true,"ShortChar02","ShortChar03")
Using(oTrans.PushDisposableStatusText("Creating Folder",true))
myPath = "c:\Temp\" + txtEpiCustom1.Text + " VendorPackSlips"
Directory.CreateDirectory(myPath)
End Using
Dim strConn As String = "Data Source=VANTAGE-APM;Initial Catalog=doclink2;Integrated Security=True"
Dim sqlConn As SQLConnection = new SqlConnection(strConn)
sqlConn.Open()
For Each dr As DataRow In dtToFind.Rows
Using(oTrans.PushDisposableStatusText("Retrieving Document " + dr("ShortChar03").ToString(),true))
Dim sqlCom As SQLCommand = new SQLCommand("SELECT DocumentStoreFiles.FileData FROM doclink2.dbo.DocumentFiles DocumentFiles, doclink2.dbo.Documents Documents, doclink2.dbo.PropertyCharValues PropertyCharValues, doclink2.dbo.DocumentStoreFiles WHERE PropertyCharValues.ParentId = DocumentFiles.ParentId AND DocumentFiles.ParentId = Documents.DocumentId AND CAST(DocumentFiles.DocumentStoreFileID AS uniqueidentifier) = DocumentStoreFiles.DocumentStoreFileID AND ((PropertyCharValues.PropertyCharValue='" + dr("ShortChar03").ToString() + "') AND (DocumentFiles.DocumentStoreFileID<>'') AND (PropertyCharValues.PropertyID <> 4))", sqlConn)
Dim byTiff() As byte = CType(sqlCom.ExecuteScalar(),byte())
If Not(byTiff Is Nothing) Then
Try
Dim wFile As System.IO.FileStream
wFile = New FileStream(myPath + "\" + dr("ShortChar02") + "_" + dr("ShortChar03") + ".tif", FileMode.Append)
wFile.Write(byTiff, 0, byTiff.Length)
wFile.Close()
intDocuments += 1
Catch ex As IOException
MsgBox(ex.ToString)
End Try
End If
sqlCom = Nothing
byTiff = Nothing
End Using

Next
sqlConn.Close()
sqlConn = Nothing
strConn = Nothing
End If
callResult = Nothing
opts = Nothing
Dim dlgResult As DialogResult = MessageBox.Show(intDocuments.ToString + " Vendor Documents Retrieved")
If (dlgResult = DialogResult.OK) Then
Dim myDir As String = myPath + "\"
Process.Start("Explorer.exe","/Root," + myDir)
End If
End Sub

End Module

--- In vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com>, "sbraudrick@..." <sbraudrick@...> wrote:
>
> I'd love to see the code for retrieving documents, and simple sounds even better!
>
> SB
>
> --- In vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com>, "bw2868bond" <bwalker@> wrote:
> >
> > Documents printed to the APM printer are indexed automatically.
> > scanned documents and the like can be indexed using the smart client (APM 2.7)
> >
> > I have some simple code for retrieving documents but none for putting documents into storage.
> >
> > --- In vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com>, "ericzuerche" <ezuercher@> wrote:
> > >
> > > Does anyone have code examples of indexing a document into Altec's Doc-link (aka Epicor APM+) through VB.Net?
> > >
> > > Thanks,
> > > Eric
> > >
> >
>





[Non-text portions of this message have been removed]
Does anyone have code examples of indexing a document into Altec's Doc-link (aka Epicor APM+) through VB.Net?

Thanks,
Eric
Documents printed to the APM printer are indexed automatically.
scanned documents and the like can be indexed using the smart client (APM 2.7)

I have some simple code for retrieving documents but none for putting documents into storage.

--- In vantage@yahoogroups.com, "ericzuerche" <ezuercher@...> wrote:
>
> Does anyone have code examples of indexing a document into Altec's Doc-link (aka Epicor APM+) through VB.Net?
>
> Thanks,
> Eric
>
Yes, we've got the APM printer set up, as well as the smart client. I can probably use VB Net to do a one-button index through the APM printer, but I'd rather go directly through the exposed doc-link Net assemblies if possible so that I can eliminate any problems with the printer recognizing the key words on the report; also, it would remove some of the steps.

I've got the retrieve working through VB net and a SQL query. It's just the indexing that I'm trying to figure out.

Eric

--- In vantage@yahoogroups.com, "bw2868bond" <bwalker@...> wrote:
>
> Documents printed to the APM printer are indexed automatically.
> scanned documents and the like can be indexed using the smart client (APM 2.7)
>
> I have some simple code for retrieving documents but none for putting documents into storage.
>
> --- In vantage@yahoogroups.com, "ericzuerche" <ezuercher@> wrote:
> >
> > Does anyone have code examples of indexing a document into Altec's Doc-link (aka Epicor APM+) through VB.Net?
> >
> > Thanks,
> > Eric
> >
>
I'd love to see the code for retrieving documents, and simple sounds even better!

SB

--- In vantage@yahoogroups.com, "bw2868bond" <bwalker@...> wrote:
>
> Documents printed to the APM printer are indexed automatically.
> scanned documents and the like can be indexed using the smart client (APM 2.7)
>
> I have some simple code for retrieving documents but none for putting documents into storage.
>
> --- In vantage@yahoogroups.com, "ericzuerche" <ezuercher@> wrote:
> >
> > Does anyone have code examples of indexing a document into Altec's Doc-link (aka Epicor APM+) through VB.Net?
> >
> > Thanks,
> > Eric
> >
>
Our APM documents are stored in SQL db not in File Store.
We Generate a Legal Number at receipt entry.
We attach a barcode label to the receipt which contains the Legal Number
We scan Vendor pack slips (and Certs) which are indexed into DocLink using the Legal Number
As components are used on jobs, the barcodes are scanned and the job number / legal number is stored in a UD table
When QA wants to gather component documents for a job, they enter the job number in a customized Vantage form and all of the scanned vendor documents are dumped into a folder on their PC. (the SQL server storing our documents is "VANTAGE-APM" - you would need to change that to what is relevant in your environment)

The Customization:

'//**************************************************
'// Custom VB.NET code for UD04Form
'// Created: 6/30/2011 10:28:05 AM
'//**************************************************
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Diagnostics
Imports System.IO
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 Epicor.Mfg.BO


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 **



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

'// End Custom Method Calls
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
End Sub



Private Sub btnEpiCustom1_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom1.Click
'// ** Place Event Handling Code Here **
Dim myPath As string
Dim intDocuments as integer = 0
Dim opts As New SearchOptions(Epicor.Mfg.UI.Searches.SearchMode.AutoSearch)
opts.DataSetMode = DataSetMode.ListDataSet
opts.PreLoadSearchFilter = "Key1 = '" + txtEpiCustom1.Text + "' AND ShortChar03 MATCHES '*RR*'"
Dim callResult As Object = ProcessCaller.LaunchSearch(UD04Form,"UD04Adapter",opts)
If(TypeOf callResult Is System.Data.Dataset) AndAlso (DirectCast(callResult,DataSet).Tables(0).Rows.Count > 0) Then
Dim dtToFind As DataTable = DirectCast(callResult,DataSet).Tables(0).DefaultView.ToTable(true,"ShortChar02","ShortChar03")
Using(oTrans.PushDisposableStatusText("Creating Folder",true))
myPath = "c:\Temp\" + txtEpiCustom1.Text + " VendorPackSlips"
Directory.CreateDirectory(myPath)
End Using
Dim strConn As String = "Data Source=VANTAGE-APM;Initial Catalog=doclink2;Integrated Security=True"
Dim sqlConn As SQLConnection = new SqlConnection(strConn)
sqlConn.Open()
For Each dr As DataRow In dtToFind.Rows
Using(oTrans.PushDisposableStatusText("Retrieving Document " + dr("ShortChar03").ToString(),true))
Dim sqlCom As SQLCommand = new SQLCommand("SELECT DocumentStoreFiles.FileData FROM doclink2.dbo.DocumentFiles DocumentFiles, doclink2.dbo.Documents Documents, doclink2.dbo.PropertyCharValues PropertyCharValues, doclink2.dbo.DocumentStoreFiles WHERE PropertyCharValues.ParentId = DocumentFiles.ParentId AND DocumentFiles.ParentId = Documents.DocumentId AND CAST(DocumentFiles.DocumentStoreFileID AS uniqueidentifier) = DocumentStoreFiles.DocumentStoreFileID AND ((PropertyCharValues.PropertyCharValue='" + dr("ShortChar03").ToString() + "') AND (DocumentFiles.DocumentStoreFileID<>'') AND (PropertyCharValues.PropertyID <> 4))", sqlConn)
Dim byTiff() As byte = CType(sqlCom.ExecuteScalar(),byte())
If Not(byTiff Is Nothing) Then
Try
Dim wFile As System.IO.FileStream
wFile = New FileStream(myPath + "\" + dr("ShortChar02") + "_" + dr("ShortChar03") + ".tif", FileMode.Append)
wFile.Write(byTiff, 0, byTiff.Length)
wFile.Close()
intDocuments += 1
Catch ex As IOException
MsgBox(ex.ToString)
End Try
End If
sqlCom = Nothing
byTiff = Nothing
End Using

Next
sqlConn.Close()
sqlConn = Nothing
strConn = Nothing
End If
callResult = Nothing
opts = Nothing
Dim dlgResult As DialogResult = MessageBox.Show(intDocuments.ToString + " Vendor Documents Retrieved")
If (dlgResult = DialogResult.OK) Then
Dim myDir As String = myPath + "\"
Process.Start("Explorer.exe","/Root," + myDir)
End If
End Sub


End Module


--- In vantage@yahoogroups.com, "sbraudrick@..." <sbraudrick@...> wrote:
>
> I'd love to see the code for retrieving documents, and simple sounds even better!
>
> SB
>
> --- In vantage@yahoogroups.com, "bw2868bond" <bwalker@> wrote:
> >
> > Documents printed to the APM printer are indexed automatically.
> > scanned documents and the like can be indexed using the smart client (APM 2.7)
> >
> > I have some simple code for retrieving documents but none for putting documents into storage.
> >
> > --- In vantage@yahoogroups.com, "ericzuerche" <ezuercher@> wrote:
> > >
> > > Does anyone have code examples of indexing a document into Altec's Doc-link (aka Epicor APM+) through VB.Net?
> > >
> > > Thanks,
> > > Eric
> > >
> >
>