Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

Angular.js Hosting UK - HostForLIFE.eu :: Create Web Workers In Angular

clock February 14, 2020 08:29 by author Peter
In this article, we'll learn how to use web workers in Angular 8/9.

Web Workers
Web workers speed up in your application when we start working on CPU-intensive tasks. They let you offload work to a background thread. Once we allow a web worker to run, we can use it normally in our application, and the Angular cli will be able to split bundle and code.

The Following Browser versions which are supported in web workers:

  • Firefox: 3.5
  • Chrome: 4
  • Safari: 4
  • IE:10
  • Opera: 10.6

Installing AngularCLI
Let’s get started by installing Angular CLI, which is the official tool for creating and working with Angular projects. Open a new terminal and run the below command to install Angular CLI.

npm install -g @angular/cli.

If you want to install Angular 9, simply add @next
npm install --g @angular/cli@next

Please check the below command for the Angular version.
ng version

Steps to follow:
Step 1
Create an Angular project setup using the below command or however you want to create it.
ng new projectname
 
Example,
ng new webworker

Step 2
Now, we must generate web workers from our Angular cli. Open a new terminal and run the below command.
ng generate webWorker my-worker
 
Create Web Workers In Angular 8/9
 
Step 3
Now, Create a Web Worker Object in App.component.ts(main scripts)
    const worker = new Worker ('./my-worker.worker', {type: 'module'});  

We can do some code in App.component.ts (main scripts)
    if (typeof Worker !== 'undefined') { 
        // Create a new 
        const worker = new Worker('./my-worker.worker', { 
            type: 'module' 
        }); 
        worker.onmessage = ({ 
            data 
        }) => { 
            console.log(`page got message: ${data}`); 
        }; 
        worker.postMessage('welcome'); 
    } else { 
        console.log('Web Workers are not supported in this environment.'); 
        // Web Workers are not supported in this environment. 
        // You should add a fallback so that your program still executes correctly. 
    } 


Step 4
Now, we can do some code in my-worker.worker.ts
    addEventListener('message', ({ 
        data 
    }) => { 
        const response = `worker response to ${data}`; 
        postMessage(response); 
    });  

    Web Workers are supported in the browser
    Create a new worker (main scripts).
    Post message to the worker in my-worker.worker.ts.
    When the worker gets the message, addEventListener will fire, and it will create a response to the object then it will call postMessage method.

Step 5
Now, run the application.
npm start

Step 6
Now, we will get the following output,



Drupal 8.8.1 CMS Hosting - HostForLIFE.eu :: How to Create an Image Style Programatically from Module

clock January 30, 2020 11:26 by author Peter

Today, I'm gonna tell you how to create an image style programatically from Drupal Module. You can use this in a .install file to create the needed image style when the module is installed.

The code below will allow you to create an image style from within a module programatically:

<?php
  $style = image_style_save(array('name' => 'avatar'));
  $effect = array(
    'name' => 'image_scale',
    'data' => array(
      'width' => 64,
      'height' => 64,
      'upscale' => TRUE,
    ),
    'isid' => $style['isid'],
  );
  image_effect_save($effect);
?>

This code below shows how to remove the image style:

<?php
  image_style_delete(image_style_load('avatar'));
?>

Hope this will works for you.

Drupal CMS with Free ASP.NET Hosting
Try our Drupal CMS with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.



Ajax Hosting UK - HostForLIFE.eu :: How to call ASP.NET Page Method using jQuery AJAX ?

clock January 21, 2020 11:25 by author Peter

jQuery may be a powerful JavaScript library that permits you to call ASP.NET page method directly without any postback. you can call page method while not involving ScriptManager at all.

Creating page method:
First we've got to make page method, it ought to be declared as static with the [WebMethod] attribute.    [WebMethod]
    public static string GetDate()
    {
        return DateTime.Now.ToString();
    }

jQuery.ajax method:
           $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Default.aspx/MethodName",
                    data: "{}",
                    dataType: "json",
                    success: function (msg) {
                       //do something
                    }
                });

Type: the type of request the type ("POST" or "GET")
URL: A string containing the URL to that the request is sent.
ContentType: By default we've got to use "application/x-www-form-urlencoded; charset=UTF-8", when we sending information to server we've got to use this content type, that is okay for many cases.
Data: data send to be server, if data isn't a string it’ll be converted to query string.
DataType: the type of data that you are expecting back from the server.

Source code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery AJAX call</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // Add the page method call as an onclick handler for the div.
            $('#btnGetTime').click(function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Default.aspx/GetDate",
                    data: "{}",
                    dataType: "json",
                    success: function (msg) {
                        alert('Current Time is ' + msg.d);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="button" id="btnGetTime" value="Get Time" />
    </div>
    </form>
</body>
</html>

C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    [WebMethod]
    public static string GetDate()
    {
        return DateTime.Now.ToString();
    }
}

Output:

HostForLIFE.eu AJAX Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



DotNetNuke Hosting - HostForLIFE.eu : Forgot Your DNN Password?

clock December 5, 2019 11:47 by author Peter

I found myself having to access as administrator a site built with DotNetNuke Hosting without knowing the password or being able to reach the person who created it. What was I to do?

 

1. Create a new website (I am using C# here) in Visual Studio

2. Inside the web.config file, add the machineKey tag and provide “validationKey” and “decryptionKey” as found from web.config file of your running DNN site using which passwords are stored. (The keys provided here will work with the password as given in step)

<machineKey validationKey="5D47DA8BBE8C9D02378BC3360FD6724A43C69016" decryptionKey="F5292CB499D6A71955A7B389BFBF3712D0A48D1971DEE889" decryption="3DES" validation="SHA1" >

3. Create a new class and name it, “RecoverPassword.cs”

 using System; 
 using System.Configuration.Provider; 
 using System.Text; 
 using System.Web.Security; 
 public class RecoverPassword : MembershipProvider { 
   //Create a static instance of this class as a singelton  
   private static readonly RecoverPassword _instance = new RecoverPassword(); 
   public override MembershipPasswordFormat PasswordFormat { 
     get { 
       return MembershipPasswordFormat.Encrypted; 
     }   
   }  
   public static string RecoverEncryptedString(string target)   
   {     
     try     
     {       
       // Decode the password in Base64       
       byte[] data = Convert.FromBase64String(target); 
       //Get advantage of the DecryptPassword method 
       byte[] decryptedPassword = _instance.DecryptPassword(data); 
       string encodedPassword = Encoding.Unicode.GetString(decryptedPassword); 
       // Remove the salt value prepended to the value 
       // Salt value doesn''t do anything more than being appended to thte password string, just strip it out 
       return encodedPassword.Substring(8); 
     } 
     catch (ProviderException ex) 
     { 
       throw ex; 
     } 
   } 
   public override string ApplicationName 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
     set 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool ChangePassword(string username, string oldPassword, string newPassword) { 
     throw new NotImplementedException(); 
   } 
   public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string 
 newPasswordAnswer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, 
 bool isApproved, object providerUserKey, out MembershipCreateStatus status) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool DeleteUser(string username, bool deleteAllRelatedData) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool EnablePasswordReset 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool EnablePasswordRetrieval 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int GetNumberOfUsersOnline() 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(string username, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetUserNameByEmail(string email) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int MaxInvalidPasswordAttempts 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredNonAlphanumericCharacters 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredPasswordLength 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int PasswordAttemptWindow 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string PasswordStrengthRegularExpression 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresQuestionAndAnswer 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresUniqueEmail 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string ResetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool UnlockUser(string userName) 
   { 
     throw new NotImplementedException(); 
   } 
   public override void UpdateUser(MembershipUser user) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool ValidateUser(string username, string password) 
   { 
     throw new NotImplementedException(); 
   } 
 }

4. Copy paste the following code inside the above created class. This way we inherit our class from aspnet membership provider pattern class and thus will use its decryption procedure to decrypt the passwords. If you want to do that manually, do remember that Ctrl+K+M is a nice shortcut to implement base class methods which saves quite an effort from your end.

 using System; 
 using System.Configuration.Provider; 
 using System.Text; 
 using System.Web.Security; 
 public class RecoverPassword : MembershipProvider { 
   //Create a static instance of this class as a singelton  
   private static readonly RecoverPassword _instance = new RecoverPassword(); 
   public override MembershipPasswordFormat PasswordFormat { 
     get { 
       return MembershipPasswordFormat.Encrypted; 
     }   
   }  
   public static string RecoverEncryptedString(string target)   
   {     
     try     
     {       
       // Decode the password in Base64       
       byte[] data = Convert.FromBase64String(target); 
       //Get advantage of the DecryptPassword method 
       byte[] decryptedPassword = _instance.DecryptPassword(data); 
       string encodedPassword = Encoding.Unicode.GetString(decryptedPassword); 
       // Remove the salt value prepended to the value 
       // Salt value doesn''t do anything more than being appended to thte password string, just strip it out 
       return encodedPassword.Substring(8); 
     } 
     catch (ProviderException ex) 
     { 
       throw ex; 
     } 
   } 
   public override string ApplicationName 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
     set 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool ChangePassword(string username, string oldPassword, string newPassword) { 
     throw new NotImplementedException(); 
   } 
   public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string 
 newPasswordAnswer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, 
 bool isApproved, object providerUserKey, out MembershipCreateStatus status) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool DeleteUser(string username, bool deleteAllRelatedData) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool EnablePasswordReset 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool EnablePasswordRetrieval 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int GetNumberOfUsersOnline() 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(string username, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetUserNameByEmail(string email) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int MaxInvalidPasswordAttempts 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredNonAlphanumericCharacters 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredPasswordLength 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int PasswordAttemptWindow 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string PasswordStrengthRegularExpression 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresQuestionAndAnswer 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresUniqueEmail 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string ResetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool UnlockUser(string userName) 
   { 
     throw new NotImplementedException(); 
   } 
   public override void UpdateUser(MembershipUser user) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool ValidateUser(string username, string password) 
   { 
     throw new NotImplementedException(); 
   } 
 } 

5. Your default.ascx.cs file must be like this (Change the password in Page_Load with the password you want to decipher):

 using System; 
 public partial class _Default : System.Web.UI.Page { 
   protected void Page_Load(object sender, EventArgs e)     
   { 
      //This password can be obtained from the DNN''s table aspnet_Membership column "Password"    
      //Or you can query ther datbase row and call decryption method for each user    
      string password = "vhicPWw3Eo/+z+mrKM5ZQCIcURj1O5Cq9Epw942lfpmsDPagupzLGw=="; 
     //Call our inherited class to get Decrypted Password    
     string recoveredPassword = RecoverPassword.RecoverEncryptedString(password); 
     //Write down the decrypted password       
    Response.Write(recoveredPassword);  
   } 
 } 

6. Right click > View in Browser and the password is decrypted on a fly.



European Visual Studio 2017 Hosting - HostForLIFE.eu :: Drawing rubber-band lines and shapes in VB.NET

clock November 13, 2019 08:29 by author Peter

The lack of XOR Drawing feature in GDI+ was not certainly welcome in the programmer's community.

 

I guess it will be hard to survive with this handicap. In spite of this, I would like to show how we can draw rubber-band lines and shapes in GDI+ with just a few lines of code.

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
    Dim size As Size = SystemInformation.PrimaryMonitorMaximizedWindowSize 
    bitmap = New Bitmap(size.Width, size.Height) 
    gB = Graphics.FromImage(bitmap) 
    Dim bckColor As Color = Me.BackColor 
    gB.Clear(bckColor) 
    End Sub 
    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs) 
    Dim p As Point = New Point(e.X, e.Y) 
    x0 = p.X 
    y0 = p.Y 
    drag = True 
    End Sub 
    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs) 
    Dim p As Point = New Point(e.X, e.Y) 
    x= p.X 
    y = p.Y 
    Dim cx As Integer = x - x0 
    Dim cy As Integer = y - y0 
    If drag Then 
    Dim gx As Graphics = CreateGraphics() 
    gx.DrawImage(bitmap, 0, 0) 
    gx.Dispose() 
    Dim g As Graphics = CreateGraphics() 
    Dim pen As Pen = New Pen(Color.Blue) 
    Select Case DrawMode 
    Case 1 
    g.DrawLine(pen, x0, y0, x, y) 
    Exit Select 
    Case 2 
    g.DrawEllipse(pen, x0, y0, cx, cy) 
    Exit Select 
    Case 3 
    g.DrawRectangle(pen, x0, y0, cx, cy) 
    Exit Select 
    End Select 
    g.Dispose() 
    pen.Dispose() 
    End If 
    End Sub 
    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs) 
    Dim cx As Integer = x - x0 
    Dim cy As Integer = y - y0 
    Dim pen As Pen = New Pen(Color.Blue) 
    Select Case DrawMode 
    Case 1 
    gB.DrawLine(pen, x0, y0, x, y) 
    Exit Select 
    Case 2 
    gB.DrawEllipse(pen, x0, y0, cx, cy) 
    Exit Select 
    Case 3 
    gB.DrawRectangle(pen, x0, y0, cx, cy) 
    Exit Select 
    End Select 
    drag = False 
    pen.Dispose() 
    End Sub 
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.PaintEventArgs) 
    Dim gx As Graphics = CreateGraphics() 
    gx.DrawImage(bitmap, 0, 0) 
    gx.Dispose() 
    End Sub 
    Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)button1.ForeColor = Color.Red 
    button2.ForeColor = Color.Black 
    button3.ForeColor = Color.Black 
    DrawMode = 1 
    End Sub 
    Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    button2.ForeColor = Color.Red 
    button1.ForeColor = Color.Black 
    button3.ForeColor = Color.Black 
    DrawMode = 2 
    End Sub 
    Private Sub button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    button3.ForeColor = Color.Red 
    button1.ForeColor = Color.Black 
    button2.ForeColor = Color.Black 
    DrawMode = 3 
    End Sub 
    Private Sub panel1_Paint(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.PaintEventArgs) 
    button1.ForeColor = Color.Red 
    button1.Focus() 
    End Sub

 



Crystal Report Hosting - HostForLIFE.eu :: BackgroundWorker and Crystal Reports

clock September 12, 2019 12:22 by author Peter

I have a DBClass that is responsible for executing database queries and SPs.


Here is the code snippet that shows how to use a background thread to get data and generate reports. This is useful when the main thread of your applications is doing something else, data entry and you want reports to be generated in the background.
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using System.Threading; 
namespace myCryst 

    public partial class Form1 : Form 
    { 
        DataSet ds; 
        frmCryst f = new frmCryst(); 
        public Form1() 
        { 
            InitializeComponent(); 
        } 
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e) 
        { 
            bgWorker.ReportProgress(10); 
            Thread.Sleep(164); 
            bgWorker.ReportProgress(20); 
            Thread.Sleep(164); 
            bgWorker.ReportProgress(30); 
            Thread.Sleep(164); 
            ds = DBClass.ExecQuery("select * from students"); 
            bgWorker.ReportProgress(40); 
            Thread.Sleep(164); 
            bgWorker.ReportProgress(50); 
            Thread.Sleep(164); 
            bgWorker.ReportProgress(70); 
            Thread.Sleep(164); 
            bgWorker.ReportProgress(95); 
            Thread.Sleep(164); 
            bgWorker.ReportProgress(100); 
        } 
        private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) 
        { 
            this.progressBar1.Value = e.ProgressPercentage; 
        } 
        private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 
        { 
            showCrystalReport(); 
        } 
        private void button1_Click(object sender, EventArgs e) 
        { 
            bgWorker.ProgressChanged += new ProgressChangedEventHandler(bgWorker_ProgressChanged); 
            bgWorker.WorkerReportsProgress = true; 
            bgWorker.RunWorkerAsync(); 
        } 
        private void showCrystalReport() 
        { 
            CrystalReport1 c = new CrystalReport1(); 
            Reportds d = new Reportds(); 
            d.Tables[0].Merge(ds.Tables["tab"]); 
            frmCryst f = new frmCryst(); 
            c.SetDataSource(d); 
            f.crystRep.ReportSource = c; 
            f.Show(); 
        } 
        private void button2_Click(object sender, EventArgs e) 
        { 
            Application.Exit(); 
        } 
    } 
}



AngularJS with Free ASP.NET Hosting - HostForLIFE.eu :: AngularJS: $http

clock August 21, 2019 12:35 by author Peter

In this tutorial, I will tell you about $http in AngularJS. I am gonna show you AngularJS Basic Filters. $http is a service for reading data from web services. It will use get (service URL) method for the process. Now, write the following code:

<div ng-app="httpApp" ng-controller="httpController"> 
     <ul> 
        <li ng-repeat="det in details">{{ det.name + ', ' + det.countrycode }} 
</li> 
    </ul> 
</div>

In the below code, we've an Angular app httpApp and a controller httpController. currently we want to make our controller part, right?
    < script > 
    var app = angular.module('httpApp', []); 
    app.controller('httpController', function($scope, $http) {          $http.get("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=- 22.4&west=55.2&lang=de&username=demo") 
            .success(function(response) { 
            $scope.details = response.geonames; 
        }); 
    }); < /script> 


In the preceding code we are using the $http.get() technique of Angular. within the url part we've got given a sample web service url of geo data. you'll get these free net services here. So within the success part we tend to are returning the response of the web service. Now if you write the response.geonames within the success in the browser console as follows, you'll get the array as shown on the following code:

console.log(response.geonames); 

Once it is returned we are showing the response data to the UI using the repeat directive.
And here is the complete HTML
    <!DOCTYPE html> 
    <html 
        xmlns="http://www.w3.org/1999/xhtml"> 
        <head> 
            <title>Angular $http</title> 
            <style> 
             li { 
                border: 1px solid #ccc; 
                border-right: none; 
                border-left: none; 
                padding: 2px; 
                text-align: center; 
                list-style:none; 
              }  
             </style> 
            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> 
       </head> 
        <body> 
            <div ng-app="httpApp" ng-controller="httpController"> 
                <ul> 
                    <li ng-repeat="det in details">{{ det.name + ', ' + det.countrycode }} </li> 
                </ul> 
            </div> 
           <script>  
                var app = angular.module('httpApp', []); 
                app.controller('httpController', function ($scope, $http) { 
                $http.get("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=peter") 
                .success(function (response) {  
                   $scope.details = response.geonames;  
                   console.log(response.geonames); 
                   }); 
             }); 
             </script> 
        </body> 
    </html> 


You can add the following CSS to your page.
    < style > li { 
        border: 1px solid#ccc; 
        border - right: none; 
        border - left: none; 
        padding: 2px; 
        text - align: center; 
        list - style: none; 
    } < /style>

AngularJS with Free ASP.NET Hosting

Try our AngularJS with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.



SQL Server 2019 Hosting Europe - HostForLIFE.eu :: Create and Schedule a Job in SQL Server

clock August 16, 2019 09:27 by author Peter

In this article, you will learn how to create a new job and schedule that job for execution in SQL Server. What is a SQL Job? A job is a specified series of actions that SQL Server Agent performs. Use jobs to define an administrative task that can be run one or more times and monitored for success or failure. A job can run on one local server or on multiple remote servers. Some examples of SQL Jobs are automatic weekly backup, sending auto emails, newsletters, writing log files, and audit logs.


First of all, start SQL Server 2008 Management Studio. Expand Databases node and select a database you want to use to create and schedule a job from.

Image 1.
For this database I am going to create a job and schedule that job.

Now click on SQL Server agent and select "Jobs" and right-click and click on "New Job".

Image 2.

As you can see there are many steps, so let's go one by one. First provide a job name and description and click "OK".
General Tab


Image 3.

Now click on "Next". The step name is Steps and provides a name, type and select database and write a command to save in a location and click "OK".
Steps Tab

Image 4.

Now click on the "Schedules" tab and provide name, type, frequency and click "OK".
Schedules Tab

Image 5.

Now click on the alerts tab and click on the "Add" button and provide alert name, type, database name and click "Ok".
Alerts Tab

Image 6.

Now click on the notifications tab and select how you want notifications.
Notifications Tab

Image 7.

The final tab is the "Targets" tab that shows you the options of the target server, you can also select multiple target servers.
Targets Tab

Image 8.
Summary
In this article, we learned how to setup and schedule a job in SQL Server.

HostForLIFE.eu SQL Server 2019 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



SQL Server 2019 Hosting Europe - HostForLIFE.eu :: Introduction To SQL And SQL Commands

clock July 31, 2019 12:27 by author Peter

SQL

SQL stands for Structured Query Language. SQL is used to create, remove, alter the database and database objects in a database management system and to store, retrieve, update the data in a database. SQL is a standard language for creating, accessing, manipulating database management system. SQL works for all modern relational database management systems, like SQL Server, Oracle, MySQL, etc.

Different types of SQL commands
SQL commands can be categorized into five categories based on their functionality.

DDL
DDL stands for data definition language. DDL commands are used for creating and altering the database and database object in the relational database management system, like CREATE DATABASE, CREATE TABLE, ALTER TABLE, etc. The most used DDL commands are CREATE, DROP, ALTER, and TRUNCATE.
    CREATE
    CREATE command is used to create a database and database object like a table, index, view, trigger, stored procedure, etc.

    Syntax
    CREATE TABLE Employee (Id INT, Name VARHCAR (50), Address VARCHAR (100));

    ALTER
    ALTER command is used to restructure the database object and the settings in the database.

    Syntax
    ALTER TABLE Employee ADD Salary INT;

    TRUNCATE
    TRUNCATE command is used to remove all the data from the table. TRUNCATE command empties a table.

    Syntax
    TRUNCATE TABLE Employee;

    DROP
    DROP command is used to remove the database and database object.

    Syntax
    DROP TABLE Employee;

DML
DML stands for data manipulation language. DML commands are used for manipulating data in a relational database management system. DML commands are used for adding, removing, updating data in the database system, like INSERT INTO TableName, DELETE FROM TableName, UPDATE tableName set data, etc. The most used DML commands are INSERT INTO, DELETE FROM, UPDATE.
    INSERT INTO
    INSERT INTO command is used to add data in the database table.

    Syntax
    INSERT INTO Employee (Id, Name, Address, Salary) VALUES (1, ‘Arvind Singh’, ‘Pune’, 1000);

    UPDATE
    UPDATE command is used to update data in the database table. A condition can be added using the WHERE clause to update a specific row.

    Syntax
    UPDATE Employee SET Address = ‘Pune India’, Salary = 100 WHERE Id =1;

    DELETE
    DELETE command is used to remove data from the database table. A condition can be added using the WHERE clause to remove a specific row which meets the condition.

    Syntax
    DELETE FROM Employee WHERE Id =1;

DQL
DQL stands for data query language. DQL command is used for fetching the data. DQL command is used for selecting data from the table, view, temp table, table variable etc. There is only one command under DQL which is the SELECT command.

Syntax
SELECT * FROM Employee;

DCL
DCL stands for data control language. DCL commands are used for providing and taking back the access rights on the database and database objects. DCL command used for controlling user’s access on the data. Most used DCL commands are GRANT and REVOKE.

GRANT
GRANT is used to provide access right to user.

Syntax
GRANT INSERT, DELETE ON Employee TO user;

REVOKE
REVOKE command is used to take back access right from the user, it cancels access right of the user from the database object.

Syntax
REVOKE ALL ON Employee FROM user;

TCL
TCL stands for transaction control language. TCL commands are used for handling transactions in the database. Transactions insure data integrity in the multi user environment. TCL commands can rollback and commit data modification in the database. The most used TCL commands are COMMIT, ROLLBACK, SAVEPOINT, and SET TRANSACTION.

COMMIT
COMMIT command is used to save or apply the modification in the database.

ROLLBACK
ROLLBACK command is used to undo the modification.

SAVEPOINT

SAVEPOINT command is used to temporarily save a transaction, the transaction can roll back to this point when it's needed.

Syntax
Just write COMMIT or ROLLBACK or SAVEPOINT;

HostForLIFE.eu SQL Server 2019 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



SQL Server 2019 Hosting Europe - HostForLIFE.eu :: Triggers In SQL Server

clock July 19, 2019 09:07 by author Peter

A SQL trigger is a database object just like a stored procedure or we can say it is a special kind of Stored Procedure that automatically fires when an event occurs in a database. Learn what is a trigger in SQL Server and how to create triggers on a database table. A SQL trigger is a database object just like a stored procedure, or we can say it is a special kind of stored procedure which fires when an event occurs in a database. We can execute a SQL query that will "do something" in a database when an event is fired.

For example, a trigger can be set on a record insert in a database table. For example, if you want to increase the number of count of blogs in the Reports table when a new record is inserted in the Blogs table, we can create a trigger on the Blogs's table on INSERT and update the Reports table by increaing blog count to 1.

Difference Between a Stored Procedure and a Trigger
Triggers are fired implicitly while stored procedures are fired explicitly.

Types of Triggers
There are two types of triggers:

  • DDL Trigger
  • DML Trigger

DDL Triggers
The DDL triggers are fired in response to DDL (Data Definition Language) command events that start with Create, Alter and Drop, such as Create_table, Create_view, drop_table, Drop_view and Alter_table.

Code of a DDL Trigger
create trigger saftey 
on database 
for 
create_table,alter_table,drop_table 
as 
print'you can not create ,drop and alter table in this database' 
rollback;


When we create, alter or drop any table in a database then the following message appears:

DML Triggers
The DML triggeres are fired in response to DML (Data Manipulation Language) command events that start with with Insert, Update and Delete. Like insert_table, Update_view and Delete_table.
    create trigger deep 
    on emp 
    for 
    insert,update,delete 
    as 
    print'you can not insert,update and delete this table i' 
    rollback;


When we insert, update or delete in a table in a database then the following message appears,
dml-triggers-in-sql.jpg
There are two types of DML triggers

AFTER Triggers
AFTER triggers are executed after the action of an INSERT, UPDATE, or DELETE statement.
    create trigger insertt 
    on emp 
    after insert 
    as 
    begin 
    insert into empstatus values('active') 
    end  


INSTEAD Of Triggers
It will tell the database engine to execute the trigger instead of executing the statement. For example an insert trigger executes when an event occurs instead of the statement that would insert the values in the table .

    CREATE TRIGGER instoftr 
    ON v11 
    INSTEAD OF INSERT 
    AS 
    BEGIN 
    INSERT INTO emp 
    SELECT I.id, I.names 
    FROM INSERTED I 
      
    INSERT INTO emp1values 
    SELECT I.id1, I.name1 
    FROM INSERTED I 
    END  

When we insert data into a view by the following query then it inserts values in both tables :
    insert into v11 values(1,'d','dd') 

You can see both tables by the folowing query:
    select * from emp 
    select * from emp1values 

HostForLIFE.eu SQL Server 2019 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in