<% '======================================================================================================================= ' Settings Model '======================================================================================================================= Class SnailWorksExportModel_Class Public Header Public DetailRecords End Class Class SnailWorksExportHeaderModel_Class Public Class_Get_Properties Public RecordType Public Version Public UserId Public ClientName Public ParentClientName Public JobName Public JobDescription Public SplitName Public SplitDescription Public PieceType Public MailDate Public UploadType Public TrackedQuanity Public PiecesMailed Public TargetInHomeDateStart Public TargetInHomeDateEnd Public ConfirmationEmail Public JobId Public SplitId Public TypeOfTracking Public ReturnedPostalRoutingCode Public ReportId1 Public Report1Email Public ReportId2 Public Report2Email Public INFOONLY Private Sub Class_Initialize 'ValidateExitsts Me, "","" Class_Get_Properties = Array("RecordType","Version","UserId","ClientName","ParentClientName","JobName" _ ,"JobDescription","SplitName","SplitDescription","PieceType","MailDate","UploadType" _ ,"TrackedQuanity","PiecesMailed","TargetInHomeDateStart","TargetInHomeDateEnd","ConfirmationEmail","JobId" _ ,"SplitId","TypeOfTracking","ReturnedPostalRoutingCode","ReportId1","Report1Email","ReportId2","Report2Email","INFOONLY") End Sub End CLass Class SnailWorksExportDetailModel_Class Public Class_Get_Properties Public RecordType Public CustomerUniqueIdentifier Public IMB Public Greeting Public FirstName Public MI Public LastName Public Suffix Public FullName Public Company Public Title Public Address1 Public Address2 Public City Public State Public Zip Public UserDefined1 Public UserDefined2 Public UserDefined3 Public UserDefinedIdentifier4 Public UserDefinedIdentifier5 Public SeedIndicator Public InductionPoint Public InductionDate Public InBoundIMB Public IMCB Public IMTB Private Sub Class_Initialize 'ValidateExitsts Me, "","" Class_Get_Properties = Array("RecordType","CustomerUniqueIdentifier","IMB","Greeting","FirstName" _ ,"MI","LastName","Suffix","FullName","Company","Title","Address1","Address2","City","State","Zip" _ ,"UserDefined1","UserDefined2","UserDefined3","UserDefinedIdentifier4","UserDefinedIdentifier5" _ ,"SeedIndicator","InductionPoint","InductionDate","InBoundIMB","IMCB","IMTB") End Sub End Class '======================================================================================================================= ' SnailWorks Repository '======================================================================================================================= Class SnailWorksRepository_Class Public Function GetSnailWorksExportById(id) dim SnailWorksExport:set SnailWorksExport = new SnailWorksExportModel_Class set SnailWorksExport.Header = GetSnailWorksHeaderByKitId(id) set SnailWorksExport.DetailRecords = FindSnailWorksDetailRecordsByKitId(id) set GetSnailWorksExportById = SnailWorksExport End Function Private Function GetSnailWorksHeaderByKitId(id) Dim Header:Set Header = New SnailWorksExportHeaderModel_Class dim sql : sql = "SELECT ""H"" as RecordType,""5.1"" as Version, ""KCI2024Type2FTPUser"" as UserId,[Jcode] as ClientName,"""" as ParentClientName," &_ """Tracking Kit - "" & [JobNumber] as JobName,"""" as JobDescription,"""" as SplitName,"""" as SplitDescription,""L"" as PieceType," &_ "Year(Now()) & ""/"" & RIGHT(""0"" & Month(Now()),2) & ""/"" & RIGHT(""0"" & Day(Now()),2) as MailDate,""N"" as UploadType,"""" as TrackedQuanity," &_ """"" as PiecesMailed,"""" as TargetInHomeDateStart,"""" as TargetInHomeDateEnd,"""" as ConfirmationEmail,"""" as JobId," &_ """"" as SplitId,""R"" as TypeofTracking,"""" as ReturnedPostalRoutingCode,"""" as ReportId1," &_ """"" as Report1Email,"""" as ReportId2,"""" as Report2Email,"""" as INFOONLY From Kit WHERE ID =?;" dim rs : set rs = DAL.Query(sql,id) If rs.EOF then Err.Raise 1, "GetSnailWorksHeaderByKitId", "SnailWorksHeaderByKitId was not found with Id of: " & id Else Set GetSnailWorksHeaderByKitId = Automapper.AutoMap(rs,"SnailWorksExportHeaderModel_Class") Destroy rs End If End Function Private Function FindSnailWorksDetailRecordsByKitId(id) dim sql : sql = "SELECT ""D"" as RecordType, OutboundSerial as CustomerUniqueIdentifier, OutboundIMBDigits as IMB, """" as Greeting , """" as FirstName," &_ """"" as MI, """" as LastName,"""" as Suffix,"""" as FullName,"""" as Address1,"""" as Address2,"""" as City,"""" as State," &_ """"" as Zip,Jcode as UserDefined1,"""" as UserDefined2,"""" as UserDefined3,"""" as UserDefinedIdentifier4,"""" as UserDefinedIdentifier5,"""" as SeedIndicator," &_ """"" as InductionPoint,"""" as InductionDate,InBoundIMBDigits as InboundIMB,"""" as IMCB,"""" as IMTB " &_ "FROM (InkjetRecords RIGHT JOIN [KitLabels] ON InkjetRecords.KitLabelID = KitLabels.ID) INNER JOIN Kit On Kit.ID = KitLabels.KitID WHERE KitLabels.KitID = ?" dim rs : set rs = DAL.Query(sql,id) If rs.EOF then Err.Raise 1,"FindSnailWorksDetailRecordsByKitId","FindSnailWorksDetailRecordsByKitId was not ound with Id of: " & id Else set FindSnailWorksDetailRecordsByKitId = SnailWorksDetailRecordList(rs) Destroy rs End If End Function Private Function SnailWorksDetailRecordList(rs) dim list : set list = new LinkedList_Class dim model Do until rs.EOF set model = new SnailWorksExportDetailModel_Class list.Push Automapper.AutoMap(rs, model) rs.MoveNext Loop set SnailWorksDetailRecordList = list End Function End Class dim SnailWorksRepository__Singleton Function SnailWorksRepository() If IsEmpty(SnailWorksRepository__Singleton) then set SnailWorksRepository__Singleton = new SnailWorksRepository_Class End If set SnailWorksRepository = SnailWorksRepository__Singleton End Function %>