Files
tgstation-server/TGServerService/InterfaceBase.cs
T
Jordan Brownandoranges 8c6d31f394 TGS3 (#3)
Let's just get this merged instead of having a massive PR

Original PR: tgstation/tgstation#26534
2017-06-01 13:06:42 +12:00

125 lines
3.1 KiB
C#

using System;
using System.ServiceModel;
using System.Threading;
using TGServiceInterface;
namespace TGServerService
{
//I know the fact that this is one massive partial class is gonna trigger everyone
//There really was no other succinct way to do it
//this line basically says make one instance of the service, use it multithreaded for requests, and never delete it
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
partial class TGStationServer : IDisposable, ITGStatusCheck, ITGServerUpdater
{
//call partial constructors/destructors from here
//called when the service is started
public TGStationServer()
{
InitChat();
InitByond();
InitCompiler();
InitDreamDaemon();
}
//called when the service is stopped
void RunDisposals()
{
DisposeDreamDaemon();
DisposeCompiler();
DisposeByond();
DisposeRepo();
DisposeChat();
}
//one stop update
public string UpdateServer(TGRepoUpdateMethod updateType, bool push_changelog_if_enabled, ushort testmerge_pr)
{
string res;
switch (updateType)
{
case TGRepoUpdateMethod.Hard:
case TGRepoUpdateMethod.Merge:
res = Update(updateType == TGRepoUpdateMethod.Hard);
if (res != null && res != RepoErrorUpToDate)
return res;
break;
case TGRepoUpdateMethod.Reset:
res = Reset(true);
if (res != null)
return res;
break;
case TGRepoUpdateMethod.None:
break;
}
if (testmerge_pr != 0)
{
res = MergePullRequest(testmerge_pr);
if (res != null && res != RepoErrorUpToDate)
return res;
}
GenerateChangelog(out res);
if (res != null)
return res;
if (push_changelog_if_enabled && SSHAuth())
{
res = Commit();
if (res != null)
return res;
res = Push();
if (res != null)
return res;
}
if (!Compile())
return "Compilation could not be started!";
return null;
}
//just here to test the WCF connection
public void VerifyConnection()
{}
//mostly generated code with a call to RunDisposals()
//you don't need to open this
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
RunDisposals();
// TODO: dispose managed state (managed objects).
}
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
disposedValue = true;
}
}
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
// ~TGStationServer() {
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
// Dispose(false);
// }
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
// TODO: uncomment the following line if the finalizer is overridden above.
// GC.SuppressFinalize(this);
}
#endregion
}
}