internal void Install(string assemblyPath, ParameterParser parameters)
		{
            Console.WriteLine("Installing : " + assemblyPath);

            try
            {
                IResourceAction action = m_manager.ResourceActions.Add(assemblyPath);
                action.Enabled = true;
                action.AllowTransparent = parameters.AllowTransparent;
                action.AllowException = parameters.AllowException;
				m_manager.WriteResources();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error Installing : '{0}', exception {1}", assemblyPath, e);
            }
		}
Esempio n. 2
0
		static int Main(string[] args)
		{
			ParameterParser parameterParser = new ParameterParser(args);

			try
			{
				if (!parameterParser.IsSilent)
				{
					Win32Imports.AllocConsole();
				}

				if ((args.Length == 0) || (parameterParser.IsHelp) || (!parameterParser.AllAssembliesExist))
				{
					Console.WriteLine("<program name> <action assembly> [/silent] [/?]");
					Console.WriteLine("<program name> /publishToServer /userName <name> /password <password> [/silent]");
					Console.WriteLine("<program name> <action assembly> [/silent] [/?] /publishToServer /userName <name> /password <password>");
					return 87; // Invalid parameter
				}

				string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Workshare\\Protect Enterprise");

				if (!Directory.Exists(appDataPath))
					Directory.CreateDirectory(appDataPath);

				ActionResourceInstaller installer = null;

				for (int timeoutSteps = 30; installer == null && timeoutSteps >= 0; --timeoutSteps)
				{
					try
					{
						installer = new ActionResourceInstaller();
					}
					catch (System.Runtime.Remoting.RemotingException)
					{
						Logger.LogInfo(timeoutSteps.ToString(System.Globalization.CultureInfo.InvariantCulture) + ": Client Caching service not available");
						if (timeoutSteps > 0)
							System.Threading.Thread.Sleep(1000);
						else
							throw;
					}
				}

				//	Create an authentication token from the parameters
				if (parameterParser.PublishToServer)
				{
					throw new Exception("Publish to Server is no longer valid");
				}
				 
				if (parameterParser.TargetAssemblies.Count != 0)
				{
					foreach (string targetAssembly in parameterParser.TargetAssemblies)
					{
						installer.Install(targetAssembly, parameterParser);
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError(ex);
				return 1;
			}
			finally
			{
				if (!parameterParser.IsSilent)
				{
					Console.ReadLine();
					Win32Imports.FreeConsole();
				}
			}

			return 0;
		}