public IActionResult OnPostSwitch(string id, Middleware.SyncSwitch flag) { var node = _db.GetCollectionData <Middleware.SyncNode>(database, collection, $"{{'_id':new ObjectId('{id}')}}").FirstOrDefault(); if (node != null) { if (flag == Middleware.SyncSwitch.Run) { if (node.Switch == Middleware.SyncSwitch.Run) { node.Switch = Middleware.SyncSwitch.Stoping; } } else { if (node.Switch == Middleware.SyncSwitch.Stop) { node.Switch = Middleware.SyncSwitch.Run; } if (node.Status == Middleware.SyncStatus.ScanException) { node.Status = Middleware.SyncStatus.WaitForScan; } if (node.Status == Middleware.SyncStatus.TailException) { node.Status = Middleware.SyncStatus.WaitForTail; } } _db.UpdateCollectionData <Middleware.SyncNode>(database, collection, node); } return(RedirectToPage()); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } if (string.IsNullOrWhiteSpace(Node.ID)) { _db.InsertCollectionData <Middleware.SyncNode>(database, collection, Node); } else { Node.UpdateTime = DateTime.Now; _db.UpdateCollectionData <Middleware.SyncNode>(database, collection, Node); } return(RedirectToPage("/SyncNode/Index")); }