Subversion Repositories DevTools

Rev

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

Rev 2141 Rev 2145
Line 13... Line 13...
13
	/// element used to control ReqPro imports for requirement-to-design tracability 
13
	/// element used to control ReqPro imports for requirement-to-design tracability 
14
	/// purposes. 
14
	/// purposes. 
15
	/// </summary>
15
	/// </summary>
16
	public class ReqProDB_Artifact
16
	public class ReqProDB_Artifact
17
	{
17
	{
-
 
18
      /// <summary>
-
 
19
      /// A ReqProDB artifact can be used for document model (document generation) purposes,
-
 
20
      /// or requirement-to-design traceability purposes, and this is to be recorded in the element
-
 
21
      /// as a tagged value. We need an enum to represent the differning modes.
-
 
22
      /// </summary>
-
 
23
      public enum MODE
-
 
24
      {
-
 
25
         TRACEABILITY,
-
 
26
         DOC_MODEL,
-
 
27
         UNDEFINED
-
 
28
      }
-
 
29
 
18
      private ReqPro40.Application reqPro;
30
      public ReqPro40.Application RQ_app;
19
 
31
 
20
      /// <summary>
32
      /// <summary>
21
      /// Constructor logic
33
      /// Constructor logic
22
      /// </summary>
34
      /// </summary>
23
		public ReqProDB_Artifact()
35
		public ReqProDB_Artifact()
24
		{
36
		{
25
         reqPro = new ReqPro40.ApplicationClass();
37
         RQ_app = new ReqPro40.ApplicationClass();
26
		}
38
		}
27
 
39
 
28
  
40
  
29
      /// <summary>
41
      /// <summary>
30
      /// This method is used to open a ReqPro database file indicated by a given ReqProDB artifact
42
      /// This method is used to open a ReqPro database file indicated by a given ReqProDB artifact
Line 40... Line 52...
40
         Logon logon = new Logon(EA_Utils.ReadTag(rq_artifact, "Username"));
52
         Logon logon = new Logon(EA_Utils.ReadTag(rq_artifact, "Username"));
41
         
53
         
42
         DialogResult dlgRes = logon.ShowDialog();
54
         DialogResult dlgRes = logon.ShowDialog();
43
         if (dlgRes == DialogResult.OK)
55
         if (dlgRes == DialogResult.OK)
44
         {
56
         {
45
            ReqPro40.Project project = reqPro.OpenProject(
57
            ReqPro40.Project project = RQ_app.OpenProject(
46
               EA_Utils.ReadTag(rq_artifact, "Location"),
58
               EA_Utils.ReadTag(rq_artifact, "Location"),
47
               ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
59
               ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
48
               EA_Utils.ReadTag(rq_artifact, "Username"),
60
               EA_Utils.ReadTag(rq_artifact, "Username"),
49
               logon.ebPassword.Text, 
61
               logon.ebPassword.Text, 
50
               enumProjectFlags.eProjFlag_Normal,
62
               enumProjectFlags.eProjFlag_Normal,
Line 65... Line 77...
65
 
77
 
66
 
78
 
67
      /// <summary>
79
      /// <summary>
68
      /// This method is used to return the ReqProDB artifact, on the assumption that it is the
80
      /// This method is used to return the ReqProDB artifact, on the assumption that it is the
69
      /// item the user has highlighted in EA's project browser prior to initiating the process
81
      /// item the user has highlighted in EA's project browser prior to initiating the process
70
      /// leading up to the call to this method.
82
      /// leading up to the call to this method. If the user however has selected a package, then
-
 
83
      /// that package is searched for the first ReqProDB artifact that can be found, and that one
-
 
84
      /// is returned.
71
      /// </summary>
85
      /// </summary>
72
      /// <param name="ea_repository"></param>
86
      /// <param name="ea_repository"></param>
73
      /// <returns></returns>
87
      /// <returns></returns>
74
      public EA.Element get_rq_artifact(EA.Repository ea_repository)
88
      public EA.Element get_rq_artifact(EA.Repository ea_repository)
75
      {
89
      {
76
         // assumes this method will only be used when user has selected a ReqProDB element
-
 
77
         // in the project browser.
-
 
78
         return (EA.Element)ea_repository.GetTreeSelectedObject();
-
 
79
      }
-
 
80
 
-
 
81
 
-
 
82
      /// <summary>
-
 
83
      ///This method is used to associate a package in EA with a specific ReqPro database
-
 
84
      ///file. 
-
 
85
      /// </summary>
-
 
86
      /// <param name="repository"></param>
-
 
87
      public void AssociatePackageToReqProDatabase(EA.Repository ea_repository)
-
 
88
      {
-
 
89
         object o;
90
         object o;
-
 
91
         EA.ObjectType type;
-
 
92
 
90
         EA.ObjectType type = ea_repository.GetTreeSelectedItem(out o);
93
         type = ea_repository.GetTreeSelectedItem(out o);
91
         if (type == EA.ObjectType.otPackage)
94
         if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB"))
92
         {
95
         {
93
            EA.Package package = (EA.Package)o;
96
            return (EA.Element)o;
94
 
97
         }
-
 
98
         else if (type == EA.ObjectType.otPackage)
95
            try
99
         {
-
 
100
            for(short i=0; i < ((EA.Package)o).Elements.Count; i++)
96
            {
101
            {
97
               // Get user to identify the ReqPro database file
-
 
98
               OpenFileDialog ofd = new OpenFileDialog();
-
 
99
               ofd.Title = "Select Requisite Pro project file";
-
 
100
               ofd.Filter = "ReqPro files (*.rqs)|*.rqs|All files (*.*)|*.*";
102
               EA.Element ea_ele = (EA.Element)((EA.Package)o).Elements.GetAt(i);
101
               DialogResult dlgRes = ofd.ShowDialog();
-
 
102
 
103
 
103
               if (dlgRes == DialogResult.OK)
104
               if (ea_ele.Stereotype == "ReqProDB")
104
               {
105
               {
105
                  // Get user to login to the database
-
 
106
                  Logon logon = new Logon("");
-
 
107
                  dlgRes = logon.ShowDialog();
-
 
108
 
-
 
109
                  if (dlgRes == DialogResult.OK)
-
 
110
                  {
-
 
111
                     string username = logon.ebUserName.Text;
-
 
112
                     string password = logon.ebPassword.Text;
-
 
113
                  
-
 
114
                     // attempt to test if the database can be opened
-
 
115
                     ReqPro40.Project rq_project = reqPro.OpenProject(
-
 
116
                        ofd.FileName,
-
 
117
                        ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
-
 
118
                        logon.ebUserName.Text,
-
 
119
                        logon.ebPassword.Text, 
-
 
120
                        enumProjectFlags.eProjFlag_Normal,
-
 
121
                        enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
-
 
122
 
-
 
123
                     if (rq_project != null)
-
 
124
                     {
-
 
125
                        // Success - add the RQ project to the EA repository
-
 
126
                        EA.Element rq_artifact = create_rq_artifact( ea_repository, 
-
 
127
                           package, 
106
                  return ea_ele;
128
                           rq_project.Name, 
-
 
129
                           rq_project.Description, 
-
 
130
                           logon.ebUserName.Text, 
-
 
131
                           ofd.FileName, 
-
 
132
                           rq_project.GUID );
-
 
133
 
-
 
134
                        if (rq_artifact != null)
-
 
135
                        {
-
 
136
                           UpdatePackageToReqProDatabaseAssociation(ea_repository, rq_artifact);
-
 
137
                        }
-
 
138
 
-
 
139
                        rq_project.CloseProject();
-
 
140
                     }
-
 
141
                  }
-
 
142
               }
107
               }
143
            }
108
            }
144
            catch (Exception ex)
-
 
145
            {
109
         }
146
               MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
-
 
147
            }
110
         return null;
148
         }
111
      }
149
      }
112
 
150
 
113
 
-
 
114
 
151
 
115
 
152
      /// <summary>
116
      /// <summary>
153
      /// This method updates a ReqProDB artifact elements internal data. Such an update may be
117
      /// This method updates a ReqProDB artifact elements internal data. Such an update may be
154
      /// needed if the user has deleted requirements from EA that are linked to the specified
118
      /// needed if the user has deleted requirements from EA that are linked to the specified
155
      /// ReqProDB artifact.
119
      /// ReqProDB artifact.
Line 221... Line 185...
221
      /// <param name="description"></param>
185
      /// <param name="description"></param>
222
      /// <param name="reqpro_db_username"></param>
186
      /// <param name="reqpro_db_username"></param>
223
      /// <param name="reqpro_db_filename"></param>
187
      /// <param name="reqpro_db_filename"></param>
224
      /// <param name="reqpro_db_guid"></param>
188
      /// <param name="reqpro_db_guid"></param>
225
      /// <returns></returns>
189
      /// <returns></returns>
226
      private EA.Element create_rq_artifact( EA.Repository ea_repository, 
190
      public EA.Element create_rq_artifact( EA.Repository ea_repository, 
227
         EA.Package package,
191
         EA.Package package,
228
         string name,
192
         string name,
229
         string description,
193
         string description,
230
         string reqpro_db_username,
194
         string reqpro_db_username,
231
         string reqpro_db_filename,
195
         string reqpro_db_filename,
232
         string reqpro_db_guid )
196
         string reqpro_db_guid)
233
      {
197
      {
234
         EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
198
         EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
235
 
199
 
236
         package.Notes = description;
200
         package.Notes = description;
237
         package.Update();
201
         package.Update();
Line 244... Line 208...
244
            element.Notes = description;
208
            element.Notes = description;
245
 
209
 
246
            EA_Utils.WriteTag( element, "Location", reqpro_db_filename);
210
            EA_Utils.WriteTag( element, "Location", reqpro_db_filename);
247
            EA_Utils.WriteTag( element, "Username", reqpro_db_username);
211
            EA_Utils.WriteTag( element, "Username", reqpro_db_username);
248
            EA_Utils.WriteTag( element, "GUID", reqpro_db_guid);
212
            EA_Utils.WriteTag( element, "GUID", reqpro_db_guid);
249
            EA_Utils.WriteTag( element, "Enable_Update", "false");
-
 
-
 
213
 
250
 
214
 
251
            element.Update();
215
            element.Update();
252
            element.Refresh();
216
            element.Refresh();
253
            element.TaggedValues.Refresh();
217
            element.TaggedValues.Refresh();
-
 
218
            package.Update();
254
            package.Packages.Refresh();
219
            package.Packages.Refresh();
255
            package.Elements.Refresh(); 
220
            package.Elements.Refresh(); 
256
            
221
            
257
            return element;
222
            return element;
258
         }
223
         }
Line 277... Line 242...
277
         {
242
         {
278
            repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "New Connector Error : " + c.GetLastError(), ea_req.ElementID );
243
            repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "New Connector Error : " + c.GetLastError(), ea_req.ElementID );
279
         }
244
         }
280
      }
245
      }
281
 
246
 
-
 
247
      public void set_traceability_mode(EA.Repository ea_repository, EA.Element rq_artifact)
-
 
248
      {
-
 
249
         EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
-
 
250
         EA_Utils.WriteTag( rq_artifact, "Mode", "Traceability");
-
 
251
         rq_artifact.Update();
-
 
252
      }
282
 
253
 
-
 
254
      public void set_doc_model_mode(EA.Repository ea_repository, EA.Element rq_artifact)
-
 
255
      {
-
 
256
         EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
-
 
257
         EA_Utils.WriteTag( rq_artifact, "Mode", "DocModel");
-
 
258
         rq_artifact.Update();
-
 
259
      }
-
 
260
 
-
 
261
      public MODE get_mode(EA.Repository ea_repository, EA.Element rq_artifact)
-
 
262
      {
-
 
263
         EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
-
 
264
         string mode = EA_Utils.ReadTag(rq_artifact, "Mode");
-
 
265
                 
-
 
266
         if (0 == mode.CompareTo("Traceability"))
-
 
267
            return MODE.TRACEABILITY;
-
 
268
         else if (0 == mode.CompareTo("DocModel"))
-
 
269
            return MODE.DOC_MODEL;
-
 
270
         
-
 
271
         return MODE.UNDEFINED;
-
 
272
      }
283
 
273
 
284
	}
274
	}
285
}
275
}