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
Knowledge Collection
Tuesday, February 21, 2017
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
马来西亚的车牌号码都是由英文字母和数字组成的,数字是有可能重叠的,但是字母却是根据不同的州属,而有不同的字母代表。这样一来,就很容易分辨马来西亚的车子是来自哪里一个州属的。
以下就为大家整理出马来西亚各州属车牌字母
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
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
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();
}
}
{
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.
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();
}
}
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.
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/
Sunday, January 22, 2017
WCF REST Error Handling And Custom Header
REST, or Representational State Transfer represents an architectural style for building distributed applications. When applied to the world of web services, REST is most commonly used to refer to the transmission of XML over HTTP, and the identification of XML resources via URIs. According to REST, HTTP, XML and URIs provide all the infrastructure for building robust web services, and most developers can therefore safely skip over the pain of learning SOAP and WSDL. If you are new to REST, check out Paul Prescod’s excellent REST articles on xml.com.
A major element of web services is planning for when things go wrong, and propagating error messages back to client applications. However, unlike SOAP, REST-based web services do not have a well-defined convention for returning error messages. In fact, after surveying a number of REST-based web services in the wild, there appear to be four different alternatives for handling errors. Below, I outline the four alternatives, and then provide my opinion on which option or combination of options is best.
Option 1: Stick to HTTP Error Codes
In this scenario, the web service propagates error messages via standard HTTP Error Codes. For example, assume we have the following URL:
http://www.example.com/xml/book?id=1234&dev_token=ABCD1234
This service expects a single parameter: id indicating a book ID. The service extracts the idparameter, does a database look-up and returns an XML representation of the specified book. If the URL specifies an invalid or obsolete id parameter, the service returns an HTTP 404 Not Found Error Code.
Option 2: Return an Empty Set
In this scenario, the web service always returns back an XML document which can have 0 or more subelements. If some error occurs, an XML document with zero elements is returned. The O’Reilly Meerkat news service currently uses this approach. For example, the following URL connects to Meerkat and requests all Linux related articles from the past two days, and formats the results in RSS 0.91:
http://www.oreillynet.com/meerkat/?c=cat10&t=2DAY&_fl=xml
Now, try specifying an invalid category. For example, set c =ten, like this:
http://www.oreillynet.com/meerkat/?c=ten&t=2DAY&_fl=rss
In this case, Meerkat returns an RSS document with zero
item elements. This indicates that there are no matching results, but it does not indicate whether this is a valid category ID which contains no news items, or an invalid category ID.Option 3: Use Extended HTTP Headers
In this scenario, the web service always returns an HTTP 200 OK Status Code, but specifies an application specific error code within a separate HTTP Header. The Distributed Annotation System (DAS) currently uses this alternative approach. For example, the following URL requests sequence data from Human Chromosome 1 from the Ensembl DAS Server:
http://servlet.sanger.ac.uk:8080/das/ensembl1533/sequence?segment=1:100000,100100
Now, try issuing this request for Human Chromosome 30 (there is no human chromosome 30!):
http://servlet.sanger.ac.uk:8080/das/ensembl1533/sequence?segment=30:100000,100100
If you click on the link above, you will see an empty page. However, if you have network sniffer, you can see the following HTTP response:
HTTP/1.1 200 OK Server: Resin/2.0.5 Content-Encoding: gzip X-DAS-Version: 1.5 X-DAS-Server: DazzleServer/0.98 (20030508; BioJava 1.3) X-DAS-Capabilities: dsn/1.0; dna/1.0; types/1.0; stylesheet/1.0; features/1.0; encoding-dasgff/1.0; encoding-xff/1.0; entry_points/1.0; error-segment/1.0; unknown-segment/1.0; component/1.0; sequence/1.0 X-DAS-Status: 403 Content-Type: text/plain Content-Length: 10 Date: Sun, 30 Nov 2003 21:02:13 GMT
As you can see, the DAS server has returned an HTTP 200 OK Status code and a required X-DAS-Status code. In this case, the code 403 refers to a DAS Specific error code: “Bad reference object (reference sequence unknown)”.
Option 4: Return an XML Error Document
In this scenario, the web service always returns an HTTP Status Code of 200, but also includes an XML document containing an application specific error message. The XooMLeapplication currently uses this approach (XooMLe provides a RESTful API wrapper to the existing SOAP based Google API). For example, the Google API requires that you specify a valid developer token. If you specify an invalid token, XooMLe returns an XML error document. As the XooMLe documentation puts it, “If you do something wrong, XooMLe will tell you in a nice, tasty little XML-package.” For example, try this URL:
http://xoomle.dentedreality.com.au/search/?hl=en&ie=ISO-8859-1&key=&q=oreilly+php
The request does not include a Google developer token. Hence, XooMLe returns back the following XML document:
<?xml version="1.0" ?> <xoomleError> <method>doGoogleSearch</method> <errorString>Invalid Google API key supplied</errorString> <arguments> <hl>en</hl> <ie>ISO-8859-1</ie> <key></key> <q>oreilly php</q> </arguments> </xoomleError>
The Amazon.com web services API also follows this approach, and each returned XML document can specify an ErrorMsg element. For example, see the Amazon.com Dev-Lite Schema.
Best Practices for REST Error Handling
Assuming you are busy implementing a REST-based web service, which error handling option do you choose? I don’t believe there are (yet) any best practices for REST error handling (for an overview of other best REST practices, see Paul Costello’s REST presentation, in particular [Side 59].)
Nonetheless, here are my votes for most important criteria:
- Human Readable Error Messages: Part of the major appeal of REST based web services is that you can open any browser, type in the right URL, and see an immediate response — no special tools needed. However, HTTP error codes do not always provide enough information. For example, if we take option 1 above, and request and invalid book ID, we get back a 404 Error Code. From the developer perspective, have we actually typed in the wrong host name, or an invalid book ID? It’s not immediately clear. In Option 3 (DAS), we get back a blank page with no information. To view the actual error code, you need to run a network sniffer, or point your browser through a proxy. For all these reasons, I think Option 4 has a lot to offer. It significantly lowers the barrier for new developers, and enables all information related to a web service to be directly viewable within a web browser.
- Application Specific Errors: Option 1 has the disadvantage of not being directly viewable within a browser. It also has the additional disadvantage of mapping all HTTP error codes to application specific error codes. HTTP status codes are specific to document retrieval and posting, and these may not map directly to your application domain. For example, one of the DAS error codes relates to invalid genomic coordinates (sequence coordinate is out of bounds/invalid). What HTTP error code would we map to in this case?
- Machine Readable Error Codes: As a third criteria, error codes should be easily readable by other applications. For example, the XooMLe application returns back only human readable error messages, e.g. “Invalid Google API key supplied”. An application parsing a XooMLe response would have to search for this specific error message, and this can be notoriously brittle — for example, the XooMLe server might simply change the message to “Invalid Key Supplied”. Error codes, such as those provided by DAS are important for programmatic control, and easy creation of exceptions. For example, if XooMLe returned a 1001 error code, a client application could do a quick lookup and immediately throw an InvalidKeyException.
Based on these three criteria, here’s my vote for best error handling option:
- Use HTTP Status Codes for problems specifically related to HTTP, and not specifically related to your web service.
- When an error occurs, always return an XML document detailing the error.
- Make sure the XML error document contains both an error code, and a human readable error message. For example:
<?xml version="1.0" encoding="UTF-8" ?> <error> <error_code>1001</error_code> <error_msg>Invalid Google API key supplied</error_msg> </error>
By following these three simple practices, you can make it significantly easier for others to interface with your service, and react when things go wrong. New developers can easily see valid and invalid requests via a simple web browser, and programs can easily (and more robustly) extract error codes and act appropriately.
Create Custom Header
Reference : Adding Custom Http Header To All WCF Requests
Friday, September 30, 2016
Index column order affect Index seek or scan
Cols
1 2 3
-------------
| | 1 | |
| A |---| |
| | 2 | |
|---|---| |
| | | |
| | 1 | 9 |
| B | | |
| |---| |
| | 2 | |
| |---| |
| | 3 | |
|---|---| |
See how restricting on A first, as your first column eliminates more results than restricting on your second column first? It's easier if you picture how the index must be traversed across, column 1, then column 2, etc...you see that lopping off most of the results in the fist pass makes the 2nd step that much faster.
Another case, if you queried on column 3, the optimizer wouldn't even use the index, because it's not helpful at all in narrowing down the result sets. Anytime you're in a query, narrowing down the number of results to deal with before the next step means better performance.
Since the index is also stored this way, there's no backtracking across the index to find the first column when you're querying on it.
In short: No, it's not for show, there are real performance benefits.
Wednesday, September 28, 2016
合理价层次与看法
如果你有留意股市,你会发觉股价都会分成三个层次。
1. 比合理价低
2. 合理价
3. 比合理价高
而这三种股价又出现在三种股市的趋势里。
1. 熊市
2. 平稳
3. 牛市
所以买股,最重要就是要了解你买的公司的性质,不然你就会有一种捉龟跑鄨的感觉。
可能你会问什么是合理价?合理价有可以分成三种看法
1. 实质分析
根据市场先生的说法,就是把整间公司清盘了,就是它的合理价。合理价再减30%的折扣,防止意想不到的损失或亏损,这个价位就可以买入了。
2. 赚益分析
这种说法就是如果公司每年的赚益有超过其他的投资,这个价位就可以买入。比方,你用一元买,一年它赚一角,那么它的赚益就是10%,本益比就是10。如果,你在市场上,比方做生意还是买卖房产都无法赚取这样的赚益,那么这个投资就是适合你了。
3. 股息分析
这种说法就是不看公司的赚益,单看股息的发派。如果你用一元买,每年公司发放5分的股息。那么你的回酬就是5%。如果你找不到银行利息或其他的投资让你享有5%的回酬,那么这个投资就是适合你了。
当你了解了合理价,你就要考虑到时机了,因为你要把你的盈利放到最大。所以,你就要在三种趋势里分类出公司的性质。或许我简单的说说,让你明白一下。
1. 高股息优质股。
熊市>比合理价高一点或低一点
平稳>比合理价高一点
牛市》比合理价高一点
2. 成长性优质股
熊市>比合理价低一点
平稳>比合理价高
牛市》比合理价高很多
3。 投机性股
熊市>比合理价低很多
平稳>合理价或高或低,看个股
牛市》比合理价高很多
4. 垃圾股
没有合理价,纯粹赌运。
1. 比合理价低
2. 合理价
3. 比合理价高
而这三种股价又出现在三种股市的趋势里。
1. 熊市
2. 平稳
3. 牛市
所以买股,最重要就是要了解你买的公司的性质,不然你就会有一种捉龟跑鄨的感觉。
可能你会问什么是合理价?合理价有可以分成三种看法
1. 实质分析
根据市场先生的说法,就是把整间公司清盘了,就是它的合理价。合理价再减30%的折扣,防止意想不到的损失或亏损,这个价位就可以买入了。
2. 赚益分析
这种说法就是如果公司每年的赚益有超过其他的投资,这个价位就可以买入。比方,你用一元买,一年它赚一角,那么它的赚益就是10%,本益比就是10。如果,你在市场上,比方做生意还是买卖房产都无法赚取这样的赚益,那么这个投资就是适合你了。
3. 股息分析
这种说法就是不看公司的赚益,单看股息的发派。如果你用一元买,每年公司发放5分的股息。那么你的回酬就是5%。如果你找不到银行利息或其他的投资让你享有5%的回酬,那么这个投资就是适合你了。
当你了解了合理价,你就要考虑到时机了,因为你要把你的盈利放到最大。所以,你就要在三种趋势里分类出公司的性质。或许我简单的说说,让你明白一下。
1. 高股息优质股。
熊市>比合理价高一点或低一点
平稳>比合理价高一点
牛市》比合理价高一点
2. 成长性优质股
熊市>比合理价低一点
平稳>比合理价高
牛市》比合理价高很多
3。 投机性股
熊市>比合理价低很多
平稳>合理价或高或低,看个股
牛市》比合理价高很多
4. 垃圾股
没有合理价,纯粹赌运。
Subscribe to:
Comments (Atom)

