private void UpdateIpCamEmuConfiguration(string ipCamEmuConfiguration, LocalSetupSettings settings) { var document = new XmlDocument(); document.Load(ipCamEmuConfiguration); document["Configuration"]["Servers"]["Server"]["Uri"].InnerText = string.Format("http://localhost:{0}/", settings.IpCameraEmulatorPort); document["Configuration"]["Servers"]["Server"]["Source"].Attributes["Name"].Value = settings.IpCamName; File.Delete(ipCamEmuConfiguration); document.Save(ipCamEmuConfiguration); }
private void ReplaceAndSave(string file, string template, LocalSetupSettings settings) { File.Delete(file); File.WriteAllText(file, template .Replace("{ClientInputPort}", settings.ClientInputPort.ToString()) .Replace("{IpCamId}", settings.IpCamId) .Replace("{IpCamName}", settings.IpCamName) .Replace("{IpCameraEmulatorPort}", settings.IpCameraEmulatorPort.ToString()) .Replace("{MessageRouterInputPort}", settings.MessageRouterInputPort.ToString()) .Replace("{UserPassword}", settings.UserPassword) .Replace("{UserName}", Environment.UserName) .Replace("{Client1QueueName}", "Client-1 Queue") .Replace("{MessageRouterQueue}", "Message Router Queue")); }
private void RegisterIpCamera(LocalSetupSettings settings) { if (Environment.OSVersion.Version.Major >= 6) { // we need configure firewall to allow ip camera to work var startProcessInfo = new ProcessStartInfo(); startProcessInfo.Verb = "runas"; startProcessInfo.UseShellExecute = true; startProcessInfo.FileName = "netsh"; startProcessInfo.Arguments = string.Format( @"http add urlacl url=http://localhost:{0}/ user={1}\{2} listen=yes", settings.IpCameraEmulatorPort, Environment.UserDomainName, Environment.UserName); Process .Start(startProcessInfo) .WaitForExit(); } }
public void Setup(LocalSetupController controller, LocalSetupSettings settings) { string operation = null; try { operation = "IP Camera Emulator preparing"; controller.Log.Info("{0}...", operation); UpdateIpCamEmuConfiguration(controller.Model.IpCamEmu_Configuration, settings); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } try { operation = "IP Camera Emulator registering"; controller.Log.Info("{0}...", operation); RegisterIpCamera(settings); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } try { operation = "Prepare configuration folder"; controller.Log.Info("{0}...", operation); if (Directory.Exists(controller.Model.ConfigurationFolder)) { var files = Directory.GetFiles(controller.Model.ConfigurationFolder); foreach (var file in files) { File.Delete(file); } Directory.Delete(controller.Model.ConfigurationFolder); } Directory.CreateDirectory(controller.Model.ConfigurationFolder); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } try { operation = "Prepare client configuration: Report Tool"; controller.Log.Info("{0}...", operation); ReplaceAndSave(controller.Model.Client_ReportToolConfig, _reportToolConfigTemplate, settings); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } try { operation = "Prepare client configuration: Cam View Tool"; controller.Log.Info("{0}...", operation); ReplaceAndSave(controller.Model.Client_CamViewerToolConfig, _camViewToolConfigTemplate, settings); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } try { operation = "Prepare message router congiguration"; controller.Log.Info("{0}...", operation); ReplaceAndSave(controller.Model.MessageRouter_WpfServerConfig, _messageRouterConfigTemplate, settings); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } try { operation = "Prepare console image processing server congiguration"; controller.Log.Info("{0}...", operation); ReplaceAndSave(controller.Model.ImageProcessingServer_ServerCConfig, _ipsConfigTemplate, settings); } catch (Exception unhandledException) { controller.Log.Error(unhandledException); ShowError(operation, unhandledException); } MessageBox.Show("Configuration was created."); Application.OpenForms[0].DialogResult = DialogResult.OK; Application.OpenForms[0].Close(); }
public void Setup(LocalSetupSettings settings) { new SetupCmd().Setup(this, settings); }