add folder refesh after 15 days as well
This commit is contained in:
parent
fb1225060e
commit
f8bc020aa7
@ -101,15 +101,18 @@ $OfficeList | ForEach-Object -parallel {
|
||||
# Write-Progress @CurentLoopProgress
|
||||
}
|
||||
elseif ($result.Length -ge 5) {
|
||||
$RefreshDays = -15
|
||||
|
||||
$Server = $_.FullName.Substring(1, 4) -replace (':|\\', '')
|
||||
$Path = $_.FullName.Replace("'", "`'") #SQL Formatted Path
|
||||
$Path = $Path.Replace("X:\", "\\mpe.ca\datadrive\")
|
||||
$projectnumber = $result.tostring()
|
||||
$DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy
|
||||
$Query = "Select Project FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";"
|
||||
$Query = "Select Project,fld_LastRefresh FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";"
|
||||
$sql_result = Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query
|
||||
|
||||
if (($sql_result.project -eq $null)) {
|
||||
|
||||
if (($sql_result.project -eq $null) -or ($sql_result.fld_LastRefresh -le (Get-Date).AddDays($RefreshDays).ToShortDateString())) {
|
||||
$CurentLoopProgress = @{
|
||||
ID = $JobID
|
||||
Activity = "Loading Telemetry for " + $_.FullName
|
||||
@ -118,6 +121,13 @@ $OfficeList | ForEach-Object -parallel {
|
||||
|
||||
Write-Progress @CurentLoopProgress
|
||||
|
||||
if ($sql_result.project -ne $null) {
|
||||
# found a record, but needs updating - delete old record from DB
|
||||
$Query = "Delete from FolderData WHERE '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`""
|
||||
Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
|
||||
$FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse
|
||||
@ -145,6 +155,7 @@ $OfficeList | ForEach-Object -parallel {
|
||||
FileLastAccess = $folder_LastAccess
|
||||
Status = $null # added to support Migration Status
|
||||
fld_MigrationID = $null
|
||||
fld_LastRefresh = (Get-Date).ToShortDateString()
|
||||
} | Out-DataTable
|
||||
|
||||
Invoke-SQLiteBulkCopy -DataSource $PathToDB_Copy -Table "FolderData" -DataTable $out -Force
|
||||
|
Loading…
Reference in New Issue
Block a user