Blockchains.razor.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Threading.Tasks;
  3. using System.Net;
  4. using System.IO;
  5. using System.Text;
  6. using Microsoft.AspNetCore.Components;
  7. namespace HyperCube.Pages
  8. {
  9. public partial class Blockchains
  10. {
  11. Models.AccountModel _currentAccount;
  12. [Parameter]
  13. public int Smart { get; set; }
  14. public string answer;
  15. public string myWallet;
  16. public string balanceToken
  17. {
  18. get { return HyperCube.Models.Blockchain.balanceToken; }
  19. set { }
  20. }
  21. //public partial class Blocchains
  22. //{
  23. // [Parameter]
  24. // public string Smart { get; set; }
  25. //}
  26. //public string mypath = @"Wallet";
  27. public string mypath = @"getfile";
  28. public string getFiles(string wallet, string cmd, string pwd = "")
  29. {
  30. mypath = @"c:\Users\Администратор\AppData\Local\Ethereum\rinkeby\keystore\";
  31. string ret = "";
  32. var files = Directory.GetFiles(mypath);
  33. foreach (var file in files)
  34. {
  35. string fileName = file.Substring(mypath.Length + 1);
  36. var name = fileName.Split("--");
  37. try
  38. {
  39. if ("0x" + name[2] == wallet)
  40. {
  41. if (cmd == "key")
  42. {
  43. Console.WriteLine($"pwd {pwd}");
  44. return Models.Blockchain.ExecuteCommand(name[2] + " " + pwd)[1];
  45. }
  46. else if (cmd == "json")
  47. {
  48. var content = File.ReadAllText(file);
  49. return content;
  50. }
  51. }
  52. }
  53. catch (Exception e)
  54. {
  55. Console.WriteLine($"Exception file {fileName}: {e.Message}");
  56. }
  57. }
  58. return ret;
  59. }
  60. }
  61. }