Blockchains.razor.cs 2.1 KB

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