예제 #1
0
파일: Common.cs 프로젝트: qmlab/goodbet
        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);
        }
예제 #2
0
파일: Common.cs 프로젝트: qmlab/goodbet
        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);
        }
예제 #3
0
파일: Common.cs 프로젝트: qmlab/goodbet
        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);
        }
예제 #4
0
 public bool Deserialize(string fileName, OddsType oddsType)
 {
     return(GBCommon.Deserialize(out this.CurrentBets, fileName, oddsType));
 }
예제 #5
0
 public bool Serialize(string fileName)
 {
     return(GBCommon.Serialize(this.CurrentBets, fileName));
 }