Thursday, 25 June 2020

Troubleshooting in SQL

1. SSRS Error 

Round () need to be done in  SQL itself 

2. Default Date In SSRS 

Start Date
=CDate(Format(DateAdd("d",-50,Now()), "MM/dd/yyyy") + " 07:00:00")

End Date 
=CDate(Format(DateAdd("d",0,Now()), "MM/dd/yyyy") + " 06:59:59")

Sunday, 22 September 2019

c# Read Excel Data and Parse then convert to text file

Create a windows Form Application
Create a button while clicking button perform these operations



using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.Office.Interop.Excel;
using System;
using System.Linq;
using System.Windows.Forms;
using NPOI.HSSF.UserModel;
using System.Runtime.InteropServices;
using System.IO;

namespace ReadExcel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static void get_ExcelFile_append_textFiile()
        {
            //Excel File
            Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:\Users\karthikeyan\Documents\sample.xlsx");
            Microsoft.Office.Interop.Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            Microsoft.Office.Interop.Excel.Range xlRange = xlWorksheet.UsedRange;
            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;
            string fileName = @"C:\Users\karthikeyan\Documents\sample.txt";
            String[] str_array = new String[2];
         

            // Traversal
            for (int i = 1; i <= colCount; i++)
            {
                for (int j = 1; j <= rowCount; j++)
                {
                    if (xlRange.Cells[j, i] != null && xlRange.Cells[j, i].Value2 != null)
                    {
                            str_array[0] += xlRange.Cells[j, i].Value2.ToString() + ",";
                    }
                    else if (xlRange.Cells[j, i].Value2 == null)
                    {
                            str_array[0] += xlRange.Cells[j, i].Value2 + ",";
                    }
                }
                using (StreamWriter stream = File.AppendText(fileName))
                {
                    str_array[0] = str_array[0].Remove(str_array[0].LastIndexOf(','));
                    str_array[0] = str_array[0] + (";");
                    stream.WriteLine(str_array[0]);
                    Console.WriteLine(str_array[0]);
                }
                str_array[0] = null;
            }

            //cleanup
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Marshal.ReleaseComObject(xlRange);
            Marshal.ReleaseComObject(xlWorksheet);
            xlWorkbook.Close();
            Marshal.ReleaseComObject(xlWorkbook);
            xlApp.Quit();
            Marshal.ReleaseComObject(xlApp);
        }

        //Text File
        public static void create_text_file()
        {
            string fileName = @"C:\Users\karthikeyan\Documents\sample.txt";
            try
            {
                if (File.Exists(fileName))
                    File.Delete(fileName);
                using (FileStream fs = File.Create(fileName))
                {
                    Console.WriteLine("File Created Sucessfully");
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.ToString());
            }
        }

        private void ReadExcel_Click(object sender, EventArgs e)
        {
            create_text_file();
            get_ExcelFile_append_textFiile();
           
        }
    }
}

Tuesday, 27 November 2018

HTML MIstake

if Default scroll is not working
give  overflow: scroll;
for the whole content

In JavaScript the function name should not begin with
close()
open()
because there is  already in build functions

 If two css is applied to a same html entities then you may occur a problem

Example scenario:
 If you applied css to list as in common as  li and
again you are creating a class or id    #header li  or .header li

this may occur during editing others code

Thursday, 15 November 2018

C++ Programming Logics

Variable - Integer and String
#include <iostream>
#include <string>
using namespace std;
int main(){
int num,len;
string str;
cout<<"Enter the Value";
cin>>num;
cout<<"Enter the Character";
cin>>str;
cout<<"\n" << num <<"\n"<< str;
}



Leap Year

#include <iostream>
using namespace std;
int main(){
int num;
cout << "Enter a year";
cin >> num;
if((num % 4) == 0 || (num % 100)==0 || (num%400) ==0 ){
cout <<num <<"is a Leap year";
}
else{
cout <<num <<"is not a Leap year";
}
return 0;
}


Tuesday, 31 July 2018

Important Concepts In Programming

Programming


Sorting and Searching
Linked List
Graph
Tree
Dynamic Programming
Bit manipulation N



Tuesday, 8 May 2018

Testing

Errors and Solution
 


Some of the Common steps to be followed to Solve the Problem
  •  Analyse the Code step by step While Running the Code Analyze the Log Step By Step
  •  Use Print Statement then and there to find till which the function is working 
  •  If you are working in UI related Work Check the Resource Id Package name is correct
  •  Do manually the testcase is Working 
  • Check the build is Current build 
  •  The function Schould be called correctly 
  • If any registration is done after that the Spinner or loader may come We schould analyse that during testing because in the Code they may be forget to handle this situation of loader or spinner 
  • while running anything if TestNg error came first check the jars are there in the respective lcations Clean the build and build again
  • ADB related issues if Multiple Services run in background your code will call unnecessary functions so you can kill all thhe services I have mentioned in the Error :11 you can proceed that 
  • Check the respective APK installed in the device

1.Error:
      [TestNG] [Error] No test suite found. Nothing to run
       Usage: <main class> [options] The XML suite files to run
Solution:
         while running Command Path Schould be Correct
         Example:
         src/test/com/activity/second 
         src/test/com/Activity/Second (Case Sensitive)

2.Error :
       RHEL not found
      or Failed to bootstrap /home/local/ANT/rzamzn/rzamzn/Subs/env/JDK8-1.0/runtime: 
Solution: 
         brazil ws --use --platform RHEL5_64

3.Errors
       Assert function does not return Boolean
       Example:
       TestStatus &= assertTrue(uiHandle.validateAndAcceptOffer(DynamicUpsellConstants.AUDIBLE_ID),"Validating and accepting Audible");
Solution :
          TestStatus &= uiHandle.validateAndAcceptOffer(DynamicUpsellConstants.AUDIBLE_ID);

4.Errors:
          Unwanted Errors in Eclipse like log cannot be resolved
Sollution:
             Project - Clean 
             Select the below terms 
             Clean all projects
             start a build immediately
             Build the entire workspace

5.Error :
        no suitable constructor found for Date(no arguments)                              
        [javac]     constructor Date.Date(int,int,int) is not applicable
        [javac]       (actual and formal argument lists differ in length)
        [javac]     constructor Date.Date(long) is not applicable
        [javac]       (actual and formal argument lists differ in length)
Solution:
        Import java Date Function


6.Error:
     In imports Log can be resolved
Solution:(For Eclipsce)
  • Right Click the file
  • Build Path
  • ConfigureBuildPath
  • Libraries
  • Add Library
  • Brazil managed Dependencies
  • Next
  • Finish
  • Ok

7.Error:
            Failed to Bootstrap Error is also due to the following Mistakes
Solution:
            If there is a Service and Model
           We should run the model First and then we want to run the service
           If we run the Service First then it throughout the Error Failed to bootstrap

8.Error:      
            'Java Null Pointer Exception 
Solution:
                 Due to Many reasons it may Come 
                 Boolean Variable declared but not yet Initialised  anywhere 

9. Error :
               Any Path like image or any other files aceessed in source Java file  If it not given correctly it doesnot shows error 
Solution:
                  /datafiles/sampleimage.png  is Incorrect
                Example : datafiles/sampleimage.png need to give 

10.Error:
                 In UI Automator  E/ddms: transfer error: Permission denied
Solution:                 
                  Start adb as root 

11.Error
                 If ADB is not  responding  it may be the  multiple services can run at a time in bacground so you need to kill the services
Solution:
                 Step1:   
                  ps -ef | grep -i adb
         rzamzn    3710  3689  0 17:25 pts/11   00:00:00 sh -c adb wait-for-device
        rzamzn    3711  3710  0 17:25 ?        00:00:00 adb wait-for-device
        rzamzn    3713  3711  0 17:25 pts/11   00:00:00 adb -P 5037 fork-server server
        rzamzn    3994  3501  0 17:27 pts/11   00:00:00 adb reboot
        rzamzn    4265  3501  0 17:35 pts/11   00:00:00 grep --color=auto -i adb

                   List of Services will be displayed

                 Step2:
                      
                   kill -9 3710
        kill -9 3711
        kill -9 3713
        kill -9 3994


12:Error   VNC related Issues 
                   Connection refused due to Security issues or upgrade to recent versions from relavnc 
 Solution:     
                            type this command 
                   gsettings set org.gnome.Vino require-encryption false

Wednesday, 14 February 2018

Commands

Commands 

Eclipse Shortcuts:


CTRL+H
        To search a Particular word in the Whole File

CTRL+SHIFT+F 
        To align the Code

CTRL+SHIFT+R
         To search a Particular file in the Work space



Ubuntu commands :

sudo
        If the user don't have the root permission before each command sudo  is used 

ls (list)
       To display all the files and folders in the directory that you are working in 

cd (Changing Directory)
        The folder you want to go from the current directory 

cd ..
       if you want to go up just type cd .. as a parameter 

mkdir
        To create a new folder or sub folder

cp 
       To copy and paste the file cp source destination 

rm  (remove)
      To remove your file or Directory 

    rm -r  
    rm -f  if it needs the root permissions 




Saturday, 8 July 2017

Amazon

There are Many Efficient Solutions Than this

Amazon - First Round -1
*******************

Count the number of duplicate Elements  present in the array 

Sample Input:
10
1 2 2 4 4 5 5 6 6 10
 Sample Output:
4

Explanation :
2 present twice count is incremented
4 present twice count is incremented
5 present twice count is incremented
6 present twice count is incremented


#include <stdio.h>
#include <limits.h>
int main() {
    int n,max=0,hash[1000]={0},count=0;
    scanf("%d",&n);
    int arr[n],i;   
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        hash[arr[i]]++;       // the values are stored in the hash table
        if(arr[i]>max)
        {
            max = arr[i];   // for finding the max value of array
        }
    }
    for(i=0;i<=max;i++)
    {
        if(hash[i]>1)    //if a number present more than once 
         count++;
    }
    printf("%d",count);
    return 0;
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Amazon- First Round -2
*****************

Given two arrays merge and sort the arrays

Sample Input:
5                            --->size of the array
2 4 6 8 10              ---->Elements of array 1
1 3 5 7 9                ---->Elements of array 2

Sample Output:

1 2 3 4 5 6 7 8 9 10 


// The vector is similar to the array
// push_back() is used to insert the value into the vector
// size() is used to find the length of the array


#include<bits/stdc++.h>
using namespace std;
#define lli long long int

vector<lli> mergeArray(vector<lli> a,vector<lli> b)
{
      vector<lli> res;

      lli size1=a.size(),size2=b.size();
      lli i=0,j=0;

        while((i<size1)&&(j<size2))
        {
                if(a[i]<b[j])
                {
                        res.push_back(a[i]);
                        i++;               // if smallest element the values are pushed into this
                      
                }
                else
                {   
                        res.push_back(b[j]);
                         j++;                 // if largest element the values are pushed into this
                       
                }
        }
        while(i<size1)
        {
           res.push_back(a[i]); // in some Testcases only these two conditions needed
            i++;   
        }
        while(j<size2)
        {
            res.push_back(b[j]);
            j++;
        }
        return res;
}
        int main()
        {
                vector<lli> a,b;
                lli n;
                cin>>n;
                for(lli i=0;i<n;i++)
                {
                        lli k;
                        cin>>k;
                        a.push_back(k);                //Reading the first array
                }
                for(lli i=0;i<n;i++)
                {
                        lli k;
                        cin>>k;
                        b.push_back(k);             //Reading the second  array
                }
                vector<lli> res=mergeArray(a,b);
                       n+=n;                           //The vectors are  passed to the function
               
                for(lli i=0;i<n;i++)
                     {
                           cout<<res[i]<<" ";
                      }
        }




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Amazon Second Round - 1
*****************
Even numbers at Even Positions and Odd numbers at odd numbers at Positions if Exceeds the array is Untouched
http://www.crazyforcode.com/rearrange-array-even-numbers-odd-numbers/


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Amazon Second Round - 2
*******************

Given a string Count the number of unequalities and make as Palindrome
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Amazon Third Round - 1
*****************

 Search in the array:
                        http://www.geeksforgeeks.org/efficient-search-in-an-array-where-difference-between-adjacent-is-1/


 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Amazon Third Round - 2
*****************

Sort the array:
                            http://www.geeksforgeeks.org/sort-an-array-of-0s-1s-and-2s/   

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Amazon - Fourth Round
*****************
  •  Testing     --->An application sends an automatic Birthday wishes Write test case for that
  • Troubleshooting ---> An ecommerce Website Located in 14 countries Example(an website is located in many countries In one country alone in one Account book is not downloading troubleshoot that)
  • Linux Comands
  • Dbms (SQL Querries)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




Amazon - Fifth Round
*****************
  •  Project                                      
                                    If  Web (HTML, CSS ,JAVA ,JAVASRIPT ,SERVLET , DBMS)
  •  Testing 
  •  Troubleshooting
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Odessa Technologies

Odessa Technologies-first round - 1
Given an array in unsorted order sort the array and sum the last two elements in the array and find the difference of first two elements in the array
then find the sum by difference

Sample input:1 2 3 4 5 6
Sample input:11

Note: The N (number of elements is not given)

 solution:

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<limits.h>
#include<stdlib.h>

int main() {
    int arr[1000],sarr[1000],hash[1000]={0},l=0,i=0,j,k,max=INT_MIN;
    int start,end;
   
while(scanf("%d",&arr[i])==1)
    {
        hash[arr[i]]++;                            // The counts are stored in the hash table
        if(arr[i]>=max)
          {
            max = arr[i];              // The maximum values of the array is stored in the Max
          } 

    i++;

    }

    for(j=0;j<=max;j++)

    {

        if(hash[j])                           //To remove duplicates and print in sorted order

        {
             sarr[l]=j;
             l++;
        }

    }
    l--;

        end = sarr[l]+sarr[l-1];           // sum the last two index
        start = sarr[0]-sarr[1];           // diference the first two index
        start = abs(start);
        printf("%d",end/start);            //last two index sum / first two index difference
    return 0;

}




Odessa Technologies first round - 2 
To remove duplicate and print the array in the sorted order

the number of element N is not given (it is possible only in Online compiler)

sample Input: 1 2 1 2 1 2 1 2 1 2 4 3

Sample Output: 1 2 3 4


Solution:

#include<stdio.h>
#include<string.h>
#include<limits.h>
#include<stdlib.h>
int main() {int arr[1000],hash[1000]={0},l=0,i=0,j,max=INT_MIN;

while(scanf("%d",&arr[i])==1)
    {
        hash[arr[i]]++;                            // The counts are stored in the hash table
        if(arr[i]>=max)
          {
            max = arr[i];      // The maximum values of the array is stored in the Max
          }  
    i++;
    }
    for(j=0;j<=max;j++)
    {
        if(hash[j])                           //To remove duplicates and print in sorted order
        {
              printf("%d ",j);
        }
    }
    return 0;
}

Tuesday, 4 July 2017

Troubleshooting in SQL

1. SSRS Error  Round () need to be done in  SQL itself  2. Default Date In SSRS  Start Date =CDate(Format(DateAdd("d",-50,Now()), ...