public void CalculateAbsoluteFileNameTest() { Assert.AreEqual <string>(m_AbsolutePath, RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, m_AbsolutePath)); Assert.AreEqual <string>(m_AbsoluteFilePath, RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsoluteFilePath, m_AbsolutePath)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_Relative1, m_AbsolutePath)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_Relative2, m_AbsolutePath)); Assert.AreEqual <string>(Path.Combine(m_AbsolutePath, m_FileName), RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_FileName, m_AbsolutePath)); }
public void CalculateAbsoluteFileNameTest() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, m_AbsolutePath)); Assert.AreEqual <string>(@"C:\VS.git\UAOOI\ASMD210\ModelDesigner.ModelsContainer\bin\Model_0.xml", RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, @"C:\VS.git\UAOOI\ASMD210\ModelDesigner.ModelsContainer\bin\Release\..\Model_0.xml")); Assert.AreEqual <string>(m_AbsoluteFilePath, RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, m_AbsoluteFilePath)); Assert.AreEqual <string>(Path.Combine(Directory.GetCurrentDirectory(), @"Documents"), RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, m_Relative1)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, m_Relative2)); Assert.AreEqual <string>(Path.Combine(m_AbsolutePath, m_FileName), RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, m_FileName)); Assert.AreEqual <string>(@"C:\VS.git\UAOOI\ASMD210\ModelDesigner.ModelsContainer\bin\Model_0.xml", RelativeFilePathsCalculator.CalculateAbsoluteFileName(@"C:\VS.git\UAOOI\ASMD210\ModelDesigner.ModelsContainer\bin\Release\", @"..\Model_0.xml")); Assert.AreEqual <string>(String.Empty, RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, String.Empty)); Assert.AreEqual <string>(String.Empty, RelativeFilePathsCalculator.CalculateAbsoluteFileName(m_AbsolutePath, null)); }
/// <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 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"); }
private static string ReplaceTokenAndReturnFullPath(string fileNameToBeProcessed, string projectName, string solutionDirectory) { string _Name = fileNameToBeProcessed.Replace(Resources.Token_ProjectFileName, projectName); return(RelativeFilePathsCalculator.CalculateAbsoluteFileName(solutionDirectory, _Name)); }
/// <summary> /// Builds the model managed by this project using external compiler. /// </summary> /// <param name="traceMessage">Action to be used to trace the .</param> void IProjectConfigurationManagement.Build(Action <string> traceMessage) { string _filePath = RelativeFilePathsCalculator.CalculateAbsoluteFileName(this.m_ISolutionConfigurationManagement.DefaultDirectory, m_UAModelDesignerProject.FileName); if (!File.Exists(this.DefaultFileName)) { string msg = string.Format(Resources.BuildError_Fie_DoesNotExist, _filePath); traceMessage(msg); GraphicalUserInterface.MessageBoxShowError(msg, Resources.Build_Caption); return; } (string CSVFileName, string OutputDirectory) = BuildCalculateFileNames(); if (!Directory.Exists(OutputDirectory)) { Directory.CreateDirectory(OutputDirectory); } if (!File.Exists(CSVFileName)) { string msg = string.Format(Resources.BuildError_Fie_DoesNotExist_doyouwanttocreateone, CSVFileName); if (GraphicalUserInterface.MessageBoxShowWarningAskYN(msg, Resources.Build_Caption)) { using (StreamWriter myCsvFile = new StreamWriter(CSVFileName, false))//we are creating an blank file (one empty line inside) { myCsvFile.WriteLine(" "); myCsvFile.Flush(); } } else { traceMessage(string.Format(Resources.BuildError_Fie_DoesNotExist, CSVFileName)); return; } } string _commandLine = string.Format(Properties.Settings.Default.Build_ProjectCompilationString, _filePath, CSVFileName, OutputDirectory); string _compilerPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Properties.Settings.Default.ProjectCompilationExecutable); ProcessStartInfo myStartInfo = new ProcessStartInfo(_compilerPath) { Arguments = _commandLine, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; traceMessage($"{_compilerPath} "); traceMessage(_commandLine); traceMessage(""); Process _buildProcess = new Process { StartInfo = myStartInfo }; if (!_buildProcess.Start()) { GraphicalUserInterface.MessageBoxShowWarning(Resources.Build_click_ok_when_build_has_finished, Resources.Build_Caption); } else { _buildProcess.WaitForExit(); string _outputfrombuildprocess = _buildProcess.StandardOutput.ReadToEnd(); string _erroroutputfrombuildprocess = _buildProcess.StandardError.ReadToEnd(); if (!string.IsNullOrEmpty(_erroroutputfrombuildprocess)) { _erroroutputfrombuildprocess = string.Format(Resources.BuildError_error_occured, _erroroutputfrombuildprocess); } else { _erroroutputfrombuildprocess = Resources.Build_project_ok; } _outputfrombuildprocess += _erroroutputfrombuildprocess; if (!string.IsNullOrEmpty(_outputfrombuildprocess)) { traceMessage(_outputfrombuildprocess); } } }
/// <summary> /// Calculates the effective absolute model file path. /// </summary> /// <returns>System.String.</returns> internal string CalculateEffectiveAbsoluteModelFilePath() { return(RelativeFilePathsCalculator.CalculateAbsoluteFileName(this.FileName, m_SolutionHomeDirectory.BaseDirectory)); }