Subversion Repositories DevTools

Rev

Rev 2151 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2151 Rev 2153
Line 135... Line 135...
135
      /// Export the requirements found in the selected package to a ReqPro CSV file.
135
      /// Export the requirements found in the selected package to a ReqPro CSV file.
136
      /// </summary>
136
      /// </summary>
137
      /// <param name="ea_repository"></param>
137
      /// <param name="ea_repository"></param>
138
      public void Export()
138
      public void Export()
139
      {
139
      {
140
         object o;
140
         try
141
         EA.ObjectType type;
-
 
142
         type = Main.EA_Repository.GetTreeSelectedItem(out o);
-
 
143
         if (type == EA.ObjectType.otPackage)
-
 
144
         {
141
         {
145
            EA.Package EA_ParentPackage = (EA.Package)o;
-
 
146
 
-
 
147
            // Choose CSV file name and location
142
            object o;
148
            SaveFileDialog ofd = new SaveFileDialog();
-
 
149
            ofd.Title = "Select Name of Export file";
143
            EA.ObjectType type;
150
            ofd.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
144
            type = Main.EA_Repository.GetTreeSelectedItem(out o);
151
            DialogResult dlgRes = ofd.ShowDialog();
-
 
152
            if (dlgRes == DialogResult.OK)
145
            if (type == EA.ObjectType.otPackage)
153
            {
146
            {
-
 
147
               EA.Package EA_ParentPackage = (EA.Package)o;
-
 
148
 
-
 
149
               // Choose CSV file name and location
-
 
150
               SaveFileDialog ofd = new SaveFileDialog();
-
 
151
               ofd.Title = "Select Name of Export file";
-
 
152
               ofd.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
-
 
153
               DialogResult dlgRes = ofd.ShowDialog();
-
 
154
               if (dlgRes == DialogResult.OK)
-
 
155
               {
154
               Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
156
                  Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
155
               Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exporting to ReqPro CSV File", -1);
157
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exporting to ReqPro CSV File", -1);
156
 
158
 
157
               // Begin to build the CSV file content, starting with the header line ReqPro requires.
159
                  // Begin to build the CSV file content, starting with the header line ReqPro requires.
158
               csv_text = new StringBuilder();
160
                  csv_text = new StringBuilder();
159
               csv_text.Append( String.Format("\"{0} Tag\",\"Requirement text\",\"Name\"\r\n", textBox_tag.Text));
161
                  csv_text.Append( String.Format("\"{0} Tag\",\"Requirement text\",\"Name\"\r\n", textBox_tag.Text));
160
 
162
 
161
               // recursively descend the package
163
                  // recursively descend the package
162
               parse_package(EA_ParentPackage, 0);
164
                  parse_package(EA_ParentPackage, 0);
163
 
165
 
164
               // write the CSV file content
166
                  // write the CSV file content
165
               TextWriter tw = new StreamWriter( ofd.FileName );
167
                  TextWriter tw = new StreamWriter( ofd.FileName );
166
               tw.WriteLine(csv_text.ToString());
168
                  tw.WriteLine(csv_text.ToString());
167
               tw.Close();
169
                  tw.Close();
168
               MessageBoxEx.Show("Export Completed");
170
                  MessageBoxEx.Show("Export Completed", "Progress");
-
 
171
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Export Completed", -1);
-
 
172
               }
169
            }
173
            }
170
         }
174
         }
-
 
175
         catch (Exception exc)
-
 
176
         {
-
 
177
            Main.MessageBoxException(exc, "Export Failed");
-
 
178
         }
171
      }
179
      }
172
 
180
 
173
      /// <summary>
181
      /// <summary>
174
      /// Recursive method to process the EA package and all its sub-packages.
182
      /// Recursive method to process the EA package and all its sub-packages.
175
      /// For each package found, the method grabs all of the elements in the package and for each
183
      /// For each package found, the method grabs all of the elements in the package and for each