diff --git a/Compress.ps1 b/Compress.ps1 new file mode 100644 index 0000000..a8be0a2 --- /dev/null +++ b/Compress.ps1 @@ -0,0 +1,109 @@ +# تابع فشرده‌سازی فایل متنی +function Compress-File { + param( + [Parameter(Mandatory = $true, Position = 0)] + [string]$InputPath, + + [Parameter(Mandatory = $true)] + [string]$OutputPath, + + [ValidateSet("UTF8", "UTF16", "UTF32")] + [string]$Encoding = "UTF8" + ) + + # بررسی وجود فایل ورودی + if (-not (Test-Path -Path $InputPath)) { + Write-Error "فایل ورودی یافت نشد: $InputPath" + return + } + + # خواندن محتوای فایل + Write-Host "در حال خواندن فایل: $InputPath..." -ForegroundColor Cyan + $rawContent = Get-Content -Path $InputPath -Raw -Encoding $Encoding + + Write-Host "حجم فایل اصلی: $([math]::Round((($rawContent.Length) / 1KB), 2)) KB" -ForegroundColor Yellow + + # تبدیل رشته به بایت + $bytes = [System.Text.Encoding]::UTF8.GetBytes($rawContent) + + # ایجاد جریان‌های حافظه برای فشرده‌سازی + $memoryStream = New-Object System.IO.MemoryStream + $gzipStream = New-Object System.IO.Compression.GzipStream($memoryStream, [System.IO.Compression.CompressionMode]::Compress) + + try { + # نوشتن و فشرده‌سازی + $gzipStream.Write($bytes, 0, $bytes.Length) + $gzipStream.Flush() + + # خواندن داده‌های فشرده شده + $memoryStream.Position = 0 + $compressedBytes = $memoryStream.ToArray() + + # تبدیل به Base64 + $base64Output = [Convert]::ToBase64String($compressedBytes) + + # نوشتن خروجی در فایل جدید + Write-Host "در حال نوشتن خروجی به: $OutputPath..." -ForegroundColor Cyan + Set-Content -Path $OutputPath -Value $base64Output -Encoding UTF8 + + # نمایش آمار فشرده‌سازی + $compressionRatio = ($compressedBytes.Length / $bytes.Length) * 100 + + Write-Host "" + Write-Host "=============================================" -ForegroundColor Green + Write-Host " گزارش فشرده‌سازی" -ForegroundColor Green + Write-Host "=============================================" -ForegroundColor Green + Write-Host "فایل اصلی: $InputPath" -ForegroundColor Gray + Write-Host "فایل خروجی: $OutputPath" -ForegroundColor Gray + Write-Host "حجم اصلی: $([math]::Round($bytes.Length / 1KB, 2)) KB" -ForegroundColor Gray + Write-Host "حجم فشرده: $([math]::Round($compressedBytes.Length / 1KB, 2)) KB" -ForegroundColor Gray + Write-Host "نسبت فشرده: $([math]::Round($compressionRatio, 2))%" -ForegroundColor Gray + Write-Host "=============================================" -ForegroundColor Green + + } + finally { + if ($gzipStream) { $gzipStream.Dispose() } + if ($memoryStream) { $memoryStream.Dispose() } + } +} + +# --- اجرای اسکریپت با ورودی از خط فرمان --- + +# اگر کاربر ورودی نداده باشد، راهنما نمایش داده شود +if (-not $args[0]) { + Write-Host "=============================================" -ForegroundColor Cyan + Write-Host " اسکریپت فشرده‌سازی فایل‌های متنی" -ForegroundColor Cyan + Write-Host "=============================================" -ForegroundColor Cyan + Write-Host "نحوه استفاده:" + Write-Host " .\Compress.ps1 -InputPath 'پاتhto_file.txt' -OutputPath 'output_Compressed.txt'" + Write-Host "" + Write-Host "مثال:" + Write-Host " .\Compress.ps1 -InputPath 'C:\Data\article.txt' -OutputPath 'C:\Data\article_Compressed.txt'" + Write-Host "" + exit 0 +} + +# دریافت پارامترها از خط فرمان +$InputPath = $args[0] +$OutputPath = $args[1] + +# اعتبارسنجی پارامترها +if (-not (Test-Path -Path $InputPath)) { + Write-Error "فایل ورودی وجود ندارد: $InputPath" + exit 1 +} + +# اگر خروجی مشخص نشده، پیش‌فرض ایجاد کن +if (-not $OutputPath) { + $OutputPath = [System.IO.Path]::ChangeExtension($InputPath, "_Compressed.txt") + Write-Host "خروجی پیش‌فرض: $OutputPath" -ForegroundColor Yellow +} + +# اجرای تابع +try { + Compress-File -InputPath $InputPath -OutputPath $OutputPath +} +catch { + Write-Error "خطا در پردازش فایل: $_" + exit 1 +} diff --git a/Documents/Boards/xDashboard.kanban b/Documents/Boards/xDashboard.kanban index a2823f9..e85223e 100644 --- a/Documents/Boards/xDashboard.kanban +++ b/Documents/Boards/xDashboard.kanban @@ -539,6 +539,63 @@ "labels": [], "checkboxes": [], "comments": [] + }, + { + "id": "5d103817-846f-477f-a381-50e86c3cc7d4", + "listId": "1706107f-ace2-4240-aa32-3d2031264a41", + "title": "Adding State Management Actions in AI Services ...", + "description": "", + "labels": [], + "checkboxes": [ + { + "id": "18ec2658-7924-4a19-83d2-e0bf99a4c402", + "title": "Projects", + "checked": false + }, + { + "id": "cae40bd2-c3b5-42ca-9156-5b77abb41719", + "title": "Conversations", + "checked": false + }, + { + "id": "3261fcc6-7b2e-466d-b5ab-08b061dbdd18", + "title": "Mechanism of Base Handling ", + "checked": false + }, + { + "id": "d055d603-aab1-4a5a-805c-746f9d13549b", + "title": "Base Controller Implementation", + "checked": false + } + ], + "comments": [] + }, + { + "id": "17bbcc83-4330-4631-a08a-521c99047ebc", + "listId": "1706107f-ace2-4240-aa32-3d2031264a41", + "title": "Try to Implement Audio, Video and Document Content Extraction in XAi Service ...", + "description": "", + "labels": [], + "checkboxes": [], + "comments": [] + }, + { + "id": "7785aecc-0b27-4428-a50b-03c046c5a0d6", + "listId": "1706107f-ace2-4240-aa32-3d2031264a41", + "title": "R&D about MCP Servers and how i can Use them ?", + "description": "", + "labels": [], + "checkboxes": [], + "comments": [] + }, + { + "id": "5f8a8b2f-06ce-46a9-8101-f14e34b51249", + "listId": "1706107f-ace2-4240-aa32-3d2031264a41", + "title": "implement Api Key Mechanism using IDServer and Clients sides ...", + "description": "", + "labels": [], + "checkboxes": [], + "comments": [] } ] },