Guest User

Untitled

a guest
Jan 25th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace Pinger
  7. {
  8. class LogReader
  9. {
  10. public StreamReader GetStreamReaderFromRemotePC(string ip)
  11. {
  12. var userName = "Администратор";
  13. var password = "Vfdnjpfdh2016";
  14. var filePath = $@"\\{ip}\C$\UTM\monitoring\l\monitor.log";
  15. var destinationPath = Path.Combine(Environment.CurrentDirectory, $"log\\monitor{ip}.log");
  16. NetworkCredential networkCredential = new NetworkCredential(userName, password);
  17. CredentialCache netCache = new CredentialCache
  18. {
  19. { new Uri($@"\\{ip}"), "Basic", networkCredential }
  20. };
  21. if (File.Exists(destinationPath)) File.Delete(destinationPath);
  22. File.Copy(filePath, destinationPath);
  23. return new StreamReader(destinationPath);
  24. }
  25.  
  26. public string GetSmartCardVersion(StreamReader sr)
  27. {
  28. var line = String.Empty;
  29. while ((line = sr.ReadLine()) != null)
  30. {
  31. if (line.Contains("Найден слот"))
  32. {
  33. var regex = new Regex(@"\[([^\[\]]+)\]");
  34. var match = regex.Matches(line);
  35. return match[0].ToString().Substring(3, match[0].ToString().Length-4).Trim();
  36. }
  37. }
  38.  
  39. return String.Empty;
  40. }
  41.  
  42. }
  43. }
Add Comment
Please, Sign In to add comment