jwcoleman87
Well-known member
- Joined
- Oct 4, 2014
- Messages
- 124
- Programming Experience
- Beginner
VB.NET:
Public Function GetDispatchInformation(data As String) As Dispatch
Dim NewDispatch As New Dispatch
Dim sb As New StringBuilder
Dim wordDelimiters() As Char = New Char() {vbCrLf}
Dim wordDelimiters1() As Char = New Char() {":"c}
Dim counter As Integer = 1
For Each word As String In data.Split(wordDelimiters, StringSplitOptions.None)
If word.Length < 3 Then
'nothing
Else
If word.Contains("You have been assigned dispatch number") Then
'parse dispatch
ElseIf word.Contains("Service Administrator:") Then
NewDispatch.ServiceAdministrator = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Purchased From:") Then
NewDispatch.Client = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Model:") Then
NewDispatch.Model = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Name:") Then
NewDispatch.Name = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Address") Then
'parse address
ElseIf word.Contains("Home Phone:") Then
NewDispatch.ConsumerHomePhone = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Consumer Email:") Then
NewDispatch.ConsumerEmail = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Problem Description:") Then
NewDispatch.ProblemDescription = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Payment Type:") Then
NewDispatch.PaymentType = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("CRM Number:") Then
NewDispatch.CRMNumber = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Authorization Number:") Then
NewDispatch.AuthorizationNumber = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Authorization Amount:") Then
NewDispatch.AuthorizationAmount = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Date of Purchase:") Then
NewDispatch.DateOfPurchase = DateTime.Parse(word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf))
ElseIf word.Contains("Brand:") Then
NewDispatch.Brand = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Service Site:") Then
NewDispatch.ServiceSite = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Mailing Label Method:") Then
NewDispatch.MailingLabelMethod = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement1:") Then
NewDispatch.Entitlement1 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement2:") Then
NewDispatch.Entitlement2 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement3:") Then
NewDispatch.Entitlement3 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement4:") Then
NewDispatch.Entitlement4 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement5:") Then
NewDispatch.Entitlement5 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement6:") Then
NewDispatch.Entitlement6 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
ElseIf word.Contains("Entitlement7:") Then
NewDispatch.Entitlement7 = word.Split(wordDelimiters1, StringSplitOptions.None)(1).Trim.Trim(vbCrLf)
End If
counter = counter + 1
End If
Next
Return NewDispatch
End Function
The emails look like this:
VB.NET:
You have been assigned dispatch number # which has been automatically accepted.
To review and view entitlements this dispatch, log on at #, open the Dispatch Inbox from
the Quick Links shown on the Main Menu, select 'Accepted' from the dropdown
and click on the Search button. This will bring up the list of accepted Dispatches.
Service Administrator: NEW WarLoc
Purchased From: WAL-MART.COM
Model: E E1-571-6607
Serial Number: NXM09AA03032918BBD3400
Name: #
Address: #
Home Phone: #
Consumer Email: #
Problem Description: SCREEN IS CRACKED
Special Instructions: Cracked Screen
Payment Type: Service Contract
CRM Number: #
Authorization Number: #
Authorization Amount: 504.00
Date of Purchase: 08-NOV-2013
Brand: ACER001
Service Site: Depot
Mailing Label Method: MailContract Covers:
Entitlement1: EXCLUSION - FAILURES NOT COVERED UNDER PLAN - COMMERCIAL USE OF PRODUCT PRODUCTS USED IN A BUSINESS ENVIRONMENT OR PRODUCTS SPECIFICALLY DESIGNED FOR NON-RESIDENTIAL USE.
Entitlement2: COVERED FAILURE - DAMAGE CAUSED BY POWER SURGE COVERED FROM DATE OF PURCHASE PRIMARY COVERAGE BEGINS DATE OF PURCHASE
Entitlement3: COVERED FAILURE - ACCIDENTAL DAMAGE FROM SPILLS AND DROPS IS COVERED FROM DOP LAPTOPS ONLY COVER ACCIDENTAL DAMAGE, SUCH AS SPILLS, DROPS FROM DOP
Entitlement4: DOP ENDORSEMENT ADH-LAPTOPS
Entitlement5: PARTS UNDER NEW
Entitlement6: LABOR UNDER NEW
Entitlement7: EXCEPTIONAL PARTS UNDER NA
Entitlement8: EXCEPTIONAL LABOR UNDER NA
Out for Repair Number: NULL
Follow this link to view the dispatch: #
Is there a better way to do this?
Open for discussion/comments/advice.
Thanks,
Jonathan Coleman