Run html using Visual Studio Code

This short blog show you how to run html in Visual Studio Code

1. Open the folder with the html you want to browse.

clip_image002

2. Open the Command Palette by choose View -> Command Palette then choose Tasks: Configure Task Runner.

clip_image004

3. Select Others.

clip_image006

4. Changed

{

    // See https://go.microsoft.com/fwlink/?LinkId=733558

    // for the documentation about the tasks.json format

    “version”: “0.1.0”,

    “command”: “echo”,

    “isShellCommand”: true,

    “args”: [“Hello World”],

    “showOutput”: “always”

}

to

{

    // See https://go.microsoft.com/fwlink/?LinkId=733558

    // for the documentation about the tasks.json format

   “version”: “0.1.0”, 

    “command”: “IE”, 

    “windows”: { 

        “command”: “explorer.exe”

    }, 

    “args”: [“index.html”],

    “showOutput”: “always”

}

clip_image008

5. Press Ctrl+Shift+B to view your html in browser.

Reference:

http://mikemengell.com/uncategorized/how-to-add-a-browser-to-task-runner-in-visual-studio-code/

Posted in .Net, Community, Computers and Internet | Tagged , , , , | Leave a comment

The domain is blocked due to content filtering

This short blog showing you a workaround to the problem “The domain is blocked due to content filtering” by OpenDNS.

I got 2 PCs at home hit by this error “The domain is blocked due to content filtering” when using OpenDNS. What surprised me was the webpage is http://www.msn.com/. This is cross-browser, all the IE, Edge, and Chrome.

 dnsissue

I have scanned the PC using Norton NPE, tdsskiller, Rkill, and Malwarebytes but I could not find anything.

What I can do for now is changed my PC DNS server to google 8.8.8.8 instead of OpenDNS.

Hope whatever sent to OpenDNS from the browser is harmless to the rest of the files. I am yet to find time to reinstall the Windows.

Posted in Community, Computers and Internet, Operating System | Tagged , , , , , | Leave a comment

Script Component Transformation in SSIS

This article shows you how to use Script Component in SSIS to transform a database column.

Assumption: You have at least Visual Studio 2013 with SQL Server Data Tool installed.

Scenario: Appending a “1” in all the product number and store in a new table.

1.      Create an Integration Services Project in Visual Studio 2015.

You can also use VS 2013

image

2.      Drag the Data Flow Task to the Control Flow.

image

3.      Double click the Data Flow Task. Drag the ADO.NET to Data Flow.

image

4.      Double click to data source to point to the database. In this example I used Northwind database.

image

image

image

5.      Drag the Script Component to Data Flow. Select Transformation then link the ADO.NET Source (blue color arrow) to it.

image

6.      Double click the Script Component to open the Script Transformation Editor.

7.      Create a Connection Managers. In this example, I name in DWConnection. You need to use this name in your code later.

 7

8.      In the Input Column I choose ProductID and ProductIDNew. I created another new column in the Products table. Realize two things here.

a.      The Usage Type for ProductIDNew is ReadWrite.

b.      The Input name is Input 0.

8

9.      Go to Script and click the Edit Script… button.

image

10.   Insert the code below.

#region Namespaces

using System;

using System.Data;

using System.Data.SqlClient;

using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

using Microsoft.SqlServer.Dts.Runtime.Wrapper;

#endregion

 

/// <summary>

/// This is the class to which to add your code.  Do not change the name, attributes, or parent

/// of this class.

/// </summary>

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]

public class ScriptMain : UserComponent

{

 

    IDTSConnectionManager100 connMgr;

    SqlConnection sqlConn;

    SqlCommand sqlCmd;

    SqlParameter sqlParam;

 

    public override void AcquireConnections(object Transaction)

    {

        connMgr = this.Connections.DWConnection;

        sqlConn = (SqlConnection)connMgr.AcquireConnection(null);

    }

 

    public override void PreExecute()

    {

        base.PreExecute();

        /*

         * Add your code here

         */

    }

 

    public override void PostExecute()

    {

        base.PostExecute();

        /*

         * Add your code here

         */

    }

 

    public override void Input0_ProcessInputRow(Input0Buffer Row)

    {

        /*

         * Add your code here

         */

        string strTemp = Row.ProductID.ToString();

        strTemp = strTemp + “1”;

        Row.ProductIDNew = int.Parse(strTemp);

    }

 

}

 

11.   Save and close the script editor.

12.   Drag ADO.NET Destination to Data Flow.

13.   Connect the Script Component to ADO.NET Destination.

14.   Configure the ADO.NET Destination to point to the destination table (for this example the Products2 table structure is the same as the Products1 tables, these are the tables that I created beforehand).

15.   Mapping the columns.

image

image

Now you can test the project (click Start).

 15

 16

Posted in .Net, Community, Computers and Internet | Tagged , , , , , | Leave a comment

var keywrod in C#

Once upon the time there is a group of .NET developer just want to use var to declare all the variable.

MSDN has written “Beginning in Visual C# 3.0, variables that are declared at method scope can have an implicit type var. An implicitly typed local variable is strongly typed just as if you had declared the type yourself, but the compiler determines the type.” So if you read the code without the compiler then you need to use your best guess to guess what data the var is.

There is one new refactor feature in Visual Studio 2017. The feature suggest that Use explicit type instead of ‘var’, cool feature.

clip_image002

Posted in .Net, Cloud, Community | Tagged , , , , , , , , | Leave a comment

The SSL certificate is signed by an unknown certificate authority

This short blog shows you one of the ways to resolve the error “The SSL certificate is signed by an unknown certificate authority”.

When I tried to do a deployment from Visual Studio Release Management to Windows Azure then I got the error:

The server certificate on the destination computer (callcenter-prod.cloudapp.net:5986) has the following errors: The SSL certificate is signed by an unknown certificate authority.

Your machine name could be different but most likely your port will be 5986 if you did not change it.

You can see my picture below has two successes that is because I have resolve the error or else the second row for the deployment will failed.

clip_image002

 

In order to resolve this I can only use Google Chrome to get the certificate from my Windows Azure VM and install it in Trusted Root Certification Authorities of the server you are running the Release Management tool.

For this example, open your google chrome browser https://callcenter-prod.cloudapp.net:5986. Click on the Padlock icon then the certificate will drop down. Save the certificate and install it as in the reference link.

clip_image003

 

 

Reference:

https://blogs.endjin.com/2014/03/a-step-by-step-guide-to-connecting-to-an-azure-virtual-machine-with-powershell-remoting/

Posted in .Net, Cloud, Community | Tagged , , , , | Leave a comment

Sharing Office Add-ins using Shared File

The blog shows you how to share Office Add-ins using Shared File option instead of have to use Visual Studio everything when you want to use your Office Add-ins.

The one who are reading this should have already known following:

1. Create a Web Application in IIS Website.

2. Share a folder using Windows Explorer.

3. Installed Excel 2016.

You must first create an Office Add-ins https://chanmingman.wordpress.com/2016/07/31/how-to-create-office-add-ins-for-cross-platform/.

Create a Web Application in IIS Website.

 1

Open your Office Add-ins solution then you should have 2 projects. Publish your Web project to IIS Web Application, for example, officeapp.

2

Open the. Double click the Manifest file in your project. I point my url to my Web Application, for example, http://localhost:8082/officeapp/addin/home/home.html.

 3

Now in Visual Studio select Build -> Deploy Build.

4

You should now see a folder, for example, OfficeAddIn1Manifest under your Manifest project folder.

Copy all the files into the same folder where the home.html is located.

Share the folder with Change permission. Here I use officeapp.

5

If you open your Excel go to Insert Tab and click Store then you will not see SHARED FOLDER tab available.

6

Go to File -> Options  -> Trust Center -> Trust Center Setting… -> Trust Add-in Catalog. Put in the url, for example, \\WIN-6Q4CPR3O6CC\officeapp\AddIn\Home. Click  Add catalog and check Show in Menu checkbox. (Ignore the http there, it still does not work for me).

 7

Click OK and restart your Excel. You should see SHARED FOLDER and the Office Add-in now when you click on the Insert Tab and select Store.

8

Posted in .Net, Cloud, Community, Microsoft Office | Tagged , , , , , | Leave a comment

Binary Search in C#

This short blog contents the code snippet for Binary Search in C#.

The code below has been converted from the Binary Search for Java code https://www.geekboots.com/java/binary-search.

using System;

using System.Collections.Generic;

 

namespace ConAppBinarySearch

{

    class search

    {

        search(int[] list, int srchdata)

        {

 

            /* ‘min’ use for starting location of the array, ‘max’ use for end location of the array and ‘mid’ use for middle location of the array */

            int min = 0;

            int max = list.Length – 1;

            int mid = (min + max) / 2;

            while (min <= max)

            {

                if (list[mid] < srchdata)

                    min = mid + 1;

                else if (list[mid] == srchdata)

                {

                    Console.WriteLine(srchdata + ” is found at location “ + (mid + 1));

                    break;

                }

                else

                    max = max – 1;

                mid = (max + min) / 2;

            }

            if (min > max)

                Console.WriteLine(srchdata + ” not found on the list!”);

        }

 

        class Program

        {

            static void Main(string[] args)

            {

                /* For binary search, the array should be arranged in ascending or descending order */

                int[] list = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

 

                Console.WriteLine(“Enter an number to search:”);

                new search(list, int.Parse(Console.ReadLine()));

            }

        }

    }

}

Posted in .Net, Community | Tagged , , , , | Leave a comment