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;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionTreeNode" /> class.
 /// </summary>
 /// <param name="messageBoxHandling">The Message Box instance to provide messages on the screen.</param>
 /// <param name="solution">The configuration.</param>
 /// <param name="solutionPath">The solution path.</param>
 /// <param name="OnChangeHandler">The on change handler.</param>
 /// <param name="creteLibraryTreeNode">The call back to create <see cref="LibraryTreeNode"/>.</param>
 /// <exception cref="ArgumentNullException">configuration
 /// or
 /// messageBoxHandling</exception>
 internal SolutionTreeNode(IMessageBoxHandling messageBoxHandling, UAModelDesignerSolution solution, string solutionPath, EventHandler <EventArgs> OnChangeHandler, Action <LibraryTreeNode> creteLibraryTreeNode) :
     base(null, solution == null ? Guid.NewGuid().ToString() : solution.Name)
 {
     MessageBoxHandling = messageBoxHandling ?? throw new ArgumentNullException(nameof(messageBoxHandling));
     HomeDirectory      = solutionPath;
     if (solution.ServerDetails == null)
     {
         solution.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance();
     }
     Server = new ServerSelector(new GraphicalUserInterface(), solutionPath, solution.ServerDetails.codebase, solution.ServerDetails.configuration);
     Server.OnConfigurationChanged += new EventHandler <UAServerConfigurationEventArgs>(Server_OnConfigurationChanged);
     //TODO OnDataChanged += OnChangeHandler;
     //TODO OnNameChanged += new EventHandler(configuration_OnNameChanged);
     AddProjectsNodes(solution.Projects);
     BaseDirectoryHelper.Instance.SetBaseDirectoryProvider(this);
     SolutionRoot = this;
     LibraryRoot.AddNodes(creteLibraryTreeNode);
 }
        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");
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionTreeNode" /> class.
 /// </summary>
 /// <param name="messageBoxHandling">The Message Box instance to provide messages on the screen.</param>
 /// <param name="solution">The configuration.</param>
 /// <param name="solutionPath">The solution path.</param>
 /// <param name="OnChangeHandler">The on change handler.</param>
 /// <param name="creteLibraryTreeNode">The call back to create <see cref="LibraryTreeNode"/>.</param>
 /// <exception cref="ArgumentNullException">configuration
 /// or
 /// messageBoxHandling</exception>
 internal SolutionTreeNode(IMessageBoxHandling messageBoxHandling, UAModelDesignerSolution solution, string solutionPath, EventHandler <EventArgs> OnChangeHandler, Action <LibraryTreeNode> creteLibraryTreeNode) :
     base(null, solution == null ? Guid.NewGuid().ToString() : solution.Name)
 {
     MessageBoxHandling = messageBoxHandling ?? throw new ArgumentNullException(nameof(messageBoxHandling));
     m_PathManagement.SetNewPath(solutionPath);
     if (solution == null)
     {
         throw new ArgumentNullException(nameof(solution), $"In constructor {nameof(SolutionTreeNode)} this argument must not be null.");
     }
     if (solution.ServerDetails == null)
     {
         solution.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance();
     }
     Server = new ServerSelector(new GraphicalUserInterface(), m_PathManagement, solution.ServerDetails.codebase, solution.ServerDetails.configuration);
     Server.OnConfigurationChanged += new EventHandler <UAServerConfigurationEventArgs>(Server_OnConfigurationChanged);
     //TODO OnDataChanged += OnChangeHandler;
     //TODO OnNameChanged += new EventHandler(configuration_OnNameChanged);
     AddProjectsNodes(solution.Projects);
     SolutionRoot = this;
     LibraryRoot.AddNodes(creteLibraryTreeNode);
 }