public static StockPrice ScrapingStart(LoadFrom from, string code) { var exceptions = new List <Exception>(); var TotalNumberOfAttempts = 3 /*Configurable*/; var numberOfAttempts = 0; StockPrice stockPrice = new StockPrice(); var httpResposeMessage = string.Empty; //code = "16510001"; //[DK: Remove] just to test string webURL = string.Empty; bool found = false; while (!found) { try { switch (from) { case LoadFrom.Rediff: webURL = $"https://money.rediff.com/money/jsp/current_stat.jsp?companyCode={code}" /*Configurable*/; httpResposeMessage = GetWebRespose(webURL).GetAwaiter().GetResult(); stockPrice = HtmlExtractor.FilerTheStockpriceFromRediff(httpResposeMessage); found = true; break; case LoadFrom.Yahoo: webURL = $"https://finance.yahoo.com/quote/{code}" /*Configurable*/; httpResposeMessage = GetWebRespose(webURL).GetAwaiter().GetResult(); stockPrice = HtmlExtractor.FilerTheStockpriceFromYahoo(httpResposeMessage); found = true; break; case LoadFrom.BSE: break; default: break; } } catch (Exception ex) { exceptions.Add(ex); numberOfAttempts++; Thread.Sleep(1 * 1000 /*Configurable*/); } if (numberOfAttempts >= TotalNumberOfAttempts || found) { break; } } if (exceptions.Count > 0) { // throw new AggregateException(exceptions); System.Diagnostics.Debug.WriteLine(exceptions); } return(stockPrice); }
private bool LoadSections(Stream stream, LoadFrom from) { long fsize = stream.Length; long hsize = fsize / SectionSize; var sections = new FileSection[hsize]; for (int i = 0; i < sections.Length; i++) { if (from == LoadFrom.Either && FileSection.TryLoadSection(stream, false, i, BlockSize, out sections[i])) { continue; } if (!FileSection.TryLoadSection(stream, from != LoadFrom.FirstBlock, i, BlockSize, out sections[i])) { return(false); } } int lastIndex = (int)(hsize * BlocksPerSection) - 1; OrdinalList freeHandles = new OrdinalList(); freeHandles.Ceiling = lastIndex; OrdinalList usedBlocks = new OrdinalList(); usedBlocks.Ceiling = lastIndex; foreach (var section in sections) { section.GetFree(freeHandles, usedBlocks, _fget); } _sections = sections; _freeHandles = freeHandles; _freeBlocks = usedBlocks.Invert(lastIndex); if (!_options.CommitOnWrite) { _reservedBlocks = usedBlocks; } _firstFreeBlock = _prevFreeBlock = _prevFreeHandle = 0; return(true); }
internal static async Task <List <object> > GetStocksCodedbAsync(string IsActive, LoadFrom from) { var stocks = new List <Stock>(); var vReturn = new List <object>(); try { string stm = string.Empty; switch (from) { case LoadFrom.Rediff: stm = SISDBQueryCollection.qGetRediffCode; break; case LoadFrom.Yahoo: stm = SISDBQueryCollection.qGetYahooCode; break; } using (SQLiteConnection conn = SISDBContext.GetdbConnection()) { using (SQLiteCommand cmd = new SQLiteCommand(stm, conn)) { cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@StatusType", IsActive); using (var reader = await cmd.ExecuteReaderAsync()) { while (await reader.ReadAsync()) { //var o = new JsonResult(); vReturn.Add(new JsonResult(new { SID = reader[0], SName = reader[1].ToString(), Code = reader[2].ToString() })); } } } return(vReturn); } } catch (SQLiteException ex) { System.Diagnostics.Debug.WriteLine("SQLiteException:" + ex.Message); throw ex; } catch (Exception ex) { throw ex; } }
Function RPGLoad(LoadFrom:TJCRDir,Dir$="")
public AssetBundleInfo(LoadFrom type, string path) { Type = type; Path = path; }