Microsoft.Office.Interop.Excel dll is missing in visual studio 2015, quick fix

If you have newly installed visual studio 2015, you might not be having the Microsoft.office related dlls. So your existing project or new project in which you are using Microsoft  office related dlls you may face the library reference issues. to avoid these things you have to install micorsoft office tools for VisualStudio.
you can get the installer  here : download
Once you have done with the installation you can check office related dlls in this folder
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\

Installing MongoDb on windows,creating first database,collection and basic queries

The tech world is moving into Artificial Intelligence, data mining and prediction algorithms and much more into the intelligent use of data, so the data storing technology also changing from the relational database architecture to non-relational architecture, NoSQL database etc.
MongoDb is one of the fast growing NoSql database, In which we will be storing the data as collections, basically, document.It will help really good in data mining and data prediction operations.
Let's see step by step how to install MongoDb into a windows machine

Step 1: Download mongo MSI installer here: Download
           The non-commercial version is free, Click install the application using MSI

Step 2: provide a space to store the data & log >>  type cmd and open command prompt
             paste this command in terminal
             data : md \data\db
             log : md \data\log
Step 3 : Now go the mongo installed path bin folder  in command prompt and type mongod

The server will be up and it will be waiting for connections, the default port is 27017

Step 4: open another terminal and go to the mongo bin folder and type mongo.exe
             mongo server will be up and  running you can write your queries

Queries

>> For creating database
     use database-name eg : use coder_juggernaut
>> Display databse
     show dbs :> list all dbs
     db :> current db
>>Creating Collections
     db.firstcollection.insert({"name":"coder juggernaut"})
>> view items in Collections
     db.firstcollection.find()

These all some basic queries to start with, instead of terminal you can use Studio 3T, it's a good tool it will give good visualization and simple querying features.

Step 2 extension: If you didn't get the log in the mentioned folder create a config file and place it in the mongo root folder with this text.

systemLog:
                 destination:file
                 path: log path.

Create Zip file using C#, extracting the Zip programatically

For creating Zip file using C#, There are so many approaches we will go with simple approaches 
first we need to select a source folder and keep the files needs to be zipped and we will create a result zip path.
Now we have to add the reference of  System.IO.Compression library and System.IO.Compression.Filesystem libraries
Once you have add the references, you have to use the "CreateFromDirectory" static method for creating the Zip 
"ExtractToDirectory" method for unzipping the same

 Another approach is little bit complicated, you can create a zip file instance and update the same using the "ZipArchive" 



code for the same given below, comment if you have any doubts.




       

 static void Main(string[] args)
        {
            string filepath = @"C:\Files";
            string resultpath = @"C:\Zip\zip.zip";
            string unZippath = @"C:\UnZip";

            //Creates the zip file
            ZipFile.CreateFromDirectory(filepath, resultpath);

            // Un Zip the zip file
            ZipFile.ExtractToDirectory(resultpath, unZippath);

            // Creating new Zip file
            using (ZipArchive newFile = ZipFile.Open(@"C:\LogFiles\Zip\zip.zip", ZipArchiveMode.Create))
            {

                newFile.CreateEntryFromFile(@"C:\LogFiles\log1.txt", "log1.txt");
            }
            //Updating the Zip file
            using (ZipArchive updateFile = ZipFile.Open(@"C:\LogFiles\Zip\zip.zip", ZipArchiveMode.Update))
            {

                updateFile.CreateEntryFromFile(@"C:\LogFiles\log1.txt", "log2.txt");
            }
        }


Reading XML file nodes as key value pair using C#

Problem Statement: we have an XML file and it has a set of keys and values we have to read it using C#

XML Look like this :

       

<?xml version="1.0" encoding="UTF-8"?>

<root>

<bangalore>

<item key="madiwala" value="56043" />

<item key="whitefield" value="56048" />

<item key="hebbal" value="56050" />

</bangalore>

</root>


Solution: We will use System.Xml library in the dot net framework to load the file and then we will select the specific node we want and loop all the item from it and we will add to a dictionary as key-value pair.



so here you can check the code for the same.











       
 //Loading Xml

  string xmlPath = @"C:\Tony\Location.xml"

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(xmlPath);



  // Getting Node

            XmlNodeList locationDetails = xmlCountryDocument.SelectNodes("root/bangalore");

            Dictionary<string, string> dicPlacePinXml = new Dictionary<string, string>();

   

   //Looping

            foreach (XmlNode locationNode in locationDetails)

            {


               foreach (XmlNode elementLoc in locationNode.ChildNodes)

                {

                    dicPlacePinXml.Add(elementLoc.Attributes["key"].Value, elementLoc.Attributes["value"].Value);
                }

            }

So here our "dicPlacePinXml" variable will be having the place and pin as key-value pair.

The application requires more database privileges than you have currently been granted Oracle DB

After your installation of oracle10g and if you have unlocked account like scott,hr etc , you may not be able to login,
you will be getting the following error message, to resolve this issue you have to grand the catalog role to the user.

Error Message :The application requires more database privileges than you have currently been granted

Solution : grant select_catalog_role to scott


Epoch time in C#

How we can convert normal date time to epoch time using C#
please see the following console application for epoch time in Seconds


       


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
           string date = "2017-02-02 16:26:43";
           DateTime dt= Convert.ToDateTime(date);
           long epoch= ConvertToEpoch(dt);
        }

        public static long ConvertToEpoch(DateTime date)
        {
            return (date.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
        }

    }
}
 
 
for epoch time in Milli Seconds
       


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
           string date = "2017-02-02 16:26:43";
           DateTime dt= Convert.ToDateTime(date);
           long epoch= ConvertToEpoch(dt);
        }

        public static long ConvertToEpoch(DateTime date)
        {
            return (date.ToUniversalTime().Ticks - 621355968000000000) / 10000;
        }

    }
}
 
 

.net core configuration in visual studio 2015, Hello world in .net core

Microsoft's powerful open source development platform .net core is the new trending technology in the tech market, so if you have visual studio 2015 you can do the development in easy updates.
So I will be explaining the steps required to configure the .net core in visual studio 2015.
1. download the visual studio update for 2015: download
    If you don't have the visual studio 2015: download
2. Download the .net core tool for the visual studio: download

I hope you have downloaded and installed all the above items, now we are good to go to the next step
So let us create a hello world console application using .net core
Select the new project option from vs you can see the .net core option under C#
select the console application and create one project with that


now you can just write the code in the same way you used to write with C#

The DLL generated in windows machine for this application you can run in Mac/Linux it will give you the same result.

you can check more details here :details

single setup using Install shield

If you are building setup using install shield by default the configuration selected will be DVD 5
In this case, the bin folder will not be consolidated in the setup it will be a separate folder.
to make it as the single one you have to change the configuration to SingleImage
Select your project> Build> configuration manager and change project configuration type to Single Instance