Exemplo n.º 1
0
        private void fileImportMenuItem_Click(object sender, EventArgs e)
        {
            // Confirm that everything currently in the database will be blown away
            string msg = String.Empty;

            msg += ("Importing will replace the content of current database." + System.Environment.NewLine);
            msg += ("Are you sure that's what you want to do?");
            if (MessageBox.Show(msg, "Confirm Import", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            OpenFileDialog dial = new OpenFileDialog();

            dial.Title  = "Locate file containing the new environment";
            dial.Filter = "Backsight environment files (*.xml)|*.xml|All files (*.*)|*.*";

            if (dial.ShowDialog() == DialogResult.OK)
            {
                // Load the file into its own dataset
                EnvironmentFile ef = new EnvironmentFile(dial.FileName);

                // Get rid of the content of the current database (including empty rows)
                m_Data.Replace(ef);
                RefreshList();
                MessageBox.Show("Done");
            }

            dial.Dispose();
        }
Exemplo n.º 2
0
        private void FindMatches(
            EnvironmentFile item,
            List <FileMatch> possibleXmlTransformations,
            DirectoryInfo configContentDirectory,
            List <FileMatch> replaceFiles)
        {
            string targetFile = $"{item.FileNameParts[0]}.{item.FileNameParts.Last()}";

            _logger.Debug("Found possible file target to transform '{TargetFile}'", targetFile);

            string action = item.FileNameParts.Skip(3).First();

            if (action.Equals("XdtTransform", StringComparison.OrdinalIgnoreCase))
            {
                possibleXmlTransformations.Add(
                    new FileMatch(targetFile, item.File, configContentDirectory));
            }
            else if (action.Equals("Replace", StringComparison.OrdinalIgnoreCase))
            {
                replaceFiles.Add(
                    new FileMatch(targetFile, item.File, configContentDirectory));
            }
            else
            {
                _logger.Debug("There was no well-known action defined for file '{FullName}'", item.File.FullName);
            }
        }
Exemplo n.º 3
0
        void WriteExportFile(string fileName)
        {
            // A by-product of the following is that the database name gets re-assigned
            // to the supplied filename, so we'll need to fix it up. Should really handle
            // names a bit better.
            string dbName = m_Data.Name;

            try
            {
                EnvironmentFile ef = new EnvironmentFile(fileName, m_Data);
                ef.Write();
            }

            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            finally
            {
                m_Data.Name = dbName;
                MessageBox.Show("Done");
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Try to load the file.
 /// Possibly this might raise an exception. That exception is not caught here
 /// </summary>
 /// <param name="file">The file that needs to be loaded</param>
 public override void TryLoading(string file)
 {
     var ENVFile = new EnvironmentFile(file);
 }