Posts

Override Methods in C#

In C#, when we override methods we have to keep remember some important points. Assume there is a parent class called ClassA and it has a method called method().  If we are going to override that method in  a subclass ClassB, we have to use virtual and override keywords properly in suitable places. virtual should be used with method() in parent class and  override should be used with method() in sub class. If we do not use these keywords properly Overridden functionality  is not working properly.  namespace BasicLangEx {     class ClassA     {         public virtual void method()         {             Console.WriteLine("Method A");         }     } } namespace BasicLangEx {     class ClassB : ClassA     { ...

Tips to Tune SQL Queries

In this post I hope to give some knowledge about the Oracle Execution plan and  the some tips to optimize sql queries for better performances. Execution Plan Oracle can run Explain plan for given SELECT, INSERT,UPDATE, DELETE SQL  statements as below Oracle - EXPLAIN PLAN FOR SELECT customer_name FROM CUSTOMER; MySql -   Explain SELECT customer_name FROM CUSTOMER;   Then it displays the execution plan chosen by the Oracle optimizer, which contains the  sequence of operations used to run a particular sql statement. Execution plan contains,  tables, views referenced by the statement access methods for each tables and views (table access full,table access by index) join methods data operations such as sort, aggregate cost, cardinality parallel executions   According to the execution plan you can get the idea to optimize a given sql statement in  a proper way.Now I am going to explain the ways that can be used to tune/optimize the...

How To call Java Jar from C# Code

First I will say how to create a jar file for given java package using command prompt You can create Manifest file using note pad by including below mentioned contents                        Manifest-Version: 1.0                        Main-Class: Main Here manifest file is named as manifest.mf Here Main is the main class of the java project. In my example java project it only contains Main.java with below code.                                        public class Main {                   ...

How to set and get Metadata to image using BitmapMetadata class in C#

When images are considered, those are storing their Meta data using different types of Meta containers such as EXIF, Adobe XMP, IPTC, Photoshop Image resource and Text descriptions. This every container has their specific unique rules to encode (store) and decode (extract) Meta data. As well as these each Meta container is storing specific Meta information. Exif Meta containers are mostly storing location information and GPS (Global Positioning System) records. As well as, Adobe XMP is responsible to store Dublin core Meta data which provides standard Meta tags that can be used to describe digital objects basically and IPTC is storing Meta information about application records. Meta data extractor is mainly considering these Exif, IPTC and adobe XMP Meta containers when it is extracting Meta data from images. As well as, these different Meta data containers are considered; they are structuring Meta tags in different dir...

How to add standard and custom Metadata to PDF using iTextSharp

In a previous blog, I explained How to add custom metadata using Syncfusion library. But this package gives so many difficulties when adding metadata to pdf. Such problems are,    1. When once add custom meta data to a pdf, it does not able to change or remove those custom meta data from the pdf.    2. It does not compatible with meta data search engines. It does not show custom meta data properly when those are searched through the search engines. Due to these reasons, Syncfusion is not good library for custom meta data. But, iTextSharp provides flexible framework to deal with custom meta data as well as standard meta data for PDF. Below I have provided the source code to show usage of iTextSharp library. You can download iTextShrp.dll from here                              PdfReader pdf = new PdfReader(input_path); ...

How To Kill WinWOrd Process In C#

When You open MS Word Document pro-grammatically using 'Microsoft.Office.Interop.Word', you are creating 'winword' process. So after dealing with opened MS Word document  pro-grammatically though you close it using 'close' method, the 'winword' process is not terminating, it is still running on your OS. So you have to terminate it in the end of the program otherwise, it creates so many 'winword' processes for each time you open MS Word document and you may face to memory problems later.  You can use below code to kill 'Winword' process. foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName("winword"))             {                 if (!p.HasExited)                 {             ...

DSOFile.SummaryProperties.DateCreated

When we want to get the Created Date Meta Date from MS Document we can use ' DSOFile.SummaryProperties.DateCreated ' instance variable. This variable is given the date of file is originally created.                     System.IO.FileInfo file = new System.IO.FileInfo(@""+input_path);                     string creation_date = file.CreationTime.ToString(); This creation date does not mean originally created date of the document. For example, Consider I create MS Word document and save it in 'D' Storage of the memory and then I copy and paste it into MyDocument. Then the created date of copied document is considered as the copied time in above code. But, ' DSOFile.SummaryProperties.DateCreated ' is taking created date as the date of document originally created in Location 'D'