static void Main(string[] args) { LogManager.Assign(new SimpleLogManager <ConsoleLogger>()); // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", string.Format(@"C:\Users\{0}\Downloads", Environment.UserName)); // Create the file module and allow files to be listed. var module = new FileModule(fileService) { ListFiles = true }; // Add the module moduleManager.Add(module); moduleManager.Add(new BodyDecodingModule(new UrlFormattedDecoder())); moduleManager.Add(new MyModule()); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, 8080); Console.ReadLine(); }
// The routing and controller service allows you to serve create flexible custom controllers public static void Main() { // Initialize logging Logger.Initialize(new DebugLogger(), LoggerLevel.Debug); // Create Http server pipeline ModuleManager ModuleManager = new ModuleManager(); // Add the router module as the fist module to pipeline ModuleManager.Add(new RouterModule()); // Add the controller module to pipeline ModuleManager.Add(new ControllerModule()); // Add the error module as the last module to pipeline ModuleManager.Add(new ErrorModule()); // Create the Http server HttpService HttpServer = new HttpService(ModuleManager); // Sets interface ip address HttpServer.InterfaceAddress = IPAddress.GetDefaultLocalAddress(); // Starts Http service HttpServer.Start(); }
// The disk file service allows you to serve and browse files from flash/disk storage public static void Main() { // Initialize logging Logger.Initialize(new DebugLogger(), LoggerLevel.Debug); // Create Http server pipeline ModuleManager ModuleManager = new ModuleManager(); // Create file/disk service for storage DiskFileService fileService = new DiskFileService(@"/", @"\WINFS\WebSite"); // Add the file module to pipeline and enable the file listing feature ModuleManager.Add(new FileModule(fileService) { AllowListing = true }); // Add the error module as the last module to pipeline ModuleManager.Add(new ErrorModule()); // Create the http server HttpService HttpServer = new HttpService(ModuleManager); // Sets interface ip address HttpServer.InterfaceAddress = IPAddress.GetDefaultLocalAddress(); // Starts Http service HttpServer.Start(); // Set local time SntpClient TimeService = new SntpClient(); TimeService.Synchronize(); }
static void Main(string[] args) { //LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", string.Format(@"C:\Users\{0}\Downloads", Environment.UserName)); // Create the file module and allow files to be listed. var module = new FileModule(fileService) {AllowFileListing = true}; // Add the module moduleManager.Add(module); moduleManager.Add(new MyModule()); moduleManager.Add(new MyModule2()); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, 0); Console.WriteLine("PORT " + server.LocalPort); //TrySendARequest(server); Console.ReadLine(); }
static void Main(string[] args) { //LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", $@"C:\Users\{Environment.UserName}\Downloads"); // Create the file module and allow files to be listed. var module = new FileModule(fileService) { AllowFileListing = true, }; // Add the module moduleManager.Add(module); moduleManager.Add(new MyModule()); moduleManager.Add(new MyModule2()); // And start the server. var server = new HttpServer(moduleManager); server.AllowedSslProtocols = SslProtocols.Ssl2; server.Start(IPAddress.Any, 0); Console.WriteLine("PORT " + server.LocalPort); //TrySendARequest(server); Console.ReadLine(); }
static void Main(string[] args) { if (!Environment.UserInteractive) { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new ServerSVC() }; ServiceBase.Run(ServicesToRun); } else { dnsServer.Responded += DnsServer_Responded; dnsServer.Errored += DnsServer_Error; bwThread.DoWork += DnsThread; bwThread.RunWorkerAsync(); if (!Directory.Exists(ServerDirectory)) { Directory.CreateDirectory(ServerDirectory); File.WriteAllText(ServerDirectory + @"\index.html", DefaultIndexHtml); } DiskFileService fileService = new DiskFileService("/", ServerDirectory); FileModule module = new FileModule(fileService) { AllowFileListing = false, }; Console.WriteLine("Server IP: " + ServerIP); ModuleManager httpManager = new ModuleManager(); httpManager.Add(module); httpManager.Add(new HTTP_Module()); HttpServer httpServer = new HttpServer(httpManager); httpServer.Start(IPAddress.Any, 80); Console.WriteLine("HTTP Server Started"); ModuleManager httpsManager = new ModuleManager(); httpsManager.Add(module); httpsManager.Add(new HTTPS_Module()); HttpServer httpsServer = new HttpServer(httpsManager); X509Certificate2 certificate = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "\\cert.pfx", "server"); httpsServer.Start(IPAddress.Any, 443, certificate); Console.WriteLine("HTTPS Server Started"); Console.ReadLine(); } }
static void Main(string[] args) { //LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", string.Format(@"C:\Users\{0}\Downloads", Environment.UserName)); // Create the file module and allow files to be listed. var module = new FileModule(fileService) { ListFiles = true }; // Add the module moduleManager.Add(module); moduleManager.Add(new MyModule()); moduleManager.Add(new MyModule2()); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, 0); Console.WriteLine("PORT " + server.LocalPort); var request = @"GET /?signature=1dfea26808d632903549c69d78558fce1c418405&echostr=5867553698596935317×tamp=1365661332&nonce=1366146317 HTTP/1.0 User-Agent:Mozilla/4.0 Host:58.215.164.183 Pragma:no-cache Connection/Value:Keep-Alive "; var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(IPAddress.Loopback, server.LocalPort); socket.Send(Encoding.UTF8.GetBytes(request)); var buffer = new byte[65535]; var len = socket.Receive(buffer, 0, buffer.Length, SocketFlags.None); var answer = Encoding.UTF8.GetString(buffer, 0, len); Console.WriteLine(answer); len = socket.Receive(buffer, 0, buffer.Length, SocketFlags.None); answer = Encoding.UTF8.GetString(buffer, 0, len); Console.WriteLine(answer); Console.ReadLine(); }
public void Start(int port) { // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", Settings.WebServerFolder); // Create the file module and allow files to be listed. var module = new FileModule(fileService) { ListFiles = false }; var routerModule = new RouterModule(); // Add the module //moduleManager.Add(module); moduleManager.Add(new WebServerModule()); //moduleManager.Add(new BodyDecodingModule(new UrlFormattedDecoder())); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, port); }
public Issue14_should_work_with_concurrent_requests() { var moduleManager = new ModuleManager(); moduleManager.Add(this); _server = new HttpServer(moduleManager); _server.Start(IPAddress.Any, 0); }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var moduleId = itemDataModel.Id; var currentRequest = geMenuItemInput.CurrentRequest; var propertyName = itemDataModel.PropertyName; var isPrivate = NewsItemBusinessModule.IsPrivate(propertyName); if (isPrivate && geMenuItemInput.IsSitemap) { return; } var menuItem = await NewsItemBusinessModule.GetMenuItemAsync(_urlProvider, itemDataModel, currentRequest, ModuleName, isPrivate); if (menuItem != null) { var expendoMenu = CacheProvider.ToExpando(menuItem); { var items = await geMenuItemInput.DataFactory.ItemRepository.GetItemsAsync(itemDataModel.SiteId, new ItemFilters { ParentId = moduleId }); await CacheProvider.GetChildsAsync(_businessModuleFactory, geMenuItemInput.CurrentRequest, items, expendoMenu, geMenuItemInput.DataFactory); } ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, expendoMenu, itemDataModel.PropertyType); } }
public void Start(int port) { try { // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", Settings.WebServerFolder); // Create the file module and allow files to be listed. var module = new FileModule(fileService) { ListFiles = false }; var routerModule = new RouterModule(); // Add the module //moduleManager.Add(module); moduleManager.Add(new WebServerModule()); //moduleManager.Add(new BodyDecodingModule(new UrlFormattedDecoder())); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, port); } catch (Exception ex) { Log.Error("Unable to start web server ", ex); } }
public Issue14_should_work_with_concurrent_requests() { var moduleManager = new ModuleManager(); moduleManager.Add(this); _server = new HttpServer(moduleManager); _server.Start(IPAddress.Any, 0); }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var seoBusinessModel = (SeoBusinessModel)geMenuItemInput.ItemDataModel.Data; ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, seoBusinessModel, itemDataModel.PropertyType); }
public Module() { Name = GetType().Name; Stats = new UpdateStats { Name = Name }; ModuleManager.Add(this); }
public void Run(IBackgroundTaskInstance taskInstance) { // Get the deferral and save it to local variable so that the app stays alive this.backgroundTaskDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += TaskCanceled; // Setup system logging logProvider.Add(systemDebugLogger, new NamespaceFilter("MicroServer")); LogManager.Provider = logProvider; ILogger Logger = LogManager.GetLogger<StartupTask>(); try { // Create Http server pipeline ModuleManager ModuleManager = new ModuleManager(); // Add the router module as the fist module to pipeline ModuleManager.Add(new RouterModule()); // Add the storage service module to pipeline //ModuleManager.Add(new FileModule(new StorageService("/", @"WebRoot"))); // Add the controller module to pipeline ModuleManager.Add(new ControllerModule()); // Add the error module as the last module to pipeline ModuleManager.Add(new ErrorModule()); // Create the http server HttpServer webServer = new HttpServer(ModuleManager); IAsyncAction asyncAction = ThreadPool.RunAsync( async (workItem) => { await webServer.StartAsync("80"); }); Logger.Info("Background task is running..."); } catch (Exception ex) { Debug.WriteLine("Exception in Run: {0}", ex.Message); } }
public Issue8CrashDuringDecodingOfHttpMessage() { _messageReceivedEvent = new ManualResetEvent(false); var moduleManager = new ModuleManager(); var myM = new MyModule(_messageReceivedEvent); moduleManager.Add(myM); _server = new HttpServer(moduleManager); _server.Start(IPAddress.Any, 8088); }
static void Main(string[] args) { //LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", string.Format(@"C:\Users\{0}\Downloads", Environment.UserName)); // Create the file module and allow files to be listed. var module = new FileModule(fileService) {ListFiles = true}; // Add the module moduleManager.Add(module); moduleManager.Add(new MyModule()); moduleManager.Add(new MyModule2()); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, 0); Console.WriteLine("PORT " + server.LocalPort); var request = @"GET /?signature=1dfea26808d632903549c69d78558fce1c418405&echostr=5867553698596935317×tamp=1365661332&nonce=1366146317 HTTP/1.0 User-Agent:Mozilla/4.0 Host:58.215.164.183 Pragma:no-cache Connection/Value:Keep-Alive "; var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(IPAddress.Loopback, server.LocalPort); socket.Send(Encoding.UTF8.GetBytes(request)); var buffer = new byte[65535]; var len = socket.Receive(buffer, 0, buffer.Length, SocketFlags.None); var answer = Encoding.UTF8.GetString(buffer, 0, len); Console.WriteLine(answer); len = socket.Receive(buffer, 0, buffer.Length, SocketFlags.None); answer = Encoding.UTF8.GetString(buffer, 0, len); Console.WriteLine(answer); Console.ReadLine(); }
public void Run(IBackgroundTaskInstance taskInstance) { // Get the deferral and save it to local variable so that the app stays alive this.backgroundTaskDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += TaskCanceled; // Setup system logging logProvider.Add(systemDebugLogger, new NamespaceFilter("MicroServer")); LogManager.Provider = logProvider; ILogger Logger = LogManager.GetLogger <StartupTask>(); try { // Create Http server pipeline ModuleManager ModuleManager = new ModuleManager(); // Add the router module as the fist module to pipeline ModuleManager.Add(new RouterModule()); // Add the storage service module to pipeline //ModuleManager.Add(new FileModule(new StorageService("/", @"WebRoot"))); // Add the controller module to pipeline ModuleManager.Add(new ControllerModule()); // Add the error module as the last module to pipeline ModuleManager.Add(new ErrorModule()); // Create the http server HttpServer webServer = new HttpServer(ModuleManager); IAsyncAction asyncAction = ThreadPool.RunAsync( async(workItem) => { await webServer.StartAsync("80"); }); Logger.Info("Background task is running..."); } catch (Exception ex) { Debug.WriteLine("Exception in Run: {0}", ex.Message); } }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var moduleId = itemDataModel.Id; var currentRequest = geMenuItemInput.CurrentRequest; var menuItem = new MenuItemBusiness(); var title = GetTitle(itemDataModel); var normalizedTitle = UrlHelper.NormalizeTextForUrl(title); menuItem.Title = title; menuItem.RouteDatas = GetRouteData("Index", ModuleName, normalizedTitle, moduleId); var urlInfo = await _urlHelper.GetUrlAsync(currentRequest, "Index", ModuleName, new { title = normalizedTitle, moduleId }); menuItem.Url = urlInfo.Path; menuItem.RoutePath = urlInfo.RoutePath; menuItem.RoutePathWithoutHomePage = urlInfo.RoutePathWithoutHomePage; menuItem.Route = urlInfo.Route; menuItem.ModuleId = moduleId; menuItem.ModuleName = ModuleName; menuItem.Seo = new SeoBusiness(); menuItem.Seo.UpdateDate = itemDataModel.UpdateDate.HasValue ? itemDataModel.UpdateDate.Value : itemDataModel.CreateDate; menuItem.Seo.SitemapFrequence = SitemapFrequence.Yearly; menuItem.Childs = new List <MenuItemBusiness>(); var menuItemChild = new MenuItemBusiness(); menuItemChild.Title = title; menuItemChild.RouteDatas = GetRouteData("Authentification", ModuleName, normalizedTitle, moduleId); var urlInfoChild = await _urlHelper.GetUrlAsync(currentRequest, "Authentification", ModuleName, new { title = normalizedTitle, moduleId }); menuItemChild.Url = urlInfoChild.Path; menuItemChild.RoutePath = urlInfoChild.RoutePath; menuItemChild.RoutePathWithoutHomePage = urlInfoChild.RoutePathWithoutHomePage; menuItemChild.Route = urlInfoChild.Route; menuItemChild.ModuleId = moduleId; menuItemChild.ModuleName = ModuleName; menuItemChild.Seo = new SeoBusiness(); menuItemChild.Seo.UpdateDate = itemDataModel.UpdateDate.HasValue ? itemDataModel.UpdateDate.Value : itemDataModel.CreateDate; menuItemChild.Seo.SitemapFrequence = SitemapFrequence.Yearly; menuItem.Childs.Add(menuItemChild); ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, menuItem, itemDataModel.PropertyType); }
public Issue8CrashDuringDecodingOfHttpMessage() { _messageReceivedEvent = new ManualResetEvent(false); var moduleManager = new ModuleManager(); var myM = new MyModule(_messageReceivedEvent); moduleManager.Add(myM); _server = new HttpServer(moduleManager); _server.Start(IPAddress.Any, 8088); }
static void Main() { //开启控制台监控 UserFunc.AllocConsole(); // Create Module manager that handles all modules in the server var moduleManager = new ModuleManager(); // Add the LogicModule moduleManager.Add(new CommOfWebModule()); // Start the WebServer. server = new HttpServer(moduleManager); server.Start(IPAddress.Any, 9988); Console.WriteLine("WebServer Listened On PORT " + server.LocalPort); //开启任务队列 new Thread(delegate() { while (StopService == false) { try { if (QueueWorker != null) { PacketOfWeb data = QueueWorker.Remove(); if (data != null) { data.SyncOper(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } QueueWorker.Release(); }).Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMainForm()); //关闭线程服务 StopService = true; //End the WebServer server.Stop(); //关闭控制台 UserFunc.FreeConsole(); }
public SimpleWebServer(string prefixes, X509Certificate2 certificate = null) { Uri uri = new Uri(prefixes); this.port = uri.Port; this.certificate = certificate; _worker = new HttpWorker(); ModuleManager moduleManager = new ModuleManager(); moduleManager.Add(_worker); _listener = new HttpServer(moduleManager); }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var currentRequest = geMenuItemInput.CurrentRequest; var propertyName = itemDataModel.PropertyName; var isPrivate = NewsItemBusinessModule.IsPrivate(propertyName); if (isPrivate && geMenuItemInput.IsSitemap) { return; } var menuItem = await NewsItemBusinessModule.GetMenuItemAsync(_urlProvider, itemDataModel, currentRequest, ModuleName, isPrivate); if (menuItem != null) { //var expendoMenu = CacheProvider.ToExpando(menuItem); { var items = await geMenuItemInput.DataFactory.ItemRepository.GetItemsAsync(itemDataModel.SiteId, new ItemFilters { ParentId = itemDataModel.Id, ExcludedModules = new List <string>() { "Image", "Video" } }); foreach (var dataModel in items) { var menuItemChild = await NewsItemBusinessModule.GetMenuItemAsync(_urlProvider, dataModel, currentRequest, dataModel.Module, isPrivate); if (menuItemChild != null) { if (menuItem.Childs == null) { menuItem.Childs = new List <MenuItemBusiness>(); } menuItem.Childs.Add(menuItemChild); } } } ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, menuItem, itemDataModel.PropertyType); } }
private void StartWebServer(int httpPort) { if (!isWebServerStarted) { //if (Log != null) // Log(this, "Starting web server... ", false, LogLevel.Normal); try { var moduleManager = new ModuleManager(); //string root = Path.GetPathRoot(Assembly.GetExecutingAssembly().Location); string root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\WebSite\"; var fileService = new DiskFileService("/", root); var module = new FileModule(fileService) { ListFiles = false }; // Add the module moduleManager.Add(new RootModule()); moduleManager.Add(module); //moduleManager.Add(new BodyDecodingModule(new UrlFormattedDecoder())); // And start the server. webServer = new HttpServer(moduleManager); webServer.Start(IPAddress.Any, httpPort); isWebServerStarted = true; } catch (Exception) { isWebServerStarted = false; } //if (Log != null) // Log(this, isWebServerStarted ? "Success." : "Failed.", true, isWebServerStarted ? LogLevel.Success : LogLevel.Error); } }
protected override void OnStart(string[] args) { bwThread.DoWork += DnsThread; bwThread.RunWorkerAsync(); if (!Directory.Exists(ServerDirectory)) { Directory.CreateDirectory(ServerDirectory); File.WriteAllText(ServerDirectory + @"\index.html", DefaultIndexHtml); } DiskFileService fileService = new DiskFileService("/", ServerDirectory); FileModule module = new FileModule(fileService) { AllowFileListing = false, }; ModuleManager httpManager = new ModuleManager(); httpManager.Add(module); httpManager.Add(new HTTP_Module()); HttpServer httpServer = new HttpServer(httpManager); httpServer.Start(IPAddress.Any, 80); ModuleManager httpsManager = new ModuleManager(); httpsManager.Add(module); httpsManager.Add(new HTTPS_Module()); HttpServer httpsServer = new HttpServer(httpsManager); X509Certificate2 certificate = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "\\cert.pfx", "server"); httpsServer.Start(IPAddress.Any, 443, certificate); }
static void Main(string[] args) { LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Let's serve our downloaded files (Windows 7 users) var fileService = new DiskFileService("/", string.Format(@"C:\Users\{0}\Downloads", Environment.UserName)); // Create the file module and allow files to be listed. var module = new FileModule(fileService) {ListFiles = true}; // Add the module moduleManager.Add(module); moduleManager.Add(new BodyDecodingModule(new UrlFormattedDecoder())); moduleManager.Add(new MyModule()); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, 8080); Console.ReadLine(); }
/// <summary> /// Creates the module. /// </summary> /// <param name="unitViewModel">The module view model.</param> public bool CreateModule(ModuleViewModel moduleViewModel) { try { if (moduleViewModel != null) { Module module = ObjectMapper.Map <ModuleViewModel, Model.Entities.Module>(moduleViewModel); module = ModuleManager.Add(module); return(true); } } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } return(false); }
public ActionResult CreateEntity(Module model) { if (!ModelState.IsValid) { return(Json( new OperateResult { content = Model.Utility.GetModelStateErrors(ModelState), }, JsonRequestBehavior.AllowGet )); } OperateResult or = ModuleManager.Add(model); return(Json(or, JsonRequestBehavior.AllowGet)); }
private static void StartWebServer() { // Module manager handles all modules in the server var moduleManager = new ModuleManager(); // Add the module moduleManager.Add(new WebModule()); // var fileService = new DiskFileService("/", Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"..\..\WebUI")); // var module = new FileModule(fileService) { AllowFileListing = false }; // moduleManager.Add(module); // And start the server. var server = new HttpServer(moduleManager); server.Start(IPAddress.Any, Configuration.Port); Logger.InfoFormat("Listening on port {0}", server.LocalPort); }
public SWebServerTcp(Func <string, string, Stream, string> handleResponse, int port) { myModule = new JsonTextModule(headers); myModule.Callback = handleResponse ?? DefaultHandleRequest; ModuleManager moduleManager = new ModuleManager(); moduleManager.Add(myModule); server = new HttpServer(moduleManager); // Add support to content-type: application/JSON, otherwise Griffin WebServer returns // error 400. CompositeIMessageSerializer compositeSerializer = (CompositeIMessageSerializer)server.BodyDecoder; JsonSerializer jsonSerializer = new JsonSerializer(); compositeSerializer.Add("application/json", jsonSerializer); this.port = port; }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var currentRequest = geMenuItemInput.CurrentRequest; var propertyName = itemDataModel.PropertyName; var isPrivate = IsPrivate(propertyName); if (isPrivate && geMenuItemInput.IsSitemap) { return; } var menuItem = await GetMenuItemAsync(_urlProvider, itemDataModel, currentRequest, ModuleName, isPrivate); if (menuItem != null) { ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, menuItem, itemDataModel.PropertyType); } }
private void GetPluginsList(string moduleFolder) { //1- AppDomain appDomainInfo; Assembly assembly = null; Type pluginType = null; IModule plugin = null; ToolStripMenuItem tsmItem = null; // Exit if folder do not exists ? if (!Directory.Exists(moduleFolder)) { Common.MakeAllSubFolders(moduleFolder); Log.Write("No plugin to load", this, "GetPluginsList", Log.LogType.WARNING); return; } // Get all dll files from directory string[] modulePathList = Directory.GetFiles(moduleFolder, "*.dll"); // create temp domain for module info assemblys //1- appDomainInfo = AppDomain.CreateDomain("InfoDomain"); // For each dll file check it is typeof UberToolsPluginAttribute foreach (string modulePath in modulePathList) { pluginType = null; assembly = null; // Try load assembly file try { assembly = null; assembly = Assembly.LoadFile(modulePath); //AssemblyName assemblyName = new AssemblyName(); //assemblyName.CodeBase = dllFile; //appDomainModule.Load(assemblyName); //ModuleLoader lp = (ModuleLoader)appDomainModule.CreateInstanceAndUnwrap("UberToolsPlugins"Assembly.GetExecutingAssembly().FullName, "DamirM.Module.ModuleLoader"); //ModuleLoader lp = (ModuleLoader)appDomainInfo.CreateInstanceAndUnwrap("UberToolsPlugins", "DamirM.Modules.ModuleLoader"); //ModuleLoader lp = (ModuleLoader)appDomainInfo.CreateInstanceAndUnwrap("UberTools", "UberTools.Class.ModuleLoader"); //assembly = lp.ReflectionOnlyLoadAssambly(modulePath); //// - - - - fix neki - -- -- - -temp //FileStream fs = new FileStream(modulePath, FileMode.Open); //byte[] buffer = new byte[(int)fs.Length]; //fs.Read(buffer, 0, buffer.Length); //fs.Close(); //assembly = Assembly.Load(buffer); if (assembly != null) { foreach (Type type in assembly.GetTypes()) { if (type.IsAbstract) { continue; } if (type.IsDefined(typeof(ModuleAttribute), true)) { pluginType = type; break; } } if (pluginType != null) { Log.Write("Loading module info: " + pluginType.ToString(), this, "GetPluginsList", Log.LogType.DEBUG); // Activite plugin, interface plugin = (IModule)Activator.CreateInstance(pluginType); // Create ModuleObject class in ModuleMenager and add it to list of moduls in sleep ModuleObject moduleObject = moduleManager.Add(modulePath, plugin.Name); // Show ToolStripMenu menu in main form tsmItem = new ToolStripMenuItem(plugin.Name); //plugin.GetModuleLog.OnLog += new ModuleLog.delLog(Log.Write); if (plugin.Icon != null) { tsmItem.Image = plugin.Icon.ToBitmap(); } // Bound menu click event with moduleObject Activete methot, when user clikc on menu it will load plugin and show it tsmItem.Click += new EventHandler(moduleObject.Activeite); tsmPlugins.DropDownItems.Add(tsmItem); } else { Log.Write(new string[] { "Error loading module: " + modulePath, "Invalid module type" }, this, "GetPluginsList", Log.LogType.ERROR); } } } catch (Exception ex) { Log.Write("Error loading plugin " + modulePath, this, "GetPluginsList", Log.LogType.DEBUG); Log.Write(ex, this, "GetPluginsList", Log.LogType.ERROR); } finally { // list assembly for this domain assembly = null; plugin = null; pluginType = null; //1- GetAssemblies(appDomainInfo); //1- AppDomain.Unload(appDomainInfo); } } }
protected override void RegisterModule() { ModuleManager.Add <ModuleA>(); }
private void AddModules() { m_moduleMgr.Add <UIModule>(); }
public void StartAll() { _service = this; // DHCP Service if (_dhcpEnabled == true) { _dhcpService.InterfaceAddress = _interfaceAddress; _dhcpService.ServerName = _serverName; _dhcpService.DnsSuffix = _dnsSuffix; _dhcpService.StorageRoot = _storageRoot; if (_sntpEnabled == true) { _dhcpService.RemoveOption(DhcpOption.NTPServer); _dhcpService.AddOption(DhcpOption.NTPServer, _interfaceAddress.GetAddressBytes()); } _dhcpService.Start(); } // DNS Service if (_dnsEnabled == true) { _dnsService.InterfaceAddress = _interfaceAddress; _dnsService.ServerName = _serverName; _dnsService.DnsSuffix = _dnsSuffix; if (!StringUtility.IsNullOrEmpty(_serverName) || !StringUtility.IsNullOrEmpty(_dnsSuffix)) { Answer record = new Answer(); record.Domain = string.Concat(_serverName, ".", _dnsSuffix); record.Class = RecordClass.IN; record.Type = RecordType.A; record.Ttl = 60; record.Record = new ARecord(_interfaceAddress.GetAddressBytes()); _service.DnsService.ZoneFile.Add(record); Logger.WriteInfo(this, "Device registered with dns: " + record.Domain); } _dnsService.Start(); } // SNTP Service if (_sntpEnabled == true) { _sntpService.InterfaceAddress = _interfaceAddress; _sntpService.Start(); } // HTTP Service if (_httpEnabled == true) { ModuleManager _moduleManager = new ModuleManager(); // Add the router module as the fist module to pipeline _moduleManager.Add(new RouterModule()); if (StorageRoot != null) { // Create disk file service for the root storage DiskFileService fileService = new DiskFileService("/", StorageRoot + @"\" + MicroServer.Net.Http.Constants.HTTP_WEB_ROOT_FOLDER + @"\"); // Add the file module to pipeline _moduleManager.Add(new FileModule(fileService) { AllowListing = _allowListing }); } // Add the controller module to pipeline _moduleManager.Add(new ControllerModule()); // Add the error module as the last module to pipeline _moduleManager.Add(new ErrorModule()); // Create the Http service _httpService = new HttpService(_moduleManager); _httpService.InterfaceAddress = _interfaceAddress; _httpService.Start(); } Logger.WriteInfo(this, "Service Manager started all services"); }
//Control public static void Init() { //See if there is a new version of the web files waiting before we start the server if (File.Exists(Core.RootFolder + @"\web.zip")) { if (Directory.Exists(Core.RootFolder + @"\web\")) Directory.Delete(Core.RootFolder + @"\web\", true); Directory.CreateDirectory(YAMS.Core.RootFolder + @"\web\"); AutoUpdate.ExtractZip(YAMS.Core.RootFolder + @"\web.zip", YAMS.Core.RootFolder + @"\web\"); File.Delete(Core.RootFolder + @"\web.zip"); } //create module manager to add all modules to admin webserver adminModuleManager = new ModuleManager(); //Handle the requests for static files var fileService = new DiskFileService("/assets/", YAMS.Core.RootFolder + "\\web\\assets\\"); var assets = new FileModule(fileService) { AllowFileListing = false }; adminModuleManager.Add(assets); //Handle requests to API adminModuleManager.Add(new Web.AdminAPI()); adminServerThread = new Thread(new ThreadStart(StartAdmin)); adminServerThread.Start(); //Open firewall ports if (Database.GetSetting("EnableOpenFirewall", "YAMS") == "true") { Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")), "Admin website"); } if (Database.GetSetting("EnablePortForwarding", "YAMS") == "true") { Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")), "Admin website", YAMS.Database.GetSetting("YAMSListenIP", "YAMS")); } if (Database.GetSetting("EnablePublicSite", "YAMS") == "true") { //Add any server specific folders publicModuleManager = new ModuleManager(); publicModuleManager.Add(assets); SqlCeDataReader readerServers = YAMS.Database.GetServers(); while (readerServers.Read()) { var intServerID = readerServers["ServerID"].ToString(); if (!Directory.Exists(Core.StoragePath + intServerID + "\\renders\\")) Directory.CreateDirectory(Core.StoragePath + intServerID + "\\renders\\"); publicModuleManager.Add(new FileModule(new DiskFileService("/servers/" + intServerID + "/renders/", Core.StoragePath + intServerID + "\\renders\\"))); if (!Directory.Exists(Core.StoragePath + intServerID + "\\backups\\")) Directory.CreateDirectory(Core.StoragePath + intServerID + "\\backups\\"); publicModuleManager.Add(new FileModule(new DiskFileService("/servers/" + intServerID + "/backups/", Core.StoragePath + intServerID + "\\backups\\"))); } //Handle requests to API publicModuleManager.Add(new Web.PublicAPI()); //publicServer.Add(HttpListener.Create(IPAddress.Any, Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")))); publicServerThread = new Thread(new ThreadStart(StartPublic)); publicServerThread.Start(); //Open firewall ports if (Database.GetSetting("EnableOpenFirewall", "YAMS") == "true") { Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")), "Public website"); } if (Database.GetSetting("EnablePortForwarding", "YAMS") == "true") { Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")), "Public website", YAMS.Database.GetSetting("YAMSListenIP", "YAMS")); } } }
public SimpleWebServer(string prefixes, X509Certificate2 certificate = null) { Uri uri = new Uri(prefixes); this.port = uri.Port; this.certificate = certificate; _worker = new HttpWorker(); ModuleManager moduleManager = new ModuleManager(); moduleManager.Add(_worker); _listener = new HttpServer(moduleManager); }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { var itemDataModel = geMenuItemInput.ItemDataModel; var moduleFree = (MasterBusinessModel)geMenuItemInput.ItemDataModel.Data; var masterInfo = new Master(); masterInfo.Id = itemDataModel.Id; masterInfo.ImageIcones = GetImages(moduleFree, "ImageIcone"); if (masterInfo.ImageIcones != null && masterInfo.ImageIcones.Count > 0) { var imageIcone = masterInfo.ImageIcones.First(); masterInfo.ImageIconeId = imageIcone.Id; masterInfo.ImageIconeFileName = imageIcone.Name; } masterInfo.ImageLogos = GetImages(moduleFree, "ImageLogo"); if (masterInfo.ImageLogos != null && masterInfo.ImageLogos.Count > 0) { var imageLogo = masterInfo.ImageLogos.First(); masterInfo.ImageLogoId = imageLogo.Id; masterInfo.ImageLogoFileName = imageLogo.Name; } var jumbotron = moduleFree.Elements.FirstOrDefault(e => e.Property == "Jumbotron"); if (jumbotron != null) { masterInfo.IsJumbotron = jumbotron.Data == "true"; } masterInfo.Title = moduleFree.Elements.First(e => e.Property == "Title").Data; var colorBackgroundMenu = GetData(moduleFree, "ColorBackgroundMenu"); masterInfo.ColorBackgroundMenu = colorBackgroundMenu; masterInfo.ColorHoverBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 50); masterInfo.ColorSelectedBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 32); masterInfo.ColorH1 = GetData(moduleFree, "ColorH1"); masterInfo.ColorH2 = GetData(moduleFree, "ColorH2"); masterInfo.ColorH3 = GetData(moduleFree, "ColorH3"); masterInfo.ColorJumbotron = GetData(moduleFree, "ColorJumbotron"); masterInfo.ColorBackgroundMenuBottom = GetData(moduleFree, "ColorBackgroundMenuBottom"); var color = GetData(moduleFree, "Color"); masterInfo.Color = color; var colorBackground = GetData(moduleFree, "ColorBackground"); masterInfo.ColorBackground = colorBackground; var colorH1 = GetData(moduleFree, "ColorH1"); var styleModel = new StyleModel { Color = color, ColorBackground = colorBackground, ColorBackgroundMenu = colorBackgroundMenu, ColorHoverBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 50), ColorBackgroundTableHeader = ColorHelper.Grayer(colorBackgroundMenu, -20), ColorBackgroundTableFooter = ColorHelper.Grayer(colorBackgroundMenu, -40), ColorSelectedBackgroundMenu = ColorHelper.Grayer(colorBackgroundMenu, 32), ColorH1 = colorH1, ColorH2 = GetData(moduleFree, "ColorH2"), ColorJumbotron = GetData(moduleFree, "ColorJumbotron"), ColorBackgroundMenuBottom = GetData(moduleFree, "ColorBackgroundMenuBottom"), ColorLoader = ColorHelper.Grayer(colorBackgroundMenu, -20), ColorSeparator = ColorHelper.Grayer(colorBackgroundMenu, -70, 0, 220) }; var template = ResourcesLoader.Load(Path.Combine("Renderers", "Style.st")); var styleTemplate = new StringTemplateRenderer().Render(template, styleModel); masterInfo.StyleTemplate = styleTemplate; //var theme = moduleFree.Elements.FirstOrDefault(e => e.Property == "Theme"); //TODO masterInfo.Theme = "theme1"; /* if (theme != null) * { * masterInfo.Theme = theme.Data; * } * else * { * masterInfo.Theme = "default"; * }*/ masterInfo.Seo = new SeoBusinessMaster(); masterInfo.FacebookAuthenticationAppId = _routeProvider.Domains.Where(d => d.Id == geMenuItemInput.CurrentRequest.DomainId) .Select(d => d.FacebookAppId) .FirstOrDefault(); ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, masterInfo, itemDataModel.PropertyType); }
public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput) { if (geMenuItemInput.IsSitemap) { return; } var itemDataModel = geMenuItemInput.ItemDataModel; var moduleId = itemDataModel.Id; var currentRequest = geMenuItemInput.CurrentRequest; var moduleSocial = (SocialBusinessModel)geMenuItemInput.ItemDataModel.Data; string title; if (string.IsNullOrEmpty(moduleSocial.Title)) { switch (moduleSocial.Socials) { case Socials.Phone: title = moduleSocial.Url; break; case Socials.Email: title = moduleSocial.Url; break; default: title = moduleSocial.Socials.ToString(); break; } } else { title = moduleSocial.Title; } var normalizedTitle = UrlHelper.NormalizeTextForUrl(title); var isPrivate = NewsItemBusinessModule.IsPrivate(itemDataModel.PropertyName); object o = new { title = normalizedTitle, moduleId }; if (isPrivate) { o = new { title = normalizedTitle, moduleId, @private = "privee" }; } var urlInfo = await _urlProvider.GetUrlAsync(currentRequest, "Index", ModuleName, o); var menuItem = new MenuItemBusiness(); menuItem.Title = title; menuItem.RouteDatas = NewsItemBusinessModule.GetRouteData(moduleSocial.Socials.ToString(), ModuleName, normalizedTitle, moduleId, itemDataModel.PropertyName); menuItem.TypeMenuItem = TypeMenuItem.Link; string socialUrl = String.IsNullOrEmpty(moduleSocial.Url) ? "#" : moduleSocial.Url; string url = null; if (moduleSocial.Socials == Socials.Phone) { url = "tel:" + socialUrl; } else if (moduleSocial.Socials == Socials.Phone) { url = "mailto:" + socialUrl; } else { url = socialUrl; } menuItem.Url = url; menuItem.RoutePath = url; menuItem.RoutePathWithoutHomePage = urlInfo.RoutePathWithoutHomePage; menuItem.ModuleId = itemDataModel.Id; menuItem.ModuleName = ModuleName; ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, menuItem, itemDataModel.PropertyType); }