Professional Documents
Culture Documents
Final
Final
Step-By-Step Tutorial
PREAMBLE ............................................................................................................................................................. 2 PART 1. INITIAL SETUP PREPARING FOLDERS TO STORE LOG-FILES AND USERS EXPUNGE .................................. 2 PART 2. DATABASES CHECK ................................................................................................................................... 3 PART 3. RUN INTER-DB MACROSES ........................................................................................................................ 3 PART 4. SPATIAL MAP UPDATE .............................................................................................................................. 4 PART 5. PIPING CHECK ........................................................................................................................................... 4 PART 6. REVIEW FILE CREATION ............................................................................................................................. 4 PART 7. SESSION MERGING .................................................................................................................................... 5 PART 8. CLASHES CHECK ........................................................................................................................................ 5 PART 9. SENDING EMAIL WITH ALL LOGS ATTACHED ............................................................................................. 6 APPENDIX A. COMPLETE CODE CONSISTS OF ALL ABOVE PARTS ............................................................................ 7
AVEVA PDMS/MARINE
Step-By-Step Tutorial
PREAMBLE
Administrator of AVEVA PDMS/Marine systems should maintain project performing some tasks which usually done on periodical basis. Some of them are databases integrity check, sessions merging, creation of Review file (RVM), Inter-DB macro run, piping consistency check, clashes check etc. Many of these procedures could be done in auto mode running with the scheduler for example at nights. In next several examples, we will review some of the procedures The result of some following actions is a log-file where administrator can check if there are any problems found. It is also possible automatically send any logs to email some PML code should be added (not done here). Although it is possible to try to fix the problems in automode, we highly recommend to do it manually under control of Administrator after reading the log visually. All the following procedures written on PML and checked on SAM project supplied with AVEVA PDMS. For any other projects it should modified by Administrator of this project therefore prerequisites for those who wants to use it and modify are PML and Admin knowledge. To run it you need to do following:
1.Copy all needed PML from following blocks into one file and call it for example night-process-run.pmlmac 2.Create a copy of your projects run bat-file shortcut and add folling to shortcut properties: ..\pdms.bat TTY SAM SYSTEM/XXXXXX /SAMPLE $M/\\yourserverpath\night-process-run.pmlmac
where TTY - terminal mode of PDMS run (non-graphics) SAM project name SYSTEM/XXXXXX username and password (must be a system user) /SAMPLE MDB And as a last parameter call for night macro You dont need to point any module here as far as PML macro will manage them automatically
3.Create a schedule with using for example Windows scheduler and point ot this shortcut
BEFORE DO ANY ACTION YOU MUST BE SURE THAT YOUR PROJECT IS BACKUPED
PART 1. Initial setup preparing folders to store log-files and users expunge
--first file database check log-file folder --second file piping consistency check log-file folder --third file - AVEVA Review file folder --if folders do not exist then create it with CMD MKDIR command !folders[1] = 'C:\temp\NIGHT-WORK\DatabaseCheck\' !folders[2] = 'C:\temp\NIGHT-WORK\PipingCheck\' !folders[3] = 'C:\temp\NIGHT-WORK\Review\' !folders[4] = 'C:\temp\NIGHT-WORK\Clashes\' do !x from 1 to !folders.Size() !fo = object file('$!folders[$!x]') if (!fo.Exists().Not()) then !comm = |SYSCOM 'MKDIR $!folders[$!x]'| $!comm endif Enddo --Block 1. EXPUNGE ALL CLAMILISTS/USERS BEFORE --Goto Admin module ADMIN
--doing users expunge
EXPUNGE
--run thru all databases and expunge from claimlists
VAR !DBS COLLECT ALL DB do!x from 1 to !DBS.Size() !DBNA = !DBS[!X].Dbref().Name.After('/*') EXPUNGE DB $!DBNA HANDLE (1,271)(1,273)
--if database is UPDATE or is FOREIGN
ENDHANDLE
AVEVA PDMS/MARINE
Step-By-Step Tutorial ENDDO --end of Block 1
AVEVA PDMS/MARINE
Step-By-Step Tutorial --back to Monitor MONITOR do !x from 1 to !files.Size() --delete processed macroses DELETE MAC $!x enddo endif --End of Block 3
AVEVA PDMS/MARINE
Step-By-Step Tutorial EXPORT ALL PIPE FOR CE COLOUR 10 EXPORT ALL PIPE WITH (NAME OF ZONE EQ '/CABLETRAY') FOR CE COLOUR 11 EXPORT ALL PIPE WITH (MATCHWILD(NAME,'*A*') AND NAME OF ZONE EQ '/PIPES') FOR CE COLOUR 2 EXPORT ALL PIPE WITH (MATCHWILD(NAME,'*B*') AND NAME OF ZONE EQ '/PIPES') FOR CE COLOUR 3 EXPORT ALL PIPE WITH (MATCHWILD(NAME,'*C*') AND NAME OF ZONE EQ '/PIPES') FOR CE COLOUR 6 EXPORT ALL PIPE WITH (NAME OF ZONE EQ '/HEATING-VENTS') FOR CE COLOUR 12 EXPORT ALL EQUI FOR CE COLOUR 4 EXPORT ALL STRU FOR CE COLOUR 8 EXPORT ALL STRU WITH (NAME OF ZONE EQ '/STEEL' OR NAME OF ZONE EQ '/RACKPIPES') FOR CE COLOUR 7
AVEVA PDMS/MARINE
Step-By-Step Tutorial --check site /STABILIZER from SAM project CHECK /STABILIZER ALPHA FILE END REPORT MACRO OFF EXIT --End of Block 8
AVEVA PDMS/MARINE
Step-By-Step Tutorial
--PART 2 VAR !DBS COLL ALL DB !outputLOG = object array() !outputLOGFILE = object file('$!folders[1]' + '!TotalLOG-DB.log') VAR !mdbn MDB CHECKOPTION EXT CHECK PREF $!mdbn do !x from 1 to !DBS.Size() skip if (!DBS[!x].DbRef().Fore EQ 'FOREIGN') !dbName = !DBS[!x].DbRef().Name !nfile = '$!folders[1]' & !DBS[!x].DbRef().Name.After('/*').Replace('/','!') & '.txt' ALPHA LOG/$!nfile OVER HANDLE ANY ALPHA LOG END SKIP ENDHANDLE !dbN = !DBS[!x].DbRef().Name.After('/*') CHECK DB $!dbN HANDLE ANY ALPHA LOG END SKIP ENDHANDLE ALPHA LOG END !logfile = object file(!nfile) !logfileRead = !logfile.ReadFile() if (!logfileRead[!logfileRead.Size() - 1].Matchwild('*Database has no structural errors*').Not()) then !outputLOG.Append('DBS $!dbName : inconsistencies found.. Manual check needed...') endif do !y from 1 to !logfileRead.Size() if (!logfileRead[!y].Matchwild('*invalid*') OR !logfileRead[!y].Matchwild('*unknown*')) then !outputLOG.Append('DBS $!dbName : inconsistencies found.. Manual check needed...') SKIP endif enddo Enddo !outputLOGFILE.WriteFile('OVERWRITE',!outputLOG)
--PART 3 VAR !PROJCODE PROJ CODE !TOEVAL = |VAR !MACFOLDER EVAR '$!PROJCODE| & |MAC'| $!TOEVAL
AVEVA PDMS/MARINE
Step-By-Step Tutorial !MacroFolder = object file(!MACFOLDER) DESIGN !files = !MacroFolder.Files() if (!files.Size() NEQ 0) then do !x from 1 to !files.Size() !path = !files[!x].String() $M/$!path enddo MONITOR do !x from 1 to !files.Size() DELETE MAC $!x enddo endif
--PART 5 ZONE /PIPES !pipes = !!CollectAllFor('PIPE',||,CE) !outputLOG = object array() !outputLOGFILE = object file('$!folders[2]' + '!TotalLOG-PIPES.log') do !x from 1 to !pipes.Size() !nfile = '$!folders[2]' & !pipes[!x].Name.Replace('/','!') & '.txt' ALPHA LOG/$!nfile OVER $!pipes[$!x] VAR !userm USERM VAR !lastm LASTM !user = 'Modified by user: $!userm , $!lastm' $P $!user CHECK CE ALPHA LOG END !logfile = object file(!nfile) !logfileRead = !logfile.ReadFile() if (!logfileRead[!logfileRead.Size()].Matchwild('*NO DATA INCONSISTENCIES*').Not()) then !outputLOG.Append('PIPE $!!CE.Name : inconsistencies found... Manual check needed') endif enddo !outputLOGFILE.WriteFile('OVERWRITE',!outputLOG)
--PART 6 SITE /STABILIZER !CEName = !!CE.Name VAR !projcode PROJ CODE !revFile = object file('$!folders[3]' + '$!projcode' + '_model.rvm') EXPORT FILE/$!revFile OVER EXPORT ENCODING UTFE EXPORT ALL PIPE FOR CE COLOUR 10 EXPORT ALL PIPE WITH (NAME OF ZONE EQ '/CABLETRAY') FOR CE COLOUR 11 EXPORT ALL PIPE WITH (MATCHWILD(NAME,'*A*') AND NAME OF ZONE EQ '/PIPES') FOR CE COLOUR 2 EXPORT ALL PIPE WITH (MATCHWILD(NAME,'*B*') AND NAME OF ZONE EQ '/PIPES') FOR CE COLOUR 3 EXPORT ALL PIPE WITH (MATCHWILD(NAME,'*C*') AND NAME OF ZONE EQ '/PIPES') FOR CE COLOUR 6 EXPORT ALL PIPE WITH (NAME OF ZONE EQ '/HEATING-VENTS') FOR CE COLOUR 12 EXPORT ALL EQUI FOR CE COLOUR 4 EXPORT ALL STRU FOR CE COLOUR 8 EXPORT ALL STRU WITH (NAME OF ZONE EQ '/STEEL' OR NAME OF ZONE EQ '/RACKPIPES') FOR CE COLOUR 7 EXPORT FINISH
AVEVA PDMS/MARINE
Step-By-Step Tutorial skip if (!DBS[!x].DbRef().Fore EQ 'FOREIGN') !mergewhere = !DBS[!x].DbRef().Name.After('/*') MERGE CHAN $!mergewhere HANDLE (1,18)(1,293) ENDHANDLE enddo
PART 8 DESIGN !clashTemplateFile = !folders[4] + 'clashtemplate.tmp' !templData[1] = '$$CLANUM$$ # $$CLATYPE$$' !templData[2] = '$$CLA1$$' !templData[3] = 'with' !templData[4] = '$$CLA2$$' !templData[5] = 'at $$CLAPOS$$' !templData[6] = '--------------' !clashTemplateFileObject = object file(!clashTemplateFile) !clashTemplateFileObject.Writefile('OVERWRITE',!templData) !clashOutputFile = !folders[4] + '!TotalLOG-CLASHES.log' DESCLASH REPORT MACRO /$!clashTemplateFile ALPHA FILE /$!clashOutputFile OVER OVERRIDE ON REMOVE OBST All OBST ALL NOCHECK WITHIN BRAN NOCHECK WITHIN EQUI INCLUDE CONNECTIONS INCLUDE TOUCHES CHECK /STABILIZER ALPHA FILE END REPORT MACRO OFF EXIT
--PART 9 MONITOR !emailAddresses = 'pdmsmagic@gmail.com;anothersender@hisadrees.com' VAR !getPU EVAR PDMSUSER !pdmsuser1 = !getPU.Split()[1] !scriptFile = !pdmsuser1 + |\send-night-report.vbs| !attachment1File = !folders[1] + '!TotalLOG-DB.log' !attachment2File = !folders[2] + '!TotalLOG-PIPES.log' !attachment3File = !folders[4] + '!TotalLOG-CLASHES.log' !scriptFileOF = object FILE(!scriptFile) if (!scriptFileOF.Exists()) then !scriptFileOF.Deletefile() HANDLE ANY ENDHANDLE endif VAR !getU EVAR USERNAME !session = current session var !projCode PROJ CODE !nightDate = object datetime() !nightDateString = !nightDate.String() !lines = OBJECT ARRAY() !lines.append(|Set olApp = CreateObject("Outlook.Application")|) !lines.append(|Set objMail = olApp.CreateItem(olMailItem)|) !lines.append(|objMail.Display|) !lines.append(|Set colAttach = objMail.Attachments|) !lines.append(|Set oAttach = colAttach.Add("| & !attachment1File & |")|) !lines.append(|colAttach.Add("| & !attachment2File & |")|)
AVEVA PDMS/MARINE
Step-By-Step Tutorial !lines.append(|colAttach.Add("| & !attachment3File & |")|) !lines.append(|objMail.To = "$!emailAddresses"|) !lines.append(|objMail.Subject = "Night Check Results ( $!nightDateString )"|) !lines.append(|objMail.HTMLBody = "<BODY><p style='font-face:Tahoma; color=#000000 size=12pt;'>" & _ |) !lines.append(|"<b style='font-face:Verdana; color:#ff0000; font-size:12pt;'>Project: </b>| & !projCode & |<br/>" & _ |) !lines.append(|"<b style='font-face:Verdana; color:#ff0000; font-size:12pt;'>MDB: </b>| & !session.mdb().string() & |</p></BODY>"|) !lines.append(|Set olApp = Nothing|) !lines.append(|objMail.Send()|) !scriptFileOF.writeFile(|OVER|, !lines) !!pmlTranscFile('$!scriptFile', '', '', '', '') SYSCOM |CSCRIPT "$!<scriptFile>" /x|
FINISH