Tighten up some exceptions in the log
Some checks failed
Build .NET Project / build (push) Has been cancelled
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -239,6 +239,7 @@ namespace MarketData.Helper
|
||||
responseString = Utility.KeepAfter(responseString, "earnings_announcements_earnings_table");
|
||||
if (null == responseString) return null;
|
||||
responseString = Utility.KeepBefore(responseString, "] ]");
|
||||
responseString = Utility.RemoveAfter(responseString, "earnings_announcements_sales_table"); // so don't bleed into next table
|
||||
if (null == responseString) return null;
|
||||
responseString = responseString + "]";
|
||||
responseString = Utility.KeepAfter(responseString, "[ [");
|
||||
@@ -264,7 +265,7 @@ namespace MarketData.Helper
|
||||
if (null != periodEndingItems && 2 == periodEndingItems.Length)
|
||||
{
|
||||
int month = (int)FeedParser.ParseValueLong(periodEndingItems[0]);
|
||||
int year = (int)FeedParser.ParseValueLong(periodEndingItems[1]);
|
||||
int year = (int)FeedParser.ParseValueLong(periodEndingItems[1]);
|
||||
earningsAnnouncement.PeriodEnding = new DateTime(year, month, DateTime.DaysInMonth(year, month));
|
||||
}
|
||||
earningsAnnouncement.Estimate = FeedParser.ParseValue(columnData[2]);
|
||||
@@ -1537,7 +1538,6 @@ namespace MarketData.Helper
|
||||
symbol = symbol.ToUpper();
|
||||
|
||||
WebProxy webProxy = HttpNetRequest.GetProxy("GetCompanyProfileYahoo");
|
||||
// sb.Append("http://finance.yahoo.com/q/pr?s=").Append(symbol).Append("+Profile");
|
||||
sb.Append("https://finance.yahoo.com/quote/").Append(symbol).Append("/profile/");
|
||||
strRequest = sb.ToString();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
|
||||
@@ -1628,8 +1628,12 @@ namespace MarketData.Helper
|
||||
|
||||
// parse inner JSON
|
||||
JObject inner = Newtonsoft.Json.Linq.JObject.Parse(bodyJson);
|
||||
|
||||
return inner["quoteSummary"]?["result"]?[0]?["assetProfile"]?["longBusinessSummary"]?.ToString();
|
||||
JToken resultToken = inner["quoteSummary"]?["result"]; // Ensure result is an array with at least one element
|
||||
if (resultToken is not JArray resultArray || resultArray.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return resultArray[0]?["assetProfile"]?["longBusinessSummary"]?.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -374,16 +374,20 @@ namespace MarketData.Utils
|
||||
|
||||
public static String KeepBefore(String strItem,String strKeepBefore)
|
||||
{
|
||||
if(null==strItem)return strItem;
|
||||
int startPos=strItem.IndexOf(strKeepBefore);
|
||||
if(-1==startPos)return null;
|
||||
return strItem.Substring(0,startPos);
|
||||
}
|
||||
|
||||
public static String KeepAfter(String strItem,String strKeepAfter)
|
||||
{
|
||||
if(null==strItem)return strItem;
|
||||
int startPos=strItem.IndexOf(strKeepAfter);
|
||||
if(-1==startPos)return null;
|
||||
return strItem.Substring(startPos+strKeepAfter.Length);
|
||||
}
|
||||
|
||||
public static String KeepAfterLast(String strItem,String strKeepAfter)
|
||||
{
|
||||
if(null==strItem)return null;
|
||||
@@ -391,6 +395,21 @@ namespace MarketData.Utils
|
||||
if(-1==startPos)return null;
|
||||
return strItem.Substring(startPos+strKeepAfter.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RemoveAfter - If remove after cannot find the target it simply returns the strign that was provided.
|
||||
/// </summary>
|
||||
/// <param name="strItem"></param>
|
||||
/// <param name="strRemoveAfter"></param>
|
||||
/// <returns></returns>
|
||||
public static String RemoveAfter(String strItem,String strRemoveAfter)
|
||||
{
|
||||
if(null==strItem)return strItem;
|
||||
int endPos=strItem.IndexOf(strRemoveAfter);
|
||||
if(-1==endPos)return strItem;
|
||||
return strItem.Substring(0,endPos + 1);
|
||||
}
|
||||
|
||||
public static String Find(String strItem,String search,char delimeter)
|
||||
{
|
||||
if(null==strItem)return null;
|
||||
@@ -412,6 +431,7 @@ namespace MarketData.Utils
|
||||
if(!foundDelimeter)return null;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static String FindFirst(String strItem,String search,char delimeter)
|
||||
{
|
||||
if(null==strItem)return null;
|
||||
@@ -433,10 +453,12 @@ namespace MarketData.Utils
|
||||
if(!foundDelimeter)return null;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static String AddQuotes(String item)
|
||||
{
|
||||
return "\"" + item + "\"";
|
||||
}
|
||||
|
||||
public static long DateToLong(DateTime date)
|
||||
{
|
||||
int year = date.Year;
|
||||
@@ -444,6 +466,7 @@ namespace MarketData.Utils
|
||||
int day = date.Day;
|
||||
return (year * 10000) + (month * 100) + day;
|
||||
}
|
||||
|
||||
public static DateTime LongToDate(long longDate)
|
||||
{
|
||||
int year = (int)(longDate / 10000);
|
||||
@@ -451,6 +474,7 @@ namespace MarketData.Utils
|
||||
int day = (int)(longDate - ((int)(longDate / 100)) * 100);
|
||||
return new DateTime(year, month, day);
|
||||
}
|
||||
|
||||
public static String DayOfWeekToString(DayOfWeek dayOfWeek)
|
||||
{
|
||||
switch(dayOfWeek)
|
||||
|
||||
Reference in New Issue
Block a user