public static WebResponse GetResponseWithRetries(WebRequest getRequest, int retries) { int retry = 0; WebResponse response = null; while (null == response) { try { response = getRequest.GetResponse(); } catch (WebException e) { if (retry++ >= retries) { GBCommon.LogInfo("Too many failures. Stop retrying."); throw e; } else { GBCommon.LogInfo("Retry {0} time(s)", retry); Thread.Sleep(30000); } } } return(response); }
public static int ReadContinuationIndex(string continuationFile) { int continuationIndex = 0; using (Stream stream = File.Open(continuationFile, FileMode.OpenOrCreate)) { using (StreamReader reader = new StreamReader(stream)) { string content = reader.ReadLine(); if (!int.TryParse(content, out continuationIndex)) { GBCommon.LogInfo("{0} does not exist or no last index found. Will start from 0.", continuationFile); } } } return(continuationIndex); }
public static DateTime ReadContinuationDate(string continuationFile) { DateTime continuationDate = DateTime.Parse(@"1/1/1980"); using (Stream stream = File.Open(continuationFile, FileMode.OpenOrCreate)) { using (StreamReader reader = new StreamReader(stream)) { string content = reader.ReadLine(); if (!DateTime.TryParse(content, out continuationDate)) { GBCommon.LogInfo("{0} does not exist or no last date found. Will parse all files.", continuationFile); } } } return(continuationDate); }
public bool Deserialize(string fileName, OddsType oddsType) { return(GBCommon.Deserialize(out this.CurrentBets, fileName, oddsType)); }
public bool Serialize(string fileName) { return(GBCommon.Serialize(this.CurrentBets, fileName)); }