DECLARE @stSqlString NVARCHAR(MAX) = ''
DECLARE @stStrXml XML
SET @stSqlString = 'set @stStrXml=(select * from TableName FOR XML AUTO, elements)'
EXEC sp_executesql @stSqlString, N'@stStrXml XML OUTPUT',@stStrXml OUTPUT
SELECT @stStrXml
Tuesday, February 13, 2018
How to get list of all Folder in network sharing path using SQL Server
IF OBJECT_ID('tempdb..#TempTableName') IS NOT NULL
DROP TABLE #TempTableName ;
CREATE TABLE #TempTableName
(
id INT IDENTITY(1, 1) ,
subdirectory NVARCHAR(512) ,
depth INT
) ;
INSERT #TempTableName
( subdirectory
)
EXEC MASTER.dbo.xp_cmdshell 'dir DriveName:\ /b /o:n /ad'
IF NOT EXISTS ( SELECT 1
FROM #TempTableName )
BEGIN
EXEC XP_CMDSHELL 'net use DriveName: \\ServerName\DriveName /user:domain\USERNAME PASSWORD'---code for Mapping drive in local Pc
END
Create Window Service Setup Using .bat file
-----------------------------For Install-------------------------------------------------
@ECHO OFF
echo Installing WindowsService...
echo ---------------------------------------------------
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil /i C:\RapnetService\Debug\ImportRapnetData.exe
echo ---------------------------------------------------
echo Service Install Done Successfully.
pause
---------------------------------For Uninstall---------------------------------------------
@ECHO OFF
echo Installing WindowsService...
echo ---------------------------------------------------
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil /u C:\RapnetService\Debug\ImportRapnetData.exe
echo ---------------------------------------------------
echo Service UnInstall Done Successfully.
pause
Monday, February 12, 2018
Query For Calculate CPU Usage in SQL Server
SELECT TOP 10
ObjectName = OBJECT_SCHEMA_NAME(qt.objectid,dbid) + '.' + OBJECT_NAME(qt.objectid, qt.dbid)
,TextData = qt.text
,DiskReads = qs.total_physical_reads -- The worst reads, disk reads
,MemoryReads = qs.total_logical_reads --Logical Reads are memory reads
,Executions = qs.execution_count
,TotalCPUTime = qs.total_worker_time
,AverageCPUTime = qs.total_worker_time/qs.execution_count
,DiskWaitAndCPUTime = qs.total_elapsed_time
,MemoryWrites = qs.max_logical_writes
,DateCached = qs.creation_time
,DatabaseName = DB_Name(qt.dbid)
,LastExecutionTime = qs.last_execution_time
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
ORDER BY qs.total_worker_time DESC
-- Find queries that have the highest average CPU usage
SELECT TOP 10
ObjectName = OBJECT_SCHEMA_NAME(qt.objectid,dbid) + '.' + OBJECT_NAME(qt.objectid, qt.dbid)
,TextData = qt.text
,DiskReads = qs.total_physical_reads -- The worst reads, disk reads
,MemoryReads = qs.total_logical_reads --Logical Reads are memory reads
,Executions = qs.execution_count
,TotalCPUTime = qs.total_worker_time
,AverageCPUTime = qs.total_worker_time/qs.execution_count
,DiskWaitAndCPUTime = qs.total_elapsed_time
,MemoryWrites = qs.max_logical_writes
,DateCached = qs.creation_time
,DatabaseName = DB_Name(qt.dbid)
,LastExecutionTime = qs.last_execution_time
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
ORDER BY qs.total_worker_time/qs.execution_count DESC
Angular Project Demo
1) create Two Folder :- Controllers and Factory (WebApplication2 is project name)
-----------------------------------------MytestConroller.js---------------------------------------------------------
angular.module('WebApplication2.Controllers').controller('MytestController', MytestController);
MytestController.$inject = ['$scope', 'MyButtonClickEvent', '$http'];
function MytestController($scope, MyButtonClickEvent, $http) {
var vm = this;
$scope.username = 'World';
$scope.sayHello = function () {
//First Code
//$scope.greeting = MyButtonClickEvent.BtnClick($scope.username);
//MyButtonClickEvent.GetData($scope.username).then(function (result) {
// $scope.greeting = result.data.aaData;
//})
///Second Code
var item = { 'msgName': $scope.username }
MyButtonClickEvent.GetDataClass(item).then(function (result) {
debugger
$scope.greeting = result.data.aaData.msgName;
})
// third code
//var item = [];
//item.push({ msgName: $scope.username });
//MyButtonClickEvent.GetDataList(item).then(function (result) {
// $scope.greeting = result.data.aaData[0].msgName;
//})
};
}
-----------------------------------------MytestFactory.js---------------------------------------------------------
angular.module('WebApplication2.Services').service('MyButtonClickEvent', MyButtonClickEvent);
MyButtonClickEvent.$inject = ['$http'];
function MyButtonClickEvent($http) {
var list = {};
list.BtnClick = function (data) {
return 'Hello ' + data;
}
list.GetData = function (data) {
return $http({
url: '/Mytest/GetMsg',
method: "GET",
params: { MyData: data },
});
};
list.GetDataClass = function (data) {
return $http({
url: '/Mytest/GetMsgClass',
method: "GET",
params: data
});
};
list.GetDataList = function (myObject) {
return $http({
url: '/Mytest/GetMsgList',
method: "post",
data: myObject
});
};
return list;
}
-----------------------------------App.js--------------------------------------------------------------------
angular.module('WebApplication2', ['WebApplication2.Controllers', 'WebApplication2.Services']);
angular.module('WebApplication2.Controllers', []);
angular.module('WebApplication2.Services', []);
-----------------------------------Index.cshtml----------------------------------------------------------
MyData)
{
var JsonResult = Json(new { aaData = MyData }, JsonRequestBehavior.AllowGet);
JsonResult.MaxJsonLength = Int32.MaxValue;
return JsonResult;
}
}
}
public class myList
{
public string msgName { get; set; }
}
----------------------------------Layout.cshtml-------------------------
Your name:
{{greeting}}
-------------------------------------Controller.cs--------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication2.Controllers
{
public class MytestController : Controller
{
// GET: Mytest
public ActionResult Index()
{
return View();
}
[HttpGet]
public JsonResult GetMsg(string MyData)
{
var JsonResult = Json(new { aaData = MyData }, JsonRequestBehavior.AllowGet);
JsonResult.MaxJsonLength = Int32.MaxValue;
return JsonResult;
}
[HttpGet]
public JsonResult GetMsgClass(myList MyData)
{
var JsonResult = Json(new { aaData = MyData }, JsonRequestBehavior.AllowGet);
JsonResult.MaxJsonLength = Int32.MaxValue;
return JsonResult;
}
[HttpPost]
public JsonResult GetMsgList(List{{greeting}}
File Upload in Angular 2
****************Change Event *************
onChange(event: EventTarget) {
let formData = new FormData();
let eventObj: MSInputMethodContext = event;
let target: HTMLInputElement = eventObj.target;
let files: FileList = target.files;
this.file = files[0];
let formData = new FormData();
formData.append('FileDocument', this.file);
return this.http.post(`UrlPath`, formData)
.map((res: Response) => {
});
}
******************WEB API******************
[HttpPost]
public void GetImage()
{
var ImageData= System.Web.HttpContext.Current.Request.Files["FileDocument"];
ImageData.SaveAs(Path);
}
Input Only Number in Iput Type in Angular 2
Input Only Number in Input Type in Angular 2
-- Html Code here
First Create Directive.ts File and Put Code Inside
*************************onlynumber.directive.ts***************************
import { Directive, ElementRef, HostListener, Input } from '@angular/core';
@Directive({
selector: '[OnlyNumber]'
})
export class OnlyNumber {
constructor(private el: ElementRef) { }
@Input() OnlyNumber: boolean;
@HostListener('keydown', ['$event']) onKeyDown(event) {
let e = event;
if (e.which == 13) {
e.preventDefault();
var $next = $('[tabIndex=' + (+ parseInt(e.target['tabIndex']) + 1) + ']');
if (!$next.length) {
$next = $('[tabIndex=1]');
}
$next.focus();
}
else if (this.OnlyNumber) {
if ([46, 8, 9, 27, 13, 190].indexOf(e.keyCode) !== -1 ||
(e.keyCode == 65 && e.ctrlKey === true) ||
(e.keyCode == 67 && e.ctrlKey === true) ||
(e.keyCode == 88 && e.ctrlKey === true) ||
(e.keyCode >= 35 && e.keyCode <= 39)) {
return;
}
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
}
}
}
Passing Data To Component in Agular2 With Using Service
-------------Create First Service---------------
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
@Injectable()
export class ProgressSpinner {
public _subject = new Subject();
public event = this._subject.asObservable();
public SpinnerLoader(data: any) {
this._subject.next(data);
}
}
------------Create Object in AppComponent--------------
import { Component } from '@angular/core';
import { alertservice, ProgressSpinner } from './shared'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
loading: boolean = false;
constructor(public _ProgressSpinner: ProgressSpinner) {
_ProgressSpinner.event.subscribe((data) => { this.loading = data });
}
}
***************Second Component***************
import { Component, OnInit, ViewEncapsulation, ElementRef } from '@angular/core'
import { MenuItem, Message, Shape_Master, Shape_Col } from '../../shared'
import { DepartmentGroupervice, GenericClass, Pagination, ProgressSpinner } from '../../shared'
import { ConfirmationService, GrowlModule } from 'primeng/primeng';
@Component({
selector: 'app-shape',
templateUrl: './shape.component.html',
styleUrls: ['./shape.component.css']
})
export class ShapeComponent implements OnInit {
constructor( private _ProgressSpinner: ProgressSpinner) {
this._ProgressSpinner.SpinnerLoader(false);
}
}
Subscribe to:
Posts (Atom)