IBM Rational DOORS經過DXL進行二次開發

代碼記錄windows


Module m //定義模塊
Object o //定義對象
Item i   //定義項
int objCount  //定義計數
string itemType  //定義相類型
string modName, fullModName//定義模塊名字,模塊全名(路徑名)
string objectnumber[1000]={null}//定義需求編號
string objectheading[1000]={null}//定義需求標題數組
string objecturl[1000]={null}//定義需求連接數組
string objecttext[1000]={null}//定義需求內容數組
string e //定義對象總數
int k    //用於循環計數
Project p //定義項目變量用於文件名存儲項目名稱數組

for i in current Project do //Loops through each undeleted and visible item //循環當前項目
    {
        p = current Project //定義變量等於當前項目
 
        itemType = type i  //項目類型=項的類型
 
        if( itemType == "Formal") //若是項的類型是Formal,DOORS中模塊屬性爲Formal Module
                {
 
                fullModName = fullName(i)//存儲爲模塊的項目的全名
                modName = name(i)//存儲模塊名
              
             m = read(fullModName,false)//讀取路徑模塊
                objCount=0 //計需求數
                for o in m do { //Loops through each undeleted and visible object //循環模塊
                      
                        objectnumber[objCount]=number(o) //存儲需求編號
                        objectheading[objCount]= o."Object Heading"//存儲需求標題
                        objecturl[objCount]=getURL(o)//存儲需求url
                        objecttext[objCount]= o."Object Text"//存儲需求內容
                        
                           if(objectheading[objCount]==null)//假若需求標題爲空,存儲null
       {
                              objectheading[objCount]="null"
       }
                       
                        if(objecttext[objCount]==null)//假若需求內容爲空,存儲null
       {
                              objecttext[objCount]="null"
       }
        
                        objCount++  //數量++
                        e = identifier o  //e爲當前需求對象的identifier,對象的identifier與number不一樣,爲1,2和1,1.1的區別。網絡

                        }ide

                        
                         string savefile ="\\\\WEIXINYUAN\\Users\\wxy\\"name p "&" m."Name" ".xml"//存儲到共享目錄,此處應注意windows系統下的路徑以\\分割,網絡路徑自己以\\開始,因此前面再加\\
                         Stream out = write (savefile,CP_UTF8) //定義寫入文件,爲UTF-8格式
                        
                            out<<"<?xml version=""\"""1.0""\""" encoding=\"utf-8\"?>" //寫入xml文件的頭,注意文法問題
                            out<<"\n"oop

                            out<<"<all>"  //標籤
                            out<<"\n"url

                            out<<"<objectcount>"
                            out<<e  //寫入需求對象的總數
                            out<<"</objectcount>"
                            out<<"\n"spa

                            out<<"<modulepath>"
                            out<<fullModName  //寫入模塊路徑
                            out<<"</modulepath>"
                            out<<"\n"
                            for(k=0;k<objCount;k++)  //循環寫入數組中的全部需求內容
                            {
                            out<<"<obj ID ="
                            out<<objectnumber[k] //寫入需求的ID標籤
                            out<<">"
                            out<<"\n"
                           
                            out<<"<objheading>"
                            out<<objectheading[k] //寫入需求的標題
                            out<<"</objheading>"
                            out<<"\n"orm

                            out<<"<objurl>"
                            out<<objecturl[k]   //寫入需求的url
                            out<<";"
                            out<<"</objurl>"
                            out<<"\n"xml

                            out<<"<objtext>"
                            out<<objecttext[k] //寫入需求的內容
                            out<<"</objtext>"
                            out<<"\n"對象

                            out<<"</obj>"
                            out<<"\n"
                            }
                           out<<"</all>"
                           
                close(m) //關閉當前的模塊
                }                    

        }

//結束

相關文章
相關標籤/搜索