Make the service client portable with the new version on raspberry pi 5.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using MarketData.MarketDataModel;
|
||||
using MarketData.MarketDataModel.GainLoss;
|
||||
using MarketData.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -110,6 +111,7 @@ namespace MarketData.Service
|
||||
sb.Append("/api/Authorization/GetToken?").Append("user=").Append(user);
|
||||
sb.Append("&password=").Append(password);
|
||||
String json = httpClient.GetStringAsync(sb.ToString()).Result;
|
||||
json=ToConformimgJson(json);
|
||||
String accessToken = JsonConvert.DeserializeObject<String>(json);
|
||||
return new ServiceResult(accessToken);
|
||||
}
|
||||
@@ -121,6 +123,7 @@ namespace MarketData.Service
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************************************** C O N S U M E R P R I C E I N D E X *************************************************
|
||||
public ServiceResult GetDistinctConsumerPriceIndices()
|
||||
{
|
||||
@@ -156,7 +159,6 @@ namespace MarketData.Service
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("/api/PriceIndex/GetConsumerPriceIndex?").Append("token=").Append(accessToken).Append("&").Append("indexCode=").Append(HttpUtility.UrlEncode(indexCode));
|
||||
String json = httpClient.GetStringAsync(sb.ToString()).Result;
|
||||
|
||||
List<PriceIndex> priceIndices = JsonConvert.DeserializeObject<List<PriceIndex>>(json);
|
||||
return new ServiceResult(priceIndices);
|
||||
}
|
||||
@@ -240,29 +242,6 @@ namespace MarketData.Service
|
||||
}
|
||||
}
|
||||
// ************************************************************************************************************************************************
|
||||
//public ServiceResult GetPortfolioTradesWithCombinedLots(String symbol)
|
||||
//{
|
||||
// lock(this)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if(!IsNetworkAvailable())return new ServiceResult(false,"No network.");
|
||||
// if (!IsAuthorized()) return new ServiceResult(false,"Unauthorized.");
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("/api/Portfolio/GetPortfolioTradesWithCombinedLots?").Append("token=").Append(accessToken).Append("&").Append("symbol=").Append(symbol);
|
||||
// String json = httpClient.GetStringAsync(sb.ToString()).Result;
|
||||
// List<PortfolioTrade> portfolioTrades= JsonConvert.DeserializeObject<List<PortfolioTrade>>(json);
|
||||
// return new ServiceResult(portfolioTrades);
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// exceptions.Add(exception);
|
||||
// Debug.WriteLine(exception.ToString());
|
||||
// return new ServiceResult(false,exception.ToString());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public ServiceResult GetStopLimit(String symbol)
|
||||
{
|
||||
lock(this)
|
||||
@@ -457,7 +436,7 @@ namespace MarketData.Service
|
||||
if(!IsNetworkAvailable())return new ServiceResult(false,"No network.");
|
||||
if (!IsAuthorized()) return new ServiceResult(false,"Unauthorized.");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("/api/GainLoss/GetGainLossWithDetail?").Append("token=").Append(accessToken).Append("&selectedDate=").Append(selectedDate.ToShortDateString()).Append("&").Append("account=").Append(account);
|
||||
sb.Append("/api/GainLoss/GetGainLossWithDetailByDateAndAccount?").Append("token=").Append(accessToken).Append("&selectedDate=").Append(selectedDate.ToShortDateString()).Append("&").Append("account=").Append(account);
|
||||
String json = httpClient.GetStringAsync(sb.ToString()).Result;
|
||||
List<GainLossSummaryItemDetail> gainLossSummaryDetail = JsonConvert.DeserializeObject<List<GainLossSummaryItemDetail>>(json);
|
||||
return new ServiceResult(gainLossSummaryDetail);
|
||||
@@ -480,7 +459,7 @@ namespace MarketData.Service
|
||||
if(!IsNetworkAvailable())return new ServiceResult(false,"No network.");
|
||||
if (!IsAuthorized()) return new ServiceResult(false,"Unauthorized.");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("/api/GainLoss/GetGainLossWithDetail?").Append("token=").Append(accessToken).Append("&selectedDate=").Append(selectedDate.ToShortDateString());
|
||||
sb.Append("/api/GainLoss/GetGainLossWithDetailByDate?").Append("token=").Append(accessToken).Append("&selectedDate=").Append(selectedDate.ToShortDateString());
|
||||
String json = httpClient.GetStringAsync(sb.ToString()).Result;
|
||||
List<GainLossSummaryItemDetail> gainLossSummaryDetail = JsonConvert.DeserializeObject<List<GainLossSummaryItemDetail>>(json);
|
||||
return new ServiceResult(gainLossSummaryDetail);
|
||||
@@ -619,6 +598,13 @@ namespace MarketData.Service
|
||||
if(Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi))return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String ToConformimgJson(String json)
|
||||
{
|
||||
if(String.IsNullOrEmpty(json))return json;
|
||||
if(json.StartsWith("\"") && json.EndsWith("\""))return json;
|
||||
if(json.StartsWith("[") && json.EndsWith("]"))return json;
|
||||
if(json.StartsWith("{") && json.EndsWith("}"))return json;
|
||||
return Utility.AddQuotes(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user