- is a Javascript Framework
- ng-app
- root element of Application (Tell HTML to use AngularJS)
- ng-controller
- Define Controler.
- ng-model
- Bind HTML Control value to App Data.
- ng-bind
- Bind App Data to HTML Control Value.
- {{expression}} = output {{5+5}} = 10
- ng-int
- Initialize AngularJS app variable (JSON)
- Service(AJAX) : $http
- Read Data from Server side(HTTP Request) / Text File
- $scope : parameter passed to the controller
- Is Model Between Controller and Views
- $scope.message & $scope.type is to display in HTML page.
- Validate Data
- $dirty : value has changed ?
- $Invalid: value is Invalid ?
- $error: State exact error.
- Include
- Embedding HTML Page
- Can more than 1 in 1 HTML Page.
- For Code Reuse
- Good For Header/ Footer/ Sidebar
- ng-view
- Partial Represent with controller and Route (Page's URL)
- Only 1 per HTML Page.
- Good For Content of the page.
- and Change by URL (Category, PageNum, ID)
- ng-template
- Create an html view using Script Tag.
- It contrain "id", and use &routeProvider to map a view with controller.
- &routeProvider
- Key configuration of URL map with HTML or ng-template
Thursday, March 2, 2017
Angular JS
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
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
});
}
Monday, January 9, 2017
Insert 1M Records by SQL Server
declare @id int
declare @accountID bigint
declare @IP varchar(20)
select @id = 1
while @id <= 1000000
begin
//Insert 1st Table
INSERT INTO tblE2Account values('TestAccount' + CAST(@id AS VARCHAR(10)) , 'TestName',14,1,'E2TestBY',GETDATE(),'E2TestBY',GETDate(), NULL,0,0,'63,119','10.101.1.115',2)
// Take ID
Select @accountID = Max(E2AccountId) From tblE2Account where CreatedBy='E2TestBY'
// Take ID and put in next Insert
INSERT INTO tblE2IP values('999.9.9.'+ CAST(@id AS VARCHAR(10)) , '23.1167,113.25','No Hostname','Kuala Lumpur','Kuala Lumpur','MY','59200','AS38199 Macro Lynx Sdn Bhd, Internet Service Provider, Malaysia',1,1,'E2TestBY',GETDATE(),NULL,NULL)
Select @IP = '999.9.9.' + CAST(@id AS VARCHAR(10))
INSERT INTO tblE2Transaction values(@IP, null, 2,14,@accountID,1,'1010017387,20.00,0','E2TestBY',GETDATE(),NULL,NULL)
select @id = @id + 1
end
//Avarage 30k records int 20 mins
//Avarage 30k records int 20 mins
Dictionary
static readonly Dictionary<string, DeviceType> MappedDeviceType;
static fnMapDeviceType()
{
MappedDeviceType = new Dictionary<string, DeviceType>();
MappedDeviceType.Add("Windows NT 6.3", DeviceType.Windows);
MappedDeviceType.Add("Windows NT 6.3; WOW64", DeviceType.Windows);
MappedDeviceType.Add("Windows NT 10.0", DeviceType.Windows);
MappedDeviceType.Add("Windows NT 10.0; WOW64", DeviceType.Windows);
MappedDeviceType.Add("CPU iPhone OS 9_3_2 like Mac OS X", DeviceType.Iphone);
}
public static DeviceType MapDeviceType(string device)
{
DeviceType mapValue = DeviceType.Unknown;
if (!string.IsNullOrWhiteSpace(device))
{
if (Enum.TryParse(device, true, out mapValue))
return mapValue;
if (MappedDeviceType.TryGetValue(device,
out mapValue))
return mapValue;
}
return mapValue;
}
---------------------
//Contain en with key
---------------------
//Contain en with key
string word = "en/my";
var mappingA = new Dictionary<string, string>()
{
{ "en", "en-gb" },
{ "cn", "cn-zh" },
};
string listPerson = mappingA.Where(x =>
word.Contains(x.Key)).Select(y => y.Value).FirstOrDefault();
Subscribe to:
Posts (Atom)