//Updated data from the last read/update point public static int UpdateAnalysisData(commonClass.BaseAnalysisData dataObj) { int lastDataIdx = dataObj.priceDataTbl.Count - 1; DateTime lastDateTime; if (lastDataIdx < 0) { lastDateTime = commonClass.Settings.sysStartDataDate; } else { lastDateTime = dataObj.priceDataTbl[lastDataIdx].onDate; } data.baseDS.priceDataDataTable tbl = GetData_ByTimeScale_Code_FrDate(dataObj.DataTimeScale.Code, dataObj.DataStockCode, lastDateTime); if (tbl.Count > 0) { //Delete the last data because the updated data will include this one. if (lastDataIdx >= 0) { dataObj.priceDataTbl[lastDataIdx].ItemArray = tbl[0].ItemArray; commonClass.AppLibs.DataConcat(tbl, 1, dataObj.priceDataTbl); } else { commonClass.AppLibs.DataConcat(tbl, 0, dataObj.priceDataTbl); } } //Update cache AnalysisDataCache data = new AnalysisDataCache(); data.dataTbl = (data.baseDS.priceDataDataTable)dataObj.priceDataTbl.Copy(); data.firstData = dataObj.FirstDataStartAt; AddCache(MakeAnalysisDataCacheKey(dataObj), data); return(dataObj.priceDataTbl.Count - 1 - lastDataIdx); }
public static bool LoadAnalysisData(commonClass.BaseAnalysisData dataObj) { AnalysisDataCache data; string cacheKey = MakeAnalysisDataCacheKey(dataObj); object obj = GetCache(cacheKey); if (obj != null) { data = (AnalysisDataCache)obj; dataObj.priceDataTbl = (data.baseDS.priceDataDataTable)data.dataTbl.Copy(); return(true); } using (new PleaseWait()) { data = new AnalysisDataCache(); int firstData = 0; data.dataTbl = myClient.GetAnalysis_Data(out firstData, dataObj.DataTimeRange, dataObj.DataTimeScale.Code, dataObj.DataStockCode); data.firstData = firstData; AddCache(cacheKey, data); dataObj.priceDataTbl = (data.baseDS.priceDataDataTable)data.dataTbl.Copy(); dataObj.FirstDataStartAt = firstData; } return(true); }
public static bool LoadAnalysisData(commonClass.BaseAnalysisData dataObj) { try { AnalysisDataCache data; string cacheKey = MakeAnalysisDataCacheKey(dataObj); object obj = GetCache(cacheKey); if (obj != null) { data = (AnalysisDataCache)obj; dataObj.priceDataTbl = (databases.baseDS.priceDataDataTable)data.dataTbl.Copy(); return true; } using (new PleaseWait()) { lock (myClient) { data = new AnalysisDataCache(); int firstData = 0; DataParams dataParam = new DataParams(dataObj.DataTimeScale.Code, dataObj.DataTimeRange, dataObj.DataMaxCount); data.dataTbl = myClient.GetAnalysis_Data(out firstData, dataObj.DataStockCode, dataParam); data.firstData = firstData; AddCache(cacheKey, data); dataObj.priceDataTbl = (databases.baseDS.priceDataDataTable)data.dataTbl.Copy(); dataObj.FirstDataStartAt = firstData; } } return true; } catch (Exception er) { if (OnError != null) OnError(er); } return false; }
//Updated data from the last read/update point public static int UpdateAnalysisData(commonClass.BaseAnalysisData dataObj) { int lastDataIdx = dataObj.priceDataTbl.Count - 1; DateTime lastDateTime; if (lastDataIdx < 0) lastDateTime = commonClass.Settings.sysStartDataDate; else lastDateTime = dataObj.priceDataTbl[lastDataIdx].onDate; data.baseDS.priceDataDataTable tbl = GetData_ByTimeScale_Code_FrDate(dataObj.DataTimeScale.Code, dataObj.DataStockCode,lastDateTime); if (tbl.Count > 0) { //Delete the last data because the updated data will include this one. if (lastDataIdx >= 0) { dataObj.priceDataTbl[lastDataIdx].ItemArray = tbl[0].ItemArray; commonClass.AppLibs.DataConcat(tbl, 1, dataObj.priceDataTbl); } else commonClass.AppLibs.DataConcat(tbl, 0, dataObj.priceDataTbl); } //Update cache AnalysisDataCache data = new AnalysisDataCache(); data.dataTbl = (data.baseDS.priceDataDataTable)dataObj.priceDataTbl.Copy(); data.firstData = dataObj.FirstDataStartAt; AddCache(MakeAnalysisDataCacheKey(dataObj), data); return dataObj.priceDataTbl.Count - 1 - lastDataIdx; }
public static bool LoadAnalysisData(commonClass.BaseAnalysisData dataObj) { AnalysisDataCache data; string cacheKey = MakeAnalysisDataCacheKey(dataObj); object obj = GetCache(cacheKey); if (obj != null) { data = (AnalysisDataCache)obj; dataObj.priceDataTbl = (data.baseDS.priceDataDataTable)data.dataTbl.Copy(); return true; } using (new PleaseWait()) { data = new AnalysisDataCache(); int firstData = 0; data.dataTbl = myClient.GetAnalysis_Data(out firstData, dataObj.DataTimeRange, dataObj.DataTimeScale.Code, dataObj.DataStockCode); data.firstData = firstData; AddCache(cacheKey, data); dataObj.priceDataTbl = (data.baseDS.priceDataDataTable)data.dataTbl.Copy(); dataObj.FirstDataStartAt = firstData; } return true; }