public IHttpActionResult PostServer(Model.Server server) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Servers.Add(server); try { db.SaveChanges(); } catch (DbUpdateException) { if (ServerExists(server.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = server.Id }, server)); }
static void Main(string[] args) { // Connect to Server Model.Server server = new Model.Server("http://localhost/11SP9"); // Load Solution server.LoadAssembly("Aras.Model.Design"); // Get Database Model.Database database = server.Database("Development"); // Start Session Model.Session session = database.Login("admin", IO.Server.PasswordHash("innovator")); // Find Document Model.Query docquery = session.Query("Document"); docquery.Select = "item_number,name,description"; Model.Design.Document document = (Model.Design.Document)docquery.Store.First(); using (Transaction trans = session.BeginTransaction()) { document.Update(trans); document.Name = "Test"; trans.Commit(true); } }
public IHttpActionResult PutServer(string id, Model.Server server) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != server.Id) { return(BadRequest()); } db.Entry(server).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ServerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetServer(string id) { Model.Server server = db.Servers.Find(id); if (server == null) { return(NotFound()); } return(Ok(server)); }
public void UpdateLastRead(Model.Server server) { logger.Debug($"last read: {server.FriendlyName()}"); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.lastRead = DateTime.Now; } }
public void UpdateLastWrite(Model.Server server) { Logging.Debug($"last write: {server.FriendlyName()}"); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.lastWrite = DateTime.Now; } }
public void SetFailure(Model.Server server) { logger.Debug($"failure: {server.ToString()}"); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.lastFailure = DateTime.Now; } }
public void UpdateLastWrite(Model.Server server) { Logging.Debug(String.Format("last write: {0}", server.FriendlyName())); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.LastWrite = DateTime.Now; } }
public void SetFailure(Model.Server server) { Logging.Debug(String.Format("failure: {0}", server.FriendlyName())); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.LastFailure = DateTime.Now; } }
public void UpdateLastWrite(Model.Server server) { logger.Debug($"last write: {server.ToString()}"); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.lastWrite = DateTime.Now; } }
public void SetFailure(Model.Server server) { Logging.Debug($"failure: {server.FriendlyName()}"); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.lastFailure = DateTime.Now; } }
public void UpdateLatency(Model.Server server, TimeSpan latency) { Logging.Debug($"latency: {server.FriendlyName()} {latency}"); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.latency = latency; status.lastTimeDetectLatency = DateTime.Now; } }
public void UpdateLatency(Model.Server server, TimeSpan latency) { Logging.Debug(String.Format("latency: {0} {1}", server.FriendlyName(), latency)); ServerStatus status; if (_serverStatus.TryGetValue(server, out status)) { status.Latency = latency; status.LastTimeDetectLatency = DateTime.Now; } }
public IHttpActionResult DeleteServer(string id) { Model.Server server = db.Servers.Find(id); if (server == null) { return(NotFound()); } db.Servers.Remove(server); db.SaveChanges(); return(Ok(server)); }
public NodeModel GetNode(Model.Server server) { Enable = server.Enable; Group = server.Group; Method = server.Method; Obfs = server.obfs; Obfsparam = server.ObfsParam; Password = server.Password; Protocol = server.Protocol; Remarks = server.Remarks; Remarks_Base64 = server.Remarks_Base64; Server = server.server; Server_Port = server.Server_Port; return(this); }
public Model.Server GetServer() { Model.Server server = new Model.Server(); server.Enable = Enable; server.Group = Group; server.Method = Method; server.obfs = Obfs; server.ObfsParam = Obfsparam; server.Password = Password; server.Protocol = Protocol; server.Remarks = Remarks; server.Remarks_Base64 = Remarks_Base64; server.server = Server; server.Server_Port = Server_Port; server.ProtocolParam = "18:PEUvBV"; // TODO:让后台添加此参数 return(server); }
public void RemoveTimedOutServers_RemovesTimedOutServer() { // GIVEN const string serverId = "server-001"; var server = new Model.Server { Id = serverId, LastHeartBeat = new DateTime(2000, 1, 1) }; _elasticClient.Index(server, descr => descr.Refresh(Refresh.True)).ThrowIfInvalid(); // WHEN var removedServersCount = _elasticConnection.RemoveTimedOutServers(TimeSpan.FromSeconds(1)); // THEN removedServersCount.Should().Be(1); var getServerResponse = _elasticClient.Get <Model.Server>(serverId).ThrowIfInvalid(); getServerResponse.Found.Should().BeFalse(); }
public void Heartbeat_WithExistingServer_UpdatesHeartbeat() { // GIVEN const string serverId = "server-001"; var server = new Model.Server { Id = serverId, LastHeartBeat = new DateTime(2017, 10, 1) }; _elasticClient.Index(server, descr => descr.Refresh(Refresh.True)).ThrowIfInvalid(); // WHEN _elasticConnection.Heartbeat(serverId); // THEN var getServerResponse = _elasticClient.Get <Model.Server>(serverId).ThrowIfInvalid(); getServerResponse.Found.Should().BeTrue(); getServerResponse.Source.LastHeartBeat.Should().NotBe(server.LastHeartBeat); }
/// <summary> /// Connects to local WSUS server /// </summary> /// <returns> /// Object representing the WSUS Server /// </returns> public static IUpdateServer Connect(Model.Server connectionSettings) { if (connectionSettings != null) { var hostname = connectionSettings.Hostname; if (string.IsNullOrEmpty(hostname)) { throw new System.ArgumentException("Server hostname must be specified if using a server element in the config file."); } int port = connectionSettings.Port; var secure = connectionSettings.Secure; System.Console.Out.WriteLine("Connecting to server: " + hostname + ":" + port); return(Microsoft.UpdateServices.Administration.AdminProxy.GetUpdateServer(hostname, secure, port)); } System.Console.Out.WriteLine("Connecting to server: localhost"); return(Microsoft.UpdateServices.Administration.AdminProxy.GetUpdateServer()); }
public void RemoveTimedOutServers_WithNoTimedOutServers_DoesNothing() { // GIVEN const string serverId = "server-001"; var server = new Model.Server { Id = serverId, LastHeartBeat = DateTime.UtcNow }; _elasticClient.Index(server, descr => descr.Refresh(Refresh.True)).ThrowIfInvalid(); // WHEN var removedServersCount = _elasticConnection.RemoveTimedOutServers(TimeSpan.FromDays(1)); // THEN removedServersCount.Should().Be(0); var getServerResponse = _elasticClient.Get <Model.Server>(serverId).ThrowIfInvalid(); getServerResponse.Found.Should().BeTrue(); getServerResponse.Source.ShouldBeEquivalentTo(server); }
// TODO handle errors private int AddToRepo(ServerResource serverResource) { var server = new Model.Server { Name = serverResource.Name, Description = serverResource.Description, AuthorId = userManager.Users.First().Id // TODO current user }; foreach (var link in serverResource.Links.Where(l => l.Rel == LinkTemplates.Servers.GetSimulations.Rel)) { server.AddSimulation(simulationsRepo.Get(link.GetId())); } foreach (var link in serverResource.Links.Where(l => l.Rel == LinkTemplates.Servers.GetPresentations.Rel)) { server.AddPresentation(presentationsRepo.Get(link.GetId())); } serversRepo.Add(server); return(server.Id); }
// ----------------------------------------------------------------------------------- private void ButtonServerStartOnClick(object sender, RoutedEventArgs routedEventArgs) { if (View.ButtonServerStart.Content.ToString() == "Start") { View.ButtonServerStart.Content = "Stop"; View.LabelServerStatus.Background = Brushes.Yellow; View.LabelServerStatus.Content = "Server starting..."; Server = new Model.Server(); _serverListenThread = new Thread(StartServer); _serverListenThread.Start(); } else if (View.ButtonServerStart.Content.ToString() == "Stop") { Server.StopServer(() => { View.LabelServerStatus.Background = Brushes.Red; View.LabelServerStatus.Content = "Server stopped..."; View.ButtonServerStart.Content = "Start"; }); } }
public void SetFailure(Model.Server server) { // do nothing }
public void UpdateLastWrite(Model.Server server) { // do nothing }
public void UpdateLatency(Model.Server server, TimeSpan latency) { // do nothing }
public void UpdateLastRead(Model.Server server) { // do nothing }
public FreeServers(ShadowsocksController controller) { this.controller = controller; Model.Server server = new Model.Server(); }