/// <summary> /// Constructor. /// </summary> /// <param name="args"> arguments for the service</param> public ImageService(string[] args) { InitializeComponent(); this.loggingService = new LoggingService(); this.loggingService.Log("Logger created", MessageTypeEnum.INFO); this.loggingService.Log("Test background info", MessageTypeEnum.INFO); this.loggingService.Log("Test background fail", MessageTypeEnum.FAIL); this.loggingService.Log("Test background warning", MessageTypeEnum.WARNING); this.imageModal = new ImageServiceModal(loggingService) { OutputFolder = ConfigurationManager.AppSettings["OutputDir"], ThumbnailSize = int.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]) }; this.imageController = new ImageController(this.imageModal, this.loggingService); this.imageServer = new ImageServer(loggingService, imageController); this.server = new ISMobileServer(imageServer); //this.guiServer = new GuiServer(8000, imageServer); string eventSourceName = ConfigurationManager.AppSettings["SourceName"]; string logName = ConfigurationManager.AppSettings["LogName"]; if (args.Count() > 0) { eventSourceName = args[0]; } if (args.Count() > 1) { logName = args[1]; } ImageServiceLog = new EventLog(); if (!EventLog.SourceExists(eventSourceName)) { EventLog.CreateEventSource(eventSourceName, logName); } ImageServiceLog.Source = eventSourceName; ImageServiceLog.Log = logName; this.loggingService.MessageRecieved += this.WriteEntryToLog; }
private void GetSelectedSites() { SelectedObjects selectedObjs = (SelectedObjects)this.siteTree.Tag; if ((null == selectedObjs) || (0 == selectedObjs.SelectedSites.Count())) { // // This shouldn't happen, since the Continue button is only // enabled if there is at least one site. // return; } Dictionary <IISServer, List <ApplicationPool> > allAppPools = new Dictionary <IISServer, List <ApplicationPool> >(); // Clear the list of servers this.IISServers.Servers.Clear(); foreach (IISServer selectedServer in selectedObjs.SelectedServers) { // first clear any sites the server has. selectedServer.Sites.Clear(); // save the list of AppPools and reset the server's list. allAppPools.Add(selectedServer, selectedServer.AppPools); selectedServer.AppPools = new List <ApplicationPool>(); // add this server back into the global list. this.IISServers.Servers.Add(selectedServer.Name, selectedServer); } foreach (Site selectedSite in selectedObjs.SelectedSites) { // first clear any databases the site has selectedSite.Databases.Clear(); IISServer server = selectedSite.ParentServer; selectedSite.ParentServer = null; //prevent recursion during serialization // add this site back into its server's site collection. server.Sites.Add(selectedSite); // add app pools for this site back into the server's AppPool collection. List <ApplicationPool> appPools = allAppPools[server]; if ((null == appPools) || (0 == appPools.Count)) { continue; } ApplicationPool ap = null; if (!server.AppPools.Exists(x => x.Name == selectedSite.AppPoolName)) { ap = appPools.Find(x => x.Name == selectedSite.AppPoolName); if (null != ap) { server.AppPools.Add(ap); appPools.Remove(ap); // trim the list } } foreach (Helpers.Application app in selectedSite.Applications) { if (!server.AppPools.Exists(x => x.Name == app.AppPoolName)) { ap = appPools.Find(x => x.Name == app.AppPoolName); if (null != ap) { server.AppPools.Add(ap); appPools.Remove(ap); // trim the list if (0 == appPools.Count) { break; } } } } } foreach (Database selectedDatabase in selectedObjs.SelectedDatabases) { // add any databases back to their respective sites. Site site = selectedDatabase.ParentSite; selectedDatabase.ParentSite = null; //prevent recursion during serialization site.Add(selectedDatabase); } }