internal static void SetTraceSettings(short maxTypeId, TraceSettings settings) { if (_messageTracer == null) { _messageTracer = new MessageTracer(maxTypeId, settings); } else { _messageTracer.ReloadConfig(maxTypeId, settings); } }
internal static void SetTraceSettings(short maxTypeId, TraceSettings settings) { if(_messageTracer == null) { _messageTracer = new MessageTracer(maxTypeId, settings); } else { _messageTracer.ReloadConfig(maxTypeId,settings); } }
public TraceSettings CreateSettings() { var result = new TraceSettings { IsTraceDontResolveAddress = this.IsTraceDontResolveAddress, RoundTrip = this.RoundTrip, CanTraceIpV4 = this.CanTraceIpV4, CanTraceIpV6 = this.CanTraceIpV6, MaxHops = this.MaxHops, TimeOut = this.TimeOut, Source = this.Source }; return(result); }
internal static bool AtLeastOneEventSelected(TraceSettings ts) { return(ts.EventsColumns.BatchCompleted || ts.EventsColumns.BatchStarting || ts.EventsColumns.LoginLogout || ts.EventsColumns.ExistingConnection || ts.EventsColumns.RPCCompleted || ts.EventsColumns.RPCStarting || ts.EventsColumns.SPStmtCompleted || ts.EventsColumns.SPStmtStarting || ts.EventsColumns.UserErrorMessage || ts.EventsColumns.BlockedProcessPeport || ts.EventsColumns.SQLStmtStarting || ts.EventsColumns.SQLStmtCompleted); }
internal static bool AtLeastOneEventSelected(TraceSettings ts) { return ts.EventsColumns.BatchCompleted || ts.EventsColumns.BatchStarting || ts.EventsColumns.LoginLogout || ts.EventsColumns.ExistingConnection || ts.EventsColumns.RPCCompleted || ts.EventsColumns.RPCStarting || ts.EventsColumns.SPStmtCompleted || ts.EventsColumns.SPStmtStarting || ts.EventsColumns.UserErrorMessage || ts.EventsColumns.BlockedProcessPeport || ts.EventsColumns.SQLStmtStarting || ts.EventsColumns.SQLStmtCompleted; }
private Message CreateInputExirationMessage(Message message, string stateId) { var idMessage = GetInputExirationIdMessage(message); TraceSettings traceSettings = GetTraceSettings(message); return(new Message(idMessage) { To = message.To, Content = new InputExpiration() { Identity = message.From, StateId = stateId }, Metadata = traceSettings?.GetDictionary() }); }
internal void ReloadConfig(short newMaxTypeId, TraceSettings traceSettings) { maxTypeId = newMaxTypeId; if (traceSettings != null) { _sampleSeconds = traceSettings.SampleSeconds; _outputTraceFileName = traceSettings.TraceFilename; _writingToDiagnostic = traceSettings.WriteToDiagnostic; SetMessageTypeFilter(traceSettings.GetTracedMessageTypeEnums()); SetMessageTypeIdFilter(traceSettings.TracedMessageTypeIds); } else { _writingToDiagnostic = true; _sampleSeconds = 0; _outputTraceFileName = null; SetMessageTypeFilter(null); SetMessageTypeIdFilter(null); } }
public async Task CreateNewTraceSettingsFromMessageMetadaWithoutSlowThresholdShouldSucceed() { var target = new Identity(Guid.NewGuid().ToString(), "msging.net"); var mode = "All"; var targetType = "Lime"; var message = new Message { Metadata = new Dictionary <string, string> { { "builder.trace.mode", mode }, { "builder.trace.targetType", targetType }, { "builder.trace.target", target }, } }; var traceSettings = new TraceSettings(message.Metadata); traceSettings.Mode.ToString().ShouldBe(mode); traceSettings.TargetType.ToString().ShouldBe(targetType); traceSettings.Target.ShouldBe(target); traceSettings.SlowThreshold.ShouldBe(null); }
static TracingTestSettings() { TraceListener1 = new DefaultTraceListener { Name = "test_listener1", LogFileName = "test_listener1.log" }; TraceListener2 = new DefaultTraceListener { Name = "test_listener2", LogFileName = "test_listener2.log" }; TraceListeners = new[] { TraceListener1, TraceListener2 }; TraceSettings = new TraceSettings( AutoFlush, IndentSize, UseGlobalLock, TraceListeners); TraceSource1 = new TraceSource(TraceSource1Name); TraceSource2 = new TraceSource(TraceSource2Name); TraceSources = new TraceSource[] { TraceSource1, TraceSource2 }; DiagnosticsSettings = new DiagnosticsSettings(TraceSettings, TraceSources); Tracing.Settings = DiagnosticsSettings; // Immediately lock the Settings property by reading it. Tracing.Settings.Should().BeSameAs(DiagnosticsSettings); }
public async Task TraceAsync(TraceModel model, TraceSettings settings, CancellationToken token) { for (int ttl = 1; ttl < settings.MaxHops; ttl++) { var reply = await PingProvider.Instance.EchoRequestAsync(settings.Host, 32, ttl, settings.TimeOut, token); model.Nodes.Add(reply); var hostGeoInformation = await HostGeoInformationProvider.Instance.GetHostGeoInformation(reply.Address, token); if (hostGeoInformation.Status == "success") { model.NodesGeoInformation.Add(hostGeoInformation); } await Task.Delay(settings.TimeOut); if (reply.Status == IPStatus.Success) { break; } } model.IsReady = true; }
internal MessageTracer(short maxTypeId, TraceSettings traceSettings) { //dispatchers and dispatcher queues need unique names. it's unlikely that a single class could want more than one of these. //blatantly stolen from mr custenborders logwrapper class string name = ExtractClassName(new StackFrame(1).GetMethod()); _sampleTimer = new Timer(SampleTimerCallback); ReloadConfig(maxTypeId, traceSettings); _traceDispatcher = new Dispatcher(1, ThreadPriority.BelowNormal, true, name + "TraceDispatcher"); //using only 1 thread keeps us from needing any locking on the stream output _traceMessageQueue = new DispatcherQueue(name + "DispatcherQueue", _traceDispatcher, TaskExecutionPolicy.ConstrainQueueDepthDiscardTasks, 10000); Arbiter.Activate(_traceMessageQueue, Arbiter.Receive <RelayMessage>(true, _tracePort, DoWriteTraceInfo)); Arbiter.Activate(_traceMessageQueue, Arbiter.Receive <IList <RelayMessage> >(true, _traceListPort, DoWriteTraceInfo)); Arbiter.Activate(_traceMessageQueue, Arbiter.Receive <string>(true, _stringPort, DoWriteTraceInfo)); }
internal MessageTracer(short maxTypeId, TraceSettings traceSettings) { //dispatchers and dispatcher queues need unique names. it's unlikely that a single class could want more than one of these. //blatantly stolen from mr custenborders logwrapper class string name = ExtractClassName(new StackFrame(1).GetMethod()); _sampleTimer = new Timer(SampleTimerCallback); ReloadConfig(maxTypeId, traceSettings); _traceDispatcher = new Dispatcher(1, ThreadPriority.BelowNormal, true, name + "TraceDispatcher"); //using only 1 thread keeps us from needing any locking on the stream output _traceMessageQueue = new DispatcherQueue(name + "DispatcherQueue", _traceDispatcher, TaskExecutionPolicy.ConstrainQueueDepthDiscardTasks, 10000); Arbiter.Activate(_traceMessageQueue, Arbiter.Receive<RelayMessage>(true, _tracePort, DoWriteTraceInfo)); Arbiter.Activate(_traceMessageQueue, Arbiter.Receive<IList<RelayMessage>>(true, _traceListPort, DoWriteTraceInfo)); Arbiter.Activate(_traceMessageQueue, Arbiter.Receive<string>(true, _stringPort, DoWriteTraceInfo)); }
/// [PrintEndpoints] /// [Configuration Options 2] static void ConfigureOpcUaApplicationFromCode() { // fill in the application settings in code // The configuration settings are typically provided by another module // of the application or loaded from a data base. In this example the // settings are hardcoded SecuredApplication application = new SecuredApplication(); // *********************************************************************** // standard configuration options // general application identification settings application.ApplicationName = "UnifiedAutomation GettingStartedServer"; application.ApplicationUri = "urn:localhost:UnifiedAutomation:GettingStartedServer"; application.ApplicationType = UnifiedAutomation.UaSchema.ApplicationType.Server_0; application.ProductName = "UnifiedAutomation GettingStartedServer"; // configure certificate stores application.ApplicationCertificate = new UnifiedAutomation.UaSchema.CertificateIdentifier(); application.ApplicationCertificate.StoreType = "Directory"; application.ApplicationCertificate.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\own"; application.ApplicationCertificate.SubjectName = "CN=GettingStartedServer/O=UnifiedAutomation/DC=localhost"; application.TrustedCertificateStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.TrustedCertificateStore.StoreType = "Directory"; application.TrustedCertificateStore.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\trusted"; application.IssuerCertificateStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.IssuerCertificateStore.StoreType = "Directory"; application.IssuerCertificateStore.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\issuers"; application.RejectedCertificatesStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.RejectedCertificatesStore.StoreType = "Directory"; application.RejectedCertificatesStore.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\rejected"; // configure endpoints application.BaseAddresses = new UnifiedAutomation.UaSchema.ListOfBaseAddresses(); application.BaseAddresses.Add("opc.tcp://*****:*****@"%CommonApplicationData%\unifiedautomation\logs\ConfigurationServer.log.txt"; trace.MaxLogFileBackups = 3; trace.ModuleSettings = new ModuleTraceSettings[] { new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Stack", TraceEnabled = true }, new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Server", TraceEnabled = true }, }; application.Set <TraceSettings>(trace); // Installation settings InstallationSettings installation = new InstallationSettings(); installation.GenerateCertificateIfNone = true; installation.DeleteCertificateOnUninstall = true; application.Set <InstallationSettings>(installation); // *********************************************************************** // set the configuration for the application (must be called before start to have any effect). // these settings are discarded if the /configFile flag is specified on the command line. ApplicationInstance.Default.SetApplicationSettings(application); }
public void Validate() { // Optimization to avoid multiple validations. // It can lead to errors if any property is changed meanwhile... if (_isValid) { return; } this.ValidateObject(); if (States.Count(s => s.Root) != 1) { throw new ValidationException("The flow must have one root state"); } var rootState = States.First(s => s.Root); if (rootState.Input == null || rootState.Input.Bypass) { throw new ValidationException("The root state must expect an input"); } if (rootState.Input.Conditions?.Any() == true) { throw new ValidationException("The root state must not have any conditions"); } if (InputActions != null) { foreach (var inputAction in InputActions) { inputAction.Validate(); } } foreach (var state in States) { state.Validate(); if (States.Count(s => s.Id == state.Id) > 1) { throw new ValidationException($"The state id '{state.Id}' is not unique in the flow"); } // Check if there's a direct path loop (without inputs) to this state in the flow. if (state.Outputs != null) { bool CanBeReached(State targetState, Output output, ISet <string> checkedStates) { if (checkedStates.Contains(output.StateId)) { return(false); } var outputState = States.FirstOrDefault(s => s.Id == output.StateId); if (outputState?.Outputs == null || outputState.Outputs.Length == 0) { return(false); } if (outputState.Input != null && !outputState.Input.Bypass) { return(false); } if (outputState.Outputs.Any(o => o.StateId == targetState.Id)) { return(true); } checkedStates.Add(output.StateId); return(outputState.Outputs.Any(o => CanBeReached(targetState, o, checkedStates))); } ; foreach (var output in state.Outputs) { if (States.All(s => s.Id != output.StateId)) { throw new ValidationException($"The output state id '{output.StateId}' is invalid"); } if (state.Input == null || state.Input.Bypass) { var checkedStates = new HashSet <string>(); if (CanBeReached(state, output, checkedStates)) { throw new ValidationException( $"There is a loop in the flow starting in the state {state.Id} that does not requires user input"); } } } } } if (OutputActions != null) { foreach (var outputAction in OutputActions) { outputAction.Validate(); } } // Try create trace settings from configuration keys if (TraceSettings == null && Configuration != null && Configuration.TryGetValue("TraceMode", out var traceModeValue) && Enum.TryParse <TraceMode>(traceModeValue, true, out var traceMode) && Configuration.TryGetValue("TraceTargetType", out var traceTargetTypeValue) && Enum.TryParse <TraceTargetType>(traceTargetTypeValue, true, out var traceTargetType) && Configuration.TryGetValue("TraceTarget", out var traceTarget)) { TraceSettings = new TraceSettings { Mode = traceMode, TargetType = traceTargetType, Target = traceTarget }; if (Configuration.TryGetValue("TraceSlowThreshold", out var traceSlowThresholdValue) && int.TryParse(traceSlowThresholdValue, out var traceSlowThreshold)) { TraceSettings.SlowThreshold = traceSlowThreshold; } } _isValid = true; }
public static bool ShouldCreateSpan(this TraceSettings traceSettings, string requestName) { return(!traceSettings.Exclude?.Contains(requestName) ?? true); }
private void btnReset_Click(object sender, EventArgs e) { SetSettings(TraceSettings.GetDefaultSettings()); }
public MessageHandler(ILogger logger, TraceSettings traceSettings) { _logger = logger; _traceSettings = traceSettings; }
private void CreateVetorLocal2() { CreateBitmapLocal(); Shapes shapes = this.app.ActiveLayer.Shapes; foreach (Corel.Interop.VGCore.Shape shape in shapes) { if (shape.Name == "temp_qrcode.jpg") { double x, y, w, h; shape.GetPosition(out x, out y); shape.GetSize(out w, out h); TraceSettings traceSettings = shape.Bitmap.Trace(cdrTraceType.cdrTraceLineDrawing); traceSettings.DetailLevelPercent = 100; traceSettings.BackgroundRemovalMode = cdrTraceBackgroundMode.cdrTraceBackgroundAutomatic; traceSettings.CornerSmoothness = 0; traceSettings.DeleteOriginalObject = true; traceSettings.RemoveBackground = true; traceSettings.RemoveEntireBackColor = true; traceSettings.RemoveOverlap = true; traceSettings.SetColorCount(2); traceSettings.SetColorMode(cdrColorType.cdrColorGray, cdrPaletteID.cdrCustom); traceSettings.Smoothing = 0; traceSettings.TraceType = cdrTraceType.cdrTraceClipart; traceSettings.Finish(); Corel.Interop.VGCore.ShapeRange sr = new Corel.Interop.VGCore.ShapeRange(); foreach (Corel.Interop.VGCore.Shape s in this.app.ActiveLayer.Shapes) { sr.Add(s); } sr.CreateSelection(); Corel.Interop.VGCore.Shape qrShape = this.app.ActiveSelection; Corel.Interop.VGCore.Shape cod = this.app.ActiveSelection.Weld(qrShape); cod.Name = "Cod"; Corel.Interop.VGCore.Color cWhite = new Corel.Interop.VGCore.Color(); cWhite.CMYKAssign(0, 0, 0, 0); Corel.Interop.VGCore.Shape border = this.app.ActiveLayer.CreateRectangle2(x, y - h, w, h); border.Fill.ApplyUniformFill(cWhite); border.Outline.Width = 0; border.OrderToBack(); border.Name = "Borda"; int strSize = 221; cod.AddToSelection(); border.AddToSelection(); Corel.Interop.VGCore.Shape g = this.app.ActiveSelection.Group(); this.app.ActiveDocument.Unit = this.app.ActiveDocument.Rulers.HUnits; if (Int32.TryParse(txt_size.Text, out strSize)) { g.SetSize(strSize, strSize); } else { System.Windows.MessageBox.Show("Formato de tamanho inválido", "Aviso para Você!"); } } } this.app.ActiveLayer.Name = "QrCode Vetor"; }
public async Task ProcessInputAsync(Message message, Flow flow, CancellationToken cancellationToken) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (message.From == null) { throw new ArgumentException("Message 'from' must be present", nameof(message)); } if (flow == null) { throw new ArgumentNullException(nameof(flow)); } message = _inputExpirationHandler.ValidateMessage(message); flow.Validate(); // Determine the user / owner pair var(userIdentity, ownerIdentity) = await _userOwnerResolver.GetUserOwnerIdentitiesAsync(message, flow.BuilderConfiguration, cancellationToken); // Input tracing infrastructure InputTrace inputTrace = null; TraceSettings traceSettings; if (message.Metadata != null && message.Metadata.Keys.Contains(TraceSettings.BUILDER_TRACE_TARGET)) { traceSettings = new TraceSettings(message.Metadata); } else { traceSettings = flow.TraceSettings; } if (traceSettings != null && traceSettings.Mode != TraceMode.Disabled) { inputTrace = new InputTrace { FlowId = flow.Id, User = userIdentity, Input = message.Content.ToString() }; } var inputStopwatch = inputTrace != null ? Stopwatch.StartNew() : null; var ownerContext = OwnerContext.Create(ownerIdentity); State state = default; try { // Create a cancellation token using (var cts = new CancellationTokenSource(_configuration.InputProcessingTimeout)) using (var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, cancellationToken)) { // Synchronize to avoid concurrency issues on multiple running instances var handle = await _namedSemaphore.WaitAsync($"{flow.Id}:{userIdentity}", _configuration.InputProcessingTimeout, linkedCts.Token); try { // Create the input evaluator var lazyInput = new LazyInput(message, userIdentity, flow.BuilderConfiguration, _documentSerializer, _envelopeSerializer, _artificialIntelligenceExtension, linkedCts.Token); // Load the user context var context = _contextProvider.CreateContext(userIdentity, ownerIdentity, lazyInput, flow); // Try restore a stored state var stateId = await _stateManager.GetStateIdAsync(context, linkedCts.Token); state = flow.States.FirstOrDefault(s => s.Id == stateId) ?? flow.States.Single(s => s.Root); // If current stateId of user is different of inputExpiration stop processing if (!_inputExpirationHandler.IsValidateState(state, message)) { return; } await _inputExpirationHandler.OnFlowPreProcessingAsync(state, message, _applicationNode, linkedCts.Token); // Calculate the number of state transitions var transitions = 0; // Create trace instances, if required var(stateTrace, stateStopwatch) = _traceManager.CreateStateTrace(inputTrace, state); // Process the global input actions if (flow.InputActions != null) { await ProcessActionsAsync(lazyInput, context, flow.InputActions, inputTrace?.InputActions, linkedCts.Token); } var stateWaitForInput = true; do { try { linkedCts.Token.ThrowIfCancellationRequested(); // Validate the input for the current state if (stateWaitForInput && state.Input?.Validation != null && !ValidateDocument(lazyInput, state.Input.Validation)) { if (state.Input.Validation.Error != null) { // Send the validation error message await _sender.SendMessageAsync(state.Input.Validation.Error, message.From, linkedCts.Token); } break; } // Set the input in the context if (!string.IsNullOrEmpty(state.Input?.Variable)) { await context.SetVariableAsync(state.Input.Variable, lazyInput.SerializedContent, linkedCts.Token); } // Prepare to leave the current state executing the output actions if (state.OutputActions != null) { await ProcessActionsAsync(lazyInput, context, state.OutputActions, stateTrace?.OutputActions, linkedCts.Token); } var previousStateId = state.Id; // Determine the next state state = await ProcessOutputsAsync(lazyInput, context, flow, state, stateTrace?.Outputs, linkedCts.Token); // Store the previous state await _stateManager.SetPreviousStateIdAsync(context, previousStateId, cancellationToken); // Create trace instances, if required (stateTrace, stateStopwatch) = _traceManager.CreateStateTrace(inputTrace, state, stateTrace, stateStopwatch); // Store the next state if (state != null) { await _stateManager.SetStateIdAsync(context, state.Id, linkedCts.Token); } else { await _stateManager.DeleteStateIdAsync(context, linkedCts.Token); } // Process the next state input actions if (state?.InputActions != null) { await ProcessActionsAsync(lazyInput, context, state.InputActions, stateTrace?.InputActions, linkedCts.Token); } // Check if the state transition limit has reached (to avoid loops in the flow) if (transitions++ >= _configuration.MaxTransitionsByInput) { throw new BuilderException($"Max state transitions of {_configuration.MaxTransitionsByInput} was reached"); } } catch (Exception ex) { if (stateTrace != null) { stateTrace.Error = ex.ToString(); } throw; } finally { // Continue processing if the next state do not expect the user input var inputConditionIsValid = state?.Input?.Conditions == null || await state.Input.Conditions.EvaluateConditionsAsync(lazyInput, context, cancellationToken); stateWaitForInput = state == null || (state.Input != null && !state.Input.Bypass && inputConditionIsValid); if (stateTrace?.Error != null || stateWaitForInput) { // Create a new trace if the next state waits for an input or the state without an input throws an error (stateTrace, stateStopwatch) = _traceManager.CreateStateTrace(inputTrace, state, stateTrace, stateStopwatch); } } } while (!stateWaitForInput); // Process the global output actions if (flow.OutputActions != null) { await ProcessActionsAsync(lazyInput, context, flow.OutputActions, inputTrace?.OutputActions, linkedCts.Token); } await _inputExpirationHandler.OnFlowProcessedAsync(state, message, _applicationNode, linkedCts.Token); } finally { await handle?.DisposeAsync(); } } } catch (Exception ex) { if (inputTrace != null) { inputTrace.Error = ex.ToString(); } var builderException = ex is BuilderException be ? be : new BuilderException($"Error processing input '{message.Content}' for user '{userIdentity}' in state '{state?.Id}'", ex); builderException.StateId = state?.Id; builderException.UserId = userIdentity; builderException.MessageId = message.Id; throw builderException; } finally { using (var cts = new CancellationTokenSource(_configuration.TraceTimeout)) { await _traceManager.ProcessTraceAsync(inputTrace, traceSettings, inputStopwatch, cts.Token); } ownerContext.Dispose(); } }
public void SetSettings(TraceSettings st) { m_currentsettings = st; edEvents.SelectedObject = m_currentsettings.EventsColumns; edFilters.SelectedObject = m_currentsettings.Filters; }
static void ConfigureOpcUaApplicationFromCode() { // fill in the application settings in code // The configuration settings are typically provided by another module // of the application or loaded from a data base. In this example the // settings are hardcoded SecuredApplication application = new SecuredApplication(); // *********************************************************************** // standard configuration options // general application identification settings application.ApplicationName = "OPCServer"; application.ApplicationUri = "urn:localhost:OPCServer"; application.ApplicationType = UnifiedAutomation.UaSchema.ApplicationType.Server_0; application.ProductName = "OPCServer"; // configure certificate stores application.ApplicationCertificate = new UnifiedAutomation.UaSchema.CertificateIdentifier(); application.ApplicationCertificate.StoreType = "Directory"; application.ApplicationCertificate.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\own"; application.ApplicationCertificate.SubjectName = "CN=GettingStartedServer/O=UnifiedAutomation/DC=localhost"; application.TrustedCertificateStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.TrustedCertificateStore.StoreType = "Directory"; application.TrustedCertificateStore.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\trusted"; application.IssuerCertificateStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.IssuerCertificateStore.StoreType = "Directory"; application.IssuerCertificateStore.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\issuers"; application.RejectedCertificatesStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.RejectedCertificatesStore.StoreType = "Directory"; application.RejectedCertificatesStore.StorePath = @"%CommonApplicationData%\unifiedautomation\UaSdkNet\pki\rejected"; // configure endpoints application.BaseAddresses = new UnifiedAutomation.UaSchema.ListOfBaseAddresses(); application.BaseAddresses.Add("opc.tcp://*****:*****@"%CommonApplicationData%\unifiedautomation\logs\ConfigurationServer.log.txt"; trace.MaxLogFileBackups = 3; trace.ModuleSettings = new ModuleTraceSettings[] { new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Stack", TraceEnabled = true }, new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Server", TraceEnabled = true }, }; application.Set<TraceSettings>(trace); // Installation settings InstallationSettings installation = new InstallationSettings(); installation.GenerateCertificateIfNone = true; installation.DeleteCertificateOnUninstall = true; application.Set<InstallationSettings>(installation); // *********************************************************************** // set the configuration for the application (must be called before start to have any effect). // these settings are discarded if the /configFile flag is specified on the command line. ApplicationInstance.Default.SetApplicationSettings(application); }
static void ConfigureOpcUaApplicatiopnFromCode() { SecuredApplication application = new SecuredApplication(); application.ApplicationName = "UnifiedAutomation GettingStartedServer"; application.ApplicationUri = "urn:localhost:UnifiedAutomation:GettingStartedServer"; application.ApplicationType = UnifiedAutomation.UaSchema.ApplicationType.Server_0; application.ProductName = "UnifiedAutomation GettingStartedServer"; application.ApplicationCertificate = new CertificateIdentifier(); application.ApplicationCertificate.StoreType = "Directory"; application.ApplicationCertificate.StorePath = @"Config\own"; application.ApplicationCertificate.SubjectName = "CN=GettingStartedServer/O=UnifiedAutomation/DC=localhost"; application.TrustedCertificateStore = new CertificateStoreIdentifier(); application.TrustedCertificateStore.StoreType = "Directory"; application.TrustedCertificateStore.StorePath = @"Config\trusted"; application.IssuerCertificateStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.IssuerCertificateStore.StoreType = "Directory"; application.IssuerCertificateStore.StorePath = @"Config\issuers"; application.RejectedCertificatesStore = new UnifiedAutomation.UaSchema.CertificateStoreIdentifier(); application.RejectedCertificatesStore.StoreType = "Directory"; application.RejectedCertificatesStore.StorePath = @"Config\rejected"; application.BaseAddresses = new ListOfBaseAddresses(); application.BaseAddresses.Add("opc.tcp://localhost:48040"); application.SecurityProfiles = new ListOfSecurityProfiles(); application.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.Basic256, Enabled = true }); application.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.Basic128Rsa15, Enabled = true }); application.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.None, Enabled = true }); TraceSettings trace = new TraceSettings(); trace.MasterTraceEnabled = true; trace.DefaultTraceLevel = UnifiedAutomation.UaSchema.TraceLevel.Info; trace.TraceFile = "log.txt"; trace.MaxLogFileBackups = 3; trace.ModuleSettings = new ModuleTraceSettings[] { new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Stack", TraceEnabled = true }, new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Server", TraceEnabled = true }, }; application.Set <TraceSettings>(trace); InstallationSettings installation = new InstallationSettings(); installation.GenerateCertificateIfNone = true; installation.DeleteCertificateOnUninstall = true; application.Set <InstallationSettings>(installation); ApplicationInstance.Default.SetApplicationSettings(application); }