Hi,
Anyone had experience opening an Accpac session from a Windows service. I created a windows service that monitors a folder for new CSV files. The service will read the file and prints either an Order Confirmation, Quote, Picking slip or Invoice depending on the document type indicated for that order in the CSV file. I have installed the windows service and works perfectly fine but I could not create a session connecting to Accpac (Session could not be opened - at AccpacCOMAPI.IAccpacSession.Open(String UserIdentifier, String Password, String DataBase, DateTime SessionDate, Int32 Flags, String Reserved). I have set the Account property of the ServiceProcessInstaller to LocalService. What might be the problem?
Anyone had experience opening an Accpac session from a Windows service. I created a windows service that monitors a folder for new CSV files. The service will read the file and prints either an Order Confirmation, Quote, Picking slip or Invoice depending on the document type indicated for that order in the CSV file. I have installed the windows service and works perfectly fine but I could not create a session connecting to Accpac (Session could not be opened - at AccpacCOMAPI.IAccpacSession.Open(String UserIdentifier, String Password, String DataBase, DateTime SessionDate, Int32 Flags, String Reserved). I have set the Account property of the ServiceProcessInstaller to LocalService. What might be the problem?
Code:
Public Function ConnectToSession() As Boolean 'taking parameters here
Dim booRetVal As Boolean = False
Try
mSession = New AccpacCOMAPI.AccpacSession
'Opens AS Control view
mSession.Init("", "OE", "OE0520", My.Settings.AccpacVersion)
'mSession.Open(clsUtil.Decrypt(My.Settings.AccpacUser), clsUtil.Decrypt(My.Settings.AccpacPassword), My.Settings.AccpacCompany, System.DateTime.Now, 0, "")
mSession.Open("ADMIN", "ADMIN", My.Settings.AccpacCompany, System.DateTime.Now, 0, "")
If mSession.IsOpened Then
CompanyName = My.Settings.AccpacCompany
'LogMessage("Connected to company: " & mSession.CompanyName, False, EventLogEntryType.Information)
booRetVal = True
Else
CompanyName = ""
booRetVal = False
'LogMessage("Failed to connect to " & AccpacCompanyID, False, EventLogEntryType.Information)
End If
Catch ex As Exception
clsUtil.ErrorHandler(AccpacErrorHandler(mSession), "ConnectToSession", True)
End Try
Return booRetVal
End Function