I am having a problem getting this to work correctly. I tried it with a straight INSERT statement and a Stored Proc also with the same bad results.
On the example below, the Version number is ending up in the ErrorMsg field in the database. The Log Level ends up in the UserName. Any idea why is this happening? The commandtext statement is correct.
<target xsi:type="Database"
name="dberrorlog"
connectionStringName="Logger"
keepConnection="true"
useTransactions="true" >
<commandText>
INSERT INTO [Logs].[LogError]
([ProgName], [CreatedDate], [CompName], [LogLevel], [UserName], [ErrorMsg], [Version], [SourceMethod], [StackTrace])
VALUES
(#ProgName, #CreatedDate, #CompName, #LogLevel, #UserName, #ErrorMsg, #Version, #SourceMethod, #StackTrace)
</commandText>
<parameter name="#ProgName" layout="MyProgram"/>
<parameter name="#CreatedDate" layout="${date:format=MM\-dd\-yyyy HH\:mm\:ss}"/>
<parameter name="#CompName" layout="${machinename}"/>
<parameter name="#LogLevel" layout="${level}"/>
<parameter name="#UserName" layout="${aspnet-user-identity}"/>
<parameter name="#ErrorMsg" layout="${exception:format=ToString}"/>
<parameter name="#Version" layout="1.0.0.0"/>
<parameter name="#SourceMethod" layout="${callsite}"/>
<parameter name="#StackTrace" layout="${stacktrace:format=Raw}"/>
</target>
Any Help is greatly appreciated.
Related
I am trying to parse the below XML to get the following data. There are multiple rules following, I have shared only one rule below. Is it possible to parse the XML for these values?
name from section header, rule id value, applied-to name, source names, source values, destination name, destination value.
<?xml version="1.0" encoding="UTF-8"?>
<filteredfirewallConfiguration timestamp="1621338984151">
<contextId>globalroot</contextId>
<layer3Sections>
<section id="asdfsdf" name="production" generationNumber="132" timestamp="1621930404081" managedBy="universalroot-0" tcpStrict="false" stateless="false" useSid="false" type="LAYER3">
<rule id="1213213" disabled="false" logged="true" managedBy="universalroot-0">
<name>From Conversion Server</name>
<action>allow</action>
<appliedToList>
<appliedTo>
<name>re-int-dx</name>
<value>universalwire</value>
<type>VirtualWire</type>
<isValid>true</isValid>
</appliedTo>
<appliedTo>
<name>re-ext-ap</name>
<value>universalwire</value>
<type>VirtualWire</type>
<isValid>true</isValid>
</appliedTo>
</appliedToList>
<sectionId>sfsdfafee</sectionId>
<sources excluded="false">
<source>
<name>sdfsdf101</name>
<value>ipset-werfwefdc</value>
<type>IPSet</type>
<isValid>true</isValid>
</source>
<source>
<name>sdfsfdf102</name>
<value>ipset-4wsetgfreds</value>
<type>IPSet</type>
<isValid>true</isValid>
</source>
</sources>
<destinations excluded="false">
<destination>
<name>production-database-cluster</name>
<value>sg</value>
<type>SecurityGroup</type>
<isValid>true</isValid>
</destination>
<destination>
<name>newname</name>
<value></value>
<type>IPSet</type>
<isValid>true</isValid>
</destination>
</destinations>
<services>
<service>
<name>servicenwe</name>
<value>application-dgfsdfg</value>
<type>Application</type>
<isValid>true</isValid>
</service>
</services>
<direction>inout</direction>
<packetType>any</packetType>
</rule>
sofar, I have been able to get the section header only.
import requests
import xml.etree.ElementTree as ET
tree = ET.parse("out.xml")
root = tree.getroot()
for child in root.find('./layer3Sections'):
print(child.tag, child.attrib)
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0">
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true">
my file has many line begining with word "add name".
I want to check if these lines have a string "managedRuntimeVersion".
if not exists, then i need to add managedRuntimeVersion="v2.0" to
that line.
Expected Result as below
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0">
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true" managedRuntimeVersion="v2.0">
I have tried with the below script.. but in the result.. it is given only the lines having "add name"
$sfile="C:\Users\subash.s\Desktop\backup\pool.xml"
(((gc "$sfile") | Select-String -Pattern "add name" |
select-string -notmatch "managedRuntimeVersion") -replace '>',' managedRuntimeVersion="v2.0">') |
Set-Content "$sfile"
with the above script. i got below result..
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0">
<add name="GetServiceDet" autoStart="true" managedRuntimeVersion="v2.0">
For Pete's sake, the configuration file is XML, not a text file! Edit it as an XML document, and you will save a lot of headaches.
There are a few ways to add attributes into such a document. As the XML in the question is a fragment - and of illegal syntax, the sample code uses a bit modified version of the same. Select all add nodes that don't have got managedRuntimeVersion attribute, create one and add attribute with values to the nodes. Like so,
# Dummy data for testing
[xml]$x = #'
<root>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet2" autoStart="true"/>
</APPPOOL>
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0" />
</APPPOOL>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true"/>
</APPPOOL>
</root>
'#
# Select all add elements that don't have managedRuntimeVersion attribute
$nl=$x.SelectNodes('/root/APPPOOL/add[not(#managedRuntimeVersion)]')
# Add attributes to the elements
foreach($n in $nl) {
# Create new attribute and assign a value
$a = $x.CreateAttribute('managedRuntimeVersion')
$a.Value = 'v2.0'
[void]$n.Attributes.Append($a)
}
# Print modified version to console
$x.save([console]::out)
# Output
<?xml version="1.0" encoding="ibm850"?>
<root>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet2" autoStart="true" />
</APPPOOL>
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0" />
</APPPOOL>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true" managedRuntimeVersion="v2.0" />
</APPPOOL>
</root>
Reading the actual file and saving changes to disk are left as an exercise to the reader.
I am using <updating-outbound-gateway> to insert the record using nativeQuery.
How can I pass List so that multiple records can be inserted in DB?
<int-jpa:updating-outbound-gateway native-query="insert into PARTNER_RESPONSE_DETAILS(PARTNER_ID,BANK_REFERENCE_NUMBER,REQUEST_STRING,RESPONSE_STRING,RESPONSE_DATE) values (:partnerId,:bankReferenceNumber,:requestString,:responseString,:responseDate)"
entity-manager="entityManager">
<int-jpa:transactional />
<int-jpa:parameter name="partnerId" expression="payload['partnerId']" />
<int-jpa:parameter name="bankReferenceNumber" expression="payload['bankReferenceNumber']" />
<int-jpa:parameter name="requestString" expression="payload['requestString']" />
<int-jpa:parameter name="responseString" expression="payload['responseString']" />
<int-jpa:parameter name="transactionStatus" expression="payload['transactionStatus']" />
<int-jpa:parameter name="responseDate" expression="payload['responseDate']" />
</int-jpa:updating-outbound-gateway>
Since it isn't possible with JPA Native Query to perform bulk update, the <int-jpa:updating-outbound-gateway> doesn't provide that functionality.
It is possible with the regular EntityManager.persist() though.
You task you can fix with the <splitter> in front of that <int-jpa:updating-outbound-gateway>. If you do that in the single thread, there won't be performed DB call until the TX commit after all the records.
I was wondering if anyone had succeeded in opening a password protected XL spreadsheet with UiPath.
I tried using "Open Workbook" and entering the password in password field ... but that didn't work.
I tried using Open Application ... but I can't seem to talk to the password dialogue box.
Really flumoxed !
Update the Excel Activities. Use the new Excel Application Scope. Set the password property.
Try saving this password-protected Excel dummy data file (https://cdn-business2.discourse.org/uploads/uipath/original/2X/2/25c38fb93744b863e5db1e50f757a6cdf8b77128.xlsx) and run it against this code below (save as XAML, the UiPath file).
Hope that helps.
<Activity mc:Ignorable="sap sap2010 sads" x:Class="excel_password" mva:VisualBasic.Settings="{x:Null}" sap2010:WorkflowViewState.IdRef="excel_password_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
xmlns:ui="http://schemas.uipath.com/workflow/activities"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System.Activities</x:String>
<x:String>System.Activities.Statements</x:String>
<x:String>System.Activities.Expressions</x:String>
<x:String>System.Activities.Validation</x:String>
<x:String>System.Activities.XamlIntegration</x:String>
<x:String>Microsoft.VisualBasic</x:String>
<x:String>Microsoft.VisualBasic.Activities</x:String>
<x:String>System</x:String>
<x:String>System.Collections</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Diagnostics</x:String>
<x:String>System.Drawing</x:String>
<x:String>System.IO</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Net.Mail</x:String>
<x:String>System.Xml</x:String>
<x:String>System.Xml.Linq</x:String>
<x:String>UiPath.Core</x:String>
<x:String>UiPath.Core.Activities</x:String>
<x:String>System.Windows.Markup</x:String>
<x:String>System.Xml.Serialization</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Drawing</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>UiPath.Core</AssemblyReference>
<AssemblyReference>UiPath.Core.Activities</AssemblyReference>
<AssemblyReference>PresentationFramework</AssemblyReference>
<AssemblyReference>WindowsBase</AssemblyReference>
<AssemblyReference>PresentationCore</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Sequence DisplayName="excel_password" sap2010:WorkflowViewState.IdRef="Sequence_2">
<Sequence.Variables>
<Variable x:TypeArguments="sd:DataTable" Name="dt" />
<Variable x:TypeArguments="x:String" Name="dt_op" />
</Sequence.Variables>
<ui:ReadRange AddHeaders="True" DataTable="[dt]" DisplayName="Read range" sap2010:WorkflowViewState.IdRef="ReadRange_1" Password="uipath" SheetName="Sheet1" WorkbookPath="dummy.xlsx">
<ui:ReadRange.Range>
<InArgument x:TypeArguments="x:String">
<Literal x:TypeArguments="x:String" Value="" />
</InArgument>
</ui:ReadRange.Range>
</ui:ReadRange>
<ui:OutputDataTable DataTable="[dt]" DisplayName="Output data table" sap2010:WorkflowViewState.IdRef="OutputDataTable_1" Text="[dt_op]" />
<WriteLine DisplayName="Write line" sap2010:WorkflowViewState.IdRef="WriteLine_1" Text="[dt_op]" />
<ui:MessageBox Caption="{x:Null}" ChosenButton="{x:Null}" Buttons="Ok" DisplayName="Message box" sap2010:WorkflowViewState.IdRef="MessageBox_1" Text="[dt_op]" TopMost="True" />
<sads:DebugSymbol.Symbol>dyxDOlxVc2Vyc1xtbWlhb1xEb3dubG9hZHNcZXhjZWxfcGFzc3dvcmQueGFtbA47A0sOAgEBQAVGFAIBDUcFR48BAgEISAVIaAIBBUkFSbUBAgECQC9ANQIBEkMLQzoCARFAhgFAjgECARBAmQFAoQECAQ9ArwFAuwECAQ5HgwFHjAECAQtHI0cpAgEJSFxIZQIBBkmaAUmjAQIBAw==</sads:DebugSymbol.Symbol>
</Sequence>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="ReadRange_1" sap:VirtualizedContainerService.HintSize="314,87" />
<sap2010:ViewStateData Id="OutputDataTable_1" sap:VirtualizedContainerService.HintSize="314,22" />
<sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="314,61" />
<sap2010:ViewStateData Id="MessageBox_1" sap:VirtualizedContainerService.HintSize="314,59" />
<sap2010:ViewStateData Id="Sequence_2" sap:VirtualizedContainerService.HintSize="336,473">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="excel_password_1" sap:VirtualizedContainerService.HintSize="376,553" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
Use Excel application scope and read the excel through that.
when you use excel application on your right hand side,under file you have a field called Password.
Enter the password which would make the excel sheet open.
This should work
i would need a help on how to parse xml files with nested tags taking the user input as attribute value of a particular tag.
for eg:
if xml code has 12 mappings and we want to select the below mapping name "m_IF1_TD_SALESORDER_STG_PR4_VBPA_BUSINESS_PARTNER" as user input and thereby printing the particular mapping details.
<MAPPING NAME="m_IF1_TD_SALESORDER_STG_PR4_VBPA_BUSINESS_PARTNER" DESCRIPTION="Data Mapping for loading Sales Order Business Partners from the staging database for PR4." OBJECTVERSION="1" ISVALID="YES" VERSIONNUMBER="1">
<TRANSFORMATION NAME="sq_STG_PR4_VBPA" DESCRIPTION="" TYPE="Source Qualifier" OBJECTVERSION="1" REUSABLE="NO" VERSIONNUMBER="1">
<TRANSFORMFIELD NAME="MANDT" DESCRIPTION="" DATATYPE="string" PORTTYPE="INPUT/OUTPUT" PRECISION="3" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="MANDT" EXPRESSIONTYPE="GENERAL"/>
<TRANSFORMFIELD NAME="VBELN" DESCRIPTION="" DATATYPE="string" PORTTYPE="INPUT/OUTPUT" PRECISION="10" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="VBELN" EXPRESSIONTYPE="GENERAL"/>
<TRANSFORMFIELD NAME="POSNR" DESCRIPTION="" DATATYPE="decimal" PORTTYPE="INPUT/OUTPUT" PRECISION="6" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="POSNR" EXPRESSIONTYPE="GENERAL"/>
<TRANSFORMFIELD NAME="PARVW" DESCRIPTION="" DATATYPE="string" PORTTYPE="INPUT/OUTPUT" PRECISION="2" SCALE="0" PICTURETEXT="" DEFAULTVALUE="" EXPRESSION="PARVW" EXPRESSIONTYPE="GENERAL"/>
I would suggest using the XML ElementTree module of python.
It is very simple to use. For example:
import xml.etree.ElementTree as ET
tree = ET.parse('/filename.xml')
root = tree.getroot()
for subchild in root.findall('subchildName'):
print(subchild.get('subchildAttribute')