Tuesday, June 2, 2015

BULK COPY with oledb



public static void UpDataDB(string DB, DataTable DT)
        {
            string ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB +
                                ";User Id=admin;Password=;";
            string SQL = "SELECT * FROM table1 WHERE ReadingID=0";
            string INSERT = "INSERT INTO table1 (Column1, Column2, Column3, Column4) " +
                            "VALUES (@Column1, @Column2, @Column3, @Column4)";

            OleDbConnection OleConn = new OleDbConnection(ConnString);
            OleDbDataAdapter OleAdp = new OleDbDataAdapter(SQL, OleConn);
            OleAdp.InsertCommand = new OleDbCommand(INSERT);
            OleAdp.InsertCommand.Parameters.Add("@Column1", OleDbType.Integer, 8, "Meter1");
            OleAdp.InsertCommand.Parameters.Add("@Column2", OleDbType.Integer, 8, "Meter2");
            OleAdp.InsertCommand.Parameters.Add("@Column3", OleDbType.Integer, 8, "Meter3");
            OleAdp.InsertCommand.Parameters.Add("@Column4", OleDbType.Integer, 8, "Meter4");
            OleAdp.InsertCommand.Connection = OleConn;
            OleAdp.InsertCommand.Connection.Open();
            OleAdp.Update(DT);
            OleAdp.InsertCommand.Connection.Close();
        }

Upload excel file into oracle

http://www.c-sharpcorner.com/UploadFile/1326ef/upload-exceltxt-file-data-into-oracle-table-using-toad/

Message Contracts in WCF



Message Contracts in WCF

With data contracts we have very limited control over the SAOP XML Request and response Messages that are generated. Use message contracts for full control over the generated XML SOAP messages.
SOAP header are used to pass user credentials, License keys and session key etc.


KnownTypeAttribute in WCF



KnowType Attribute in WCF
If we have classes related by inheritance, the wcf services generally accepts and returns the base type. If you expect the service to accept and return inherited types, then use Knowtypes 


WCF DataContracts and DataMembers




WCF DataContracts and DataMembers
Serialization is the process of converting object to xml representation
 By default WCF uses DataContractSerializer 
If you want explicit control on what fields and properties get serialized then use DataContract and DataMember attributes


WCF interview Questions Part 1


WCF
Is it possible for WCF Service to implement multiple Services ?
Yes, we make the service class implement multiple service interfaces and then expose each service using a different endpoint
How to make changes to wcf service without breaking existing clients?
Use Name property of serviceContractAttribute and give it an explicit name to prevent the client from breaking when service contract interface name is changed 


Interview Question on SOA




What is SOA ? Services and messages?
Services - Self contained, Communicate using messages and orchestration
+
Messages – follow industry standards, Cross platform, Asynchronous, reliable, secured and describe and discover services
= SOA: is architecture style for building business applications using loosely coupled services.

What is difference between service and component?
Services enable u r component to go across any heterogeneous platform while component work within programming boundary 

What are Endpoints, Address Contracts and bindings?
Address (where)
Binding  (How)
Contracts (what)

Logging Application block?
In order log error we need understand 3 important things.
Source :  EventLog, file, email and Database etc..
Trace Listener : will pass the error to the respective source
Formater : how do you want this trace listerner want to write data the format of data into the source
                    Custom, binary and Text 

What is factory Pattern?
Its type of creational pattern and it constructs and create objects            
We avoid two things using this.
  • Lot of new keywords scattered
  • Client aware of all concrete classes
What is Command Design pattern?
It belongs to behavioral category
Command pattern allows a request to exist as an object
When you want your request as class or objects then go command design pattern

What is proto type pattern?
Its type of creational pattern and it will create new objects from existing instance of object. In one sentence we clone existing object with its data. by cloning it doesn’t  affect the original object.

What is builder Pattern?
Its type of creational category and it helps us to separate the construction of complex objects from its representation so that the same construction process can create different representation.

  • Builder : define construction process for individual parts. Builder has those individual process to initialize and configure the product.
  • Director :  takes those individual processes from the builder and defines the sequence to build product.
  • Product : is the final object which is produced from builder and director coordination.