public static string ExecuteURL(string url) { if (Debugger.IsAttached) { return(""); } try { var request = (HttpWebRequest)WebRequest.Create(url); request.Credentials = CredentialCache.DefaultCredentials; var response = Task <WebResponse> .Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null); response.Wait(); //using (Stream responseStream = response.GetResponseStream()) //{ // StreamReader reader = new StreamReader(responseStream, Encoding.UTF8); // return reader.ReadToEnd(); //} response.Result.Close(); request.Abort(); return("SUCCESS"); } catch (WebException ex) { LogErrorUtils.WriteLogError("ProcessGoiDi:", ex); return(""); } }
public static void PlaySoundAlert() { try { string path = Application.StartupPath; path = Path.Combine(path, "Sound"); // Create folder if it doesn't already exist if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, "notify.wav"); if (!File.Exists(path)) { System.Media.SystemSounds.Beep.Play(); } else { using (var player = new System.Media.SoundPlayer(path)) { player.Play(); } } } catch (Exception ex) { LogErrorUtils.WriteLogError("PlaySoundAlert", ex); } }
public static string FormatIP(string pInput, string pSeperator) { try { string result = string.Empty; string[] arrString = pInput.Split(new[] { pSeperator }, StringSplitOptions.RemoveEmptyEntries); if (arrString.Any()) { result = arrString[0]; } return(result); } catch (Exception ex) { LogErrorUtils.WriteLogError("FormatIP:", ex); return(string.Empty); } }
public static bool PingHost(string nameOrAddress) { bool pingable = false; Ping pinger = new Ping(); try { PingReply reply = pinger.Send(nameOrAddress); if (reply.Status == IPStatus.Success) { pingable = true; } } catch (PingException ex) { LogErrorUtils.WriteLogError("PingHost: ", ex); } return(pingable); }