Program.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using Masuit.Tools.NoSQL.MongoDBClient;
  5. using MongoDB.Bson;
  6. using MongoDB.Driver;
  7. namespace Test
  8. {
  9. internal static class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. //FileStream fs = new FileStream(@"D:\boot.vmdk", FileMode.OpenOrCreate, FileAccess.ReadWrite);
  14. //{
  15. // fs.CopyToFileAsync(@"D:\1.bak");
  16. // string md5 = fs.GetFileMD5Async().Result;//获取文件的MD5
  17. //}
  18. //Console.WriteLine("复制完成");
  19. //bool isUrl;
  20. //var match = "//music.163.com/#/search/m/?%23%2Fmy%2Fm%2Fmusic%2Fempty=&s=fade&type=1!k".MatchUrl(out isUrl);
  21. //Console.WriteLine(isUrl);
  22. //foreach (Group g in match.Groups)
  23. //{
  24. // if (g.Captures.Count > 0)
  25. // {
  26. // foreach (Capture c in g.Captures)
  27. // {
  28. // Console.WriteLine(c.Index + " : " + c.Value);
  29. // }
  30. // }
  31. // else
  32. // {
  33. // Console.WriteLine(g.Index + " : " + g.Value);
  34. // }
  35. //}
  36. //bool b1 = "512002199509230611".MatchIdentifyCard();//False
  37. //bool b2 = "140108197705058894".MatchIdentifyCard();//True
  38. //Console.WriteLine(b1 + "----" + b2);
  39. //bool isIP;
  40. //"114.114.256.114".MatchInetAddress(out isIP);//False
  41. //"114.114.114.114".MatchInetAddress(out isIP);//True
  42. //Console.WriteLine(isIP);
  43. //Console.WriteLine(WindowsCommand.Execute("help"));
  44. //string match = "vawevbgw".MatchRandomImgSrc();
  45. //Console.WriteLine(match);
  46. //PhysicsAddress address = "4.2.2.1".GetPhysicsAddressInfo();
  47. //List<MyClass> mc = new List<MyClass> {new MyClass() {Name = "aaa", Age = 10, MyClass3 = new MyClass3(), MyClass2s = new List<MyClass2>() {new MyClass2() {Age = 22, Name = "dddd"}}}, new MyClass() {Name = "aaa", Age = 10, MyClass3 = new MyClass3()}, new MyClass() {Name = "aaa", Age = 10, MyClass3 = new MyClass3(), MyClass2s = new List<MyClass2>() {new MyClass2() {Age = 22, Name = "dddd"}}}, new MyClass() {Name = "aaa", Age = 10, MyClass3 = new MyClass3(), MyClass2s = new List<MyClass2>() {new MyClass2() {Age = 22, Name = "dddd"}}}};
  48. //List<MyClass2> list = mc.Map<MyClass, MyClass2>().ToList();
  49. //MyClass mc = null;
  50. //MyClass2 mc2 = mc.Map<MyClass, MyClass2>();
  51. //Dictionary<string, object> dic = new Dictionary<string, object>();
  52. //for (int i = 0; i < 100000; i++)
  53. //{
  54. // string s = string.Empty.CreateShortToken(100);
  55. // Console.WriteLine(s);
  56. // dic.Add(s, s);
  57. //}
  58. //var list = MongoDbClient.GetInstance("mongodb://192.168.3.238:27017", "AccountBalance").Database.GetCollection<BsonDocument>("201803-NEO").Indexes.List();
  59. //while (list.MoveNext())
  60. //{
  61. // if (!list.Current.Any(doc => doc["name"].AsString.StartsWith("AccountId")))
  62. // {
  63. // string index = MongoDbClient.GetInstance("mongodb://192.168.3.238:27017", "AccountBalance").Database.GetCollection<BsonDocument>("201803-NEO").Indexes.CreateOne(Builders<BsonDocument>.IndexKeys.Ascending(doc => doc["AccountId"]));
  64. // }
  65. //}
  66. //LogManager.Event += s =>
  67. //{
  68. // if (s.Contains("ERROR") || s.Contains("FATAL"))
  69. // {
  70. // Console.ForegroundColor = ConsoleColor.Red;
  71. // }
  72. // if (s.Contains("DEBUG"))
  73. // {
  74. // Console.ForegroundColor = ConsoleColor.Green;
  75. // }
  76. // Console.WriteLine(s);
  77. // Console.ForegroundColor = ConsoleColor.White;
  78. //};
  79. //LogManager.Info("aaaaaaaaaaaaaaaaaaaaaaaaa");
  80. //LogManager.Debug("bbbbbbbbbbbbbbbbb");
  81. //LogManager.Error(typeof(object), "bbbbbbbbbbbbbbbbb");
  82. //LogManager.Info("aaaaaaaaaaaaaaaaaaaaaaaaa");
  83. //bool b = "[email protected]".MatchEmail();
  84. MongoDbClient mc = MongoDbClient.ThreadLocalInstance("mongodb://127.0.0.1:27000,127.0.0.1:27001,127.0.0.1:27002/?slaveOk=true;maxPoolSize=100000;minPoolSize=32", "repl");
  85. Parallel.For(0, 100000, i => mc.InsertOne("repl",new { name = "aa", value = 100 }));
  86. Parallel.For(0, 100000, i => mc.GetMany("repl",Builders<BsonDocument>.Filter.Eq(doc => doc["value"], 100)).ToList());
  87. //Console.ReadKey();
  88. }
  89. }
  90. public class Banlance
  91. {
  92. public string Name { get; set; }
  93. public int Amount { get; set; }
  94. }
  95. public class MyClass
  96. {
  97. public string Name { get; set; }
  98. public int Age { get; set; }
  99. public MyClass3 MyClass3 { get; set; }
  100. public List<MyClass2> MyClass2s { get; set; }
  101. }
  102. public class MyClass2
  103. {
  104. public string Name { get; set; }
  105. public int Age { get; set; }
  106. public MyClass3 MyClass3 { get; set; }
  107. public List<MyClass2> MyClass2s { get; set; }
  108. }
  109. public class MyClass3
  110. {
  111. public string MyProperty { get; set; }
  112. }
  113. }