Vous désirez vérifier dans votre référentiel si vous avez un modèle qui possède plus d’un objet avec le même OID.
Option Explicit dim fso set fso = CreateObject("Scripting.FileSystemObject") if not(RepositoryConnection.Connected) then output "La connexion au référentiel est fermée. Impossible d'exécuter le script" end if CheckRepositoryElements RepositoryConnection.ChildObjects '********************************************************************* Sub CheckRepositoryElements(RepObjColl) output "Vérification du dossier: " & RepObjColl.Source.Location & "/" & RepObjColl.Source.DisplayName dim repobj for each repobj in RepObjColl if (repobj.IsKindOf(cls_RepositoryModel)) then CheckRepositoryModel repobj end if next for each repobj in RepObjColl if not (repobj.IsKindOf(cls_RepositoryModel)) then if (repobj.IsKindOf(cls_RepositoryBaseFolder)) then CheckRepositoryElements(repobj.ChildObjects) end if end if next End Sub '************************************************************************ Sub CheckRepositoryModel(repmdl) output "Vérification du modèle dans le référentiel: " & repmdl dim filename, pResult, pFolder Set pFolder = fso.GetSpecialFolder(2) ' 2=TemporaryFolder filename = fso.BuildPath(pFolder.Path, fso.GetTempName) repmdl.CheckOutToFile filename, 1, False if (fso.FileExists(filename)) then CheckModelFile filename fso.DeleteFile filename, True else output "Erreur d'extraction::" & repmdl end if End Sub '*********************************************************************** Sub CheckModelFile(fname) dim idmap, tfile, text, rxp, mch, interid set idmap = CreateObject("Scripting.Dictionary") Set tfile = fso.OpenTextFile(fname) text = tfile.ReadAll() tfile.Close() set rxp = new RegExp rxp.IgnoreCase = False rxp.MultiLine = True rxp.Global = True ' Pattern Property ' https://www.vbsedit.com/html/648fb4cf-2968-491c-b9de-51a7dad965f1.asp ' "$1" ' Example : Id="o4"> ' Id=" ' (pattern) Matches pattern and remembers the match ' ( ' [^""] Matches any character not enclosed. For example, [^""] matches the o4 in "o4"> ' + Matches the preceding character one or more times. ' ) ' ' ' "> ' \s Matches any white space including space, tab, form-feed, etc. Equivalent to "[ \f\n\r\t\v] ' * Matches the preceding character zero or more times. ' "$2" ' (pattern) Matches pattern and remembers the match ' ( ' [^<] Remove any character after. For example,[^<] Hello<"x4", result "x4" ' + Matches the preceding character one or more times. ' ) rxp.Pattern = "Id=""([^""]+)"">\s*([^<]+)" for each mch in rxp.Execute(text) interid = rxp.Replace(mch, "$1") ' output "interid " & rxp.Replace(mch, "$1") if (idmap.Exists(interid)) then output " *** *** *** *** ID en double a été trouvé: " & interid else idmap.Add interid, "OID" end if next End Sub
A propos des méthodes et des propriétes vbscript suivantes :
- Execute method (vbscript) : http://www.vbsedit.com/html/711116fb-9c47-47cb-b664-db8141b8cc69.asp
- Replace method (vbscript) : https://www.vbsedit.com/html/810607c5-5926-43d9-b7e8-4126e97000d2.asp
- Pattern Property : https://www.vbsedit.com/html/648fb4cf-2968-491c-b9de-51a7dad965f1.asp