private static void Snipe(string pokemonName, string latt, string lonn) { try { double lat = double.Parse(latt, CultureInfo.InvariantCulture); double lon = double.Parse(lonn, CultureInfo.InvariantCulture); foreach (var item in Process.GetProcessesByName(Variables.BotEXEName)) { string username = item.MainWindowTitle.Split('-').First().Split(' ')[2]; if (!isBotUpperThan094(item.MainModule.FileVersionInfo)) { Log.WriteLine(culture.GetTranslation(TranslationString.IncompatibleVersionMsg, username), ConsoleColor.Red); continue; } string pathRemote = GetSnipeMSLocation(Path.GetDirectoryName(item.MainModule.FileName)); List <MSniperInfo> MSniperLocation = ReadSnipeMS(pathRemote); MSniperInfo newPokemon = new MSniperInfo() { Latitude = lat, Longitude = lon, Id = pokemonName }; if (MSniperLocation.FindIndex(p => p.Id == newPokemon.Id && p.Latitude == newPokemon.Latitude && p.Longitude == newPokemon.Longitude) == -1) { MSniperLocation.Add(newPokemon); if (WriteSnipeMS(MSniperLocation, newPokemon, pathRemote)) { Log.WriteLine(culture.GetTranslation(TranslationString.SendingPokemonToNecroBot, newPokemon.Id.ToLower(), newPokemon.Latitude, newPokemon.Longitude, username), ConsoleColor.Green); } } else { Log.WriteLine(culture.GetTranslation(TranslationString.AlreadySnipped, newPokemon), ConsoleColor.Red); } } } catch (Exception ex) { Log.WriteLine(ex.Message, ConsoleColor.Red); } }
private static bool WriteSnipeMS(List <MSniperInfo> _MSniperLocation, MSniperInfo _newpokemon, string path) { do { try { StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8); sw.WriteLine(JsonConvert.SerializeObject( _MSniperLocation, Formatting.Indented, new StringEnumConverter { CamelCaseText = true })); sw.Close(); return(true); break; } catch { Thread.Sleep(200); } }while (true);//waiting access }