//Stored when created classed public MOTR_Webserver(IWebSocketLogger logger, MOTR_Sessions sessions, MOTR_Users users, MOTR_Dirs dirs, MOTR_Queue queue, MOTR_Admin admin, MOTR_Downloads downloads) { _logger = logger; _sessions = sessions; _users = users; _dirs = dirs; _queue = queue; _admin = admin; _downloads = downloads; pMe = this; //Stored for the static calls aWebservers = new List <MOTR_WebserverObject>(); }
//public event EventHandler<QueueIDEventArg> OnQueueExecute; public MOTR_Queue() { lQueueNumber = 0; //Could be anything, an unique identifier for a job running aQueue = new ArrayList(); aProcessRunning = new ArrayList(); pMaster = this; //Convert profiles variable for returning what we support convertprofiles = new MOTR_Convertprofiles(); string test = convertprofiles.GetProfiles(); string test2 = convertprofiles.GetDescription(5); string test3 = convertprofiles.GetDescription("Normal"); ArrayList test5 = convertprofiles.GetProfilesArray(); }
public MOTR_WebserverFactory(string webRoot, MOTR_Sessions sessions, MOTR_Users users, MOTR_Dirs dirs, MOTR_Queue queue, MOTR_Admin _admin, MOTR_Downloads _downloads, IWebSocketLogger logger, MOTR_Webserver _webserver) { _logger = logger; _webRoot = string.IsNullOrWhiteSpace(webRoot) ? GetWebRoot() : webRoot; m_Sessions = sessions; m_Users = users; m_Dirs = dirs; m_Queue = queue; m_WebServer = _webserver; m_Admin = _admin; m_Downloads = _downloads; if (!Directory.Exists(_webRoot)) { _logger.Warning(this.GetType(), "Web root not found: {0}", _webRoot); } else { _logger.Debug(this.GetType(), "Web root: " + _webRoot); } }
/// <SUMMARY> /// /// </SUMMARY> protected void ServiceMain() { //First of all, check the port is available if (IsPortOpen(iHTTP) == true) { LogEventError("Port for http " + iHTTP + " is already open, MOTR cannot run on this port"); m_OnStopTimer.Start(); return; } if (IsPortOpen(iHTTPS) == true) { LogEventError("Port for https " + iHTTPS + " is already open, MOTR cannot run on this port"); m_OnStopTimer.Start(); return; } //Here we are ready to go bool bSignaledThreadToStop = false; IWebSocketLogger _logger = new WebSocketLogger(); //_logger.Information(typeof(WindowsService), "-----------------------------------------------------"); // private static MOTR_Webserver m_WebServerSSL; MOTR_Users m_Users = new MOTR_Users(); MOTR_Sessions m_Sessions = new MOTR_Sessions(m_Users); MOTR_Dirs m_Dirs = new MOTR_Dirs(); MOTR_Queue m_Queue = new MOTR_Queue(); MOTR_Admin m_Admin = new MOTR_Admin(); MOTR_Downloads m_Downloads = new MOTR_Downloads(m_Dirs); if (m_Admin.HasError) { _logger.Error(typeof(MOTR_Admin), m_Admin.GetErrorString()); } MOTR_Webserver m_WebServer = new MOTR_Webserver(_logger, m_Sessions, m_Users, m_Dirs, m_Queue, m_Admin, m_Downloads); m_Queue.OnQueueProcentage += m_WebServer.HandleEventUpdateProcentage; m_Queue.OnQueueUpdate += m_WebServer.HandleEvent; m_Downloads.OnMobileDownload += m_WebServer.HandleEventSendMobileDownload; //Create the webserver //Note: HTTPS is only started when there are users available #if DEBUG m_WebServer.CreateWebServer(iHTTP, @"..\..\WebFiles"); if (iHTTPS > 0 && iHTTPS <= 0x0000FFFF) { m_WebServer.CreateWebServer(iHTTPS, @"..\..\WebFiles", true, @".\motrd.pfx", ""); } #else //Get directory where the motrd.exe file is located... string webDirectory = AppDomain.CurrentDomain.BaseDirectory; m_WebServer.CreateWebServer(iHTTP, webDirectory + @"WebFiles"); if (iHTTPS > 0 && iHTTPS <= 0x0000FFFF) { m_WebServer.CreateWebServer(iHTTPS, webDirectory + @"WebFiles", true, webDirectory + @"motrd.pfx", ""); } #endif LogEventInformation("MOTRd everything created, program started..."); _logger.Debug(typeof(WindowsService), "MOTRd everything created, program started git version..."); //Wait forever for the shutdown event bSignaledThreadToStop = m_shutdownEvent.WaitOne(-1, true); _logger.Information(typeof(WindowsService), "--- ENDING -----------------------------------------------------"); //Clear the queue items and let it run out of scope... m_Queue.ClearProcessListAndClean(); _logger.Information(this.GetType(), "Finished with ClearProcessListAndClean()"); }