diff --git a/Excel/prod/Cuisine.ps1 b/Excel/prod/Cuisine.ps1 new file mode 100644 index 0000000..f1c4b14 --- /dev/null +++ b/Excel/prod/Cuisine.ps1 @@ -0,0 +1,42 @@ +$source = "\\mj91.fr\PyCharm\Ratio_Inventaires\Excel\prod" +$dest = "C:\Users\$env:USERNAME\Domo91" + +$nomFichier = "Ratio_Cuisine.xlsm" +$nomVersion = "Ratio_Cuisine_VERSION.txt" + +$sourceXlsm = Join-Path $source $nomFichier +$sourceVersion = Join-Path $source $nomVersion + +$destXlsm = Join-Path $dest $nomFichier +$destVersion = Join-Path $dest $nomVersion + +if (!(Test-Path $dest)) { + New-Item -ItemType Directory -Path $dest -Force | Out-Null +} + +if (!(Test-Path $sourceVersion)) { + Add-Type -AssemblyName PresentationFramework + [System.Windows.MessageBox]::Show("Le dossier de mise à jour sur le NAS est inaccessible.", "Mise à jour Ratio Cuisine") + exit +} + +$versionServeur = (Get-Content $sourceVersion -ErrorAction Stop).Trim() + +if (Test-Path $destVersion) { + $versionLocale = (Get-Content $destVersion -ErrorAction SilentlyContinue).Trim() +} else { + $versionLocale = "" +} + +if ($versionServeur -ne $versionLocale) { + $excel = Get-Process EXCEL -ErrorAction SilentlyContinue + if ($excel) { + $excel | Stop-Process -Force + Start-Sleep -Seconds 2 + } + + Copy-Item -Path $sourceXlsm -Destination $destXlsm -Force + Copy-Item -Path $sourceVersion -Destination $destVersion -Force +} + +Start-Process $destXlsm \ No newline at end of file diff --git a/Excel/prod/Lancer_Ratio_Cuisine.bat b/Excel/prod/Lancer_Ratio_Cuisine.bat new file mode 100644 index 0000000..9c8be39 --- /dev/null +++ b/Excel/prod/Lancer_Ratio_Cuisine.bat @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy Bypass -File "%~dp0Maj_Ratio_Cuisine.ps1" \ No newline at end of file diff --git a/Excel/prod/Lancer_Ratio_Restauration.bat b/Excel/prod/Lancer_Ratio_Restauration.bat new file mode 100644 index 0000000..0289305 --- /dev/null +++ b/Excel/prod/Lancer_Ratio_Restauration.bat @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy Bypass -File "%~dp0Maj_Ratio_Restauration.ps1" \ No newline at end of file diff --git a/Excel/prod/Ratio_Cuisine.xlsm b/Excel/prod/Ratio_Cuisine.xlsm index 49f2dda..ce2c9e4 100644 Binary files a/Excel/prod/Ratio_Cuisine.xlsm and b/Excel/prod/Ratio_Cuisine.xlsm differ diff --git a/Excel/prod/Ratio_Restauration.xlsm b/Excel/prod/Ratio_Restauration.xlsm index 0f6966a..44c947a 100644 Binary files a/Excel/prod/Ratio_Restauration.xlsm and b/Excel/prod/Ratio_Restauration.xlsm differ diff --git a/Excel/prod/Restauration.ps1 b/Excel/prod/Restauration.ps1 new file mode 100644 index 0000000..3ddd3b7 --- /dev/null +++ b/Excel/prod/Restauration.ps1 @@ -0,0 +1,42 @@ +$source = "\\mj91.fr\PyCharm\Ratio_Inventaires\Excel\prod" +$dest = "C:\Users\$env:USERNAME\Domo91" + +$nomFichier = "Ratio_Restauration.xlsm" +$nomVersion = "Ratio_Restauration_VERSION.txt" + +$sourceXlsm = Join-Path $source $nomFichier +$sourceVersion = Join-Path $source $nomVersion + +$destXlsm = Join-Path $dest $nomFichier +$destVersion = Join-Path $dest $nomVersion + +if (!(Test-Path $dest)) { + New-Item -ItemType Directory -Path $dest -Force | Out-Null +} + +if (!(Test-Path $sourceVersion)) { + Add-Type -AssemblyName PresentationFramework + [System.Windows.MessageBox]::Show("Le dossier de mise à jour sur le NAS est inaccessible.", "Mise à jour Ratio Restauration") + exit +} + +$versionServeur = (Get-Content $sourceVersion -ErrorAction Stop).Trim() + +if (Test-Path $destVersion) { + $versionLocale = (Get-Content $destVersion -ErrorAction SilentlyContinue).Trim() +} else { + $versionLocale = "" +} + +if ($versionServeur -ne $versionLocale) { + $excel = Get-Process EXCEL -ErrorAction SilentlyContinue + if ($excel) { + $excel | Stop-Process -Force + Start-Sleep -Seconds 2 + } + + Copy-Item -Path $sourceXlsm -Destination $destXlsm -Force + Copy-Item -Path $sourceVersion -Destination $destVersion -Force +} + +Start-Process $destXlsm \ No newline at end of file