Hello.
I am working on a project where users can automatically create personnel advices on the mainframe through a .NET Web Service.
My current problem is that I am trying to call a function multiple times to write out the advices to different folder, based on the color sent to the function. However, the program only writes the advices out to one folder. Can you help based on the code that I am attaching to the email?
_
Public Function DoAciFunction(ByVal Key As String, ByVal Flag As String, ByVal UserID As String, ByVal ChgType As String, ByVal OrgPH As String, ByVal DocType As String) As String
Dim SendKey As String = " " & Key
Dim Color As String = "Blank"
Dim ColorFile As String = "Goldenrod"
Dim ColorPayroll As String = "Yellow"
Dim ColorBenefits As String = "Green"
Dim z As Integer
Dim PDFColor()
PDFColor(0) = Color
PDFColor(1) = ColorFile
PDFColor(2) = ColorPayroll
Try
For z = 0 To 2
If PDFColor(z).GetValue = 0 Then
Exit For
End If
CreateP17PDF(Flag, UserID, SendKey, PDFColor(z)) ‘This is supposed to happen 3 times!!!!!!
Next z
Dim TestKey As String = Flag & SendKey & OrgPH
Return "0000" & TestKey 'Run without errors.
Catch ex As Exception
DoAciFunction = ex.ToString
Dim TestKey As String = Flag & SendKey & OrgPH
Return "999X" & ex.Message & TestKey 'Run with errors.
End Try
Public Function CreateP17PDF(ByVal FlagCode As String, ByVal User As String, ByVal Key As String, ByVal Color As String) As String
Try
imp = ImpersonationHelper.Impersonate("SCDOT", Me.GetType(), "SCDOT")
For i = 0 To P17.EMP.Length - 1
If Trim(P17.EMP(i)) = "" Then
i = P17.EMP.Length
Else
DocName = "P17" & Mid(Key, 4, 4) & Mid(Key, 2, 2) & Trim(P17.ORG(i)) & Mid(P17.PH(i), 2, 2) & Trim(P17.EMP(i)) & "A" & Trim(P17.LCX(i)) & ".pdf"
Select Case Color
Case "Blank"
FolderPathColor = "Original\"
Case "Goldenrod"
FolderPathColor = "File\"
Case "Yellow"
FolderPathColor = "Payroll\"
Case Else
FolderPathColor = "Original\"
End Select
FolderPath = P17Doc() & "\" & Mid(Key, 4, 4) & Mid(Key, 2, 2) & FolderPathColor ‘This is supposed to print out to three different folders.
If Not System.IO.Directory.Exists(FolderPath) Then
System.IO.Directory.CreateDirectory(FolderPath)
End If
If User = "" Then
DocEmpName = P17.EMP(i) & "ET.pdf"
Else
DocEmpName = P17.EMP(i) & "U" & User & ".pdf"
End If
'DocEmpName = P17.EMP(i) & ".pdf"
EmpFolderPath = P17Doc() & "\" & Mid(Key, 4, 4) & Mid(Key, 2, 2) & FolderPathColor & "\EmployeeIDs\"
If Not System.IO.Directory.Exists(EmpFolderPath) Then
System.IO.Directory.CreateDirectory(EmpFolderPath)
End If
OutputFile = FolderPath & DocName
OutputEmpFile = EmpFolderPath & DocEmpName
Dim x As Integer = 0
Dim P17Page As ceTe.DynamicPDF.Page
Dim P17Document As New MergeDocument
Dim Path As String
P17PageDims = New PageDimensions(PageSize, PageOrientation)
P17PageDims.LeftMargin = LeftMargin
P17PageDims.RightMargin = RightMargin
P17PageDims.TopMargin = TopMargin
P17PageDims.BottomMargin = BottomMargin
Select Case Color ‘These are the different forms that the web service is pulling, based on the color sent.
Case "Blank"
Path = "BlankForms\P-17Blank.pdf"
Case "Goldenrod"
Path = "BlankForms\P-17File.pdf"
Case "Yellow"
Path = "BlankForms\P-17Payroll.pdf"
Case Else
Path = "BlankForms\P-17Blank.pdf"
End Select
P17Page = New Page(P17PageDims)
P17Document.Append(Server.MapPath(Path))
P17Page = P17Document.Pages(x)
'Print P17 details
P17Name = New Label(P17.NAME(i), colName, Row1, Width(cwName), LineSize, Font, FontSize, Left)
P17Page.Elements.Add(P17.Name)
P17Document.Draw(OutputFile)
P17Document.Draw(OutputEmpFile)
End If
Next i
Thanks.
[/u]