static ProcessManager() { ConfigurationManager.AppSettings["PrinterConfigurationBaseUrl"] = RegistryDataResolver.GetPcsUrl(); PrintAgentProcess.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\PrinterAgentServer.exe"; PrintAgentProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; PrintAgentProcess.StartInfo.UseShellExecute = true; }
public static string GetPrinterAgentId() { if (string.IsNullOrEmpty(PrintConfigurationCache.Secret)) { PrintConfigurationCache.Secret = RegistryDataResolver.GetStoredPrinterAgentId(); } return(PrintConfigurationCache.Secret); }
private PrintConfigurationRequestDto CreateConfigurationRequest() { var request = new PrintConfigurationRequestDto(); request.Name = GetCurrentComputerName(); request.AgentVersion = RegistryDataResolver.GetAgentVersion(); request.Printers = PrinterManager.GetAvailablePrinters(); return(request); }
private string RegisterComputer() { Logger.LogInfo("Agent id does not exist in registry. Registering computer on PCS."); RegistryDataResolver.CheckWriteAccess(); var secret = CreateConfiguration()?.Secret; if (secret == null) { return(null); } RegistryDataResolver.StorePrinterAgentId(secret); return(secret); }
public static void Main(string[] args) { int port = 0; int parentProcessId = 0; foreach (var a in args) { var arg = a.Split('='); if (arg.Length != 2) { continue; } var paramName = arg[0]; var paramValue = arg[1]; if (paramName.Equals(CommandSwitch.Port, StringComparison.InvariantCultureIgnoreCase)) { int.TryParse(paramValue, out port); } else if (paramName.Equals(CommandSwitch.ParentProcessId, StringComparison.InvariantCultureIgnoreCase)) { int.TryParse(paramValue, out parentProcessId); } } if (port <= 0) { throw new System.Exception("No valid port specified"); } if (parentProcessId > 0) { new ParentProcessMonitor(parentProcessId).Start(); } ConfigurationManager.AppSettings["PrinterConfigurationBaseUrl"] = RegistryDataResolver.GetPcsUrl(); var confPollerTask = new Task(() => new ConfigurationUpdater().Poll()); confPollerTask.ContinueWith(ExceptionHandler, TaskContinuationOptions.OnlyOnFaulted); confPollerTask.Start(); new SocketServer.SocketServer(port).Start(); }