Tuesday, February 14, 2017

Stored Prcocedure

 USE [DeviceDB]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[sp_RptNewAccVelocity]
@SubscriberId int,
@ReportLength int = null,
@Order char(30) = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @SQL_STATEMENT nvarchar(3000);

SET @SQL_STATEMENT = 'SELECT c.CreatedDate AS ''AccCreatedDate'', b.AccountId, c.AccountCode, a.DeviceId FROM dbo.tblTransaction a WITH(NOLOCK) INNER JOIN ( ';

SET @SQL_STATEMENT += 'SELECT MIN(CreatedDate) AS CreatedDate, AccountId FROM dbo. tblTransaction WITH(NOLOCK)';

SET @SQL_STATEMENT += 'WHERE SubscriberId = '+ CAST(@SubscriberId as varchar(20)) + ' ';
   
IF (@ReportLength IS NOT NULL)
SET @SQL_STATEMENT += 'AND CreatedDate >= DATEADD(day, - '+ CAST(@ReportLength as varchar(20))   +', GETUTCDATE()) ';

SET @SQL_STATEMENT += 'GROUP BY AccountId ) b ON a.AccountId = b.AccountId AND a.CreatedDate = b.createdDate ';

SET @SQL_STATEMENT += 'INNER JOIN dbo.tblAccount c WITH(NOLOCK) ON c.AccountId=b.AccountId ';
      
SET @SQL_STATEMENT += 'WHERE a.SubscriberId = '+ CAST(@SubscriberId as varchar(20)) + ' ';
   
IF (@ReportLength IS NOT NULL)
SET @SQL_STATEMENT += 'AND c.CreatedDate >=  DATEADD(day, - '+ CAST(@ReportLength as varchar(20))   +', GETUTCDATE()) ';

IF (@Order IS NOT NULL)
SET @SQL_STATEMENT += 'ORDER BY ' + CAST(@Order as varchar(30)) + ' ';

EXEC sp_executesql @SQL_STATEMENT; // print @SQL_Statement
END


Monday, February 6, 2017

Java script Obfuscator Tool

https://www.javascriptobfuscator.com/Javascript-Obfuscator.aspx

Alert allow copy

prompt("Copy to clipboard: Ctrl+C, Enter", crypted);

Encryption in Javascript

<script src="Scripts/tripledes.js"></script>
<script src="Scripts/mode-ecb.js"></script>

function encrypt() {
    var keyHex = CryptoJS.enc.Utf8.parse("mkadm11n");

    var crypted = CryptoJS.DES.encrypt("Message", keyHex, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
}