Tuesday, February 21, 2017

SQL Server - Find User Defined Table Type Dependency

BEGIN TRANSACTION
DROP PROC dbo.uspGetStockAccumulatePerMarketTriggerByEventIDList
DROP PROC dbo.uspGetStockAccumulateTotalPortfolioByEventIdList
GO

---- WRITE HERE SCRIPT TO DROP OLD USER DEFINED TABLE TYPE AND CREATE A NEW ONE ----
/********************* Change History ********************
Date   Author Description
2016-08-02 Janice Get Stock Accumulate Per Market Trigger By EventId List

EXEC [dbo].[uspGetStockAccumulatePerMarketTriggerByEventIDList]
**********************************************************/
CREATE PROCEDURE [dbo].[uspGetStockAccumulatePerMarketTriggerByEventIDList]
@CompanyID INT,
@Table udttEventIDList READONLY
AS
BEGIN
SET NOCOUNT ON;

DECLARE @CalculateStockAccumulateTypeId BIGINT
SELECT @CalculateStockAccumulateTypeId = [SettingParamValue] FROM [Setting](NOLOCK) WHERE [SettingParamName] = 'CalculateStockAccumulateType'

SELECT EventID
, WagerSelectionID
, IsRB
, ScoreHome
, ScoreAway
, MarketTypeID
, Handicap
, BetTypeSelectionID
,
--1:MixtureAmount; 2:PotentialPayout; 3: StakeAmount; 4: PotentialMemberExposure
CASE WHEN @CalculateStockAccumulateTypeId = 1 THEN MixtureAmount
WHEN @CalculateStockAccumulateTypeId = 2 THEN PotentialPayoutAmount
WHEN @CalculateStockAccumulateTypeId = 3 THEN StakeAmount
ELSE PotentialExposureAmount
END AS Stock
, WagerCount
FROM [StockAccumulatePerMarketTriggerBySelection] WITH (NOLOCK)
WHERE EventID IN (SELECT TT.EventID FROM @Table AS TT) AND (@CompanyID = 0 OR CompanyID = @CompanyID)

SET NOCOUNT OFF;
END

GO
/********************* Change History ******************************
Date   Author  Description
2016-03-30    Jason      Get StockAccumulateSelectionTotalPortfolio by event id list
********************************************************************/

CREATE PROCEDURE [dbo].[uspGetStockAccumulateTotalPortfolioByEventIdList]
@EventIdList udttEventIDList READONLY
AS
BEGIN
SET NOCOUNT ON;

SELECT
  [BusinessUnitID]
      ,[EventID]
      ,[MarketTypeID]
      ,[SportID]
      ,[MarketID]
      ,[PeriodID]
      ,[BetTypeID]
      ,[Handicap]
      ,[BetTypeSelectionID]
      ,[ScoreHome]
      ,[ScoreAway]
      ,[StockRawStartID]
      ,[StockRawEndID]
      ,[StakeAmount]
      ,[Stock]
      ,[CompanyPotentialWinAmount] AS 'PotentialPayoutAmount'
      ,[CompanyPotentialExposureAmount] AS 'PotentialExposureAmount'
 FROM [dbo].[StockAccumulateTotalPortfolioBySelection] (NOLOCK) WHERE EventID IN (SELECT EventID FROM @EventIdList) AND BetTypeID in (1,2,3,5)

END
GO
COMMIT

Thursday, February 16, 2017

大马各州属车牌字母

◤大马各州属车牌字母!◢原来这些奇奇怪怪的车牌字母就是这些州属的~以后别再说不懂了!

马来西亚的车牌号码都是由英文字母和数字组成的,数字是有可能重叠的,但是字母却是根据不同的州属,而有不同的字母代表。这样一来,就很容易分辨马来西亚的车子是来自哪里一个州属的。



以下就为大家整理出马来西亚各州属车牌字母
A – Negeri Perak
B – Selangor
C – Pahang
D – Kelantan
E – Sabah (Sebelum tahun 1980-an)

EJ – Jesselton (Sekarang Kota Kinabalu sejak 1968)
ES – Sandakan
ET – Tawau
ED – Lahad Datu
EU – Keningau
EK – Kudat
EL – Labuan



F – Putrajaya
H – 的士专用
J – Johor
K – Kedah


KV – Langkawi
L – Labuan
M – Melaka
N – Negeri Sembilan
P – Pulau Pinang
Q – Sarawak
QA dan QK – Kuching
QB – Sri Aman
QC – Samarahan
QL – Limbang
QM – Miri
QP – Kapit
QR – Sarikei
QS – Sibu
QT – Bintulu
R – Perlis
S – Sabah,(dahulu E)


SA – Kota Kinabalu
SB – Beaufort
SD – Lahad Datu
SK – Kudat
SS – Sandakan
ST – Tawau
SU – Keningau
T – Terengganu
V – Kuala Lumpur (baru menggantikan huruf W)
W – Kuala Lumpur (ditamatkan)
Z – Tentera
Z – Pemerintah Tertinggi Tentera Malaysia
ZA ke ZD – Tentera Darat
ZL – Tentera Laut Malaysia
ZU – Tentera Udara Malaysia
ZZ – Kegunaan staf Kementerian Pertahanan Malaysia

Tuesday, February 14, 2017

Jmeter - Generate HTML Report

Refer : https://learn-jmeter.blogspot.sg/2016/10/how-to-generate-jmeter-report-dashboard.html

Monday, February 6, 2017

Controlling Session Behavior in ASP.Net MVC

Introduction

ASP.NET MVC supports session state. As we know sessions are used to store data used across requests. ASP.NET MVC manages session data whether or not we store data in the session. Now with MVC, we can disable the session for the controller. This concept is called a sessionless controller.

Sessionless Controller

It is possible to disable the session for a controller. It may be that some of the controllers of our application do not use the session state feature. We can disable the session for those controllers using the SessionStateAttribute (set session state Behavior to Disabled) and we can get a slight performance improvement for our application.

Example
[SessionState(System.Web.SessionState.SessionStateBehavior. Disabled)]
public class HomeController : Controller
{
          ……
          ……
}
If we mark our controller as sessionless and we still try to access a session within the controller then it throws the exception “Object reference not set to an instance of an object”.

Example code
[SessionState(System.Web.SessionState.SessionStateBehavior. Disabled)]
public class HomeController : Controller
{
   
 public ActionResult Index()
    {
        ViewBag.Message =
 "Welcome to ASP.NET MVC!";
        Session[
"test"] = "Session less controller test";
       
 return View();
    }
}
Output


Session State Behavior

The SessionState attribute in MVC provides more control over the behavior of the session state by specifying the value of the behavior property (this is a read-only property but we can set it using a parameterized contractor of the SessionStateAttribute).

Enumeration Value
Description
Default
The default ASP.NET logic is used to determine the session state behavior for the controller.
Required
Full read and write session state behavior is enabled for the request.
ReadOnly
Read-only session state is enabled for the request. In other words we can read the data from the session but we cannot write the data into the session.
Disabled
Session State is disabled for the current request.
Session less controller and TempData

TempData in MVC uses session state internally to store the data. So when we disable the session state for the controller, it will throw the exception as below.
[SessionState(System.Web.SessionState.SessionStateBehavior.Disabled)]
public class HomeController : Controller
 
   
 public ActionResult Index()
    {
        ViewBag.Message =
 "Welcome to ASP.NET MVC!";
        TempData[
"test"] = "session less controller test";
       
 return View();
    }
}
Output
 Conclusion

The SessionState attribute specifies the session state behavior at the controller level. This attribute is a class level attribute so we cannot use it in a method (or at an action level). This attribute is very useful when we require specific behavior of session state for a specific controller. For example, for any controller, we do not want to use a session state; at this time we can mark this controller with the SessionState attribute and the behavior is disabled.




Reference ; http://www.c-sharpcorner.com/UploadFile/ff2f08/controlling-session-behavior-in-Asp-Net-mvc/