private void Window_Loaded(object sender, RoutedEventArgs e) { MyServer.GetInstance().Start(); ResetFont(); notifier = new Notifier(cfg => { cfg.PositionProvider = new WindowPositionProvider( parentWindow: Application.Current.MainWindow, corner: Corner.BottomCenter, offsetX: 10, offsetY: 10); cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor( notificationLifetime: TimeSpan.FromSeconds(3), maximumNotificationCount: MaximumNotificationCount.FromCount(5)); cfg.Dispatcher = Application.Current.Dispatcher; }); }
public MainWindow() { InitializeComponent(); this.metaData = MetaDataLoader.Load(); topics = new ObservableCollection <object>(); TopicListView.DataContext = topics; articles = new ObservableCollection <object>(); ArticleListView.DataContext = articles; ServerInd.DataContext = MyServer.GetInstance(); searchingKeyword = null; ReloadTopics(); currentState = AppState.TOPICS; currentId = -1; text = ""; UpdateView(); }
public static StringBuilder PMain(int threadCount) { StringBuilder sb = new StringBuilder(); sb.Append("\r\n\r\n*SpeedTest"); try { DBPlatform.DeleteDB(); using (var server = new MyServer()) { using (var db = server.GetInstance(1)) { var objectCount = 10; sb.Append("\r\nBegin Insert " + (threadCount * objectCount).ToString("#,#")); DDebug.StartWatch(); DBPlatform.For(0, threadCount, (i) => { using (var box = db.Cube()) { for (var o = 0; o < objectCount; o++) { var m = new Member { ID = box.NewId(0, 1), Name = i.ToString() + "_" + o.ToString(), Age = 1 }; box.Bind("TSpeed").Insert(m); } box.Commit().Assert(); } } ); var sec = DDebug.StopWatch().TotalSeconds; var avg = (threadCount * objectCount) / sec; sb.Append("\r\nElapsed " + sec + "s, AVG Insert " + avg.ToString("#,#") + " o/sec"); DDebug.StartWatch(); DBPlatform.For(0, threadCount, (i) => { using (var box = db.Cube()) { for (var o = 0; o < objectCount; o++) { long ID = i * objectCount + o + 1; var mem = box.Bind("TSpeed", ID).Select <Member>(); if (mem.ID != ID) { throw new Exception(); } } } } ); sec = DDebug.StopWatch().TotalSeconds; avg = (threadCount * objectCount) / sec; sb.Append("\r\nElapsed " + sec + "s, AVG Lookup " + avg.ToString("#,#") + " o/sec"); //Parallel Query Language DDebug.StartWatch(); int count = 0; DBPlatform.For(0, threadCount, (i) => { using (var box = db.Cube()) { var tspeed = box.Select <Member>("from TSpeed where ID>=? & ID<=?", (long)(i * objectCount + 1), (long)(i * objectCount + objectCount)); foreach (var m in tspeed) { // age == 1 Interlocked.Add(ref count, m.Age); } } } ); if (count != (threadCount * objectCount)) { throw new Exception(count.ToString()); } sec = DDebug.StopWatch().TotalSeconds; avg = count / sec; sb.Append("\r\nElapsed " + sec + "s, AVG Query " + avg.ToString("#,#") + " o/sec"); } } } catch (Exception ex) { sb.Append(ex.ToString()); } return(sb); }
public static StringBuilder PMain() { StringBuilder sb = new StringBuilder(); try { DBPlatform.DeleteDB(); using (var server = new MyServer()) { using (var db = server.GetInstance()) { // UpdateIncrement,version number from box.NewId(byte.MaxValue, 1); sb.Append("\r\n\r\n*Version Control \r\n"); MemberInc m = new MemberInc(); m.ID = 1; m.Name = "Andy"; sb.Append("number increasing: "); db.Get().Insert("MemberInc", m); MemberInc mg = db.Get().SelectKey <MemberInc>( "MemberInc", 1L); sb.Append(mg.Version); db.Get().Update("MemberInc", mg); mg = db.Get().SelectKey <MemberInc>("MemberInc", 1L); sb.Append(" " + mg.Version); db.Get().Update("MemberInc", mg); mg = db.Get().SelectKey <MemberInc>("MemberInc", 1L); sb.Append(" " + mg.Version); // Selecting Tracer sb.Append("\r\n*Selecting Tracer \r\n"); using (var boxTracer = db.Cube()) { bool keepTrace = true; Member tra = boxTracer.Bind("MemberInc", 1L) .Select <Member>(keepTrace); String currentName = tra.Name; { // another box changes the name MemberInc mm = new MemberInc(); mm.ID = 1; mm.Name = "Kelly"; db.Get().Update("MemberInc", mm.ID, mm); } // will auto rollback if (boxTracer.Commit().Equals(CommitResult.OK)) { throw new Exception(); } else { sb.Append("the name '" + currentName + "' is changed,"); } } Member nm = db.Get().SelectKey <Member>("MemberInc", 1L); sb.Append("new name is '" + nm.Name + "'"); } } } catch (Exception ex) { sb.Append(ex.ToString()); } return(sb); }
public static StringBuilder PMain() { StringBuilder sb = new StringBuilder(); sb.Append("\r\n*Start\r\n"); try { DBPlatform.DeleteDB(); using (var server = new MyServer()) { using (var db = server.GetInstance(1)) { using (var box = db.Cube()) { // insert member & product box.Bind("Member").Insert( new Member() { ID = box.NewId(Member.IncTableID, 1), Name = "Andy", RegTime = new DateTime(2013, 1, 2), Tags = new string[] { "Nice", "Strong" } } ); box.Bind("Member").Insert( new MemberVIP() { ID = box.NewId(Member.IncTableID, 1), Name = "Kelly", RegTime = new DateTime(2013, 1, 3), Tags = new string[] { "Gamer" }, VIP = 3 } ); // Dynamic Column Product game = new Product() { Type = 8, UID = new Guid("{22222222-0000-0000-0000-000000000000}"), Name = "MoonFlight" }; game["GameType"] = "ACT"; box.Bind("Product").Insert(game); box.Commit().Assert(); } using (var box = db.Cube()) { // SQL like // > < >= <= == != // & | () // [] var m = GetFirst(box.Select <MemberVIP>("from Member where VIP>?", 1)); sb.Append("Kelly RegTime " + m.RegTime + "\r\n"); m.Name = "Kelly J"; m.Amount = 100; box.Bind("Member", m.ID).Update(m); box.Commit().Assert(); } using (var box = db.Cube()) { var m = GetFirst(box.Select <Member>("from Member where Name==?", "Kelly J")); sb.Append("Updated : " + m.Name + " " + m.Amount + "\r\n"); } using (var box = db.Cube()) { // Key-Value Style , Composite-Key Supported var cs = box .Bind("Product", 8, new Guid("{22222222-0000-0000-0000-000000000000}")) .Select <Product>(); sb.Append("Product Name " + cs.Name + " " + cs["GameType"] + "\r\n"); } using (var box = db.Cube()) { //Custom QueryFunction // [] <= call IFunction Interface // [A,B] <= Fields will be passed var list = box.Select <Member>("from Member where [Tags]", new QueryArray("Strong")); sb.Append("The Strong one is "); foreach (var m in list) { sb.Append("'" + m.Name + "'\r\n"); } } } } } catch (Exception ex) { sb.Append(ex.ToString() + "\r\n"); } return(sb); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MyServer.GetInstance().Stop(); }