Пример #1
0
        /// <summary>
        /// Moves the specified solution to the top of recently opened solutions.
        /// </summary>
        /// <param name="desc">Solution descriptor</param>
        /// <returns>True if the solution was newly added to the history, false if merely moved to the top</returns>
        public static bool MemorizeRecent(SolutionDescriptor desc)
        {
            bool newRecent = !recent.Remove(desc);

            recent.Insert(0, desc);
            Backup();
            return(newRecent);
        }
Пример #2
0
        /// <summary>
        /// Restores the persistent state from file
        /// </summary>
        /// <returns>true, if a state could be restored, false otherwise</returns>
        public static bool Restore()
        {
            if (!StateFile.Directory.Exists)
            {
                StateFile.Directory.Create();
            }
            if (StateFile.Exists)
            {
                var         xreader = new XmlTextReader(StateFile.FullName);
                XmlDocument xdoc    = new XmlDocument();
                xdoc.Load(xreader);
                XmlNodeList xrecent = xdoc.SelectNodes("state/recent/solution");
                recent.Clear();
                HashSet <string> recentKnown = new HashSet <string>();
                foreach (XmlNode xr in xrecent)
                {
                    File f = new File(xr.InnerText);
                    if (f.Exists && !recentKnown.Contains(f.FullName))
                    {
                        XmlNode            xdomain = xr.Attributes.GetNamedItem("domain");
                        SolutionDescriptor desc;
                        desc = new SolutionDescriptor(f, xdomain != null ? xdomain.Value : null);

                        recentKnown.Add(f.FullName);
                        recent.Add(desc);
                    }
                }
                outPaths.Clear();
                XmlNodeList xtargets = xdoc.SelectNodes("state/solution/target");
                foreach (XmlNode xt in xtargets)
                {
                    XmlNode xsolution = xt.Attributes.GetNamedItem("solutionFile");
                    if (xsolution == null)
                    {
                        continue;
                    }
                    File sol = new File(xsolution.Value);
                    File ot  = new File(xt.InnerText);
                    if (!sol.Exists)
                    {
                        continue;
                    }
                    if (!ot.Directory.Exists)
                    {
                        continue;
                    }
                    outPaths.Add(sol.FullName, ot);
                }
                XmlNode xtoolset = xdoc.SelectSingleNode("state/toolset");
                if (xtoolset != null)
                {
                    toolset = xtoolset.InnerText;
                }
                xreader.Close();
                return(true);
            }
            return(false);
        }
Пример #3
0
            public override bool Equals(object obj)
            {
                if (!(obj is SolutionDescriptor))
                {
                    return(false);
                }
                SolutionDescriptor other = (SolutionDescriptor)obj;

                return(other.File.FullName == File.FullName);
            }
        private async void ClearUnmanagedSolution_Click(object sender, RoutedEventArgs e)
        {
            var solution = GetSelectedEntity();

            if (solution == null)
            {
                return;
            }

            string question = string.Format(Properties.MessageBoxStrings.ClearSolutionFormat1, solution.UniqueName);

            if (MessageBox.Show(question, Properties.MessageBoxStrings.QuestionTitle, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
            {
                return;
            }

            try
            {
                ToggleControls(false, Properties.WindowStatusStrings.ClearingSolutionFormat2, _service.ConnectionData.Name, solution.UniqueName);

                var commonConfig = CommonConfiguration.Get();

                var descriptor = new SolutionComponentDescriptor(_service);
                descriptor.SetSettings(commonConfig);

                SolutionDescriptor solutionDescriptor = new SolutionDescriptor(_iWriteToOutput, _service, descriptor);

                this._iWriteToOutput.WriteToOutput(_service.ConnectionData, string.Empty);
                this._iWriteToOutput.WriteToOutput(_service.ConnectionData, "Creating backup Solution Components in '{0}'.", solution.UniqueName);

                {
                    string fileName = EntityFileNameFormatter.GetSolutionFileName(
                        _service.ConnectionData.Name
                        , solution.UniqueName
                        , "Components Backup"
                        );

                    string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

                    await solutionDescriptor.CreateFileWithSolutionComponentsAsync(filePath, solution.Id);

                    this._iWriteToOutput.WriteToOutput(_service.ConnectionData, "Created backup Solution Components in '{0}': {1}", solution.UniqueName, filePath);
                    this._iWriteToOutput.WriteToOutputFilePathUri(_service.ConnectionData, filePath);
                }

                {
                    string fileName = EntityFileNameFormatter.GetSolutionFileName(
                        _service.ConnectionData.Name
                        , solution.UniqueName
                        , "SolutionImage Backup before Clearing"
                        , "xml"
                        );

                    string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

                    SolutionImage solutionImage = await solutionDescriptor.CreateSolutionImageAsync(solution.Id, solution.UniqueName);

                    await solutionImage.SaveAsync(filePath);
                }

                SolutionComponentRepository repository = new SolutionComponentRepository(_service);
                await repository.ClearSolutionAsync(solution.UniqueName);

                ToggleControls(true, Properties.WindowStatusStrings.ClearingSolutionCompletedFormat2, _service.ConnectionData.Name, solution.UniqueName);
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex);

                ToggleControls(true, Properties.WindowStatusStrings.ClearingSolutionFailedFormat2, _service.ConnectionData.Name, solution.UniqueName);
            }
        }