Monday, September 30, 2019

Open a web page url by using Windows Task Scheduler

1. Task Scheduler in Windows

  • Write a VBS script, ex: schedule.vbs
  • Schedule the VBS script


Below the schedule.vbs content:

Call LogEntry()

Sub LogEntry()

        On Error Resume Next

        Dim objRequest
        Dim URL

        Set objRequest = CreateObject("Microsoft.XMLHTTP")
        URL = "http://www.your_website.com/filename.aspx"

        objRequest.open "POST", URL , false

        objRequest.Send

        Set objRequest = Nothing

End Sub

Just replace the URL variable by your url you want to call and then setup the Scheduled Tasks to run the VBS script at the time specified.

ASP.NET - Run .aspx page with Windows Task Scheduler

Here are steps to get started.


  • Write your VBS Script
  • Develop the webpage to process the HTTP Request 
  • Schedule the VBS Script
  • Write your VBS script


The script makes an HTTP request to a webpage on a timed basis. (i.e. every 5 minutes).

YourVBScript.vbs 
  Call LogEntry()
  Sub LogEntry()
     'Force the script to finish on an error.
     On Error Resume Next
     Declare variables
     Dim objRequest
     Dim URL
     Set objRequest = CreateObject("Microsoft.XMLHTTP")
     'Put together the URL link appending the Variables.
     URL = "http://www.YourDomain.com/Testlog.aspx"
     'Open the HTTP request and pass the URL to the objRequest object
     objRequest.open "POST", URL , false
     'Send the HTML Request
     objRequest.Send
     'Set the object to nothing
     Set objRequest = Nothing
 End Sub


Testlog.aspx webpage 

<%@ Page Language="VB" AutoEventWireup="false" codefile="Testlog.aspx.vb" Inherits="Testlog"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
     <head runat="server">
        <title>Log Page</title>
     </head>
          <body>
            <form id="form1" runat="server">
            <div></div>
            </form>
        </body>
</html>


Testlog.aspx.vb code behind 

Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Partial Class Testlog  Inherits System.Web.UI.Page
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          ‘Put your code in that would process when Testlog.aspx is request
           Response.write(“Testlog.aspx was called:” & System.DateTime.Now())
     End Sub
End Class


How to schedule a task using Windows Task Scheduler 
A scheduled task will allow a person to schedule any script, program, or document to run. Scheduled Tasks run at the time specified which could be multiple times per minute, hour, or day.

How to enable native XMLHTTP support in IE

To fix this issue the user will need to enable native XMLHTTP support by going to: 
Tools > Internet Options > Advanced, 
scrolling down to security and ticking the box next to Enable Native XMLHTTP Support, then click OK.
Enable XMLHTTP Support



If you do not see the advanced internet options, because you do not have the necessary administrator rights on your workstation, you need to contact your system administrator

Thursday, September 19, 2019

Difference and Definition of Library and Framework

The key difference between a library and a framework is "Inversion of Control". When you call a method from a library, you are in control. But with a framework, the control is inverted: the framework calls you.



  • A library is just a collection of class definitions. The reason behind is simply code reuse, i.e. get the code that has already been written by other developers. The classes and methods normally define specific operations in a domain specific area. For example, there are some libraries of mathematics which can let developer just call the function without redo the implementation of how an algorithm works.

  • In framework, all the control flow is already there, and there's a bunch of predefined white spots that you should fill out with your code. A framework is normally more complex. It defines a skeleton where the application defines its own features to fill out the skeleton. In this way, your code will be called by the framework when appropriately. The benefit is that developers do not need to worry about if a design is good or not, but just about implementing domain specific functions.

Thursday, September 12, 2019

How to Get Comma Separated values in SQL Server with STUFF

Select Distinct  STUFF(( 
  select Distinct ';'+ Name from tablename
 Name is not null and Emailaddress<>''
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'') Name 

Tuesday, September 10, 2019

jQuery: get the selected text as comma separated from select box



$('#<%=ddlCustomer.ClientID %>').change(function (event) {
                event.preventDefault(); 
                  var arr = $(this).val();
                    console.log(arr)
                    console.log(arr.join(", "));
                    $("#<%= hdnCustomerId.ClientID %>").val(arr.join(", "));  // 1,2,3,4,5
                  var option_all = $("select option:selected").map(function () {
                    return $(this).text();
                }).get().join(',');
                console.log(option_all);             
             $("#<%= hdnCustomerName.ClientID %>").val(option_all); // Test1,Test2,Test3,Test4,Test5
                return false;
            });