Exemple #1
0
 private void Menu_File_SaveAs_SinkFormat_Click(object aTag, string aCaption)
 {
     if (aTag is CISink)
     {
         CISink sink = (CISink)aTag;
         //
         CISinkSerializationParameters parameters = new CISinkSerializationParameters(CIContainer, base.UIManager.UIVersion, base.UIManager.UICommandLineArguments);
         FolderBrowserDialog           dialog     = new FolderBrowserDialog();
         dialog.Description = "Save Location";
         //
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             parameters.OutputDirectory = new System.IO.DirectoryInfo(dialog.SelectedPath);
             //
             sink.Serialize(parameters);
         }
     }
 }
        private void TryToCreateOutput(CISink aXmlSink, CIContainer aContainer, CACmdLineFileSource aFile, CACmdLineMessage[] aMessagesToAdd)
        {
            Trace("[CA Cmd] TryToCreateOutput() - START - container source: {0}", aContainer.Source.MasterFileName);

            // By the time we are outputting a container, there should no longer be any messages
            // associated with the file.
            System.Diagnostics.Debug.Assert(aFile.Count == 0);

            // Check whether the file contained any errors or
            // messages of it own.
            if (aMessagesToAdd.Length > 0)
            {
                // Copy warnings, messages and errors into crash item container.
                // Diagnostic messages are not copied.
                CACmdLineFSEntity.CopyMessagesToContainer(aMessagesToAdd, aContainer);
            }

            // This is where we will record the output attempt
            CACmdLineFileSource.OutputEntry outputEntry = null;
            //
            try
            {
                // Finish preparing the sink parameters
                CISinkSerializationParameters sinkParams = iInputs.SinkParameters;
                sinkParams.Container = aContainer;

                // Perform serialization
                Trace("[CA Cmd] TryToCreateOutput() - serializing...");
                object output = aXmlSink.Serialize(sinkParams);
                Trace("[CA Cmd] TryToCreateOutput() - serialization returned: " + output);

                if (aFile != null)
                {
                    // Create new output
                    string outputFileName = output is string?(string)output : string.Empty;

                    // Save output file name
                    outputEntry = aFile.AddOutput(aContainer, outputFileName, TOutputStatus.ESuccess);
                }

                // Merge in any diagnostic messages that were left into the output entry.
                // This ensure we output diagnostics in the final manifest data.
                outputEntry.AddRange(aMessagesToAdd, CACmdLineMessage.TType.ETypeDiagnostic);
            }
            catch (Exception outputException)
            {
                Trace("[CA Cmd] TryToCreateOutput() - outputException.Message:    " + outputException.Message);
                Trace("[CA Cmd] TryToCreateOutput() - outputException.StackTrace: " + outputException.StackTrace);

                if (aFile != null)
                {
                    // Something went wrong with CI serialisation for the specified container.
                    outputEntry = aFile.AddOutput(aContainer, string.Empty, TOutputStatus.EFailed);
                    //
                    outputEntry.AddError("Could not Create CI", "CI output could not be created");
                    outputEntry.AddDiagnostic("CI Sink Exception Message", outputException.Message);
                    outputEntry.AddDiagnostic("CI Sink Exception Stack", outputException.StackTrace);

                    // Since we didn't manage to sink the container to CI successfully, we must
                    // make sure we don't lose any associated messages from the original file.
                    // Merge these into the output entry also.
                    outputEntry.AddRange(aMessagesToAdd);
                }
            }
        }