Exemple #1
0
        //static string csgopath=@"E:\Visual Studio Projects\C#\VAc\VacCheck\VacCheck";
        public static void read_condumps(VCdbDataContext db)
        {
            //csgopath = Properties.Settings.Default.csgopath;
            string filedata;
            var files = Directory.EnumerateFiles(csgopath, "*.*", SearchOption.TopDirectoryOnly)
            .Where(s => s.StartsWith(csgopath + @"\condump") && s.EndsWith(".txt"));

            if (!Directory.Exists("CondumpArchieve"))
            {
                Directory.CreateDirectory("CondumpArchieve");
            }

            foreach (var file in files)
            {
                using (StreamReader sr = new StreamReader(file))
                {
                    filedata = sr.ReadToEnd();
                }

                try
                {
                    filedata = cleanGrundliste(filedata);
                    Console.WriteLine(filedata);
                }

                catch
                {
                    System.Windows.MessageBox.Show("File: " + file + " is empty/damaged");
                    continue;
                }

                Game newgame = new Game
                {
                    map = parseMap(filedata),
                    date = File.GetLastWriteTime(file)
                };

                db.Games.InsertOnSubmit(newgame);
                db.SubmitChanges();

                List<Int64> steamids = parseSteamIds64(filedata);

                foreach (var steamid in steamids)
                {
                    int playerid;

                    if (db.Ids.Any(entry => entry.Steam_ID == steamid))
                    {
                        playerid = db.Ids.First(entry => entry.Steam_ID == steamid).Id1;
                    }
                    else
                    {
                        Id newsteamid = new Id
                        {
                            Steam_ID = steamid
                        };
                        db.Ids.InsertOnSubmit(newsteamid);
                        db.SubmitChanges();
                        playerid = newsteamid.Id1;

                    }

                    ////int playerid= db.Ids.FirstOrDefault(entry => entry.Steam_ID == steamid).Id1;
                    //int playerid= from entry in db.Ids where entry.Steam_ID == steamid

                    //if (playerid==0)
                    //{
                    //    Id newsteamid= new Id
                    //    {
                    //        Steam_ID=steamid

                    //    };
                    //    db.Ids.InsertOnSubmit(newsteamid);
                    //    db.SubmitChanges();
                    //    playerid = newsteamid.Id1;
                    //}

                    db.Relations.InsertOnSubmit(new Relation { Game_Id = newgame.Id, Player_Id = playerid });

                }

                temppath = file.ToString();
                temppath = temppath.Remove(temppath.Length - 14, 14);

                temppath = temppath + @"CondumpArchieve\" + "ConDumpVacChecked" + Properties.Settings.Default.DumpNumber.ToString("0000") + ".txt";

                File.Move(file.ToString(), temppath);
                //+ @"Condump Archieve\" + "ConDumpVacChecked" + Properties.Settings.Default.DumpNumber.ToString("0000") + ".txt");

                Properties.Settings.Default.DumpNumber++;

            }

            Properties.Settings.Default.Save();
        }
 partial void UpdateId(Id instance);
 partial void DeleteId(Id instance);
 partial void InsertId(Id instance);