コード例 #1
0
        public void Initialize()
        {
            string executablePath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            ProxyDomain pd       = new ProxyDomain();
            Assembly    assembly = pd.GetAssembly(System.IO.Path.Combine(executablePath, "MaterialDesignThemes.Wpf.dll"));

            Assembly assembly1 = pd.GetAssembly(Path.Combine(executablePath, "MaterialDesignColors.dll"));

            if (assembly != null | assembly1 != null)
            {
                Active.Editor.WriteMessage("style dlls not load");
            }


            StandartCopier standartCopier = new StandartCopier();

            if (!File.Exists(standartCopier.Pc3Location) & !File.Exists(standartCopier.PmpLocation))
            {
                bool isCopied = standartCopier.CopyParamsFiles();
                if (isCopied)
                {
                    Active.Editor.WriteMessage("Файлы {0}, {1} скопированы", standartCopier.Pc3Location,
                                               standartCopier.PmpLocation);
                }
                else
                {
                    Active.Editor.WriteMessage(
                        "Не удалось скопировать файлы настройки, скопируйте с сервера \\\\uz-fs\\install\\CAD\\Blocks файлы {0}  в {1} и {2} ",
                        standartCopier.Pc3Dest, standartCopier.Pc3Location, standartCopier.PmpLocation);
                }
            }
            else
            {
                Active.Editor.WriteMessage("Файлы настройки присутствуют, для перевода в pdf наберите CreateTranspdf");
            }

            Active.Editor.WriteMessage("Файлы настройки присутствуют, для перевода в pdf наберите CreateTranspdf");
        }
コード例 #2
0
        /// <summary>
        /// Open a scraper config. We get the scraper information about the config form from the service, then use
        /// reflection to load the neccessary dll files.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miOpenConfig_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                WebScraper scraper = (WebScraper)lvScrapers.SelectedItem;
                if (scraper != null)
                {
                    System.Windows.Forms.Application.EnableVisualStyles();
                    WebConfigResult scraperDll = Proxy.GetConfig(scraper.ScraperId);


                    if (File.Exists(scraperDll.DllPath))
                    {
                        ProxyDomain pd           = new ProxyDomain();
                        Assembly    assembly     = pd.GetAssembly(scraperDll.DllPath);
                        String      assemblyName = scraperDll.PluginAssemblyName;

                        IScraperPlugin plugin = (IScraperPlugin)assembly.CreateInstance(assemblyName);
                        NativeAssemblyLoader.SetSearchDirectory(Path.GetFullPath(Path.GetDirectoryName(scraperDll.DllPath)));

                        Form config = plugin.CreateConfig();

                        WebScraperState before = Proxy.GetScraperState(scraper.ScraperId).ScraperState;
                        if (before == WebScraperState.Running)
                        {
                            bool result = Proxy.PauseScraper(scraper.ScraperId);
                        }

                        config.ShowDialog();


                        if (before == WebScraperState.Running)
                        {
                            bool result = Proxy.ResumeScraper(scraper.ScraperId);
                        }
                    }
                    else
                    {
                        Log.Warn("Couldn't load scraper config, {0} doesn't exist", scraperDll.DllPath);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error starting scraper config", ex);
            }
        }
コード例 #3
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            if (path.StartsWith(@".\"))
            {
                path = System.IO.Path.Combine(this.CurrentProviderLocation("FileSystem").ProviderPath, path.Substring(2));
            }
            else
            {
                path = System.IO.Path.Combine(this.CurrentProviderLocation("FileSystem").ProviderPath, path);
            }

            path = System.IO.Path.GetFullPath(path);

            if (!System.IO.File.Exists(path))
            {
                ThrowTerminatingError(new ErrorRecord(new FileNotFoundException(string.Format("File {0} not found", path)), "100", ErrorCategory.OpenError, path));
            }



            string         domainName     = "GetSelfHostedPSDomain-" + Guid.NewGuid().ToString().GetHashCode().ToString("x");
            Evidence       domainEvidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            AppDomainSetup domainInfo     = new AppDomainSetup();

            domainInfo.ApplicationName = domainName;
            domainInfo.ApplicationBase = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            AppDomain subDomain = AppDomain.CreateDomain(domainName, domainEvidence, domainInfo);
            Type      type      = typeof(ProxyDomain);

            ProxyDomain proxyDomain = (ProxyDomain)subDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);

            proxyDomain.LoadAssembly(GetDLLLocation("System"));
            proxyDomain.LoadAssembly(GetDLLLocation("System.Management"));
            proxyDomain.LoadAssembly(GetDLLLocation("System.Management.Automation"));
            proxyDomain.LoadAssembly(Assembly.GetExecutingAssembly().Location);

            WriteObject(proxyDomain.GetAssembly(path));

            AppDomain.Unload(subDomain);
            subDomain = null;
        }
コード例 #4
0
		static string GetEndpointName(string path)
		{		
			var assemblyFiles = new DirectoryInfo(path).GetFiles("*.dll", SearchOption.AllDirectories)
				.Union(new DirectoryInfo(path).GetFiles("*.exe", SearchOption.AllDirectories));

			assemblyFiles = assemblyFiles.Where(f => !defaultAssemblyExclusions.Any(exclusion => f.Name.ToLower().StartsWith(exclusion)));			

			var results = new List<Assembly>();
			foreach (var assemblyFile in assemblyFiles)
			{
				try
				{
					var pd = new ProxyDomain();
					var assembly = pd.GetAssembly(assemblyFile.FullName);
					assembly.GetTypes();
					results.Add(assembly);
				}
				catch(Exception e)
				{
					
				}
			}


			var endPointType = ScanAssembliesForEndpoints(results).FirstOrDefault();

			if (endPointType == null)
			{
				throw new Exception(string.Format("No implementation of IConfigureThisEndpoint found in {0}", path));
			}

			//Stolen from https://github.com/NServiceBus/NServiceBus/blob/master/src/hosting/NServiceBus.Hosting.Windows/Program.cs
			var endpointConfiguration = Activator.CreateInstance(endPointType);
			var endpointName = endpointConfiguration.GetType().Namespace;

			var arr = endpointConfiguration.GetType().GetCustomAttributes(typeof(EndpointNameAttribute), false);
			if (arr.Length == 1)
				endpointName = (arr[0] as EndpointNameAttribute).Name;

			if (endpointConfiguration is INameThisEndpoint)
				endpointName = (endpointConfiguration as INameThisEndpoint).GetName();

			return endpointName;
		}