Monday 30 June 2014

Writing Data in Excel File into a Database using a DataSet and SqlBulkCopy

In this post let’s see how we can write data in a excel file into a database using a DataSet and SqlBulkCopy.

The concept here is fairly simple. First load data in the excel file into a DataSet and then for each tables in the DataSet, use SqlBulkCopy to push the data into the database. In this case, it will be a single table.

For demonstration purpose I have the following excel file, which has only one sheet which is named as “MySheet”.


Now let’s see the whole process in action. Create a new console application. Write the following method to get excel data into a table in DataSet.

public static DataSet ReadToDataSet(string filePath, string tableName)
{
    DataSet ds = new DataSet();
    OleDbCommand cmd = new OleDbCommand();
    OleDbDataAdapter adapter = new OleDbDataAdapter();
    OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");

    try
    {
        conn.Open();
        cmd.Connection = conn;
        cmd.CommandType = CommandType.Text;

        // to select all the columns
        //cmd.CommandText = "SELECT * FROM [MySheet$]";

        // I am only selecting some columns
        cmd.CommandText = "SELECT FirstName, LastName, Department FROM [MySheet$]";

        adapter = new OleDbDataAdapter(cmd);
        adapter.Fill(ds, tableName);
        return ds;
    }
    catch (Exception ex)
    { 
    }
    finally
    {
        conn.Close();
    }
    return null;
}

Here when creating the OleDbConnection, in the query string along with the excel file path, some properties are.
  • "HDR=Yes;" indicates that the first row contains column names. If "HDR=No;", it indicates the opposite.
  • MEX=1 is a safer way to retrieve data for mixed data columns.
Once it’s done, now We need to push the data in my DataSet into the database. Before doing that here we have following two helper methods.

Following method will check if a table already exists with the given name in the database.
private static bool CheckWhetherTableExists(SqlConnection conn, string tableName)
{
    bool isExist = false;
    SqlCommand cmd;
    try
    {
        conn.Open();
        cmd = new SqlCommand("SELECT * FROM sysobjects where name = '" + tableName + "'", conn);
        isExist = cmd.ExecuteScalar() == null ? false : true;
        return isExist;
    }
    catch (Exception ex)
    {
    }
    finally
    {
        conn.Close();
    }
    return true;

}

If the table doesn't exist, following method will create a table with all the column names as in provided DataTable. Please note, here for all columns I am using “varchar(MAX)” as the column type.

private static void CreateTableInDatabase(SqlConnection conn, DataTable dt)
{
    bool isExist = false;
    SqlCommand cmd;
    try
    {
        conn.Open();
        foreach (DataColumn dc in dt.Columns)
        {
            if (!isExist)
            {
                cmd = new SqlCommand("CREATE TABLE " + dt.TableName + " (" + dc.ColumnName + " varchar(MAX))", conn);
                cmd.ExecuteNonQuery();
                isExist = true;
            }
            else
            {
                cmd = new SqlCommand("ALTER TABLE " + dt.TableName + " ADD " + dc.ColumnName + " varchar(MAX)", conn);
                cmd.ExecuteNonQuery();
            }
        }
    }
    catch (Exception ex)
    {
    }
    finally
    {
        conn.Close();
    }

}

Once the DataSet and the table created in database, all I have to do now is push the data in DataSet into the database.
public static void PushDataSetToDatabase(SqlConnection conn, DataSet ds)
{
   try
   {
       foreach (DataTable dt in ds.Tables)
       {
           if (!CheckWhetherTableExists(conn, dt.TableName))
           {
               CreateTableInDatabase(conn, dt);
           }
 
           conn.Open();
           using (SqlBulkCopy bulkcopy = new SqlBulkCopy(conn))
           {
               bulkcopy.DestinationTableName = dt.TableName;
               bulkcopy.WriteToServer(dt);
           }
       }
   }
   catch (Exception ex)
   {       
   }
   finally
   {
       conn.Close();
   }

}

Finally from the Main method, initiate the process.

static void Main(string[] args)
{
    string filePath = @"D:\SampleExcelFile.xlsx";
    DataSet ds = ReadToDataSet(filePath, "MyTable");
 
    SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=MyTestDB;Integrated Security=True");
    PushDataSetToDatabase(conn, ds);

}

Once the program completed, the data can be seen in database table.


About Author:
Lovina Dodti is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, she actively contributes to the areas of Technology and Information Security. She can be contacted at lovina.d@spluspl.com

Wednesday 25 June 2014

What is Technical Support?

One of the main criteria for the success of any product is to ensure that efficient and timely technical support is available for it. Any assistance provided by enterprises to users using products like mobile phone, camera, television, microwave, employee management system, contract management system or any other mechanical, electronic or software products is termed as technical support. Technical support mainly deals with resolving user queries on using the product or any issues faced by them. Technical support generally does not include providing training to users on using the product or dealing with any customization or change requests.

Technical Support can be provided in various forms as listed below:

Phone Support
In this type of support, customers call up a phone number provided in the product manual and get their queries / issues resolved. Many support centres provide 24/7 support which proves very beneficial for the customers.
E.g. Banks, network providers

Email Support
Customers email their issues / queries to an email address provided in the product manual and wait for response. The support providers normally have SLA which specifies the timeframe in which the customer can expect a reply.
E.g. Retail, infrastructure, Contract Management System

Live Support
In live support, customer care executives provide assistance to customers via chat. This is effective if the customers have simple queries that can be resolved quickly.
E.g. Ebay, Amazon

Online Forums
Some companies provide online forums / discussion boards where customers can interact with each other and resolve queries. This technique helps companies to reduce their support cost considerably.
E.g. Apple, Mozilla Firefox


Different levels of Technical Support

In order to serve the customers efficiently and in a better way, technical support in classified into multiple levels. Normally, a support structure revolves around three-tiered system as explained below:

Level/Tier 1 (L1/T1):
This is also commonly known as front-end support, first-line support, etc and denotes the basic support provided to customers like resolving user queries on the functionality of the product.

Level/Tier 2 (L2/T2):
Level 2 support is more in-depth as compared to Level 1 and involves more experienced support team and this is more experience. This includes product installation, troubleshooting, software repair, testing, etc.

Level/Tier 3 (L3/T3):
Level 3 is the highest level and handles complex and advanced problems. This is also known as high-end or back-end support. Level 3 support team are experts in their respective fields and also assist personnel from both level 1 and level 2.

Importance of Technical Support

Products with better technical support sell better as the customers are assured assistance in case they face any queries. Thus, we see that more and more companies are now investing in efficient support system so as to provide better service to customers.

Technical support is very essential for all mechanical, electronic and software products as it not only helps in selling the product but also ensuring the client / customer gets good value for his/her purchase. The support providers must be trained and efficient in resolving any user queries and have a thorough knowledge of the product, else it may just be an additional burden for the client trying to reach out to the support team and not get any solutions.

About Author:
Dimpy Thurakhia is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, she actively contributes to the areas of Technology and Information Security. She can be contacted at dimpy.t@spluspl.com

The Business Analyst and Testing: An Alliance

A Business Analyst is involved in all the SDLC phases of a project. He begins his job from Scoping & Requirements Gathering, then works on Optimizing Solutions and Designing, then ensures a good product is Developed and Implemented.

A very critical part of the entire SDLC life cycle is testing.  Regardless of the size of the project being implemented or the type of industry that project impacts, there is nearly always a testing phase to a project. 

The main focus of testing is:
  1.  Finding faults in the system
  2. Ensuring that the system is acceptable to all users
  3. Testing the system with other systems
  4. Testing from a business perspective
Types of testing performed by Business Analyst:

To understand the different types of testing, let’s take an example of the IRCTC Website. Assume the Business Analyst has built the website with 2 components: Booking Module, Cancellation Module.

Component testing
A business Analys can test requirements in forms of components. Component are software items for which independent requirements are given. Component testing  is analogous to the unit testing methodology but with advanced level of integration in the lexicon of application instead of just testing it directly. In this type each component of software is tested on an individual level by the Business Analyst.
Example: This would be to test each component – Booking and Cancellation individually, if it functions correctly or not.

Integration testing
After component testing, the next step a Business Analyst can look at is integration testing. On performing component wise testing individually, they are integrated. On integration, integration testing is performed to ensure that the functionality is not broken. A business Analyst should ensure that on integration, the modules continue to work as before.
Example: To ensure that both Components when integrated work correctly.

Performance testing
Many users often access the system at the same time. A good Business Analyst ensure that he thoroughly performs Performance Testing. Performance is measured in terms of response time to a particular request, number of requests that can be processed per second etc. We also need to ensure that the system can efficiently handle multiple user requests within a stipulated time.
Example: To test if the website works correctly even when 100 users login and try to access the website together.

Security testing
Security testing aims to provide protection or security to data in the system. It must eventually ensure that the data is kept highly secured and confidential and properly authenticated so as to ensure that the data is available at all times without affecting the content stored in it.
Example:  This tests the user ID and login is secured. No other user can misuse the credentials.

Database testing
The Database consists of data that your application dependent on. Thus the data stored is most often mission critical and an important asset of the organization. Database testing is performed on the database used in the application. A Business Analyst need not get into technicality but needs to make sure that the data is available accurately.
Example: A Business Analyst needs to ensure that if 10 trains are stored in the database, all of those are retrieved on the Booking page.

Functional testing
Regression testing is done on the changes made to the application to ensure that the older functionality works the same way. Test scenarios are prepared for regression testing and then the again the application is checked to ensure that it works properly. A business Analyst helps in generating various test scenarios.
Example: Functional testing is an essential part of the Business Analyst role; he must generate various possible test cases to make sure all possible situations are covered.

Most of us must have experiences that particular software did not work. The impact of faulty software can be huge considering that the organization may face loss of money, loss of time and a damaged reputation. A business analyst is responsible for the final product that is delivered; hence he must perform end to end business testing of a product.

About Author:
Shweta Samudra is a consultant in Systems Plus Pvt. Ltd. Within Systems Plus, she actively contributes to the areas of Technology and Information Security. She can be contacted at: shweta.samudra@spluspl.com

Tuesday 24 June 2014

Evolution of Outsourcing and Captive

Outsourcing

Outsourcing has been around for a long time now since the early seventies. Many companies back then realized of outsourcing most if their functions which were not their business needs. Payroll was one of the first functions being outsourced. One of the major company British Petroleum (BP) known to be a BPO giant started outsourcing their back office support services to the then Andersen Consulting (now known as Accenture). Outsourcing yielded many benefits if not all. This enabled you to leverage the experience of the service provider and improving the productivity and efficiency of your business processes. Outsourcing can be done onshore or to a remote location i.e. offshore. This was you can utilize some of your in-house resources to coordinate with the service provider remotely. Also some of the other advantages of outsourcing are – highly skilled labor available at low costs, improves productivity, saves your time from hiring new talent and the risks involved while running remote service centers.

Many service providers these days also offer hybrid solutions to your business which builds the synergy between your business needs and the overall IT alignment of your organization. Over time the outsourcing providers have matured and gradually started building generic operating models which can be used by any companies looking to improve their business. The operating model once established can also be helpful in captive engagements as well.

Captive

Captive maybe better known as Managed Captive since it gives control to the client to manage it. This is one of the sole reasons why many client organizations are switching from an outsourcing to a captive model. This makes them believe that they can build a low cost captive model when compared to their earlier outsourcing engagement. Since captive models offer greater amount of control over the operations, they can also be sure of any risks involved with offshoring their services. Captive is mostly setup at an offshore location where you setup a model the latest technology and infrastructure at a considerably lower cost. This is like owing a company offshore from where you have access broader geographies, for example Singapore, Poland, India. Captive allows complete control over these main functions – Finance, Resource, Operations and Governance. Captive ensure the following –
  1. Attract local talent for industry-specific skills
  2. IP protection
  3. Improves productivity & efficiency with 24/7 support
  4. Complete control over process management and operations
  5. Enhancing governance and service delivery
Some key drivers while building an operating model for both outsourcing and captive models –

Resource requisition
  1. Check company size – is the company big enough to leverage resources
  2. Scouting – do you access to local universities for recruitment of graduates?
  3. Retention – does your company provide sufficient career growth opportunities in an outsourcing or captive model?
  4. Advantage – Outsourcing service provider for offshore location. Captive can hold the same in onshore markets
Control Business processes
  1. Not everyone service provider gives you the entire control of your processes and operations
  2. Flexibility – check to see if the service provider is giving flexible enough to deliver or providing 24/7 support
  3. Documentation – check if you have access to the service provider’s documentation which can useful while transitioning the service delivery
  4. Advantage – Captive allows complete control and access while outsourcing engagement may not necessarily have it
Business best practices
  1. Here the service provider can leverage his experience from multiple clients to adopt best practices into your business delivery
  2. Improve resource skills and certifications like Lean/Six Sigma. Also make sure the service provider is an ISO 9000 certified professional
  3. Organization environment and work culture
  4. Advantage – The outsourcing provider usually has the advantage here
Technology and Infrastructure Setup
  1. This is an ongoing demand by the outsourcing provider to drive its productivity
  2. Latest technology systems or latest technology workflow tools integrated into the existing system
  3. Contingency planning and back up
  4. Advantage – Outsourcing provider
Outsourcing core
  1. Decide what are the services that you want to outsource whether they are the core business activities or the less business critical services like Payroll
  2. If the outsources business services are not core then it can most likely fall under a captive model
  3. Advantage – Depends on what you outsource
Governance and SLA’s
  1. Define service level agreements at the beginning of the engagement
  2. How will you track those – internal (service provider) or external (client)
  3. Benchmarking, monitoring and controlling the operations on a frequent basis
  4. Performance gauging – check if the service provider is doing its job according to the signed contract
  5. Governance activities to keep check on the current process and recommend any improvements in delivery model
  6. Advantage – Outsourcing provider
Outsourcing and captive are both effective business models when it comes to increasing efficiencies and reducing costs. Outsourcing helps you to outsource some of your non-core business functions while a captive model can act as a support function delivery model which is core to the business. A captive model can be at an onshore location or at remote geography depending upon the IT infrastructure potentially displaced employees. So these are some of the factors which you need to consider along with the company goals and vision, service delivery improvement in productivity and efficiency while choosing your appropriate operating model – outsource or captive.

About Author:
Rahil Khimani is consultant and part of Systems Plus Pvt. Ltd. He is a part of consulting team that delivers Sourcing and Vendor Management Office projects. He can be contacted at: rahil.khimani@spluspl.com

Monday 23 June 2014

SDLC V & W Model

V- Model means Verification and Validation model. Just like the waterfall model, the V-Shaped life cycle is a sequential path of execution of processes. Each phase must be completed before the next phase begins.

Under V-Model, the corresponding testing phase of the development phase is planned in parallel. So there are Verification phases on one side of the .V. and Validation phases on the other side. Coding phase joins the two sides of the V-Model.


The various phases of the V-model are as follows:

Requirements like BRS and SRS begin the life cycle model just like the waterfall model. But, in this model before development is started, a system test plan is created.  The test plan focuses on meeting the functionality specified in the requirements gathering.

The high-level design (HLD) phase focuses on system architecture and design. It provide overview of solution, platform, system, product and service/process. Anintegration test plan is created in this phase as well in order to test the pieces of the software systems ability to work together.

The low-level design (LLD) phase is where the actual software components are designed. It defines the actual logic for each and every component of the system. Class diagram with all the methods and relation between classes comes under LLD. Component tests are created in this phase as well.

The coding phase is, again, where all coding takes place. Once coding is complete, the path of execution continues up the right side of the V where the test plans developed earlier are now put to use.

Code: This is at the bottom of the V-Shape model. Module design is converted into code by developers.

Advantages of V-model:
  • Simple and easy to use.
  • Testing activities like planning, test designing happens well before coding. This saves a lot of time. Hence higher chance of success over the waterfall model.
  • Proactive defect tracking – that is defects are found at early stage.
  • Avoids the downward flow of the defects.
  • Works well for small projects where requirements are easily understood.
When to use the V-model:
  • The V-shaped model should be used for small to medium sized projects where requirements are clearly defined and fixed.
  • The V-Shaped model should be chosen when ample technical resources are available with needed technical expertise.
High confidence of customer is required for choosing the V-Shaped model approach. Since, no prototypes are produced, there is a very high risk involved in meeting customer expectations


The W Model removes the vague and ambiguous lines linking the left and right legs of the V and replaces them with parallel testing activities, shadowing each of the development activities.

As the project moves down the left leg, the testers carry out static testing (i.e. inspections and walkthroughs) of the deliverables at each stage. Ideally prototyping and early usability testing would be included to test the system design of interactive systems at a time when it would be easy to solve problems. The emphasis would then switch to dynamic testing once the project moves into the integration leg.

There are several interesting aspects to the W Model. Firstly, it drops the arbitrary and unrealistic assumption that there should be a testing stage in the right leg for each development stage in the left leg. Each of the development stages has its testing shadow, within the same leg.

The illustration shows a typical example where there are the same number of stages in each leg, but it's possible to vary the number and the nature of the testing stages as circumstances require without violating the principles of the model.

Also, it explicitly does not require the test plan for each dynamic test stage to be based on the specification produced in the twin stage on the left hand side. There is no twin stage of course, but this does address one of the undesirable by-products of a common but unthinking adoption of the V Model; a blind insistence that test plans should be generated from these equivalent documents, and only from those documents.

A crucial advantage of the W Model is that it encourages testers to define tests that can be built into the project plan, and on which development activity will be dependent, thus making it harder for test execution to be squeezed at the end of the project.

However, starting formal test execution in parallel with the start of development must not mean token reviews and sign-offs of the documentation at the end of each stage. Commonly under the V Model, and the Waterfall, test managers receive specifications with the request to review and sign off within a few days what the developers hope is a completed document. In such circumstances test managers who detect flaws can be seen as obstructive rather than constructive. Such last minute "reviews" do not count as early testing.

About Author:
Vinayak Jadhav is technology lead in Systems Plus Pvt. Ltd and keen to resolve challenges using his technical skills. He actively contributes to technology and can be contacted at: vinayak.j@spluspl.com

Friday 20 June 2014

Application Monitoring

Has anyone ever wondered about the various measures each business takes to ensure their products that are generating revenue and are not susceptible to fraud! Well, most of us would usually just test a product during purchase or immediately after its arrival to see the expected results, check for any discrepancies or defects and take action against the same.

Many Non-IT enterprises, like hotels are taking an extra step to ensure that the most critical application or feature is functioning the way it is supposed to even if it is not in daily use. For instance the entire top end hotels test their fire alarms daily so if any fire disaster occurs they are well prepared as it should be, else it would affect their reputation and affect the business. In this case devoting time and resources is considered as an investment and a duty that yields the expected results. Many of us either owning a big firm, owning a small business to being an end user or comprising of a support team, we barely take the necessary time out or invest in monitoring the performance and security of the applications we use in our business.

To initiate application monitoring tasks, respective teams or business units can have an opportunity to engage stakeholders in programs that can give in quantifiable risk mitigation values. Due to inherent challenges projects to implement Application Performance Monitoring and Application Security Monitoring needs to be undertaken for worthy efforts. The later part of this blog would provide an overview of application monitoring activities.

Application Security Monitoring
Moving the focus to applications, since they are the very susceptible to attacks and hacks from any corner of the world and every second there are security breaches to n number of businesses. Hackers now days are very organized and have gained momentum by their techniques that facilitate their combination of targets and the attacks to be unique. Hacking into organizations, criminal enterprises, and financial institutions is commonplace. None of the methods used are repetitive and are difficult to detect since it kills the purpose of the hacker to breach the security walls of your critical applications – in turn your business.

Application Performance Monitoring (APM)
Moreover the only solution to this is not just securing the perimeter but to have APM to detect and diagnose problems related to not fulfilling expected level of service of the application being used by the end users. APM literally means measuring the metrics mentioned in the Service Level Agreements (SLAs) defined by the organization or defined by the vendors in case of Software as a Service (SaaS) or as third-party applications.

Two important metrics that is strictly observed are:
  1. Load performance – depending upon the amount of transactions per second the application in encountered with will define bottlenecks and the inadequacy / adequacy to support the load.
  2. Response time performance – with respect to the above load or traffic encountered by the application the response that the user experiences is observed
All the above findings will help identify a baseline of the applications capacity to perform in different scenarios and if any attacks are taken place the deviation in the performance would help in notifying about the abnormalities.

Monitoring application performance is the critical and essential foremost line of defense against capturing all types of failures, right from configuration problems to security threats. By this means any events that unusual events are identified and reported that work as an early warning to take appropriate actions.

New generation of application monitoring should be dynamic, adaptable and agile; it should be able to create instances of applications on the fly and do its job and report the problems that have been captured, post which it should dissolve itself once the task is completed. All of this would help in gaining insights of the actual performance of the application and will support in defining a baseline for actual performance monitoring.


About Author:
Onkar Lalla is a Consultant and an important part of the Systems Plus Pvt. Ltd think tank. Within Systems Plus, he actively contributes to the areas of Technology and Information Security. He can be contacted at onkar.l@spluspl.com