uidoc.AutoReload = True
Call uidoc.Reload
Call uidoc.save
SourceDoc.saveoptions = "0"
'//--------------20130924 Run agent on server-------------
'//拋轉location & waferID
'%REM
If SourceDoc.HasItem("SRLocation") Then
If (dt_create.DateOnly >= dt_rsdate.DateOnly) And (Ucase(SourceDoc.SRLocation(0)) <> "" )Then '//上線時要變更為enable
Set agInsert = SourceDB.GetAgent ("A4.TransToCiMES")
Call agInsert.RunOnServer (SourceDoc.NoteID) '//簽核時傳送
End If '//上線時要變更為enable
End If
'%END REM
'--------------------------------------------------------------------------
Call uidoc.close
[Options]
Option Public
Option Declare
Uselsx "*LSXODBC"
Use "AgnesLibrary"
Use "SP.wfLibV2"
[Initialize]
'//點選放行通知時拋轉CiMES
Call SP_ClickRelease()
[SP_ClickRelease]
Function SP_ClickRelease() As Integer
'//當user點選"放行通知"按鍵時,call store procedure to CiMES
'//by store procedure
On Error Goto errorhandler
Dim session As New NotesSession
Dim agent As NotesAgent
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim conn As New ODBCConnection
Dim query As New ODBCQuery
Dim rs As New ODBCResultSet
Dim strSQL As String
Dim i As Integer, DataSourceNm As String
Set agent = session.CurrentAgent
Set db = session.CurrentDatabase
Print "run- " + agent.Name + " Start..." + Now()
'//connection
Conn.SilentMode=True
Set Query.connection = conn
Set rs.Query = Query
DataSourceNm = "runcard_ws"
If Not ODBC_Connect(Conn, DataSourceNm) Then Call Conn.disconnect : Error 997, "Can't Connect to ODBC (" + DataSourceNm + " )!!"
Set doc = db.GetDocumentByID (agent.ParameterDocID )
If Not doc Is Nothing Then
'//傳入三個參數LotNo、Wafer ID、Location ,若回傳空白,則是成功,若錯誤會直接回傳錯誤訊息
For i = 0 To Ubound(doc.WaferID)
strSQL = "Execute procedure ees@ws:wafer_erploc_u (" + "'" + doc.LotNo(0) + "', " '//LotNo
strSQL = strSQL + "'" + doc.WaferID(i) + "', " '//WaferID
strSQL = strSQL + "'" + doc.SRLocation(0) + "') " '//Location
Print strSQL
Query.SQL = strSQL
rs.Execute
Print rs.GetValue(1)
If rs.GetValue(1) <> "" Then
Call doc.ReplaceItemValue("ReleaseTransFlag", "S") '//寫入 comets_ws 失敗
Call doc.ReplaceItemValue("ReleaseTransMsg", rs.GetValue(1))
Print "寫入 comets_ws 失敗"
Messagebox "寫入 comets_ws 失敗", 0, "Warning"
Else
Call doc.ReplaceItemValue("ReleaseTransFlag", "S") '//寫入 comets_ws 成功
Call doc.ReplaceItemValue("ReleaseTransTime", Now())
Print "寫入 comets_ws 成功"
End If
'Call doc.Save(True,True)
Next
End If
Call rs.Close(Db_Close)
Call Conn.Disconnect
Print "run- " + agent.Name + " end..." + Now()
TheEnd:
Call rs.Close(Db_Close)
Call Conn.disconnect
Print "run SP_DataTrans_DB1 end...." + Now()
Exit Function
ErrorHandler:
Print "ag: A4. TransToCiMES: SP_ClickRelease() error line = " + Cstr(Erl) + ", error = " + Error$
Resume TheEnd
End Function
[Options]
Option Public
Option Declare
Uselsx "*LSXODBC"
Use "AgnesLibrary"
Use "SP.wfLibV2"
[Initialize]
'//點選放行通知時拋轉CiMES
Call SP_ClickRelease()
[SP_ClickRelease]
Function SP_ClickRelease() As Integer
'//當user點選"放行通知"按鍵時,call store procedure to CiMES
'//by store procedure
On Error Goto errorhandler
Dim session As New NotesSession
Dim agent As NotesAgent
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim conn As New ODBCConnection
Dim query As New ODBCQuery
Dim rs As New ODBCResultSet
Dim strSQL As String
Dim i As Integer, DataSourceNm As String
Set agent = session.CurrentAgent
Set db = session.CurrentDatabase
Print "run- " + agent.Name + " Start..." + Now()
'//connection
Conn.SilentMode=True
Set Query.connection = conn
Set rs.Query = Query
DataSourceNm = "runcard_ws"
If Not ODBC_Connect(Conn, DataSourceNm) Then Call Conn.disconnect : Error 997, "Can't Connect to ODBC (" + DataSourceNm + " )!!"
Set doc = db.GetDocumentByID (agent.ParameterDocID )
If Not doc Is Nothing Then
'//傳入三個參數LotNo、Wafer ID、Location ,若回傳空白,則是成功,若錯誤會直接回傳錯誤訊息
For i = 0 To Ubound(doc.WaferID)
strSQL = "Execute procedure ees@ws:wafer_erploc_u (" + "'" + doc.LotNo(0) + "', " '//LotNo
strSQL = strSQL + "'" + doc.WaferID(i) + "', " '//WaferID
strSQL = strSQL + "'" + doc.SRLocation(0) + "') " '//Location
Print strSQL
Query.SQL = strSQL
rs.Execute
Print rs.GetValue(1)
If rs.GetValue(1) <> "" Then
Call doc.ReplaceItemValue("ReleaseTransFlag", "S") '//寫入 comets_ws 失敗
Call doc.ReplaceItemValue("ReleaseTransMsg", rs.GetValue(1))
Print "寫入 comets_ws 失敗"
Messagebox "寫入 comets_ws 失敗", 0, "Warning"
Else
Call doc.ReplaceItemValue("ReleaseTransFlag", "S") '//寫入 comets_ws 成功
Call doc.ReplaceItemValue("ReleaseTransTime", Now())
Print "寫入 comets_ws 成功"
End If
'Call doc.Save(True,True)
Next
End If
Call rs.Close(Db_Close)
Call Conn.Disconnect
Print "run- " + agent.Name + " end..." + Now()
TheEnd:
Call rs.Close(Db_Close)
Call Conn.disconnect
Print "run SP_DataTrans_DB1 end...." + Now()
Exit Function
ErrorHandler:
Print "ag: A4. TransToCiMES: SP_ClickRelease() error line = " + Cstr(Erl) + ", error = " + Error$
Resume TheEnd
End Function
沒有留言:
張貼留言