Posts
18
Comments
59
Trackbacks
0
Monday, July 18, 2016
AngularJS2 on ASP.Net Core using TypeScript Part 3 - Attribute Directives

 

Previously we started creating our seed project then we created our first AngularJS2 app, on this post we will try to play with AngularJs2’s Attribute Directives.

Basically, Attribute Directives allows us to change the appearance or behavior of a DOM Element, such us changing colors of DIVS when our mouse enters or exits, or alter the behavior of a DOM element when clicking them.

 

For this Post, We will use the current state of the project we used on our last post, you can go back to my previous posts if you still haven't done so.

AngularJS2 on ASP.Net Core using TypeScript Part 1
AngularJS2 on ASP.Net Core using TypeScript Part 2

Target Output

image

 

Table of Procedures

1. Update main.scss
2. Create app.component.html
3. Create highlight.directive.ts
4. Update app.component.ts
5. Test our Application

 

Procedures

1. Update main.scss

First, We need to add a base class for our boxes.

$font-stack: Arial, Helvetica, sans-serif;
$primary-color: #336699;
$font-size:250%;
$margin:2em;

h1 {
  font: $font-size $font-stack;
  color: $primary-color;   
}

body {
      margin: $margin;
}

.boxes {
    display: inline-block;
    position: relative;
    float: left;
    margin: 10px;   
    width: 100px;
    height: 100px;
    text-align: center;
    vertical-align: middle;
    line-height: 100px; 
    border: 1px #000000 solid;
}

 

2. Create app.component.html

On our last project we hardcoded our HTML code on our component’s template property,

image

For this project we will use an external html file as a template, first create a HTML File under wwwrooot\app\, let’s name this file app.component.html.

Copy and paste the codes below, for now take note of [myHighlight]="color" and [defaultColor]="'violet'". We will get these values from our components once we created our custom Directive.

<h1>Welcome to the world of Directives</h1><br />
<div>
    <input type="radio" name="colors" (click)="color='lightgreen'">Green
    <input type="radio" name="colors" (click)="color='yellow'">Yellow
    <input type="radio" name="colors" (click)="color='cyan'">Cyan
</div>

<div class="boxes" [myHighlight]="color">Apple</div>
<div class="boxes" [myHighlight]="color">Bat</div>
<div class="boxes" [myHighlight]="color" [defaultColor]="'violet'">Cat</div>
<div class="boxes" [myHighlight]="color" [defaultColor]="'violet'">Dog</div>
<div class="boxes" [myHighlight]="color" [defaultColor]="'violet'">Elephant</div>
<div class="boxes" [myHighlight]="color" [defaultColor]="'violet'">Frog</div>
<div class="boxes" [myHighlight]="color" [defaultColor]="'violet'">Girrafe</div>
<div class="boxes" [myHighlight]="color" [defaultColor]="'violet'">Hippopotamus</div>

 

3. Create highlight.directive.ts

Create a new TypeScript file under our projects APP Folder(not the wwwroot/app folder) and copy and paste the complete codes at the end of this step/procedure.

What’s note worthy here is the @Directive decorator, this will locate all elements on our template HTML that has the [myHighlight] attribute and will inject our Directives capabilities.

We will also have @Hostlistener’s which will allow us to catch the MouseEnter and MouseLeave and insert what we want our Directives to do, on this case we will change the style.backgroundColor of our DIVS.

import { Directive, ElementRef, HostListener, Input } from '@angular/core';

@Directive({
    selector: '[myHighlight]'
})

export class HighlightDirective {
    private _defaultColor = 'red';
    private el: HTMLElement;

    constructor(el: ElementRef) { this.el = el.nativeElement; }

    @Input() set defaultColor(colorName: string) {
        this._defaultColor = colorName || this._defaultColor;
    }

    @Input('myHighlight') highlightColor: string;

    @HostListener('mouseenter') onMouseEnter() {
        this.highlight(this.highlightColor || this._defaultColor);
    }
    @HostListener('mouseleave') onMouseLeave() {
        this.highlight('inherit');      
    }

    private highlight(color: string) {
        this.el.style.backgroundColor = color;
    }
}

4. Update app.component.ts

Now we need to update our app.component.ts so we could use the HighlightDirective we created on step no 3. what’s note worthy here is we change the template:  to templateUrl and we told our app.component to use our newly created [HighlightDirective]

import { Component } from '@angular/core';
import { HighlightDirective } from './highlight.directive';

@Component({
    selector: 'my-app',   
    templateUrl: 'app/app.component.html',
    directives: [HighlightDirective]
})
export class AppComponent {
    constructor() {
        var test = null;
      
    }
}

 

5. Now you can press F5 to run our application.

If no option is selected it will apply our default color indicated on our Directive

private _defaultColor = 'red';

image

 

 

For the boxes that has the [defaultColor] Attribute, the color indicated on the attribute will be used.

image

image

 

If the user selected a Color, our directive should be able to pick that up and apply it to our DIVs

image

 

References:

https://angular.io/docs/ts/latest/guide/attribute-directives.html

Please feel fee to comment . . .

Posted On Monday, July 18, 2016 11:25 PM | Comments (0)
Friday, June 24, 2016
AngularJS2 on ASP.Net Core using TypeScript Part 1 - Preparing the Seed Project

 

Starting to play with technologies that are not yet released is a pain in the a#$%. First, because big changes can occur thus breaking our proof of concept projects, Second, looking for a good resource online is not as rich when looking for resources for products that are already released, Third, the list of pains goes on …

To start the series we will begin by preparing what we need. On Part 2 of  the series, We will start creating our first AngularJS2 on ASP.Net Core using TypeScript

Updates :

July 2, 2016

ASP.NET Core 1.0 is now released, so I updated the VS and Tools update links
Added an item to update TypeScript Manually


Table of Contents

1. Upgrade your Visual Studio 2015 to Update 3 (released June 27, 2016)
2. Download and Install VS Tools Update
3. Download, Install and Configure latest NodeJS Binaries
4. Download, Install and Configure latest GIT Binaries
5. Download and Install latest Web Compiler Extension for VS 2015
6. Download and Install TypeScript for Visual Studio 2015
7. Update TypeScript

 

Procedures

1. Upgrade your Visual Studio 2015 to Update 2

- download Link https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update3-vs

2. Download and Install VS Tools Update

- download link https://go.microsoft.com/fwlink/?LinkId=817245

3. Download, Install and Configure latest NodeJS Binaries

https://nodejs.org/en/

- Configure Visual Studio to use the newly installed NodeJS instead of the depracated NPM installed with VS. (Uncheck .\node_modules\bin and add a new item “C:\program files\nodejs\”)

image

- If you are using a proxy server configure NodeJS to use your companies proxy

Setup Proxy
---------------------------------------------------------
npm config set proxy http://proxy.com:8888
npm config set https-proxy http://proxy.com:8088

Remove Proxy
---------------------------------------------------------
npm config rm proxy
npm config rm https-proxy

 

 

4. Download, Install and Configure latest GIT Binaries

https://git-scm.com/downloads

- Configure Visual Studio to use the newly installed GIT instead of the depracated NPM installed with VS. (Uncheck $(VSINSTALLDIR)\Web\External\git and add a new item “C:\Program Files\Git\bin”)

image

- If you are using a proxy server configure GIT to use your companies proxy

Setup Proxy
---------------------------------------------------------
git config --global http.proxy http://proxy.com:80880

Remove Proxy
---------------------------------------------------------
git config --global --unset http.proxy

 

5. Download and Install latest Web Compiler Extension for VS 2015

https://visualstudiogallery.msdn.microsoft.com/3b329021-cd7a-4a01-86fc-714c2d05bb6c

 

6. Download and Install TypeScript for Visual Studio 2015

https://www.microsoft.com/en-us/download/details.aspx?id=48593

7. Download latest typescriptService.js file from link below and replace the file on “C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript”

https://github.com/Microsoft/TypeScript/tree/master/lib

 

 

NOTE: It is a good idea to have the latest GIT and NODEJS binaries, because Visual Studio 2015 is shipped with an older GIT and NodeJS binaries, you might encounter some errors if you are not going to have the latest versions

Posted On Friday, June 24, 2016 5:46 PM | Comments (0)
Friday, June 17, 2016
AngularJS2 on ASP.Net Core using TypeScript Part 2 - Our First App

 

On Part 1 we started preparing the stage. If you still haven't done so, please visit http://wblo.gs/lRz

On this Part of the series we will start building our first AngularJS2 on ASP.Net Core using Typescript. On Part 3 we will start coding our own Directives (component that can help us change the appearance or behavior of an HTML elements)

Note

Original Article is from AngularIO Site - https://angular.io/docs/ts/latest/quickstart.html 
I wrote this blog entry for those who want to begin doing Angular using ASP.NET Core 1.0 as a backend.

Updates

July 2, 2016 - ASP.NET CORE is now RTM and AngularJS2 RC4 is released, Updated some scripts below

Procedures Summary

  • Create a new ASP.NET Core Web Application
  • Add package.json (package.json)
  • Add a Gulp file
  • Add a typings.json file
  • Install typings
  • Add a tsconfig.json file – This will contain our TypeScript configurations
  • Create an app folder that will house all of our AngularJS2 codes
  • Create the following files within app folder
  • Create systemjs.config.js
  • Create a css folder and add a new scss file with the following code
  • Configure compilerconfig.json (automatically generated after compiling the scss file) to send css files to wwwroot/css folder
  • Create index.html
  • Edit startup.cs
  • Configure the project to use index.html as a startup page

 

PROCEDURES

1. Create a new ASP.NET Core Web Application

- File new project

image_thumb[11]

- Select Web API

image_thumb[12]

2. Add package.json (package.json)

- Open Solutions Explorer (CTRL + W then S)

- Select the your project name within src folder

image_thumb[13]

- Add a new item (CTRL + SHIFT + A)

- On the upper right side of the screen type package, this will filter the main window

image_thumb[15]

Update the contents of the file with the following code and save

{
    "version": "1.0.0",
    "name": "asp.net",
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.4",
    "systemjs": "^0.19.31",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.0-beta.9",
    "symbol-observable": "1.0.1",
    "zone.js": "0.6.12",
    "angular2-in-memory-web-api": "^0.0.14",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.1.0",   
    "gulp": "^3.9.1",
    "rimraf": "^2.5.2"

  }
}

After saving package.json, Visual Studio will use NPM to download the files required by the dependencies and devDependencies you specified.

image_thumb[16]

On your local drive, you will have a copy of the different items you included in your package.json file

image

image

3.  Add a Gulp file

image

- Update the contents of the file with the following code and save

var gulp = require('gulp');
var rimraf = require('rimraf');

gulp.task('default', function () {
    // place code for your default task here
});

gulp.task('clean:lib', function (cb) {
    return rimraf('wwwroot/lib/', cb);
});

gulp.task('copy:lib', function () {
    return gulp.src('node_modules/**/*')
    .pipe(gulp.dest('wwwroot/lib/'));
});

- right click on gulp.js and select Task Runner

image

- click refresh(upper left corner of the task runner explorer )

image

image

- right click on “copy:lib” then select RUN

- After the task runner finishes you will be able to see that the npm files previously downloaded/copied from step 2 will also be copied to wwwroot folder

image

4. Add a typings.json file

image

- Update the contents of the file with the following code and save

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160621231320"
  }
}

5. Install typings

- Open command prompt

- go to the path where your typings.json file is located

- use the following command to install the items we added in typings.json

typings install

- use the following command if you are behind a proxy

typings install –-proxy http://proxy.com:8888

- you will now have a typings folder containing the objects we included on our typings.json file

image

6. Add a tsconfig.json file – This will contain our TypeScript configurations

image

- Update the contents of the file with the following code and save

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "wwwroot/app/"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

6. Create an app folder that will house all of our AngularJS2 codes

image

7. Create the following files within app folder

app.component.js

import { Component } from '@angular/core';
@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1>'
})
export class AppComponent { }

 

main.ts

import { bootstrap }    from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';

bootstrap(AppComponent);

- js files will be generated under wwwroot\app folder as a result of our tsconfig.json after saving the ts files we created above

image

8. Create systemjs.config.js inside wwwroot folder

- Update the contents of the file with the following code and save

/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
    // map tells the System loader where to look for things
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'lib/@angular',
        'angular2-in-memory-web-api': 'lib/angular2-in-memory-web-api',
        'rxjs': 'lib/rxjs',
        'symbol-observable':'lib/symbol-observable'
    };
    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app': { main: 'main.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
        'symbol-observable': { main: 'index.js', defaultExtension: 'js' }
    };
    var ngPackageNames = [
      'common',
      'compiler',
      'core',
      'forms',
      'http',
      'platform-browser',
      'platform-browser-dynamic',
      'router',
      'router-deprecated',
      'upgrade',
    ];
    // Individual files (~300 requests):
    function packIndex(pkgName) {
        packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' };
    }
    // Bundled (~40 requests):
    function packUmd(pkgName) {
        packages['@angular/' + pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
    }
    // Most environments should use UMD; some (Karma) need the individual index files
    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
    // Add package entries for angular packages
    ngPackageNames.forEach(setPackageConfig);
    var config = {
        map: map,
        packages: packages
    };
    System.config(config);
})(this);

9. Create a css folder udner the project folder and add a new scss file with the following code

main.scss

$font-stack: Arial, Helvetica, sans-serif;
$primary-color: #336699;
$font-size:250%;
$margin:2em;

h1 {
  font: $font-size $font-stack;
  color: $primary-color;   
}

body {
      margin: $margin;
}

- right click on main.scss and select Web Compiler then Re-compile file, This will generate main.css

image

main.css and main.min.css will be generated automatically

image

10. Configure compilerconfig.json (automatically generated after compiling the scss file) to send css files to wwwroot/css folder

[
  {
    "outputFile": "wwwroot/css/main.css",
    "inputFile": "css/main.scss"
  }
]

-css files should now be automatically generated under wwwroot/css/

image

11. Create index.html Inside wwwroot folder

<html>
<head>
    <title>Angular 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css\main.css">
    <!-- 1. Load libraries -->
    <!-- Polyfill(s) for older browsers -->
    <script src="lib/core-js/client/shim.min.js"></script>
    <script src="lib/zone.js/dist/zone.js"></script>
    <script src="lib/reflect-metadata/Reflect.js"></script>
    <script src="lib/systemjs/dist/system.src.js"></script>
    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
</head>
<!-- 3. Display the application -->
<body>
    <my-app>Loading...</my-app>
</body>
</html>

12. Edit startup.cs – add the code below (BOLD)

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
          
app.UseStaticFiles();
            app.UseMvc();
        }

- click the word UseStaticFiles() and press CTRL + .  and select “Add package Microsoft.AspNetCore.StaticFiles 1.0.0

image

13. Configure the project to use index.html as a startup page

- Open Project>Properties and open Debug Tab and set Launch URL: index.html

image

14. Run the Project by pressing F5

image

 

Additional References/Notes

package.json - https://docs.npmjs.com/files/package.json
gulp.js/grunt/gulp/webpack -
https://npmcompare.com/compare/browserify,grunt,gulp,webpack
rimraf – This will traverse a folder and delete objects, similar to linux’ rm –rf command
taskrunner – task runners help developers to automate tasks by using different tools like GULP, BOWER
package.json - A package.json file contains meta data about your app or module. Most importantly, it includes the list of dependencies to install from npm when running npm install

 

Please feel fee to comment . . .

Posted On Friday, June 17, 2016 7:01 PM | Comments (4)
Thursday, May 19, 2016
Semaphores–queuing with multiple workers–C#

One of the challenges of working with queues is how to properly and neatly process each item using multiple workers, luckily on .Net we have Semaphores. “In computer science, a semaphore is a variable or abstract data type that is used for controlling access, by multiple processes, to a common resource in a concurrent system such as a multiprogramming operating system.” https://en.wikipedia.org/wiki/Semaphore_(programming)

Below is a simple program that demonstrate the use of semaphore with a parametized number of threads and HttpRequest as Payload.

References:

https://msdn.microsoft.com/en-us/library/system.threading.semaphore(v=vs.110).aspx


private const int maxThreads = 10;
private Semaphore semaphore = new Semaphore(maxThreads, maxThreads);
private Queue queue = new Queue();
private void button1_Click(object sender, EventArgs e)
{
    addTestData();
     while (queue.Count >=1)
    {
        semaphore.WaitOne();
        var item = queue.Dequeue();
        ThreadPool.QueueUserWorkItem(ProcessCurrentItem, item);
    }
  
    int count = 0;
    while (count < maxThreads)
    {
        semaphore.WaitOne();
        ++count;
    }
}

async void ProcessCurrentItem(object item)
       {
           string responseData = "";
           HttpClient hc = new HttpClient();

           hc.DefaultRequestHeaders.Add("host", "www.mywebsite.com");
          hc.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
           hc.DefaultRequestHeaders.Add("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
           hc.DefaultRequestHeaders.Add("scheme", "https");
           hc.DefaultRequestHeaders.Add("method", "GET");

           //Get the headers associated with the request.

           try
           {
               HttpResponseMessage response = await hc.GetAsync("https://www.mywebsite.com/" + item.ToString());
               responseData = response.ToString(); 

               //DO WHAT YOU WANT WITH YOUR DATA HERE

           } 

           catch (Exception ex)
           {
               Console.WriteLine(ex.Message.ToString());
           }
           Console.WriteLine(item.ToString());
           semaphore.Release();

       }

private void addTestData()
{
    queue.Enqueue("1.json");
    queue.Enqueue("2.json");
    queue.Enqueue("3.json");
    queue.Enqueue("4.json");
    queue.Enqueue("5.json");
    queue.Enqueue("6.json");
    queue.Enqueue("7.json");
    queue.Enqueue("8.json");
    queue.Enqueue("9.json");
    queue.Enqueue("10.json");
    queue.Enqueue("11.json");
    queue.Enqueue("12.json");
    queue.Enqueue("13.json");
    queue.Enqueue("14.json");
    queue.Enqueue("15.json");
    queue.Enqueue("16.json");
    queue.Enqueue("17.json");
    queue.Enqueue("18.json");
}

Posted On Thursday, May 19, 2016 9:20 PM | Comments (0)
Monday, February 29, 2016
Lock Pages In Memory

SQL Server together with other RDBMS, are the most memory consuming applications on our servers, and this is because, RDBMs usually cache objects into the memory to take advantage of the speed that physical memory offers.

Sadly when windows feels that its physical memory is currently not enough for a driver and/or processes that is requesting some resources, it is forced to trim some of currently running application’s memory working set. Now that is bad news for SQL Server because windows will be forced to push the objects from the memory to the servers’ paging file. You can verify if windows is doing this to your SQL Server by investigating SQL Server Logs for this entries

A significant part of sql server process memory has been paged out.This may result in a performance degradation. Duration: 0 seconds. Working set (KB): 1086400, committed (KB), memory Utilization: 50%.

Currently there are 2 settings that we can play with to avoid or at least alleviate this situation

1. Properly set SQL Servers’ Max Memory settings, by setting aside enough memory for the OS and other running Processes like Antivirus and Server Monitoring Software.

2. Enable SQL Server Locked Page in Memory (LPIM)

NOTE: Enabling LPIM without fully Understanding how SQL Memory Works and without knowing how your DB Server Behaves specially if it’s in a Virtual Environment might give you negative effects.

For this Post we will be focusing on LPIM. When using LPIM Windows cannot simply touch the memory space used by SQL Servers’ Buffer Pool, it is locked and cannot be paged. SQL Server does this by using Address Windowing Extensions (AWE).

When LPIM is enabled you cannot simply view how much really SQL Server is using by viewing Task Manager. As you can see on the screen shot below, SQLSERVR.EXE is only using 49, 536Kb

image

You can however use RamMap (A free RAM tool from Sysinternals: www.sysinternals.com). To view how much memory AWE is using.

image

 

Or you can also use sys.dm_os_process_memory SQL Server Dynamic Management Views (DMV).

 

How to Enable LPIM

Use Windows Group Policy tool (gpedit.msc) to enable this policy for the account used by SQL Server. You must be a system administrator to change this policy.

1. On the Start menu, click Run. In the Open box, type gpedit.msc.

2. On the Local Group Policy Editor console, expand Computer Configuration, and then expand Windows Settings.

3. Expand Security Settings, and then expand Local Policies.

4. Select the User Rights Assignment folder.

The policies will be displayed in the details pane.

5. In the pane, double-click Lock pages in memory.

6. In the Local Security Setting – Lock pages in memory dialog box, click Add User or Group.

7. In the Select Users, Service Accounts, or Groups dialog box, add an account with privileges to run sqlservr.exe.

8. Log out and then log back in for this change to take effect.

Note about SQL Server 2008 R2 Standard Edition (64-bit): Microsoft SQL Server 2008 R2 Standard Edition (64-bit, all versions RTM and later) also requires trace flag 845 to be added as a startup parameter so that SQL Server can use locked pages for the Buffer Pool when the SQL Server service account is granted the Lock Pages in Memory security privilege

Note about SQL Server 2012 Standard Edition (64-bit): Microsoft SQL Server 2012 Standard Edition (64-bit) does not require you to enable any trace flag to allow SQL Server use locked pages for the Buffer pool when the SQL Server service account is granted the Lock Pages in Memory security privilege.

 

How to determine if LPIM is enabled

Option 1 (Tested SQL 2005 )

DECLARE @LockPagesInMemory VARCHAR(255);

SET @LockPagesInMemory = 'UNKNOWN';

DECLARE @Res TABLE

(

[output] NVARCHAR(255) NULL

);

IF (SELECT value_in_use

FROM sys.configurations c

WHERE c.name = 'xp_cmdshell'

) = 1

BEGIN

INSERT INTO @Res

EXEC xp_cmdshell 'WHOAMI /PRIV';

IF EXISTS (SELECT *

FROM @Res

WHERE [output] LIKE 'SeLockMemoryPrivilege%'

)

SET @LockPagesInMemory = 'ENABLED';

ELSE

SET @LockPagesInMemory = 'DISABLED';

END

SELECT LockPagesInMemoryEnabled = @LockPagesInMemory;

Option 2 (Tested SQL 2008)

select osn.node_id,

osn.memory_node_id,

osn.node_state_desc,

omn.locked_page_allocations_kb

from sys.dm_os_memory_nodes omn

inner join sys.dm_os_nodes osn on (omn.memory_node_id = osn.memory_node_id)

where osn.node_state_desc <> 'ONLINE DAC'

NOTE: A non zero value for locked pages allocation means Locked pages in memory is enabled

Option 3 (TestedSQL 2008)

select

(physical_memory_in_use_kb/1024)Memory_usedby_Sqlserver_MB,

(locked_page_allocations_kb/1024 )Locked_pages_used_Sqlserver_MB,

(total_virtual_address_space_kb/1024 )Total_VAS_in_MB,

process_physical_memory_low,

process_virtual_memory_low

from sys. dm_os_process_memory

NOTE: A non zero Locked_pages_allocation_KB means Locked pages in memory is enabled.

Option 4

Using Exec xp

exec xp_readerrorlog 0, 1, 'locked pages'

exec xp_readerrorlog 0, 1, 'lock pages in memory'

Technical References/Further Reading:

Great SQL Server Debates: Lock Pages in Memory
https://www.simple-talk.com/sql/database-administration/great-sql-server-debates-lock-pages-in-memory/

How to reduce paging of buffer pool memory in the 64-bit version of SQL Server
https://support.microsoft.com/en-us/kb/918483

Support for Locked Pages on SQL Server Standard Edition (64-bit) systems

https://support.microsoft.com/en-us/kb/970070

How to enable the "locked pages" feature in SQL Server 2012
https://support.microsoft.com/en-us/kb/2659143

Posted On Monday, February 29, 2016 5:22 PM | Comments (0)
Friday, January 29, 2016
SQL Server 2016 Dynamic Data Masking (DDM)
SQL Server 2016 Dynamic Data Masking
Posted On Friday, January 29, 2016 11:38 PM | Comments (0)
Tuesday, June 17, 2014
Highcharts Export Tool Step by Step for IIS7 and .Net 2.0/4.0

1. Download Highcharts Export Module for ASP.Net From Tek4

2. Create New Website using IIS

3. Copy the contents of Exporting_Demo_website to the root folder of the newly created Web Site


4. Configure Application Pool entry for the new website
1. Open IIS Configuration Console 
2. Go to Application Pools
3. Right click on the name of the new application and select Advance Settings
4. Set Managed Pipeline Mode - Classic




5. Configure ISAPI and CGI restrictions
1. Open IIS Configuration Console 
2. Select the IIS server 
3. open ISAPI and CGI Restrictions
4. Select the .Net version that you require
5. put a check mark on "Allow extension path to execute"


6. Restart IIS Services

Test the Export Utility


Notes: 
1. Make sure to use the correct web.config file
2. You can test the site by opening default.aspx 
Posted On Tuesday, June 17, 2014 5:43 PM | Comments (1)
Saturday, December 1, 2012
ASP.Net MVC 4 Razor Engine For Beginners Part 1
Microsoft MVC Razor Engine ASP.Net Primer Beginner How To Step by Step Visual Studio MVC4
Posted On Saturday, December 1, 2012 10:43 PM | Comments (24)
Monday, June 13, 2011
Set your Most Popular Sites as your home page in Internet Explorer 9, IE9
Set your Most Popular Sites as your home page in Internet Explorer 9, IE9
Posted On Monday, June 13, 2011 8:20 PM | Comments (7)
Monday, May 16, 2011
CENTOS 5.6 httpd dead but subsys locked [RESOLVE]
CENTOS; CENTOS 5.6 httpd dead but subsys locked;
Posted On Monday, May 16, 2011 8:43 PM | Comments (9)
Tag Cloud