Exemple #1
0
        public bool ParseSource(string str, string fname)
        {
            int key = MainF.Bookmakers.FindIndex(item => fname.ToUpper().Contains(item.Name.ToUpper()));

            if (key == -1)
            {
                MainF.ErrorLabel("Unidentified " + fname); return(false);
            }

            ParseBookies book = MainF.Bookmakers[key].Book;

            MainF.LastBrokerTestLabel(MainF.Bookmakers[key].Name);

            List <ParsedDataFromPage> ParsDataList = new List <ParsedDataFromPage>();

            if (book.Parse(str, ref ParsDataList))
            {
                MainF.UpdateDataBase(ParsDataList, key);
            }
            else
            {
                MainF.ErrorLabel(fname); WriteBreakToFile.LogParseSave("Error Parsing " + fname); return(false);
            }
            return(true);
        }
Exemple #2
0
        private void CheckDirectory(string path)
        {
            string[] files;
            try
            {
                files = Directory.GetFiles(path);
            }
            catch (Exception)
            {
                if (path == FootballHedge.Properties.Settings.Default.Dir1Path)
                {
                    FootballHedge.Properties.Settings.Default.Dir1 = false;
                }
                if (path == FootballHedge.Properties.Settings.Default.Dir2Path)
                {
                    FootballHedge.Properties.Settings.Default.Dir2 = false;
                }
                MainF.ErrorLabel(path);
                return;
            }

            foreach (string fname in files)
            {
                StreamReader ReadFile;
                try { ReadFile = new StreamReader(fname); }
                catch (Exception) { continue; }


                string str = ReadFile.ReadToEnd();

                ReadFile.Close();

                if (fname.Contains(".mht"))
                {
                    str = str.Replace("=\r\n", "");
                    str = str.Replace("=3D", "=");
                }



                if (ParseSource(str, fname))
                {
                    try
                    {
                        File.Delete(fname);
                    }
                    catch (Exception)
                    {
                        WriteBreakToFile.LogParseSave("Can't delete file " + fname);
                        //MessageBox.Show("Can't delete " + fname);
                    }
                }
                else
                {
                    try
                    {
                        //string destination = fname.Replace(@"\Football", @"\New Folder");
                        //File.Move(fname, destination);
                        File.Delete(fname);
                    }
                    catch (Exception)
                    {
                        WriteBreakToFile.LogParseSave("Can't delete file " + fname);
                        // WriteBreakToFile.LogParseSave("File.Move Error " + fname);
                    }
                }
            }
        }