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;
            }
        }
Пример #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);
 }
Пример #3
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);
 }