123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Masuit.Tools.NoSQL.MongoDBClient;
- using MongoDB.Bson;
- using MongoDB.Driver;
- namespace Test
- {
- internal static class Program
- {
- static void Main(string[] args)
- {
- //FileStream fs = new FileStream(@"D:\boot.vmdk", FileMode.OpenOrCreate, FileAccess.ReadWrite);
- //{
- // fs.CopyToFileAsync(@"D:\1.bak");
- // string md5 = fs.GetFileMD5Async().Result;//获取文件的MD5
- //}
- //Console.WriteLine("复制完成");
- //bool isUrl;
- //var match = "//music.163.com/#/search/m/?%23%2Fmy%2Fm%2Fmusic%2Fempty=&s=fade&type=1!k".MatchUrl(out isUrl);
- //Console.WriteLine(isUrl);
- //foreach (Group g in match.Groups)
- //{
- // if (g.Captures.Count > 0)
- // {
- // foreach (Capture c in g.Captures)
- // {
- // Console.WriteLine(c.Index + " : " + c.Value);
- // }
- // }
- // else
- // {
- // Console.WriteLine(g.Index + " : " + g.Value);
- // }
- //}
- //bool b1 = "512002199509230611".MatchIdentifyCard();//False
- //bool b2 = "140108197705058894".MatchIdentifyCard();//True
- //Console.WriteLine(b1 + "----" + b2);
- //bool isIP;
- //"114.114.256.114".MatchInetAddress(out isIP);//False
- //"114.114.114.114".MatchInetAddress(out isIP);//True
- //Console.WriteLine(isIP);
- //Console.WriteLine(WindowsCommand.Execute("help"));
- //string match = "vawevbgw".MatchRandomImgSrc();
- //Console.WriteLine(match);
- //PhysicsAddress address = "4.2.2.1".GetPhysicsAddressInfo();
- //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"}}}};
- //List<MyClass2> list = mc.Map<MyClass, MyClass2>().ToList();
- //MyClass mc = null;
- //MyClass2 mc2 = mc.Map<MyClass, MyClass2>();
- //Dictionary<string, object> dic = new Dictionary<string, object>();
- //for (int i = 0; i < 100000; i++)
- //{
- // string s = string.Empty.CreateShortToken(100);
- // Console.WriteLine(s);
- // dic.Add(s, s);
- //}
- //var list = MongoDbClient.GetInstance("mongodb://192.168.3.238:27017", "AccountBalance").Database.GetCollection<BsonDocument>("201803-NEO").Indexes.List();
- //while (list.MoveNext())
- //{
- // if (!list.Current.Any(doc => doc["name"].AsString.StartsWith("AccountId")))
- // {
- // 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"]));
- // }
- //}
- //LogManager.Event += s =>
- //{
- // if (s.Contains("ERROR") || s.Contains("FATAL"))
- // {
- // Console.ForegroundColor = ConsoleColor.Red;
- // }
- // if (s.Contains("DEBUG"))
- // {
- // Console.ForegroundColor = ConsoleColor.Green;
- // }
- // Console.WriteLine(s);
- // Console.ForegroundColor = ConsoleColor.White;
- //};
- //LogManager.Info("aaaaaaaaaaaaaaaaaaaaaaaaa");
- //LogManager.Debug("bbbbbbbbbbbbbbbbb");
- //LogManager.Error(typeof(object), "bbbbbbbbbbbbbbbbb");
- //LogManager.Info("aaaaaaaaaaaaaaaaaaaaaaaaa");
- //bool b = "[email protected]".MatchEmail();
- 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");
- Parallel.For(0, 100000, i => mc.InsertOne("repl",new { name = "aa", value = 100 }));
- Parallel.For(0, 100000, i => mc.GetMany("repl",Builders<BsonDocument>.Filter.Eq(doc => doc["value"], 100)).ToList());
- //Console.ReadKey();
- }
- }
- public class Banlance
- {
- public string Name { get; set; }
- public int Amount { get; set; }
- }
- public class MyClass
- {
- public string Name { get; set; }
- public int Age { get; set; }
- public MyClass3 MyClass3 { get; set; }
- public List<MyClass2> MyClass2s { get; set; }
- }
- public class MyClass2
- {
- public string Name { get; set; }
- public int Age { get; set; }
- public MyClass3 MyClass3 { get; set; }
- public List<MyClass2> MyClass2s { get; set; }
- }
- public class MyClass3
- {
- public string MyProperty { get; set; }
- }
- }
|