Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum differentiate between set and document Get-PWDocumentsBySearch
    • Sign In

    • State Verified Answer
    • Replies 4 replies
    • Subscribers 65 subscribers
    • Views 1510 views
    • Users 0 members are here
    • document
    • Get-DocumentBySearch
    • powershell
    • pwps_dab

    differentiate between set and document Get-PWDocumentsBySearch

    Kevin
    Offline Kevin over 5 years ago

    Get-PWDocumentsBySearch is getting sets and documents from folders

    How do you differentiate between one or the other when iterating the attained document array?

    I need to skip sets and only process documents.

    Thx.

    Kevin.

    • Sign in to reply
    • Cancel

    Top Replies

    • Brian Flaherty
      Offline Brian Flaherty Tue, Nov 14 2017 7:11 AM +1 verified
      You could add something like the following to your script to filter set files: # Populate variable with set information $sets = Select-PWSQLDataTable -SQLSelectStatement "select o_projectno, o_itemno…
    • Kevin
      0 Offline Kevin Tue, Nov 14 2017 2:10 AM

      dms_doc table, column: item_type 0 = normal, 12 = set ... add type as parameter to get-pwdocumentsbysearch

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin
      0 Offline Kevin Tue, Nov 14 2017 2:19 AM in reply to Kevin

      for now ... i could place all non documents into a data table using ... select-pwsqldatatable "select o_projectno , o_itemno from dms_doc where o_itemtype <> 0" then skip matches in the document iteration

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin
      0 Offline Kevin Tue, Nov 14 2017 3:23 AM

      here's my very bad powershell to solve this ... readers are more than welcome to improve the lines (please) .

      i just put in a break for now - not sure what will be returned when I get a missing file

      cls
      Open-PWConnection -DatasourceName xxx -UserName xxx -Password xxx -Admin
      $dt1 = get-date
      $nd1 = Select-PWSQLDataTable -SQLSelectStatement "select o_projectno , o_itemno from dms_doc where o_itemtype <> 0"
      $var1 = Get-PWRichProjects -FolderPath xxx
      foreach($prj1 in $var1)
      {
          $doc1 = Get-PWDocumentsBySearch -FolderPath $prj1.FullPath -Slow
          if($doc1)
          {    
              foreach($d1 in $doc1)
              {
                   $m1 = "0"
                   foreach($n1 in $nd1)
                   {
                      if($n1."o_projectno" -eq $d1."ProjectID" -And $n1."o_itemno" -eq $d1."DocumentID")   # DocumentID
                      {
                          $m1 = "1"
                          break
                      }
                  }
                  if($m1 -eq "0")
                  {
                     $d1.Name
                     $file1 = Search-PWDocumentWithMissingFile -Document $d1
                     break
                  }
              }
              break
          }
      }
      $dt1
      get-date
      Close-PWConnection
      

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      +1 Offline Brian Flaherty Tue, Nov 14 2017 7:11 AM

      You could add something like the following to your script to filter set files:

      # Populate variable with set information
      $sets = Select-PWSQLDataTable -SQLSelectStatement "select o_projectno, o_itemno, o_itemname, o_setno FROM dms_doc WHERE o_setno > 0"

      $docs = Get-PWDocumentsBySearch -FolderPath 'Projects'

      foreach($doc in $docs) {
          # Determine if the current document is a member of the $sets variable. If yes, skip.
          if($sets.select("o_projectno = $($doc.ProjectID) AND o_itemno = $($doc.DocumentID)", "o_itemname ASC")) {
              "Found one"
              continue
          }
          # do something here
      }

      Answer Verified By: Kevin 

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies