Monday, December 02, 2019

How to configure and run UI Path Orchestra to run Robots

1- Go to https://platform.uipath.com/ and login using credentials you will be able to see the below
Screen1
2- Go to management tab and click on the user and check if you are able to see the proper user in the list
Screen2
3- Now create Robot using following steps
Screen3
4- Create New Environment show below
Screen4
5- Then go for Machines and click on the belwo shown option and check the details and copy the Machine key
Screen5
6- Now connect this created machine using UI Path Robot tool and check if you are able to connect the Orchaestra using connect button.
Screen6Screen7Screen8Screen9
7- Now publish your project to orchaestra using UI PAth Studio and click on publish as show below
Screen10Screen11
8- Now Create a process
Screen12
9- Finally run the job from the UI PAth Robot and see it is relected on Jobs screen.
Screen13Screen14
10- After finish it will be declared as Successful.
Screen15

Wednesday, October 09, 2019

1- Lets say we have following XML files along with DTD added in it
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE root [
<!ELEMENT root (element*)>
<!ELEMENT element (name,surname)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT surname (#PCDATA)>
]>
<root>
<element>
<name>Siddhartha</name>
<surname>Dhumale</surname>
</element>
</root>
2- Following is the java class that is used to check if the given xml adhere to valid xsd file or not
package com.siddhu;
import java.io.IOException;
// DOM
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
// SAX
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.InputSource;
public class ValidateXMLUsingDTD {
private ValidateXMLUsingDTD() {}


public static boolean validateWithDTDUsingDOM(String xmlFiles)
throws ParserConfigurationException, IOException
{
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.parse(new InputSource(xmlFiles));
System.out.print("XML files is valid using Dom Parser:"+xmlFiles+"---");
return true;
}
catch (ParserConfigurationException pce) {
throw pce;
}
catch (IOException io) {
throw io;
}
catch (SAXException se){
return false;
}
}

public static boolean validateWithDTDUsingSAX(String xmlFiles)
throws ParserConfigurationException, IOException
{
try {

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.parse(new InputSource( xmlFiles ));
System.out.print("XML files is valid using SAX Parser:"+xmlFiles+"---");
return true;
}
catch (ParserConfigurationException pce) {
throw pce;
}
catch (IOException io) {
throw io;
}
catch (SAXException se){
return false;
}
}

public static void main (String args[]) throws Exception{

System.out.println(ValidateXMLUsingDTD.validateWithDTDUsingDOM("C:\\Latest_JAVA_eclipse_WorkSpace\\TestXMLFilesUsingDTD\\src\\com\\siddhu\\siddhu.xml"));
System.out.println(ValidateXMLUsingDTD.validateWithDTDUsingSAX("C:\\Latest_JAVA_eclipse_WorkSpace\\TestXMLFilesUsingDTD\\src\\com\\siddhu\\siddhu.xml"));

}
}
For valid xml we will get below output
Image3

For in valid xml we will get below output

Image4


Image5

Validate xml using xsd and java

1- Lets say we have following XSD files that is going to validate the xml.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="root" type="rootType">
</xs:element>
<xs:complexType name="rootType">
<xs:sequence>
<xs:element name="addresses" type="addressesType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addressesType">
<xs:sequence>
<xs:element name="address" type="addressType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element type="xs:short" name="flatnumber"/>
<xs:element type="xs:string" name="flatname"/>
<xs:element type="xs:string" name="societyname"/>
<xs:element type="xs:string" name="country"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
2- Lets say we have following two xml first is valid and second is invalid
1-
<?xml version="1.0" encoding="UTF-8"?>
<root>
<addresses>
<address>
<flatnumber>101</flatnumber>
<flatname>flatname1</flatname>
<societyname>society name 1</societyname>
<country>India</country>
</address>
<address>
<flatnumber>102</flatnumber>
<flatname>flatname2</flatname>
<societyname>society name 2</societyname>
<country>UK</country>
</address>
</addresses>
</root>
2-
<?xml version="1.0" encoding="UTF-8"?>
<root>
<addresses>
<address>
<flatnumber>test</flatnumber>
<flatname>flatname1</flatname>
<societyname>society name 1</societyname>
<country>India</country>
</address>
<address>
<flatnumber>102</flatnumber>
<flatname>flatname2</flatname>
<societyname>society name 2</societyname>
<country>UK</country>
</address>
</addresses>
</root>
3- Following is the java class that is used to check if the given xml adhere to valid xsd file or not
package com.test.siddhu;
import org.xml.sax.SAXException;
import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.Objects;
public class XMLValidator {
//For valid
//For non valid
//public static final String XML_FILE = "C:\\Latest_JAVA_eclipse_WorkSpace\\TestXMLFiles\\src\\com\\test\\siddhu\\not_valid_address.xml";
public static final String SCHEMA_FILE = "C:\\Latest_JAVA_eclipse_WorkSpace\\TestXMLFiles\\src\\com\\test\\siddhu\\address.xsd";
public static void main(String[] args) {
XMLValidator XMLValidator = new XMLValidator();S
boolean valid = XMLValidator.validate(XML_FILE, SCHEMA_FILE);
System.out.printf("%s validation = %b.", XML_FILE, valid);
}
private boolean validate(String xmlFile, String schemaFile) {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
Schema schema = schemaFactory.newSchema(new File(schemaFile));
Validator validator = schema.newValidator();
validator.validate(new StreamSource(new File(xmlFile)));
return true;
} catch (SAXException | IOException e) {
e.printStackTrace();
return false;
}
}
private String getResource(String filename) throws FileNotFoundException {
URL resource = getClass().getClassLoader().getResource(filename);
Objects.requireNonNull(resource);
return resource.getFile();
}
}
For valid xml we will get below output
Image1

For in valid xml we will get below output saying flatnumber should be number/integer and not the text like Test

Image2

Monday, September 23, 2019

Calling Ethereum contract using Web3 Provider

For using Web Provider option we need to install Ganecha cli using npm command

npm install -g ganache-cli

once install run this command

ganache-cli

Image1

now choose the web provider as environment in remix IDE as shown below
Image2

and deploy the application and now you can perform operation of deposits and withdraw using same.

Wednesday, September 18, 2019

Accessing Ethereum files using Web Application

I am using Node and NPM and Visual studio as IDE and npm http-server. Make sure to install the same. To manipulate the value of our file on html we are using jQuery.
Consider this is our html file
'<html>
'
'<head>
' <meta charset="UTF-8">
' <title>Siddhu Ethererum Example</title>
'
'</head>
'
'<body>
' <input type="text" id="amount">
'
' <p id="balanceValue"></p>
' <button id="deposite">Deposite</button>
' <button id="withdraw">Withdraw</button>
' <script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.36/dist/web3.min.js"></script>
' <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" crossorigin="anonymous"></script>
' <script>
' var contract;
'
'
' $(document).ready(
' function () {
' web3 = new Web3(web3.currentProvider);
'
' var address = "Myaddress";
' var abi = [{
' "constant": false,
' "inputs": [{
' "name": "amount",
' "type": "int256"
' }],
' "name": "depositeMyBalance",
' "outputs": [],
' "payable": false,
' "stateMutability": "nonpayable",
' "type": "function"
' },
' {
' "constant": false,
' "inputs": [{
' "name": "amount",
' "type": "int256"
' }],
' "name": "withdrawMyBalance",
' "outputs": [],
' "payable": false,
' "stateMutability": "nonpayable",
' "type": "function"
' },
' {
' "inputs": [],
' "payable": false,
' "stateMutability": "nonpayable",
' "type": "constructor"
' },
' {
' "constant": true,
' "inputs": [],
' "name": "getBalanceValue",
' "outputs": [{
' "name": "",
' "type": "int256"
' }],
' "payable": false,
' "stateMutability": "view",
' "type": "function"
' }
' ];
' contract = new web3.eth.Contract(abi, address);
' contract.methods.getBalanceValue().call().then(
' function (bal) {
' console.log("bal"+bal);
' document.getElementById
' $("#balanceValue").html(bal);
' })
' })
' //Deposite
' $('#deposite').click(function()
' {
' var amount = 0;
' amount = parseInt($('#amount').val());
' console.log("amount"+amount);
'
' // web3.eth.getAccounts().then(e => console.log("---------------"+e));
' web3.eth.getAccounts().then(function(accounts)
' {
' var acc = accounts[0];
' console.log("acc"+ acc);
' return contract.methods.depositeMyBalance(amount).send({from: acc});
' }).then (function (tx)
' {
' console.log(tx);
' }).catch(function(tx)
' {
' console.log(tx);
' })
' })
' //Withdraw
' $('#withdraw').click(function()
' {
' var amount = 0;
' amount = parseInt($('#amount').val());
' console.log("amount"+amount);
'
' // web3.eth.getAccounts().then(e => console.log("---------------"+e));
' web3.eth.getAccounts().then(function(accounts)
' {
' var acc = accounts[0];
' console.log("acc"+ acc);
' return contract.methods.withdrawMyBalance(amount).send({from: acc});
' }).then (function (tx)
' {
' console.log(tx);
' }).catch(function(tx)
' {
' console.log(tx);
' })
' })
' </script>
'
'</body>
'
'</html>

This is our SOL files
pragma solidity ^0.4.24;

//Main class that will be used to perform operation on our block.
contract MyBank
{
//This is variable used for storing our balanceValue
int balanceValue;

//build constructor

constructor() public
{
//initialise the variable
balanceValue = 1;
}

//As getBalance is not manupulating the value it is used to show the data on the screen and use view returns(int)
function getBalanceValue() public view returns(int)
{
//return the current value of balanceValue
return balanceValue;
}


function withdrawMyBalance(int amount) public
{
balanceValue = balanceValue - amount;

}

function depositeMyBalance(int amount) public
{

balanceValue = balanceValue + amount;
}

}

Note :- For newer version when you try to get the Accounts details please check the MetaMask plugin of chorme. For safety reason you have been asked explicitly approve the access.

Image1


Image2

Image3

Tuesday, September 17, 2019

How to create blockchain using Ethereum code

To get better idea of Block chain requesting you to please refer to the below given few of the important concepts.
https://shdhumale.wordpress.com/2019/09/16/block-chain-concepts/
Ethereum is Platform to develope/code blockchain concept. You can consider it as a JAVA platform. Like in JAVA we have JVM-Java Virtual Machine same way we have EVM (not electronic voting machine :) ) - Ethereum virtual machine which provide plate form for our code to execute. In JAVA we use java as a base language. For Ethereum we use Solidity language [https://solidity.readthedocs.io/en/v0.5.3/]. For JAVA we have IDE like Eclipse for Solidity we had Solidity IDE.
One of the best use of Ehereum along with soidity language and IDE is that we can use the free available crypography to use and test our Block chain ontheir live test environment.
Before going to implementation and live coding example on Ehereum to create block chain few of you might think in perious thread in this blog it was stated we also have Hyper ledger which provide you frame work [i.e. Iroha, Sawtooth, Fabric, Undy, Burrow] and tool [i.e. Hyperledger composer, hyperledger cello, hyperledger quilt and hyperledger explorere] to develop blockchain. Let me try to give you some brief difference between Hyperledger and Ethereum with respect to its implementation strategy, Crytocurrency, its Confidentiality, use of Conseus algorithum and its development Language.



Features List Hyperledger Technolgoy Ethereum Technology
Purpose B2B B2C
Confidentiality Confidential  Transparent
Mode of Peer Participation Private and Permissioned Network Public/Private and Permissionless Network
Consensus Algo used and which one  Pluggable Consensus Algorithm and  No mining required PoW Algorithm is used and  Consensus is reached by mining where in minner do this process of mininig i.e. adding the block in chain
Programming Language  GolangSolidity
Cryptocurrency No cryptocurrency Ether cryptocurrency


Now below going directly to Ethereum for creating block chain I would like to explain you hash algotirum with simple two JAVA class as given below:-
package com.siddhu;
import java.util.Arrays;
public class MyBlock {

private int privousBlockHash;
private String[] transections;
private int currentBlockHash;


public MyBlock(int privousBlockHash, String[] transections) {
super();
this.privousBlockHash = privousBlockHash;
this.transections = transections;

//we will generate hash digital code taking into consideration its content and its previous block hashcode.
Object[] contents = {Arrays.hashCode(transections) , privousBlockHash};
this.currentBlockHash = Arrays.hashCode(contents);
}
/**
* @return the privousBlockHash
*/
public int getPrivousBlockHash() {
return privousBlockHash;
}
/**
* @param privousBlockHash the privousBlockHash to set
*/
public void setPrivousBlockHash(int privousBlockHash) {
this.privousBlockHash = privousBlockHash;
}
/**
* @return the transections
*/
public String[] getTransections() {
return transections;
}
/**
* @param transections the transections to set
*/
public void setTransections(String[] transections) {
this.transections = transections;
}
/**
* @return the currentBlockHash
*/
public int getCurrentBlockHash() {
return currentBlockHash;
}
/**
* @param currentBlockHash the currentBlockHash to set
*/
public void setCurrentBlockHash(int currentBlockHash) {
this.currentBlockHash = currentBlockHash;
}


}
/**
*
*/
package com.siddhu;
import java.util.ArrayList;
/**
* @author Siddhartha
* In this simple example we will try to learn what is hash and how it work and fit perfectly for concept like blockchain.
* To be more clear we will have following thing in the block i.e. hash= digital signature, list of transections and Previous block hash code.
*/
public class SimpleHashExample {

ArrayList<MyBlock> myBlockChain = new ArrayList<MyBlock>();

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//Lets create our first Block i.e. who will not have any previous blog hash and term as Genesis Block
String[] myGenesisTransections = {"Sid transfer 10RS to ABC"};

MyBlock myGenesisBlock = new MyBlock(0, myGenesisTransections) ;

System.out.println("Hash code for Genesis Block is:"+ myGenesisBlock.getCurrentBlockHash());

String[] mySecondBlockTransection = {"ABC transfer 5Rs to XYZ"};

MyBlock mySeondcBlock = new MyBlock(myGenesisBlock.getCurrentBlockHash(), mySecondBlockTransection) ;

System.out.println("Hash code for Second Block is:"+ mySeondcBlock.getCurrentBlockHash());
}
}
If you see above for given input the output is
Hash code for Genesis Block is:-1568564568
Hash code for Second Block is:-2100868299
Image1Image2
Now if you change any value in Genesis or any second node valye its hash value will be chaged and this is the base how the block chain make sure the data is secure and is not hamper. For this we use SHAH512 or SHAH64 and MD5,6 algorithum.
Now having understanding of the base hash method lets start having our own simple example of Ethereum.
Following things are needed to do the intial set up
1- Set up MetaMask extension in google chorme from below given url.MetaMask is used to connect you to Ethereum and the Decentralized Web.
https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en
2- Please follow below screen shots sequentially
Image3Image4Image5Image6Image7Image8Image9
Once we had done with all the setup of MetaMask we will this screen

Image10Image11
On click on view on Ether scan you will get below online screen
Image12

Now let say if we create an example in Ethereum for deposite and withdraw operation on our created blockchain to do this we need some Ether as an cryptocurrency. But if you see we have 0$. To perform above example in test environment we will required few of Ether. So as usual lets try to collect the free ether for our test environment.
1- Change your Main environment to Test as shown below

Image13

2- Now click on Deposite button of below image.

Image14

3- click on Get Ether button as shown below
Image15
4- Following site will be open now click on the below give left side Crypto Faucet option

Image16
5- If you read the text in the below given screen it wil inform you if we want Ether then we need to share our address on social media like twitter, Facebook etc.
Image17
6- Lets share our address to facebook as shown belwo I am using Twitter
i.e. https://twitter.com/SiddharathaD/status/1173863404575973378
Image18
Now paste the above link on the belwo screen
Image19
Now choose the option you want I choose 18.75 ethers/3 days and click Give me Ethers.
Image20Image21
And you will Ether is added to your account

Image22
Hurrey now we had Free Ether to use for our BlockChain concepts.
Now lets start to create our first Ethereum block or better to say our first Smart Contract. For this we need a IDE which use Ehthereum platform. For this we can use below site. This will provide
https://remix.ethereum.org/
Image23
Now please Activate all the required module as given below
- Compile
- Run
- Analysis
- Testing
- Debugger
- Search

Image24Image25
Now lets set the comipler we will use the old one for simpler side :)

Image26Image27
Here is the complete tocode

pragma solidity ^0.4.24;

//Main class that will be used to perform operation on our block.
contract MyBank
{
//This is variable used for storing our balanceValue
int balanceValue;

//build constructor

constructor() public
{
//initialise the variable
balanceValue = 1;
}

//As getBalance is not manupulating the value it is used to show the data on the screen and use view returns(int)
function getBalanceValue() public view returns(int)
{
//return the current value of balanceValue
return balanceValue;
}


function withdrawMyBalance(int amount) public
{
balanceValue = balanceValue - amount;

}

function depositeMyBalance(int amount) public
{

balanceValue = balanceValue + amount;
}

}
Image28
Now as we can see we dont have any compiler error we can run our first Smart Contract to do this click on this option

Image29
One belwo screen you will get three different option
Image30
JavaScript
Injected
Web3 Provided
JavaScript :- This will use your or client JAVA JRE and run java script on the same and will perform the operations.
We will also select our MyBank.sol file that need to be executed.
Now click on the Deploy button and you will find we get Deployed contract seen on the screen as shown below.

Image31
Lets play with this option and see how is working
A :- Click on getBalanceValue and we will see we get value as 1 which is initial values.
Image32

B:- Now lets add 20 by using rransact button
Image33
and now click on the getBalanceValue button and we will the value change to 21
Image34
c:- Same way execute the withdraw method and check if it working

Image35Image36
Now this testing of our Smart contract is done on solidity language IDE lets say we want to do it on our Browser
For this we need to choose Injected Web3 option and once we do it will ask your permission to connect. click on the connect button

Image37
Now click on deploy to deploy our MyBank.SOL on test network. It will again ask for confiration .. do it by clicking confirm button below.
Image38
See the url on which our MyBank.SOL get deployed click on it and then you will see the below screen
Image39Image40
Initial status will be pending as it will take some time for POW and then once it is sucecess we are good to do the transection.
Let see it
Now perform all your GetBalance and Deposite and withdraw operation and you will see the now for Withdraw and deposite it will ask for some GAS from you just confirm it and we are done.


Image41Image42