Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 4 and Visual Studio 2010 > .NET 4 and Visual Studio 2010 General Discussions
|
.NET 4 and Visual Studio 2010 General Discussions For discussing anything about .NET 4, WPF, WCF, the rest of the .NET 4 Framework, and Visual Studio 2010 that isn't about a specific Wrox book. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET 4 and Visual Studio 2010 General Discussions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2014, 03:51 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default Do do I change my code to throw exception when NCIC Number exist?

Can someone help me with this please.
Here is what I am trying to do but I am not sure how to go about it. I think I need to use a For Each loop.
My code in the section with the comment 'Process other identification this is where I want to add For Each to loop and get NCIC number nc:IdentificationID and ProtectionOrderOtherIdentificationTypeCode (NCICNUM).
I would like to loop through and check if that number currently exists (e.g 2222), and if it doesn't, add it.

The following line of code is adding it but it is not checking to see if the number exist first
Code:
 objProtectionOrder.AddCrossReferenceNumber(objXmlCrossReferenceNode.SelectSingleNode("nc:IdentificationID", objXMLNameSpaceManager).InnerText, objXmlCrossReferenceNode.SelectSingleNode("ext:ProtectionOrderOtherIdentificationTypeCode", objXMLNameSpaceManager).InnerText)
When For Each loop reaches the end and no NCIC numbers (nc:IdentificationID) matched, add it using the line of code above.

If For Each loop finds a match, exit loop and give exception message.

I would like the error(exception) text should say something like this:
Protection Order[PO number goes here] already has NCIC number[NCIC number from MNCIS].

Example of exception message:

Protection Order 1400456 already has NCIC number 87654321 associated with it.

Visual Studio 2010 Code

Code:
Protected Overrides Sub ProcessMessage(ByRef aobjBroker As MessageBroker.Library.v4.Broker, ByRef aobjXmlInputDoc As System.Xml.XmlDocument, ByRef aobjInstantiatedObjectsCollection As Microsoft.VisualBasic.Collection)
            MyBase.ProcessMessage(aobjBroker, aobjXmlInputDoc, aobjInstantiatedObjectsCollection)

            Dim strCaseNumber As String
            Dim strProtectionOrderNumber As String
            Dim objNameTable As NameTable
            Dim objXMLNameSpaceManager As XmlNamespaceManager
            Dim objXmlServiceNode As XmlNode
            Dim objProtectionOrder As Msc.Integration.Mncis.Library.v4.ProtectionOrder
            Dim objXmlCrossReferenceNode As XmlNode
            'create a namespace manager used for queries into inputmessage (because of namespace)
            objNameTable = New NameTable
            objXMLNameSpaceManager = New XmlNamespaceManager(objNameTable)
            objXMLNameSpaceManager.AddNamespace("ext", "http://www.courts.state.mn.us/ProtectionOrderExtension/1.0")
            objXMLNameSpaceManager.AddNamespace("nc", "http://niem.gov/niem/niem-core/2.0")


            strCaseNumber = aobjXmlInputDoc.DocumentElement.SelectSingleNode("ext:CourtFileNumber", objXMLNameSpaceManager).InnerText
            strProtectionOrderNumber = aobjXmlInputDoc.DocumentElement.SelectSingleNode("ext:ProtectionOrderID", objXMLNameSpaceManager).InnerText
            objProtectionOrder = Msc.Integration.Mncis.Library.v4.ProtectionOrder.Get(strCaseNumber, CInt(strProtectionOrderNumber), False)


'Process service 

For Each objXmlServiceNode In aobjXmlInputDoc.DocumentElement.SelectNodes("ext:ProtectionOrderService", objXMLNameSpaceManager)

Next

'Process other identification
objXmlCrossReferenceNode = aobjXmlInputDoc.DocumentElement.SelectSingleNode("ext:ProtectionOrderOtherIdentification", objXMLNameSpaceManager)
If Not objXmlCrossReferenceNode Is Nothing Then
                objProtectionOrder.AddCrossReferenceNumber(objXmlCrossReferenceNode.SelectSingleNode("ext:ProtectionOrderOtherIdentificationTypeCode", objXMLNameSpaceManager).InnerText, objXmlCrossReferenceNode.SelectSingleNode("nc:IdentificationID", objXMLNameSpaceManager).InnerText)
End If

'Save updates
            Msc.Integration.Mncis.Library.v4.Odyssey.SaveUpdates(CType(objProtectionOrder, Msc.Integration.Mncis.Library.v4.IApiObject))


End Sub

Last edited by winkimjr2; August 26th, 2014 at 03:06 PM.. Reason: Correcting a typo





Similar Threads
Thread Thread Starter Forum Replies Last Post
PTOpersonalization database does not exist in the book code MattHoff BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 0 August 18th, 2010 08:16 AM
how to change number to text charectore? Rohullah BOOK: Beginning Microsoft SQL Server 2008 Programming ISBN: 978-0-470-25701-2 0 June 16th, 2010 04:41 AM
throw an exception in catch Muyavil Java Basics 3 April 11th, 2009 10:56 PM
help me to change number format? haarishr Pro VB 6 4 June 20th, 2008 06:30 AM
Change number of significant digits displayed gurbani XSLT 1 June 25th, 2004 11:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.