Как мне обновить свою логику в VB.NET код?
Я хотел бы обновить логику операторов if, чтобы она срабатывала только тогда, когда все условия DOMNC в изменяемом предложении имеют ту же дату окончания, что и дата окончания измененного предложения DOMNC.
Я все еще хочу сохранить чек, чтобы убедиться, что измененное предложение DOMNC end date меньше или равно сегодняшнему дню
Я также не хочу пропускать, если изменяемое предложение (то есть детское предложение) не имеет никаких условий DOMNC.
Может кто-нибудь помочь?
Я забыл добавить xml-документ. Вот он. Обратите внимание, что DOMNC находится в этом 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>
Вот моя логика селектора (операторы if) в vb.net
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
Что я уже пробовал:
'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