How to Add Active Navigation Class Based on URL?

Ideally you output this class from the server side, but if you can't...

Let's say you have navigation like this:

HTML:
  1. <nav>
  2.     <ul>
  3.         <li><a href="/">Home</a></li>
  4.         <li><a href="/about/">About</a></li>
  5.         <li><a href="/clients/">Clients</a></li>
  6.         <li><a href="/contact/">Contact Us</a></li>
  7.     </ul>
  8. </nav>

And you are at the URL:

http://yoursite.com/about/team/

And you want the About link to get a class of "active" so you can visually indicate it's the active navigation.

jQuery:
  1. <script type="text/javascript">
  2.     $(function () {
  3.         var page = location.pathname.split("/")[1];
  4.         if (page != "") {
  5.             $('nav a[href^="/' + page + '"]').parent().addClass('active');
  6.         }
  7.     });
  8. </script>

JavaScript:
  1. <script type="text/javascript">
  2. (function() {
  3.     var nav = document.getElementById('nav'),
  4.         anchor = nav.getElementsByTagName('a'),
  5.         current = window.location.pathname.split('/')[1];
  6.         for (var i = 0; i < anchor.length; i++) {
  7.         if(anchor[i].href == current) {
  8.             anchor[i].className = "active";
  9.         }
  10.     }
  11. })();
  12. </script>

Essentially that will match links in the nav who's href attribute begins with "/about" (or whatever the secondary directory happens to be).

Comparison Operators:
  1. = is equal
  2. != is not equal
  3. ^= starts with
  4. $= ends with
  5. *= contains

Reference: CSS-Tricks
Thursday, 24 April 2014
Posted by Jebastin

How to enable paste option in Windows Server 2008 to copy from local machine?

Restart rdpclip.exe in Server machine.
Tuesday, 18 March 2014
Posted by Jebastin

jQuery to load first 5 elements & click "load more" to display next 5 elements

jQuery functionality to load first 5 elements & click "load more" to display next 5 elements.

HTML:
  1. <ul id="myList">
  2.     <li>One</li>
  3.     <li>Two</li>
  4.     <li>Three</li>
  5.     <li>Four</li>
  6.     <li>Five</li>
  7.     <li>Six</li>
  8.     <li>Seven</li>
  9.     <li>Eight</li>
  10.     <li>Nine</li>
  11.     <li>Ten</li>
  12.     <li>Eleven</li>
  13.     <li>Twelve</li>
  14.     <li>Thirteen</li>
  15.     <li>Fourteen</li>
  16.     <li>Fifteen</li>
  17.     <li>Sixteen</li>
  18.     <li>Seventeen</li>
  19.     <li>Eighteen</li>
  20.     <li>Nineteen</li>
  21.     <li>Twenty one</li>
  22.     <li>Twenty two</li>
  23.     <li>Twenty three</li>
  24.     <li>Twenty four</li>
  25.     <li>Twenty five</li>
  26. </ul>
  27. <div id="loadMore">Load more</div>
  28. <div id="showLess">Show less</div>

CSS:
  1. #myList li{
  2.     display:none;
  3. }
  4. #loadMore {
  5.     color:green;
  6.     cursor:pointer;
  7. }
  8. #loadMore:hover {
  9.     color:black;
  10. }
  11. #showLess {
  12.     color:red;
  13.     cursor:pointer;
  14. }
  15. #showLess:hover {
  16.     color:black;
  17. }

jQuery:
  1. $(document).ready(function () {
  2.     size_li = $("#myList li").size();
  3.     x=3;
  4.     $('#myList li:lt('+x+')').show();
  5. });
  6. $('#loadMore').click(function () {
  7.         x= (x+5 <= size_li) ? x+5 : size_li;
  8.         $('#myList li:lt('+x+')').show();
  9. });
  10. $('#showLess').click(function () {
  11.     x=(x-5<0) ? 3 : x-5;
  12.     $('#myList li').not(':lt('+x+')').hide();
  13. });
Reference: StackOverflow   jsfiddle
Wednesday, 19 February 2014
Posted by Jebastin
Tag :

How to get the class name using jQuery?

Consider the following HTML:
<div id="myId" class="myclass"></div>

jQuery:
var className = $('.myclass').attr('class');
(or)
var className = $('#myId').attr('class');

Reference: StackOverflow.com
Posted by Jebastin
Tag :

Working with jQuery ajax error function

By using the $.ajaxSetup() we can handle the error/exception as mentioned below:
  1. $(function() {
  2.     $.ajaxSetup({
  3.         error: function(jqXHR, exception) {
  4.             if (jqXHR.status === 0) {
  5.                 alert('Not connect.\n Verify Network.');
  6.             } else if (jqXHR.status == 404) {
  7.                 alert('Requested page not found. [404]');
  8.             } else if (jqXHR.status == 500) {
  9.                 alert('Internal Server Error [500].');
  10.             } else if (exception === 'parsererror') {
  11.                 alert('Requested JSON parse failed.');
  12.             } else if (exception === 'timeout') {
  13.                 alert('Time out error.');
  14.             } else if (exception === 'abort') {
  15.                 alert('Ajax request aborted.');
  16.             } else {
  17.                 alert('Uncaught Error.\n' + jqXHR.responseText);
  18.             }
  19.         }
  20.     });
  21. });
Reference: StackOverflow.com
Posted by Jebastin
Tag : ,

List of built-in functions in Javascript

The following are the list of pre-defined/built-in functions in Javascript.

Number Methods

The Number object contains only the default methods that are part of every object's definition.
MethodDescription
constructor()Returns the function that created this object's instance. By default this is the Number object.
toExponential()Forces a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.
toFixed()Formats a number with a specific number of digits to the right of the decimal.
toLocaleString()Returns a string value version of the current number in a format that may vary according to a browser's locale settings.
toPrecision()Defines how many total digits (including digits to the left and right of the decimal) to display of a number.
toString()Returns the string representation of the number's value.
valueOf()Returns the number's value.

Boolean Methods

Here is a list of each method and its description.
MethodDescription
toSource()Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
toString()Returns a string of either "true" or "false" depending upon the value of the object.
valueOf()Returns the primitive value of the Boolean object.

String Methods

Here is a list of each method and its description.
MethodDescription
charAt()Returns the character at the specified index.
charCodeAt()Returns a number indicating the Unicode value of the character at the given index.
concat()Combines the text of two strings and returns a new string.
indexOf()Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
lastIndexOf()Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
localeCompare()Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
length()Returns the length of the string.
match()Used to match a regular expression against a string.
replace()Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
search()Executes the search for a match between a regular expression and a specified string.
slice()Extracts a section of a string and returns a new string.
split()Splits a String object into an array of strings by separating the string into substrings.
substr()Returns the characters in a string beginning at the specified location through the specified number of characters.
substring()Returns the characters in a string between two indexes into the string.
toLocaleLowerCase()The characters within a string are converted to lower case while respecting the current locale.
toLocaleUpperCase()The characters within a string are converted to upper case while respecting the current locale.
toLowerCase()Returns the calling string value converted to lower case.
toString()Returns a string representing the specified object.
toUpperCase()Returns the calling string value converted to uppercase.
valueOf()Returns the primitive value of the specified object.

String HTML wrappers

Here is a list of each method which returns a copy of the string wrapped inside the appropriate HTML tag.
MethodDescription
anchor()Creates an HTML anchor that is used as a hypertext target.
big()Creates a string to be displayed in a big font as if it were in a <big> tag.
blink()Creates a string to blink as if it were in a <blink> tag.
bold()Creates a string to be displayed as bold as if it were in a <b> tag.
fixed()Causes a string to be displayed in fixed-pitch font as if it were in a <tt> tag
fontcolor()Causes a string to be displayed in the specified color as if it were in a <font color="color"> tag.
fontsize()Causes a string to be displayed in the specified font size as if it were in a <font size="size"> tag.
italics()Causes a string to be italic, as if it were in an <i> tag.
link()Creates an HTML hypertext link that requests another URL.
small()Causes a string to be displayed in a small font, as if it were in a <small> tag.
strike()Causes a string to be displayed as struck-out text, as if it were in a <strike> tag.
sub()Causes a string to be displayed as a subscript, as if it were in a <sub> tag
sup()Causes a string to be displayed as a superscript, as if it were in a <sup> tag

Array Methods

Here is a list of each method and its description.
MethodDescription
concat()Returns a new array comprised of this array joined with other array(s) and/or value(s).
every()Returns true if every element in this array satisfies the provided testing function.
filter()Creates a new array with all of the elements of this array for which the provided filtering function returns true.
forEach()Calls a function for each element in the array.
indexOf()Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
join()Joins all elements of an array into a string.
lastIndexOf()Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
map()Creates a new array with the results of calling a provided function on every element in this array.
pop()Removes the last element from an array and returns that element.
push()Adds one or more elements to the end of an array and returns the new length of the array.
reduce()Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
reduceRight()Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.
reverse()Reverses the order of the elements of an array -- the first becomes the last, and the last becomes the first.
shift()Removes the first element from an array and returns that element.
slice()Extracts a section of an array and returns a new array.
some()Returns true if at least one element in this array satisfies the provided testing function.
toSource()Represents the source code of an object
sort()Sorts the elements of an array.
splice()Adds and/or removes elements from an array.
toString()Returns a string representing the array and its elements.
unshift()Adds one or more elements to the front of an array and returns the new length of the array.

Date Methods:

Here is a list of each method and its description.
MethodDescription
Date()Returns today's date and time
getDate()Returns the day of the month for the specified date according to local time.
getDay()Returns the day of the week for the specified date according to local time.
getFullYear()Returns the year of the specified date according to local time.
getHours()Returns the hour in the specified date according to local time.
getMilliseconds()Returns the milliseconds in the specified date according to local time.
getMinutes()Returns the minutes in the specified date according to local time.
getMonth()Returns the month in the specified date according to local time.
getSeconds()Returns the seconds in the specified date according to local time.
getTime()Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC.
getTimezoneOffset()Returns the time-zone offset in minutes for the current locale.
getUTCDate()Returns the day (date) of the month in the specified date according to universal time.
getUTCDay()Returns the day of the week in the specified date according to universal time.
getUTCFullYear()Returns the year in the specified date according to universal time.
getUTCHours()Returns the hours in the specified date according to universal time.
getUTCMilliseconds()Returns the milliseconds in the specified date according to universal time.
getUTCMinutes()Returns the minutes in the specified date according to universal time.
getUTCMonth()Returns the month in the specified date according to universal time.
getUTCSeconds()Returns the seconds in the specified date according to universal time.
getYear()Deprecated - Returns the year in the specified date according to local time. Use getFullYear instead.
setDate()Sets the day of the month for a specified date according to local time.
setFullYear()Sets the full year for a specified date according to local time.
setHours()Sets the hours for a specified date according to local time.
setMilliseconds()Sets the milliseconds for a specified date according to local time.
setMinutes()Sets the minutes for a specified date according to local time.
setMonth()Sets the month for a specified date according to local time.
setSeconds()Sets the seconds for a specified date according to local time.
setTime()Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.
setUTCDate()Sets the day of the month for a specified date according to universal time.
setUTCFullYear()Sets the full year for a specified date according to universal time.
setUTCHours()Sets the hour for a specified date according to universal time.
setUTCMilliseconds()Sets the milliseconds for a specified date according to universal time.
setUTCMinutes()Sets the minutes for a specified date according to universal time.
setUTCMonth()Sets the month for a specified date according to universal time.
setUTCSeconds()Sets the seconds for a specified date according to universal time.
setYear()Deprecated - Sets the year for a specified date according to local time. Use setFullYear instead.
toDateString()Returns the "date" portion of the Date as a human-readable string.
toGMTString()Deprecated - Converts a date to a string, using the Internet GMT conventions. Use toUTCString instead.
toLocaleDateString()Returns the "date" portion of the Date as a string, using the current locale's conventions.
toLocaleFormat()Converts a date to a string, using a format string.
toLocaleString()Converts a date to a string, using the current locale's conventions.
toLocaleTimeString()Returns the "time" portion of the Date as a string, using the current locale's conventions.
toSource()Returns a string representing the source for an equivalent Date object; you can use this value to create a new object.
toString()Returns a string representing the specified Date object.
toTimeString()Returns the "time" portion of the Date as a human-readable string.
toUTCString()Converts a date to a string, using the universal time convention.
valueOf()Returns the primitive value of a Date object.

Date Static Methods:

In addition to the many instance methods listed previously, the Date object also defines two static methods. These methods are invoked through the Date( ) constructor itself:
MethodDescription
Date.parse( )Parses a string representation of a date and time and returns the internal millisecond representation of that date.
Date.UTC( )Returns the millisecond representation of the specified UTC date and time.

Math Methods

Here is a list of each method and its description.
MethodDescription
abs()Returns the absolute value of a number.
acos()Returns the arccosine (in radians) of a number.
asin()Returns the arcsine (in radians) of a number.
atan()Returns the arctangent (in radians) of a number.
atan2()Returns the arctangent of the quotient of its arguments.
ceil()Returns the smallest integer greater than or equal to a number.
cos()Returns the cosine of a number.
exp()Returns EN, where N is the argument, and E is Euler's constant, the base of the natural logarithm.
floor()Returns the largest integer less than or equal to a number.
log()Returns the natural logarithm (base E) of a number.
max()Returns the largest of zero or more numbers.
min()Returns the smallest of zero or more numbers.
pow()Returns base to the exponent power, that is, base exponent.
random()Returns a pseudo-random number between 0 and 1.
round()Returns the value of a number rounded to the nearest integer.
sin()Returns the sine of a number.
sqrt()Returns the square root of a number.
tan()Returns the tangent of a number.
toSource()Returns the string "Math".

RegExp Methods:

Here is a list of each method and its description.
MethodDescription
exec()Executes a search for a match in its string parameter.
test()Tests for a match in its string parameter.
toSource()Returns an object literal representing the specified object; you can use this value to create a new object.
toString()Returns a string representing the specified object.


Saturday, 1 February 2014
Posted by Jebastin

Working with Dynamic Pagination in ASP.NET

Pagination is a typical process in data display whereby large sets of data are broken into discrete sections for viewing, more often than not used in conjunction with some type of grid or list component.

CSHTML:

  1. @using Smp.Web.Common;
  2. @inherits umbraco.MacroEngines.DynamicNodeContext
  3. @{
  4.     Smp.Web.WebServices.HistoricalService objHS = new Smp.Web.WebServices.HistoricalService();
  5.     var HS = objHS.GetHistoricalPrices(1, PageSize, "", "");
  6.     var PageCount = 0;
  7.     var PageSize = 10;
  8.     foreach (var item in HS)
  9.     {
  10.         PageCount = item._noOfPages;
  11.         break;
  12.     }
  13. }
  14. <div class="historical_content_pop">
  15.     <div class="paginationHolder">
  16.     <ul class="hsPagination paginationList">
  17.     @for (int i = 1; i <= PageCount; i++)
  18.     {
  19.         if (i == 1)
  20.         {
  21.         <li><a pageno="@i" href="javascript:void(0);" class="currentSearchPage">@i</a></li>
  22.         }
  23.         else
  24.         {
  25.         <li><a pageno="@i" href="javascript:void(0);">@i</a></li>
  26.         }
  27.         if (i == 10 && PageCount > 10)
  28.         {
  29.         <li><a class="next" pageno="11" href="javascript:void(0);">
  30.             <img src="/images/pagination_arrow_next.png" alt=">" /></a></li>
  31.             break;
  32.         }
  33.     }
  34.     </ul>
  35.     </div>
  36.     <div class="historicalContcontain">
  37.         <div class="dateFilter">
  38.             <form id="frmHistoricalPrices">
  39.             <input id="txtStartDate" class="priceFilterField firstField" type="text" placeholder="Start Date" />
  40.             <input id="txtEndDate" class="priceFilterField" type="text" placeholder="End Date" />
  41.             <p class="formHelper">Ex: 01/01/2000</p> <a href="javascript:void(0);" id="btnApply"
  42.                 class="priceFilterBtn">SEARCH</a>
  43.             </form>
  44.         </div>
  45.         <div class="priceResultHolder">
  46.             <ul class="priceResultHeader">
  47.                 <li class="priceDateCol">Date</li>
  48.                 <li class="pricePriceCol">Price</li>
  49.                 <li class="priceHighCol">High</li>
  50.                 <li class="priceVolumeCol">Volume</li>
  51.             </ul>
  52.             @{var count = 1; var classUL = "";}
  53.             @foreach (var item in HS)
  54.             {
  55.                 if (count % 2 == 0)
  56.                 {
  57.                     classUL = "priceResultList alt";
  58.                 }
  59.                 else
  60.                 {
  61.                     classUL = "priceResultList";
  62.                 }
  63.                 count++;
  64.                 <ul class="@classUL">
  65.                     <li class="priceDateCol">@item._date</li>
  66.                     <li class="pricePriceCol">@item._price</li>
  67.                     <li class="priceHighCol">@item._high</li>
  68.                     <li class="priceVolumeCol">@Convert.ToDecimal(item._volume).ToString("N0")</li>
  69.                 </ul>
  70.             }
  71.         </div>
  72.     </div>
  73. </div>

jQuery:

  1. <script type="text/javascript">
  2. $("#btnApply").click(function () {
  3.     FetchHistoricalData(1, 10, this);
  4. });
  5. $(".hsPagination li a").die("click").live('click', function () {
  6.     var pageNo = parseInt($(this).attr('pageno'));
  7.     FetchHistoricalData(pageNo, 10, this);
  8. });
  9. function FetchHistoricalData(pageNo, pageSize, obj) {
  10.     var startDate = $("#txtStartDate").val();
  11.     var endDate = $("#txtEndDate").val();
  12.     $.ajax({
  13.         type: "POST",
  14.         data: "{pageNo:" + pageNo + ",pageSize:" + pageSize + ",'StDate':'" + startDate + "','EndDate':'" + endDate + "'}",
  15.         url: "/WebServices/HistoricalService.asmx/GetHistoricalPrices",
  16.         contentType: "application/json; charset=utf-8",
  17.         dataType: "json",
  18.         success: function (response) {
  19.             var hs = response.d;
  20.             var htmlData = "";
  21.             var htmlPagination = "";
  22.             var classUL = "";
  23.             var pageCount = 0;
  24.             htmlData += "<ul class='priceResultHeader'>";
  25.             htmlData += "<li class='priceDateCol'>Date</li>";
  26.             htmlData += "<li class='pricePriceCol'>Price</li>";
  27.             htmlData += "<li class='priceHighCol'>High</li>";
  28.             htmlData += "<li class='priceVolumeCol'>Volume</li></ul>";
  29.             for (var i = 0; i < hs.length; i++) {
  30.                 if (i % 2 == 0) {
  31.                     classUL = "priceResultList";
  32.                 }
  33.                 else {
  34.                     classUL = "priceResultList alt";
  35.                 }
  36.                 htmlData += "<ul class='" + classUL + "'>";
  37.                 htmlData += "<li class='priceDateCol'>" + hs[i]._date + "</li>";
  38.                 htmlData += "<li class='pricePriceCol'>" + hs[i]._price + "</li>";
  39.                 htmlData += "<li class='priceHighCol'>" + hs[i]._high + "</li>";
  40.                 htmlData += "<li class='priceVolumeCol'>" + (hs[i]._volume).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + "</li></ul>";
  41.                 pageCount = hs[i]._noOfPages;
  42.             }
  43.             $(".priceResultHolder").html(htmlData);
  44.             if ($(obj).hasClass('next')) {
  45.                 var prevPage = pageNo - 1;
  46.                 var nextPage = pageNo + 10;
  47.                 var lastPage = pageNo + 9;
  48.                 var last = false;
  49.                 if (lastPage > pageCount) {
  50.                     lastPage = pageCount;
  51.                     last = true;
  52.                 }
  53.                 htmlPagination += "<li><a pageno='" + prevPage + "' class='prev' href='javascript:void(0);'><img src='/images/pagination_arrow_prev.png' alt='<' /></a></li>";
  54.                 for (var i = pageNo; i <= lastPage; i++) {
  55.                     if (i == pageNo) {
  56.                         htmlPagination += "<li><a class='currentSearchPage' pageno='" + i + "' href='javascript:void(0);'>" + i + "</a></li>";
  57.                     }
  58.                     else {
  59.                         htmlPagination += "<li><a pageno='" + i + "' href='javascript:void(0);'>" + i + "</a></li>";
  60.                     }
  61.                 }
  62.                 if (!last) {
  63.                     htmlPagination += "<li><a pageno='" + nextPage + "' class='next' href='javascript:void(0);'><img src='/images/pagination_arrow_next.png' alt='>' /></a></li>";
  64.                 }
  65.                 $(".hsPagination").html(htmlPagination);
  66.                 htmlPagination = "";
  67.             }
  68.             else if ($(obj).hasClass('prev')) {
  69.                 var prevPage = pageNo - 10;
  70.                 var nextPage = pageNo + 1;
  71.                 var firstPage = pageNo - 9;
  72.                 if (pageCount > 10) {
  73.                     if (prevPage != 0) {
  74.                         htmlPagination += "<li><a pageno='" + prevPage + "' class='prev' href='javascript:void(0);'><img src='/images/pagination_arrow_prev.png' alt='<' /></a></li>";
  75.                     }
  76.                     for (var i = firstPage; i < nextPage; i++) {
  77.                         if (i == nextPage - 1) {
  78.                             htmlPagination += "<li><a class='currentSearchPage' pageno='" + i + "' href='javascript:void(0);'>" + i + "</a></li>";
  79.                         }
  80.                         else {
  81.                             htmlPagination += "<li><a pageno='" + i + "' href='javascript:void(0);'>" + i + "</a></li>";
  82.                         }
  83.                     }
  84.                     htmlPagination += "<li><a pageno='" + nextPage + "' class='next' href='javascript:void(0);'><img src='/images/pagination_arrow_next.png' alt='>' /></a></li>";
  85.                 }
  86.                 $(".hsPagination").html(htmlPagination);
  87.                 htmlPagination = "";
  88.             }
  89.             else if ($(obj).hasClass('priceFilterBtn')) {
  90.                 if (pageCount > 1) {
  91.                     for (var i = 1; i <= pageCount; i++) {
  92.                         if (i == 1) {
  93.                             htmlPagination += "<li><a class='currentSearchPage' pageno='" + i + "' href='javascript:void(0);'>" + i + "</a></li>";
  94.                         }
  95.                         else {
  96.                             htmlPagination += "<li><a pageno='" + i + "' href='javascript:void(0);'>" + i + "</a></li>";
  97.                         }
  98.                         if (i == 10 && pageCount > 10) {
  99.                             htmlPagination += "<li><a pageno='11' class='next' href='javascript:void(0);'><img src='/images/pagination_arrow_next.png' alt='>' /></a></li>";
  100.                             break;
  101.                         }
  102.                     }
  103.                 }
  104.                 $(".hsPagination").html(htmlPagination);
  105.                 htmlPagination = "";
  106.             }
  107.             else {
  108.                 $('.hsPagination li a').each(function () {
  109.                     $(this).removeClass('currentSearchPage');
  110.                 });
  111.                 $(obj).addClass('currentSearchPage');
  112.             }
  113.             htmlData = "";
  114.         }
  115.     });
  116. }
  117. </script>

Web Service:

  1. [WebMethod(EnableSession = true)]
  2. public List<HistoricalProperty> GetHistoricalPrices(int pageNo, int pageSize, string StDate, string EndDate)
  3. {
  4.     List<HistoricalProperty> historyPricesList = new List<HistoricalProperty>();
  5.     try
  6.     {
  7.         var skipPrices = (pageNo - 1) * pageSize;
  8.         if (Context.Session["historicalPrice"] != null)
  9.         {
  10.             historyPricesList = (List<HistoricalProperty>)Context.Session["historicalPrice"];
  11.             if (StDate.Trim() != "" || EndDate.Trim() != "")
  12.             {
  13.                 historyPricesList = historyPricesList.Where(x => Convert.ToDateTime(x._date) >= Convert.ToDateTime(StDate) && Convert.ToDateTime(x._date) <= Convert.ToDateTime(EndDate)).ToList();
  14.             }
  15.             var totalCount = historyPricesList.Count();
  16.             historyPricesList = historyPricesList.Skip(skipPrices).Take(pageSize).ToList();
  17.             var totalPageCount = 0;
  18.             if (totalCount % pageSize == 0)
  19.             {
  20.                 totalPageCount = totalCount / pageSize;
  21.             }
  22.             else
  23.             {
  24.                 totalPageCount = totalCount / pageSize + 1;
  25.             }
  26.             foreach (var item in historyPricesList)
  27.             {
  28.                 item._totalCount = totalCount;
  29.                 item._noOfPages = totalPageCount;
  30.             }
  31.         }
  32.         else
  33.         {
  34.             SMPHistoricalService.Header HisHeader = new SMPHistoricalService.Header();
  35.             HisHeader.Username = ApplicationConstants._HistoricalHeaderUsername;
  36.             SMPHistoricalService.SMPHIstoricalSplice HisSplice = new SMPHistoricalService.SMPHIstoricalSplice();
  37.             HisSplice.HeaderValue = HisHeader;
  38.             SMPHistoricalService.Untitled HisOutputData = HisSplice.SMPXignite_SMPHIstorical(SMPHistoricalService.IdentifierTypes.Symbol, "", "");
  39.             SMPHistoricalService.Quotes[] Quotes = HisOutputData.GetHistoricalQuotesRangeReturnObject.Quotes;
  40.             //This Splice takes the inputs Identifier, IdentifierType, StartDate, EndDate
  41.             //and calls GetHistoricalQuotesRange to generate Untitled.  
  42.             var totalCount = Quotes.Count();
  43.             var totalPageCount = 0;
  44.             if (totalCount % pageSize == 0)
  45.             {
  46.                 totalPageCount = totalCount / pageSize;
  47.             }
  48.             else
  49.             {
  50.                 totalPageCount = totalCount / pageSize + 1;
  51.             }
  52.             foreach (var quote in Quotes)
  53.             {
  54.                 historyPricesList.Add(new HistoricalProperty
  55.                 {
  56.                     _date = quote.Date,
  57.                     _price = quote.Price.ToString(),
  58.                     _high = quote.High.ToString(),
  59.                     _volume = quote.Volume.ToString(),
  60.                     _totalCount = totalCount,
  61.                     _noOfPages = totalPageCount
  62.                 });
  63.             }
  64.             Context.Session["historicalPrice"] = historyPricesList;
  65.             historyPricesList = historyPricesList.Skip(skipPrices).Take(pageSize).ToList();
  66.         }
  67.     }
  68.     catch
  69.     {
  70.         historyPricesList.Add(new HistoricalProperty { _errorMessage = ApplicationConstants._ServiceErrorMessage });
  71.     }
  72.     return historyPricesList;
  73. }
Wednesday, 29 January 2014
Posted by Jebastin

Link To This Post/Page

Spread The Word

Add this button to your blog:
JJ Technology Solutions

Blog Archive

Trackers

eXTReMe Tracker
facebook

- Copyright © JJ Technology Solutions - Powered by Source Code Solutions -