/// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">he interface to get access to the plugin.</param> /// <param name="assembly">TAn assembly containing the plug-in.</param> /// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param> /// <param name="solutionPath">The solution path.</param> /// <param name="configuration">The file path containing the configuration.</param> public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface, string solutionPath, string configuration) { Initialize(plugin, assembly); FileInfo _file = null; if (!string.IsNullOrEmpty(configuration)) { if (!RelativeFilePathsCalculator.TestIfPathIsAbsolute(configuration)) { _file = new FileInfo(Path.Combine(solutionPath, configuration)); } else { _file = new FileInfo(configuration); } } if (_file == null) { Configuration = new ConfigurationWrapper(null, m_Server, userInterface); } else { Configuration = new ConfigurationWrapper(_file, m_Server, userInterface); } }
/// <summary> /// Reads the configuration. /// </summary> /// <param name="fileName">The fully qualified name of the file, or the relative file name.</param> /// <exception cref="FileNotFoundException">The exception that is thrown when an attempt to access a file that does not exist on disk fails.</exception> /// <exception cref="InvalidOperationException">An error occurred during deserialization. The original exception is available using the System.Exception.InnerException property.</exception> internal static Type4Serialization ReadConfiguration(string fileName, IGraphicalUserInterface gui) { if (!File.Exists(fileName)) { throw new FileNotFoundException(fileName); } try { gui.UseWaitCursor = true; Type4Serialization _graph = XmlFile.ReadXmlFile <Type4Serialization>(fileName); return(_graph); } catch (InvalidOperationException _ioe) { gui.MessageBoxShowExclamation(string.Format(Resources.TypeGenericConfigurationManagement_ReadError, _ioe.GetMessageFromException()), Resources.SolutionFileOpenError); return(null); } catch (Exception _ex) { gui.MessageBoxShowExclamation(string.Format(Resources.TypeGenericConfigurationManagement_ReadError, _ex.GetMessageFromException()), Resources.SolutionFileOpenError); return(null); } finally { gui.UseWaitCursor = false; } }
///// <summary> ///// Initializes a new instance of the <see cref="ServerWrapper" /> class. ///// </summary> ///// <param name="plugin">The interface to get access to the plugin.</param> ///// <param name="assembly">TAn assembly containing the plug-in.</param> ///// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param> ///// <param name="configuration">The file path containing the configuration.</param> //public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface, string configuration) : this(plugin, assembly, userInterface, BaseDirectoryHelper.Instance.GetBaseDirectory(), configuration) { } /// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">The interface to get access to the plugin.</param> /// <param name="assembly">TAn assembly containing the plug-in.</param> /// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param> /// <param name="solutionPath">The solution path.</param> /// <param name="configuration">The file path containing the configuration.</param> public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface, ISolutionDirectoryPathManagement solutionPath, string configuration) { this.SolutionPath = solutionPath; Initialize(plugin, assembly); FileInfo _file = null; if (!string.IsNullOrEmpty(configuration)) { //TODO Error while using Save operation #129 if (!IO.RelativeFilePathsCalculator.TestIfPathIsAbsolute(configuration)) { _file = new FileInfo(Path.Combine(solutionPath.BaseDirectory, configuration)); } else { _file = new FileInfo(configuration); } } if (_file == null) { Configuration = new ConfigurationWrapper(null, m_Server, userInterface); } else { Configuration = new ConfigurationWrapper(_file, m_Server, userInterface); } }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationWrapper" /> class that is to manage the sever configuration file. /// </summary> /// <param name="file">The file containing the configuration.</param> /// <param name="configurationEditor">The server configuration editor main interface.</param> /// <param name="userInterface">The user interface that provides basic functionality to implement user interactivity.</param> /// <exception cref="System.ArgumentNullException"> /// The server configuration editor main interface cannot be null /// or /// userInterface /// </exception> public ConfigurationWrapper(FileInfo file, IConfiguration configurationEditor, IGraphicalUserInterface userInterface) { if (configurationEditor == null) { throw new System.ArgumentNullException("The server configuration editor main interface cannot be null"); } if (userInterface == null) { throw new System.ArgumentNullException($"The {nameof(userInterface)} cannot be null"); } m_ServerConfiguration = configurationEditor; m_userInterface = userInterface; if (file != null) { ConfigurationFile = file; } else { ConfigurationFile = FindConfigurationFile(); } if (ConfigurationFile != null) { file = ConfigurationFile; Read(file); } else { m_userInterface.MessageBoxShowExclamation(Resources.ConfigurationWrapper_NoConfigurationFileSelectedInfo, Resources.ConfigurationWrapper_NoConfigurationFileSelectedHeader); string selectedPath = String.Empty; using (IFolderBrowserDialog _fbd = m_userInterface.OpenFolderBrowserDialogFunc()) { if (_fbd.ShowDialog()) { selectedPath = _fbd.SelectedPath; } } if (string.IsNullOrEmpty(selectedPath)) { m_userInterface.MessageBoxShowExclamation(Resources.ConfigurationWrapperNoFolderSelectedInfo, Resources.ConfigurationWrapperNoFolderSelectedHeader); selectedPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); } configurationEditor.CreateDefaultConfiguration(); try { file = new FileInfo(Path.Combine(selectedPath, configurationEditor.DefaultFileName)); } catch (Exception exception) { m_userInterface.MessageBoxShowError(Resources.ConfigurationWrapperProblemWithOpeningOfTheFileInfo + exception.Message, Resources.ConfigurationWrapperProblemWithOpeningOfTheFileHeader); } configurationEditor.SaveConfiguration(String.Empty, file); Read(file); } }
/// <summary> /// Open dialog box to select the file to deserialize as the instance of <typeparamref name="Type4Serialization"/>. /// </summary> /// <returns>The configuration <typeparamref name="Type4Serialization"/> retrieved from a file and the rooted absolute file path or <c>null</c> if the file selection is skipped. </returns> internal static Tuple <Type4Serialization, string> ReadConfiguration(IGraphicalUserInterface gui, Action <IFileDialog> setupFileDialog) { string fileName = ShowDialogOpenFileDialog(gui, setupFileDialog); if (String.IsNullOrEmpty(fileName)) { return(null); } Type4Serialization _graph = ReadConfiguration(fileName, gui); return(new Tuple <Type4Serialization, string>(_graph, fileName)); }
internal static void NewSoliution(IGraphicalUserInterface gui) { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587504, $"New instance of the {nameof(SolutionConfigurationManagement)} is required"); if ((DefaultInstance.CurrentConfiguration != null) && (!DefaultInstance.CurrentConfiguration.TestIfChangesArePresentDisplayWindowAndReturnTrueIfShouldBeContinued())) { return; } AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587503, $"Creating new instance of the {nameof(SolutionConfigurationManagement)}"); string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UAModelDesignerSolution"); SolutionConfigurationManagement _newSolution = new SolutionConfigurationManagement(new Tuple <UAModelDesignerSolution, string>(UAModelDesignerSolution.CreateEmptyModel(m_UniqueNameGenerator.GenerateNewName()), _defPath), true, gui); DefaultInstance.OnSolutionChanged(_newSolution); return; }
internal static void OpenExisting(string solutionFileName, IGraphicalUserInterface gui) { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587501, $"Opening an existing solution captured in the file {solutionFileName} of the {nameof(SolutionConfigurationManagement)}"); if ((DefaultInstance.CurrentConfiguration != null) && !DefaultInstance.CurrentConfiguration.TestIfChangesArePresentDisplayWindowAndReturnTrueIfShouldBeContinued()) { return; } Tuple <UAModelDesignerSolution, string> _solution = null; bool _ChangesArePresent = false; try { if (String.IsNullOrEmpty(solutionFileName) || !File.Exists(solutionFileName)) { if (DefaultInstance.CurrentConfiguration != null) { _solution = SolutionConfigurationManagement.ReadConfiguration(gui, SolutionConfigurationManagement.SetupFileDialog); if (_solution == null) { return; } } else { string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UAModelDesignerSolution"); _solution = new Tuple <UAModelDesignerSolution, string>(UAModelDesignerSolution.CreateEmptyModel(m_UniqueNameGenerator.GenerateNewName()), _defPath); _ChangesArePresent = true; } } else { solutionFileName = Path.GetFullPath(solutionFileName); _solution = new Tuple <UAModelDesignerSolution, string>(SolutionConfigurationManagement.ReadConfiguration(solutionFileName, gui), solutionFileName); } if (_solution.Item1.ServerDetails == null) { _solution.Item1.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance(); } ISolutionConfigurationManagement _newSolution = new SolutionConfigurationManagement(_solution, _ChangesArePresent, gui); DefaultInstance.OnSolutionChanged(_newSolution); return; } catch (Exception ex) { string _tmp = "Cannot initialize {0} described by {1} because of exception: {2}."; AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Critical, 234587502, string.Format(_tmp, typeof(SolutionConfigurationManagement).FullName, _solution.Item2, ex.Message)); throw; } }
internal SolutionConfigurationManagement(Tuple <UAModelDesignerSolution, string> solutionDescription, bool changesArePresent, IGraphicalUserInterface gui) : base(solutionDescription.Item2, changesArePresent, gui) { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 335242041, "Creating new private solution using Empty model"); m_Name = solutionDescription.Item1.Name; UAModelDesignerSolutionServerDetails _ServerDetails = solutionDescription.Item1.ServerDetails ?? throw new ArgumentNullException(nameof(UAModelDesignerSolution.ServerDetails)); m_Projects = solutionDescription.Item1.Projects.Select <UAModelDesignerProject, IProjectConfigurationManagement>(x => ProjectConfigurationManagement.ImportModelDesign(this, base.GraphicalUserInterface, x)).ToList <IProjectConfigurationManagement>(); string _codebase = RelativeFilePathsCalculator.CalculateAbsoluteFileName(this.DefaultDirectory, _ServerDetails.codebase); string _configuration = RelativeFilePathsCalculator.CalculateAbsoluteFileName(this.DefaultDirectory, _ServerDetails.configuration); m_Server = new ServerSelector(base.GraphicalUserInterface, this, _codebase, _configuration); if (string.IsNullOrEmpty(Settings.Default.DefaultSolutionFileName)) { Settings.Default.DefaultSolutionFileName = DefaultFileName; Settings.Default.Save(); } AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 335242042, "Finished successfully CommonInitialization"); }
/// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">he interface to get access to the plugin.</param> /// <param name="assembly">TAn assembly containing the plug-in.</param> /// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param> /// <param name="configuration">The file path containing the configuration.</param> public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface, string configuration) : this(plugin, assembly, userInterface, BaseDirectoryHelper.Instance.GetBaseDirectory(), configuration) { }
private ProjectConfigurationManagement(bool newModel, UAModelDesignerProject uaModelDesignerProject, ISolutionConfigurationManagement solution, Tuple <OpcUaModelCompiler.ModelDesign, string> modelDesign, IGraphicalUserInterface gui) : base(modelDesign.Item2, newModel, gui) { m_UAModelDesignerProject = uaModelDesignerProject; m_ISolutionConfigurationManagement = solution; this.m_ModelDesign = modelDesign.Item1; m_NewModel = newModel; }
internal static IProjectConfigurationManagement ImportModelDesign(ISolutionConfigurationManagement solution, IGraphicalUserInterface gui, UAModelDesignerProject uaModelDesignerProject) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (gui == null) { throw new ArgumentNullException(nameof(gui)); } if (uaModelDesignerProject == null) { throw new ArgumentNullException(nameof(uaModelDesignerProject)); } string _filePath = Path.Combine(solution.DefaultDirectory, uaModelDesignerProject.FileName); Tuple <OpcUaModelCompiler.ModelDesign, string> _modelDesign = new Tuple <OpcUaModelCompiler.ModelDesign, string>(TypeGenericConfigurationManagement <OpcUaModelCompiler.ModelDesign> .ReadConfiguration(Path.Combine(solution.DefaultDirectory, uaModelDesignerProject.FileName), gui), _filePath); return(new ProjectConfigurationManagement(false, uaModelDesignerProject, solution, _modelDesign, gui)); }
/// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">The interface to get access to the plugin.</param> /// <param name="assembly">The assembly containing the plug-in.</param> /// <param name="gui">The user interaction interface that provides basic functionality to implement user interactivity.</param> /// <param name="configuration">The file path containing the configuration.</param> public ServerWrapper(IConfiguration plugin, IDataProviderDescription assembly, IGraphicalUserInterface gui, string configuration) { m_Server = plugin ?? throw new ArgumentNullException(nameof(plugin)); PluginDescription = assembly ?? throw new ArgumentNullException(nameof(plugin)); m_GraphicalUserInterfaceField = gui ?? throw new ArgumentNullException(nameof(plugin)); m_Server.OnModified += new EventHandler <UAServerConfigurationEventArgs>(OnConfigurationDataChangeHandler); FileInfo _file = null; if (!string.IsNullOrEmpty(configuration)) { if (!Path.IsPathRooted(configuration)) { throw new ArgumentOutOfRangeException(nameof(configuration)); } _file = new FileInfo(configuration); } Configuration = new ConfigurationWrapper(_file, m_Server, gui); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationManagement"/> class. /// </summary> public ConfigurationManagement(IGraphicalUserInterface graphicalUserInterface, string fileName) { GraphicalUserInterface = graphicalUserInterface; InitializeComponent(); DefaultFileName = fileName; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationManagement"/> class. /// </summary> public ConfigurationManagement(string fileName, bool changesArePresent, IGraphicalUserInterface gui) : base(fileName) { GraphicalUserInterface = gui; m_ChangesArePresent = changesArePresent; }
public OPCFModelConfigurationManagement(IGraphicalUserInterface graphicalUserInterface, string fileName) : base(graphicalUserInterface, fileName) { }
private OPCFSolutionConfigurationManagement(IGraphicalUserInterface graphicalUserInterface, string fileName) : base(graphicalUserInterface, fileName) { }
/// <summary> /// Initializes a new instance of the <see cref="TypeGenericConfigurationManagement{Type4Serialization}" /> class. /// </summary> /// <param name="graphicalUserInterface">The graphical user interface.</param> /// <param name="fileName">Name of the file.</param> //protected EventHandler<ConfigurationEventArg> ConfigurationChanged; #endregion private #region constructors public TypeGenericConfigurationManagement(IGraphicalUserInterface graphicalUserInterface, string fileName) : base(graphicalUserInterface, fileName) { }
public void OnNew(IGraphicalUserInterface gui) { throw new NotImplementedException(); }
public void Open(IGraphicalUserInterface gui) { SolutionConfigurationManagementRoot.OpenExisting(null, gui); }
/// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">The interface to get access to the plugin.</param> /// <param name="assembly">An assembly containing the plug-in.</param> /// <param name="gui">The user interaction interface that provides basic functionality to implement user interactivity.</param> public ServerWrapper(IConfiguration plugin, IDataProviderDescription assembly, IGraphicalUserInterface gui) : this(plugin, assembly, gui, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="TypeGenericConfigurationManagement{Type4Serialization}" /> class. /// </summary> /// <param name="gui">The graphical user interface.</param> /// <param name="fileName">Absolute path of the file.</param> protected TypeGenericConfigurationManagement(string fileName, bool changesArePresent, IGraphicalUserInterface gui) : base(fileName, changesArePresent, gui) { }
public void OnNew(IGraphicalUserInterface gui) { SolutionConfigurationManagementRoot.NewSoliution(gui); }
internal static IProjectConfigurationManagement ImportModelDesign(ISolutionConfigurationManagement solution, IGraphicalUserInterface gui) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (gui == null) { throw new ArgumentNullException(nameof(gui)); } Tuple <OpcUaModelCompiler.ModelDesign, string> _modelDesign = TypeGenericConfigurationManagement <OpcUaModelCompiler.ModelDesign> .ReadConfiguration(gui, SetupFileDialog); if (_modelDesign.Item1 == null) { return(null); } UAModelDesignerProject uaModelDesignerProject = UAModelDesignerProject.CreateEmpty(Path.GetFileNameWithoutExtension(_modelDesign.Item2)); uaModelDesignerProject.FileName = CAS.CommServer.UA.ModelDesigner.Configuration.IO.RelativeFilePathsCalculator.TryComputeRelativePath(solution.DefaultDirectory, _modelDesign.Item2); return(new ProjectConfigurationManagement(false, uaModelDesignerProject, solution, _modelDesign, gui)); }
/// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">The interface to get access to the plugin.</param> /// <param name="assembly">An assembly containing the plug-in.</param> /// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param> /// <param name="solutionPath">The solution path.</param> public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface, ISolutionDirectoryPathManagement solutionPath) : this(plugin, assembly, userInterface, solutionPath, string.Empty) { }
/// <summary> /// Creates new model encapsulated by an instance of this class /// </summary> /// <param name="solution">The solution description.</param> /// <param name="gui">The graphical user interface.</param> /// <param name="projectName">Name of the project.</param> /// <returns><see cref="IProjectConfigurationManagement"/>.</returns> internal static IProjectConfigurationManagement CreateNew(ISolutionConfigurationManagement solution, IGraphicalUserInterface gui, string projectName) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (gui == null) { throw new ArgumentNullException(nameof(gui)); } UAModelDesignerProject _projectDescription = UAModelDesignerProject.CreateEmpty(projectName); //TODO Creating new project the existing one should not be overridden #174 string _defFilePath = Path.ChangeExtension(RelativeFilePathsCalculator.CalculateAbsoluteFileName(solution.DefaultDirectory, projectName), Resources.Project_FileDialogDefaultExt); return(new ProjectConfigurationManagement(true, _projectDescription, solution, new Tuple <OpcUaModelCompiler.ModelDesign, string>(OpcUaModelCompilerModelDesigner.GetDefault(), _defFilePath), gui)); }
internal static string ShowOpenDialog(IGraphicalUserInterface graphicalUserInterface) { return(ConfigurationManagement.ShowDialogOpenFileDialog(graphicalUserInterface, SetupFileDialog)); }
internal static IProjectConfigurationManagement ImportNodeSet(ISolutionConfigurationManagement solution, IGraphicalUserInterface graphicalUserInterface, Action <TraceMessage> traceEvent) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (graphicalUserInterface == null) { throw new ArgumentNullException(nameof(graphicalUserInterface)); } Tuple <OpcUaModelCompiler.ModelDesign, string> _modelDesign = IO.ImportNodeSet.Import(solution.DefaultDirectory, traceEvent); if (_modelDesign == null) { return(null); } UAModelDesignerProject _newProjctDesription = UAModelDesignerProject.CreateEmpty(_modelDesign.Item2); return(new ProjectConfigurationManagement(true, _newProjctDesription, solution, _modelDesign, graphicalUserInterface)); }
/// <summary> /// Initializes a new instance of the <see cref="ServerWrapper" /> class. /// </summary> /// <param name="plugin">The interface to get access to the plugin.</param> /// <param name="assembly">An assembly containing the plug-in.</param> /// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param> public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface) : this(plugin, assembly, userInterface, string.Empty) { }