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 22... Line 22...
22
 
22
 
23
      /// <summary>
23
      /// <summary>
24
      /// The parser will call this virtual method when it has opened a ReqPro project
24
      /// The parser will call this virtual method when it has opened a ReqPro project
25
      /// </summary>
25
      /// </summary>
26
      /// <param name="rq_project"></param>
26
      /// <param name="rq_project"></param>
27
      protected virtual void provideReqProDatabaseInfo(ReqPro40.Project rq_project)
27
      protected virtual void provideReqProDatabaseInfo(ReqPro40.Application rq_app, 
-
 
28
         ReqPro40.Project rq_project, 
-
 
29
         ReqProDB_Artifact rq_artifact,
-
 
30
         EA.Element rq_element)
28
      {
31
      {
29
      }
32
      }
30
 
33
 
31
      /// <summary>
34
      /// <summary>
32
      /// The parser will call this virtual method for every package it finds
35
      /// The parser will call this virtual method for every package it finds
Line 77... Line 80...
77
      {
80
      {
78
      }
81
      }
79
 
82
 
80
 
83
 
81
 
84
 
82
      /// <summary>
-
 
83
      /// Initiates a ReqPro database parsing operation using a ReqProDB artifact in EA.
-
 
84
      /// This method assumes user has selected the artifact in EA's project browser.
-
 
85
      /// </summary>
-
 
86
      /// <param name="ea_repository"></param>
-
 
87
      public virtual bool parse(EA.Repository ea_repository)
-
 
88
      {
-
 
89
         ReqPro40.Project rq_project = null;
-
 
90
         try
-
 
91
         {
-
 
92
            ReqProDB_Artifact RQ_Artifact = new ReqProDB_Artifact();
-
 
93
 
-
 
94
            EA.Element rq_artifact = RQ_Artifact.get_rq_artifact(ea_repository);
-
 
95
            if (rq_artifact != null)
-
 
96
            {
-
 
97
               // open the ReqPro data base
-
 
98
               rq_project = RQ_Artifact.OpenReqProProject(ea_repository, rq_artifact);
-
 
99
               if (rq_project != null)
-
 
100
               {
-
 
101
                  // give req pro project object to user of this class
-
 
102
                  provideReqProDatabaseInfo(rq_project);
-
 
103
 
-
 
104
                  // Get the ReqPro root package and parse it
-
 
105
                  ReqPro40.RootPackage rq_rootPackage = rq_project.GetRootPackage(true);
-
 
106
 
-
 
107
                  parseRootPackage(0, ea_repository, rq_project, rq_rootPackage);
-
 
108
               }
-
 
109
               else
-
 
110
               {
-
 
111
                  return false;
-
 
112
               }
-
 
113
            }
-
 
114
         }
-
 
115
         catch (Exception ex)
-
 
116
         {
-
 
117
            MessageBox.Show(ex.Message, "Error (ReqProParser::parse)", MessageBoxButtons.OK);
-
 
118
            if (rq_project != null)
-
 
119
               rq_project.CloseProject();
-
 
120
            return false;
-
 
121
         }  
-
 
122
         return true;
-
 
123
      }
-
 
124
 
85
 
125
      /// <summary>
86
      /// <summary>
126
      /// Initiates a ReqPro database parsing operation using a prompted reqpro database open operation
87
      /// Initiates a ReqPro database parsing operation using a prompted reqpro database open operation
127
      /// </summary>
88
      /// </summary>
128
      /// <param name="ea_repository"></param>
89
      /// <param name="ea_repository"></param>
129
      /// <returns></returns>
90
      /// <returns></returns>
130
      public virtual bool prompt_and_parse(EA.Repository ea_repository)
91
      public virtual bool prompt_and_parse(EA.Repository ea_repository, ReqProDB_Artifact.MODE mode)
131
      {
92
      {
-
 
93
         ReqPro40.Application rq_app = null;
132
         ReqPro40.Project rq_project = null;
94
         ReqPro40.Project rq_project = null;
133
 
95
 
134
         try
96
         try
135
         {
97
         {
-
 
98
            // If we can find a ReqProDB artifact in the package, use it to logon to the ReqPro database
-
 
99
            ReqProDB_Artifact RQ_Artifact = new ReqProDB_Artifact();
-
 
100
            EA.Element RQ_Element = RQ_Artifact.get_rq_artifact(ea_repository);
-
 
101
            if (RQ_Element != null)
-
 
102
            {
-
 
103
               // check to see if the ReqProDB element has the same mode as that specified by parameter
-
 
104
               ReqProDB_Artifact.MODE rq_art_mode = RQ_Artifact.get_mode(ea_repository, RQ_Element);
136
            // let user select the ReqPro database file name
105
               if (rq_art_mode != ReqProDB_Artifact.MODE.UNDEFINED)
-
 
106
               {
137
            OpenFileDialog ofd = new OpenFileDialog();
107
                  if (rq_art_mode != mode)
-
 
108
                  {
-
 
109
                     DialogResult dlgRes = MessageBox.Show("You are attempting to use a ReqProDB element\n" +
138
            ofd.Title = "Select Requisite Pro project file";
110
                        "for a different purpose than that which was\n" +
139
            ofd.Filter = "ReqPro files (*.rqs)|*.rqs|All files (*.*)|*.*";
111
                        "specified when the element was first created.\n" +
-
 
112
                        "Continue Anyway?", "Confirm", MessageBoxButtons.YesNo);
140
            DialogResult dlgRes = ofd.ShowDialog();
113
                     if (dlgRes != DialogResult.Yes)
-
 
114
                     {
-
 
115
                        return false;
-
 
116
                     }
-
 
117
                  }
-
 
118
               }
141
 
119
 
-
 
120
               rq_project = RQ_Artifact.OpenReqProProject(ea_repository, RQ_Element);
-
 
121
               if (rq_project != null)
-
 
122
                  rq_app = RQ_Artifact.RQ_app;
-
 
123
            }
-
 
124
            
-
 
125
            // If no ReqProDB artifact found, prompt user to logon to the ReqPro database
142
            if (dlgRes == DialogResult.OK)
126
            if (rq_project == null)
143
            {
127
            {
-
 
128
               // let user select the ReqPro database file name
-
 
129
               OpenFileDialog ofd = new OpenFileDialog();
-
 
130
               ofd.Title = "Select Requisite Pro project file";
-
 
131
               ofd.Filter = "ReqPro files (*.rqs)|*.rqs|All files (*.*)|*.*";
-
 
132
               DialogResult dlgRes = ofd.ShowDialog();
-
 
133
               if (dlgRes != DialogResult.OK)
-
 
134
                  return false;
-
 
135
 
144
               // let user specifiy username/password
136
               // let user specifiy username/password
145
               Logon logon = new Logon("");
137
               Logon logon = new Logon("");
146
               dlgRes = logon.ShowDialog();
138
               dlgRes = logon.ShowDialog();
-
 
139
               if (dlgRes != DialogResult.OK)
-
 
140
                  return false;
147
 
141
 
148
               if (dlgRes == DialogResult.OK)
-
 
149
               {
-
 
150
                  string username = logon.ebUserName.Text;
142
               string username = logon.ebUserName.Text;
151
                  string password = logon.ebPassword.Text;
143
               string password = logon.ebPassword.Text;
152
 
144
 
153
                  // Connect to the ReqPro database using the ReqPro extensibility mechanism
145
               // Connect to the ReqPro database using the ReqPro extensibility mechanism
154
                  ReqPro40.Application reqPro = new ReqPro40.ApplicationClass();
146
               rq_app = new ReqPro40.ApplicationClass();
155
 
147
 
156
                  rq_project = 
148
               rq_project = 
157
                     reqPro.OpenProject(ofd.FileName,
149
                  rq_app.OpenProject(ofd.FileName,
158
                                        ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
150
                  ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
159
                                        username,
151
                  username,
160
                                        password, 
152
                  password, 
161
                                        enumProjectFlags.eProjFlag_Normal,
153
                  enumProjectFlags.eProjFlag_Normal,
162
                                        enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
154
                  enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
163
                  if (rq_project != null)
-
 
164
                  {
-
 
165
                     // give req pro project object to user of this class
-
 
166
                     provideReqProDatabaseInfo(rq_project);
-
 
167
 
155
 
168
                     // Get the ReqPro root package and parse it
156
               // if we do not currently have a ReqProDB artifact, create one
-
 
157
               if (RQ_Element == null)
-
 
158
               {
169
                     ReqPro40.RootPackage rq_rootPackage = rq_project.GetRootPackage(true);
159
                  EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
170
 
160
 
171
                     parseRootPackage(0, ea_repository, rq_project, rq_rootPackage);
161
                  RQ_Element = RQ_Artifact.create_rq_artifact( ea_repository, 
-
 
162
                     EA_Utils.get_selected_package(), 
172
                     return true;
163
                     rq_project.Name, 
-
 
164
                     rq_project.Description, 
-
 
165
                     logon.ebUserName.Text, 
173
                  }
166
                     ofd.FileName, 
-
 
167
                     rq_project.GUID);
174
               }
168
               }
175
            }
169
            }
-
 
170
 
-
 
171
 
-
 
172
 
-
 
173
            // Now do the parsing of the ReqPro database
-
 
174
            if (rq_project != null)
-
 
175
            {
-
 
176
               // give req pro project object to user of this class
-
 
177
               provideReqProDatabaseInfo(rq_app, rq_project, RQ_Artifact, RQ_Element);
-
 
178
 
-
 
179
               // Get the ReqPro root package and parse it
-
 
180
               ReqPro40.RootPackage rq_rootPackage = rq_project.GetRootPackage(true);
-
 
181
 
-
 
182
               parseRootPackage(0, ea_repository, rq_project, rq_rootPackage);
-
 
183
               return true;
-
 
184
            }
176
         }
185
         }
177
         catch (Exception ex)
186
         catch (Exception ex)
178
         {
187
         {
179
            MessageBox.Show(ex.Message, "Error (ReqProParser::prompt_and_parse)", MessageBoxButtons.OK);
188
            MessageBox.Show(ex.Message, "Error (ReqProParser::prompt_and_parse)", MessageBoxButtons.OK);
180
            if (rq_project != null)
189
            if (rq_project != null)