Click here to Skip to main content
15,924,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to update if statements logic to only trigger when all of the DOMNC conditions on the sentence being amended have the same end date as the amended sentence DOMNC end date.
I still want to keep the check to ensure the amended sentence DOMNC end date is less than or equal to today
I also do not want to skip if the sentence being amended (i.e child sentence) does not have any DOMNC conditions.
Can someone help?

I forgot to add xml document. Here it is. Please note the DOMNC is in this xml document.
XML
<Integration>
	<Case>
		<BaseCaseType>Adult</BaseCaseType>
		<SentenceEvent ID="208093958" Date="05/03/2018" InternalSentenceEventID="1815027597">
			<SentenceAmendmentReason Word="CTORDER">Court Order</SentenceAmendmentReason>
			<SentenceAmendmentReason Word="MOD">Modification</SentenceAmendmentReason>
			<Sentence ID="9703621" InternalSentenceID="1619846047">
				<Additional>
					<ConditionComponent InternalComponentInstanceID="1632369294">
						<Condition>
							<Type Word="DOMNC">Domestic No Contact (DANCO)</Type>
							<EffectiveDate>05/01/2018</EffectiveDate>
							<EndDate>05/02/2018</EndDate>
						</Condition>
					</ConditionComponent>
					<ConditionComponent InternalComponentInstanceID="1632369295">
						<Condition>
							<Type Word="DOMNC">Domestic No Contact (DANCO)</Type>
							<EffectiveDate>05/01/2018</EffectiveDate>
							<EndDate>05/02/2018</EndDate>
						</Condition>
					</ConditionComponent>
				</Additional>
			</Sentence>
			<SentenceEvent ID="208093956" Date="05/03/2018" InternalSentenceEventID="1815027595">
				<Sentence ID="9703620" InternalSentenceID="1619846046">
					<Additional>
						<ConditionComponent InternalComponentInstanceID="1632369292">
							<Condition>
								<Type Word="DOMNC">Domestic No Contact (DANCO)</Type>
								<EffectiveDate>05/01/2018</EffectiveDate>
								<EndDate>05/02/2018</EndDate>
							</Condition>
						</ConditionComponent>
					</Additional>
				</Sentence>
			</SentenceEvent>
		</SentenceEvent>
	</Case>
</Integration>


Here is my selector logic (if statements) in vb.net
VB
 Dim strEndDate As String = ""
 Dim objXMLConditionEventNode As XmlNode

objXMLConditionEventNode = aobjXMLInputDoc.DocumentElement.SelectSingleNode("Case//SentenceEvent")
  strEndDate = objXMLConditionEventNode.SelectSingleNode("Sentence/Additional/ConditionComponent/Condition[Type/@Word='DOMNC']/EndDate").InnerText


strEndDate = objXMLConditionEventNode.SelectSingleNode("Sentence/Additional/JuvenileConditionComponent/Condition[Type/@Word='DOMNC']/EndDate").InnerText

'SKIP - Amended sentence where the DOMNC end date is less than or equal to today, and
'the sentence being amended has a DOMNC condition with the same end date
If (Not objXMLConditionEventNode.SelectSingleNode("SentenceAmendmentReason") Is Nothing) AndAlso _
 (strEndDate.Length > 0) AndAlso ((CDate(strEndDate) <= Now())) AndAlso (blnIBDOMNCSCEventOnCase = True) Then
'Check if the DOMNC end date of the prior child sentence is the same as the value in strEndDate;
'If it is, skip this message (Note: The XPATH for adult and juvenile cases is different)
If aobjXMLInputDoc.DocumentElement.SelectSingleNode("//Integration/Case/BaseCaseType").InnerText = "Adult" Then
objXMLChildSentenceDOMNCEndDate = objXMLConditionEventNode.SelectSingleNode("SentenceEvent/Sentence/Additional/ConditionComponent/Condition[Type/@Word='DOMNC']/EndDate")
Else
objXMLChildSentenceDOMNCEndDate = objXMLConditionEventNode.SelectSingleNode("SentenceEvent/Sentence/Additional/JuvenileConditionComponent/Condition[Type/@Word='DOMNC']/EndDate")
End If
If (Not objXMLChildSentenceDOMNCEndDate Is Nothing) AndAlso (objXMLChildSentenceDOMNCEndDate.InnerText = strEndDate) Then
'Post an informational message to the message warehouse
aobjBroker.PostMessageWarehouseInformationalMessage("Message skipped - DOMNC condition on amended sentence has the same expired", 1)
aobjBroker.PostMessageWarehouseInformationalMessage("end date as the DOMNC condition on the prior sentence.", 1)
aobjBroker.PostMessageWarehouseInformationalMessage("Note: Any existing edit failures have NOT been cleared.", 1)
Return False
End If
End If


What I have tried:

VB
'SKIP - Amended sentence where the DOMNC end date is less than or equal to today, and
            'the sentence being amended has a DOMNC condition with the same end date
If (Not objXMLConditionEventNode.SelectSingleNode("SentenceAmendmentReason") Is Nothing) AndAlso _
 (strEndDate.Length > 0) AndAlso ((CDate(strEndDate) <= Now())) AndAlso (blnIBDOMNCSCEventOnCase = True) Then
'Check if the DOMNC end date of the prior child sentence is the same as the value in strEndDate;
'If it is, skip this message (Note: The XPATH for adult and juvenile cases is different)
If aobjXMLInputDoc.DocumentElement.SelectSingleNode("//Integration/Case/BaseCaseType").InnerText = "Adult" Then
objXMLChildSentenceDOMNCEndDate = objXMLConditionEventNode.SelectSingleNode("SentenceEvent/Sentence/Additional/ConditionComponent/Condition[Type/@Word='DOMNC']/EndDate")
Else
objXMLChildSentenceDOMNCEndDate = objXMLConditionEventNode.SelectSingleNode("SentenceEvent/Sentence/Additional/JuvenileConditionComponent/Condition[Type/@Word='DOMNC']/EndDate")
End If
If (Not objXMLChildSentenceDOMNCEndDate Is Nothing) AndAlso (objXMLChildSentenceDOMNCEndDate.InnerText = strEndDate) Then
'Post an informational message to the message warehouse
aobjBroker.PostMessageWarehouseInformationalMessage("Message skipped - DOMNC condition on amended sentence has the same expired", 1)
aobjBroker.PostMessageWarehouseInformationalMessage("end date as the DOMNC condition on the prior sentence.", 1)
aobjBroker.PostMessageWarehouseInformationalMessage("Note: Any existing edit failures have NOT been cleared.", 1)
Return False
End If
End If
Posted
Updated 7-May-18 7:43am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900