Compare commits
42 Commits
Feature/pr
...
Feature/ge
| Author | SHA1 | Date | |
|---|---|---|---|
| fb3375d010 | |||
| bac19b0bb2 | |||
| 1b4a380cc9 | |||
| b16261928c | |||
| cfceb2877f | |||
| 5a244ed35e | |||
| 42008d3c4d | |||
| 387682aedb | |||
| 577acfd0ae | |||
| 04cb584ae3 | |||
| f6cddff59d | |||
| 7b09cc53c3 | |||
| a7d3ff5298 | |||
| 8ecbbf6975 | |||
| 3720288bed | |||
| 4f400ccef0 | |||
| d777fad96b | |||
| fb7b04596c | |||
| 76d2c0e3c4 | |||
| a745dfff86 | |||
| 9bca1b81d6 | |||
| 9ff6b5cf56 | |||
|
|
04642b7257 | ||
| c1c9fe51cb | |||
|
|
0d2ac58bbb | ||
| 43ccb3a1dd | |||
| 0134111aba | |||
|
|
3cc7adae35 | ||
|
|
c97ea5356f | ||
| 69f4819bf6 | |||
|
|
1257e15b62 | ||
|
|
331fb24a99 | ||
| 3be1547137 | |||
| 900b4b3f4d | |||
| bdc6f95af8 | |||
| 7a73e69afa | |||
|
|
21302803b6 | ||
| b7172630e2 | |||
| 0604514190 | |||
| ff5180eb75 | |||
| a1c9335487 | |||
| 20ece4886c |
64
.gitea/workflows/deploy-dev.yml
Normal file
64
.gitea/workflows/deploy-dev.yml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: Deploy Dev (Branch Trigger)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- Feature/general/docker
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: gozareshgir-api
|
||||||
|
# مسیری که فایل docker-compose.yml مخصوص تست در سرور قرار دارد
|
||||||
|
SERVER_PATH: ~/apps/test-dev/backend-api
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# 1. لاگین به داکر هاب/رجیستری شخصی
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
# 2. بیلد و پوش کردن ایمیج با تگ :dev
|
||||||
|
- name: Build and Push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:dev
|
||||||
|
|
||||||
|
# 3. اتصال به سرور و آپدیت سرویس
|
||||||
|
- name: Update Service on Test Server
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
env:
|
||||||
|
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
|
||||||
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
APP_VERSION: dev # ورژن تست همیشه dev است
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SSH_HOST_TEST }}
|
||||||
|
username: ${{ secrets.SSH_USERNAME_TEST }}
|
||||||
|
key: ${{ secrets.SSH_KEY_TEST }}
|
||||||
|
port: 22
|
||||||
|
envs: DOCKER_REGISTRY,DOCKER_USERNAME,DOCKER_PASSWORD,APP_VERSION
|
||||||
|
script: |
|
||||||
|
cd ${{ env.SERVER_PATH }}
|
||||||
|
|
||||||
|
# لاگین مجدد در سرور برای اطمینان
|
||||||
|
echo "$DOCKER_PASSWORD" | docker login $DOCKER_REGISTRY -u $DOCKER_USERNAME --password-stdin
|
||||||
|
|
||||||
|
# اکسپورت کردن ورژن برای اینکه فایل داکر-کمپوز سرور آن را بشناسد
|
||||||
|
export APP_VERSION=$APP_VERSION
|
||||||
|
|
||||||
|
# دانلود ایمیج جدید و آپدیت کانتینر
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d --remove-orphans
|
||||||
|
|
||||||
|
# پاک کردن ایمیجهای قدیمی برای پر نشدن فضای سرور
|
||||||
|
docker image prune -f
|
||||||
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,3 +1,21 @@
|
|||||||
|
.env*
|
||||||
|
.env
|
||||||
|
certs/*.pfx
|
||||||
|
certs/*.pem
|
||||||
|
certs/*.key
|
||||||
|
certs/*.crt
|
||||||
|
Storage/
|
||||||
|
Logs/
|
||||||
|
*.user
|
||||||
|
*.suo
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
certs/*.pfx
|
||||||
|
certs/*.pem
|
||||||
|
certs/*.key
|
||||||
|
certs/*.crt
|
||||||
|
Storage/
|
||||||
|
Logs/
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using _0_Framework.Application;
|
|||||||
using _0_Framework.Application.FaceEmbedding;
|
using _0_Framework.Application.FaceEmbedding;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Http;
|
using Microsoft.Extensions.Http;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace _0_Framework.Infrastructure;
|
namespace _0_Framework.Infrastructure;
|
||||||
@@ -24,12 +25,12 @@ public class FaceEmbeddingService : IFaceEmbeddingService
|
|||||||
private readonly string _apiBaseUrl;
|
private readonly string _apiBaseUrl;
|
||||||
|
|
||||||
public FaceEmbeddingService(IHttpClientFactory httpClientFactory, ILogger<FaceEmbeddingService> logger,
|
public FaceEmbeddingService(IHttpClientFactory httpClientFactory, ILogger<FaceEmbeddingService> logger,
|
||||||
IFaceEmbeddingNotificationService notificationService = null)
|
IConfiguration configuration, IFaceEmbeddingNotificationService notificationService = null)
|
||||||
{
|
{
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_notificationService = notificationService;
|
_notificationService = notificationService;
|
||||||
_apiBaseUrl = "http://localhost:8000";
|
_apiBaseUrl = configuration["FaceEmbeddingApi:BaseUrl"] ?? "http://localhost:8000";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResult> GenerateEmbeddingsAsync(long employeeId, long workshopId,
|
public async Task<OperationResult> GenerateEmbeddingsAsync(long employeeId, long workshopId,
|
||||||
|
|||||||
@@ -1,624 +0,0 @@
|
|||||||
# راهنمای اتصال اپلیکیشن Android به SignalR برای Face Embedding
|
|
||||||
|
|
||||||
## 1. افزودن کتابخانه SignalR به پروژه Android
|
|
||||||
|
|
||||||
در فایل `build.gradle` (Module: app) خود، dependency زیر را اضافه کنید:
|
|
||||||
|
|
||||||
```gradle
|
|
||||||
dependencies {
|
|
||||||
// SignalR for Android
|
|
||||||
implementation 'com.microsoft.signalr:signalr:7.0.0'
|
|
||||||
|
|
||||||
// اگر از Kotlin استفاده میکنید:
|
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
|
|
||||||
|
|
||||||
// برای JSON پردازش:
|
|
||||||
implementation 'com.google.code.gson:gson:2.10.1'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 2. اضافه کردن Permission در AndroidManifest.xml
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
```
|
|
||||||
|
|
||||||
## 3. کد Java/Kotlin برای اتصال به SignalR
|
|
||||||
|
|
||||||
### نسخه Java:
|
|
||||||
|
|
||||||
```java
|
|
||||||
import com.microsoft.signalr.HubConnection;
|
|
||||||
import com.microsoft.signalr.HubConnectionBuilder;
|
|
||||||
import com.microsoft.signalr.HubConnectionState;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class FaceEmbeddingSignalRClient {
|
|
||||||
private static final String TAG = "FaceEmbeddingHub";
|
|
||||||
private HubConnection hubConnection;
|
|
||||||
private String serverUrl = "http://YOUR_SERVER_IP:PORT/trackingFaceEmbeddingHub"; // آدرس سرور خود را وارد کنید
|
|
||||||
private long workshopId;
|
|
||||||
|
|
||||||
public FaceEmbeddingSignalRClient(long workshopId) {
|
|
||||||
this.workshopId = workshopId;
|
|
||||||
initializeSignalR();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeSignalR() {
|
|
||||||
// ایجاد اتصال SignalR
|
|
||||||
hubConnection = HubConnectionBuilder
|
|
||||||
.create(serverUrl)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// دریافت رویداد ایجاد Embedding
|
|
||||||
hubConnection.on("EmbeddingCreated", (data) -> {
|
|
||||||
JsonObject jsonData = (JsonObject) data;
|
|
||||||
long employeeId = jsonData.get("employeeId").getAsLong();
|
|
||||||
String employeeFullName = jsonData.get("employeeFullName").getAsString();
|
|
||||||
String timestamp = jsonData.get("timestamp").getAsString();
|
|
||||||
|
|
||||||
Log.d(TAG, "Embedding Created - Employee: " + employeeFullName + " (ID: " + employeeId + ")");
|
|
||||||
|
|
||||||
// اینجا میتوانید دادههای جدید را از سرور بگیرید یا UI را بروزرسانی کنید
|
|
||||||
onEmbeddingCreated(employeeId, employeeFullName, timestamp);
|
|
||||||
|
|
||||||
}, JsonObject.class);
|
|
||||||
|
|
||||||
// دریافت رویداد حذف Embedding
|
|
||||||
hubConnection.on("EmbeddingDeleted", (data) -> {
|
|
||||||
JsonObject jsonData = (JsonObject) data;
|
|
||||||
long employeeId = jsonData.get("employeeId").getAsLong();
|
|
||||||
String timestamp = jsonData.get("timestamp").getAsString();
|
|
||||||
|
|
||||||
Log.d(TAG, "Embedding Deleted - Employee ID: " + employeeId);
|
|
||||||
onEmbeddingDeleted(employeeId, timestamp);
|
|
||||||
|
|
||||||
}, JsonObject.class);
|
|
||||||
|
|
||||||
// دریافت رویداد بهبود Embedding
|
|
||||||
hubConnection.on("EmbeddingRefined", (data) -> {
|
|
||||||
JsonObject jsonData = (JsonObject) data;
|
|
||||||
long employeeId = jsonData.get("employeeId").getAsLong();
|
|
||||||
String timestamp = jsonData.get("timestamp").getAsString();
|
|
||||||
|
|
||||||
Log.d(TAG, "Embedding Refined - Employee ID: " + employeeId);
|
|
||||||
onEmbeddingRefined(employeeId, timestamp);
|
|
||||||
|
|
||||||
}, JsonObject.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void connect() {
|
|
||||||
if (hubConnection.getConnectionState() == HubConnectionState.DISCONNECTED) {
|
|
||||||
hubConnection.start()
|
|
||||||
.doOnComplete(() -> {
|
|
||||||
Log.d(TAG, "Connected to SignalR Hub");
|
|
||||||
joinWorkshopGroup();
|
|
||||||
})
|
|
||||||
.doOnError(error -> {
|
|
||||||
Log.e(TAG, "Error connecting to SignalR: " + error.getMessage());
|
|
||||||
})
|
|
||||||
.subscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void joinWorkshopGroup() {
|
|
||||||
// عضویت در گروه مخصوص این کارگاه
|
|
||||||
hubConnection.send("JoinWorkshopGroup", workshopId);
|
|
||||||
Log.d(TAG, "Joined workshop group: " + workshopId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disconnect() {
|
|
||||||
if (hubConnection.getConnectionState() == HubConnectionState.CONNECTED) {
|
|
||||||
// خروج از گروه
|
|
||||||
hubConnection.send("LeaveWorkshopGroup", workshopId);
|
|
||||||
|
|
||||||
hubConnection.stop();
|
|
||||||
Log.d(TAG, "Disconnected from SignalR Hub");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// این متدها را در Activity/Fragment خود override کنید
|
|
||||||
protected void onEmbeddingCreated(long employeeId, String employeeFullName, String timestamp) {
|
|
||||||
// اینجا UI را بروزرسانی کنید یا داده جدید را بگیرید
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onEmbeddingDeleted(long employeeId, String timestamp) {
|
|
||||||
// اینجا UI را بروزرسانی کنید
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onEmbeddingRefined(long employeeId, String timestamp) {
|
|
||||||
// اینجا UI را بروزرسانی کنید
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### نسخه Kotlin:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
import com.microsoft.signalr.HubConnection
|
|
||||||
import com.microsoft.signalr.HubConnectionBuilder
|
|
||||||
import com.microsoft.signalr.HubConnectionState
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import android.util.Log
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
class FaceEmbeddingSignalRClient(private val workshopId: Long) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "FaceEmbeddingHub"
|
|
||||||
}
|
|
||||||
|
|
||||||
private lateinit var hubConnection: HubConnection
|
|
||||||
private val serverUrl = "http://YOUR_SERVER_IP:PORT/trackingFaceEmbeddingHub" // آدرس سرور خود را وارد کنید
|
|
||||||
|
|
||||||
init {
|
|
||||||
initializeSignalR()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initializeSignalR() {
|
|
||||||
hubConnection = HubConnectionBuilder
|
|
||||||
.create(serverUrl)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
// دریافت رویداد ایجاد Embedding
|
|
||||||
hubConnection.on("EmbeddingCreated", { data: JsonObject ->
|
|
||||||
val employeeId = data.get("employeeId").asLong
|
|
||||||
val employeeFullName = data.get("employeeFullName").asString
|
|
||||||
val timestamp = data.get("timestamp").asString
|
|
||||||
|
|
||||||
Log.d(TAG, "Embedding Created - Employee: $employeeFullName (ID: $employeeId)")
|
|
||||||
onEmbeddingCreated(employeeId, employeeFullName, timestamp)
|
|
||||||
}, JsonObject::class.java)
|
|
||||||
|
|
||||||
// دریافت رویداد حذف Embedding
|
|
||||||
hubConnection.on("EmbeddingDeleted", { data: JsonObject ->
|
|
||||||
val employeeId = data.get("employeeId").asLong
|
|
||||||
val timestamp = data.get("timestamp").asString
|
|
||||||
|
|
||||||
Log.d(TAG, "Embedding Deleted - Employee ID: $employeeId")
|
|
||||||
onEmbeddingDeleted(employeeId, timestamp)
|
|
||||||
}, JsonObject::class.java)
|
|
||||||
|
|
||||||
// دریافت رویداد بهبود Embedding
|
|
||||||
hubConnection.on("EmbeddingRefined", { data: JsonObject ->
|
|
||||||
val employeeId = data.get("employeeId").asLong
|
|
||||||
val timestamp = data.get("timestamp").asString
|
|
||||||
|
|
||||||
Log.d(TAG, "Embedding Refined - Employee ID: $employeeId")
|
|
||||||
onEmbeddingRefined(employeeId, timestamp)
|
|
||||||
}, JsonObject::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun connect() {
|
|
||||||
if (hubConnection.connectionState == HubConnectionState.DISCONNECTED) {
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
try {
|
|
||||||
hubConnection.start().blockingAwait()
|
|
||||||
Log.d(TAG, "Connected to SignalR Hub")
|
|
||||||
joinWorkshopGroup()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Error connecting to SignalR: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun joinWorkshopGroup() {
|
|
||||||
hubConnection.send("JoinWorkshopGroup", workshopId)
|
|
||||||
Log.d(TAG, "Joined workshop group: $workshopId")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun disconnect() {
|
|
||||||
if (hubConnection.connectionState == HubConnectionState.CONNECTED) {
|
|
||||||
hubConnection.send("LeaveWorkshopGroup", workshopId)
|
|
||||||
hubConnection.stop()
|
|
||||||
Log.d(TAG, "Disconnected from SignalR Hub")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// این متدها را override کنید
|
|
||||||
open fun onEmbeddingCreated(employeeId: Long, employeeFullName: String, timestamp: String) {
|
|
||||||
// اینجا UI را بروزرسانی کنید یا داده جدید را بگیرید
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun onEmbeddingDeleted(employeeId: Long, timestamp: String) {
|
|
||||||
// اینجا UI را بروزرسانی کنید
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun onEmbeddingRefined(employeeId: Long, timestamp: String) {
|
|
||||||
// اینجا UI را بروزرسانی کنید
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 4. استفاده در Activity یا Fragment
|
|
||||||
|
|
||||||
### مثال با Login و دریافت WorkshopId
|
|
||||||
|
|
||||||
#### Java:
|
|
||||||
```java
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_login);
|
|
||||||
|
|
||||||
Button btnLogin = findViewById(R.id.btnLogin);
|
|
||||||
btnLogin.setOnClickListener(v -> performLogin());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void performLogin() {
|
|
||||||
// فراخوانی API لاگین
|
|
||||||
// فرض کنید response شامل workshopId است
|
|
||||||
|
|
||||||
// مثال ساده (باید از Retrofit یا کتابخانه مشابه استفاده کنید):
|
|
||||||
// LoginResponse response = apiService.login(username, password);
|
|
||||||
// long workshopId = response.getWorkshopId();
|
|
||||||
|
|
||||||
long workshopId = 123; // این را از response دریافت کنید
|
|
||||||
|
|
||||||
// ذخیره workshopId
|
|
||||||
SharedPreferences prefs = getSharedPreferences("AppPrefs", MODE_PRIVATE);
|
|
||||||
prefs.edit().putLong("workshopId", workshopId).apply();
|
|
||||||
|
|
||||||
// رفتن به صفحه اصلی
|
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
private FaceEmbeddingSignalRClient signalRClient;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
// دریافت workshopId از SharedPreferences
|
|
||||||
SharedPreferences prefs = getSharedPreferences("AppPrefs", MODE_PRIVATE);
|
|
||||||
long workshopId = prefs.getLong("workshopId", 0);
|
|
||||||
|
|
||||||
if (workshopId == 0) {
|
|
||||||
// اگر workshopId وجود نداره، برگرد به صفحه لاگین
|
|
||||||
Intent intent = new Intent(this, LoginActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ایجاد و اتصال SignalR
|
|
||||||
signalRClient = new FaceEmbeddingSignalRClient(workshopId) {
|
|
||||||
@Override
|
|
||||||
protected void onEmbeddingCreated(long employeeId, String employeeFullName, String timestamp) {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
// بروزرسانی UI
|
|
||||||
Toast.makeText(MainActivity.this,
|
|
||||||
"Embedding ایجاد شد برای: " + employeeFullName,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
// دریافت دادههای جدید از API
|
|
||||||
refreshEmployeeList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onEmbeddingDeleted(long employeeId, String timestamp) {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
// بروزرسانی UI
|
|
||||||
refreshEmployeeList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onEmbeddingRefined(long employeeId, String timestamp) {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
// بروزرسانی UI
|
|
||||||
refreshEmployeeList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
signalRClient.connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (signalRClient != null) {
|
|
||||||
signalRClient.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshEmployeeList() {
|
|
||||||
// دریافت لیست جدید کارمندان از API
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Kotlin:
|
|
||||||
```kotlin
|
|
||||||
class LoginActivity : AppCompatActivity() {
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_login)
|
|
||||||
|
|
||||||
val btnLogin = findViewById<Button>(R.id.btnLogin)
|
|
||||||
btnLogin.setOnClickListener { performLogin() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performLogin() {
|
|
||||||
// فراخوانی API لاگین
|
|
||||||
// فرض کنید response شامل workshopId است
|
|
||||||
|
|
||||||
// مثال ساده (باید از Retrofit یا کتابخانه مشابه استفاده کنید):
|
|
||||||
// val response = apiService.login(username, password)
|
|
||||||
// val workshopId = response.workshopId
|
|
||||||
|
|
||||||
val workshopId = 123L // این را از response دریافت کنید
|
|
||||||
|
|
||||||
// ذخیره workshopId
|
|
||||||
val prefs = getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
|
||||||
prefs.edit().putLong("workshopId", workshopId).apply()
|
|
||||||
|
|
||||||
// رفتن به صفحه اصلی
|
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
|
||||||
private lateinit var signalRClient: FaceEmbeddingSignalRClient
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_main)
|
|
||||||
|
|
||||||
// دریافت workshopId از SharedPreferences
|
|
||||||
val prefs = getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
|
||||||
val workshopId = prefs.getLong("workshopId", 0L)
|
|
||||||
|
|
||||||
if (workshopId == 0L) {
|
|
||||||
// اگر workshopId وجود نداره، برگرد به صفحه لاگین
|
|
||||||
val intent = Intent(this, LoginActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// ایجاد و اتصال SignalR
|
|
||||||
signalRClient = object : FaceEmbeddingSignalRClient(workshopId) {
|
|
||||||
override fun onEmbeddingCreated(employeeId: Long, employeeFullName: String, timestamp: String) {
|
|
||||||
runOnUiThread {
|
|
||||||
// بروزرسانی UI
|
|
||||||
Toast.makeText(this@MainActivity,
|
|
||||||
"Embedding ایجاد شد برای: $employeeFullName",
|
|
||||||
Toast.LENGTH_SHORT).show()
|
|
||||||
|
|
||||||
// دریافت دادههای جدید از API
|
|
||||||
refreshEmployeeList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onEmbeddingDeleted(employeeId: Long, timestamp: String) {
|
|
||||||
runOnUiThread {
|
|
||||||
// بروزرسانی UI
|
|
||||||
refreshEmployeeList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onEmbeddingRefined(employeeId: Long, timestamp: String) {
|
|
||||||
runOnUiThread {
|
|
||||||
// بروزرسانی UI
|
|
||||||
refreshEmployeeList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signalRClient.connect()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
signalRClient.disconnect()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun refreshEmployeeList() {
|
|
||||||
// دریافت لیست جدید کارمندان از API
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### مثال ساده بدون Login:
|
|
||||||
اگر workshopId را از قبل میدانید:
|
|
||||||
|
|
||||||
#### Java:
|
|
||||||
```java
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
private FaceEmbeddingSignalRClient signalRClient;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
long workshopId = 123; // شناسه کارگاه خود را وارد کنید
|
|
||||||
|
|
||||||
signalRClient = new FaceEmbeddingSignalRClient(workshopId) {
|
|
||||||
@Override
|
|
||||||
protected void onEmbeddingCreated(long employeeId, String employeeFullName, String timestamp) {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
// بروزرسانی UI
|
|
||||||
Toast.makeText(MainActivity.this,
|
|
||||||
"Embedding ایجاد شد برای: " + employeeFullName,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
// دریافت دادههای جدید از API
|
|
||||||
refreshEmployeeList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onEmbeddingDeleted(long employeeId, String timestamp) {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
// بروزرسانی UI
|
|
||||||
refreshEmployeeList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
signalRClient.connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (signalRClient != null) {
|
|
||||||
signalRClient.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshEmployeeList() {
|
|
||||||
// دریافت لیست جدید کارمندان از API
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Kotlin:
|
|
||||||
```kotlin
|
|
||||||
class MainActivity : AppCompatActivity() {
|
|
||||||
private lateinit var signalRClient: FaceEmbeddingSignalRClient
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_main)
|
|
||||||
|
|
||||||
val workshopId = 123L // شناسه کارگاه خود را وارد کنید
|
|
||||||
|
|
||||||
signalRClient = object : FaceEmbeddingSignalRClient(workshopId) {
|
|
||||||
override fun onEmbeddingCreated(employeeId: Long, employeeFullName: String, timestamp: String) {
|
|
||||||
runOnUiThread {
|
|
||||||
// بروزرسانی UI
|
|
||||||
Toast.makeText(this@MainActivity,
|
|
||||||
"Embedding ایجاد شد برای: $employeeFullName",
|
|
||||||
Toast.LENGTH_SHORT).show()
|
|
||||||
|
|
||||||
// دریافت دادههای جدید از API
|
|
||||||
refreshEmployeeList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onEmbeddingDeleted(employeeId: Long, timestamp: String) {
|
|
||||||
runOnUiThread {
|
|
||||||
// بروزرسانی UI
|
|
||||||
refreshEmployeeList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signalRClient.connect()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
signalRClient.disconnect()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun refreshEmployeeList() {
|
|
||||||
// دریافت لیست جدید کارمندان از API
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 5. نکات مهم
|
|
||||||
|
|
||||||
### آدرس سرور
|
|
||||||
- اگر روی شبیهساز اندروید تست میکنید و سرور روی localhost اجرا میشود، از آدرس `http://10.0.2.2:PORT` استفاده کنید
|
|
||||||
- اگر روی دستگاه فیزیکی تست میکنید، از آدرس IP شبکه محلی سرور استفاده کنید (مثل `http://192.168.1.100:PORT`)
|
|
||||||
- PORT پیشفرض معمولاً 5000 یا 5001 است (بسته به کانفیگ پروژه شما)
|
|
||||||
|
|
||||||
### دریافت WorkshopId از Login
|
|
||||||
بعد از login موفق، workshopId را از سرور دریافت کنید و در SharedPreferences یا یک Singleton ذخیره کنید:
|
|
||||||
|
|
||||||
```java
|
|
||||||
// بعد از login موفق
|
|
||||||
SharedPreferences prefs = getSharedPreferences("AppPrefs", MODE_PRIVATE);
|
|
||||||
prefs.edit().putLong("workshopId", workshopId).apply();
|
|
||||||
|
|
||||||
// استفاده در Activity
|
|
||||||
long workshopId = prefs.getLong("workshopId", 0);
|
|
||||||
```
|
|
||||||
|
|
||||||
یا در Kotlin:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
// بعد از login موفق
|
|
||||||
val prefs = getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
|
||||||
prefs.edit().putLong("workshopId", workshopId).apply()
|
|
||||||
|
|
||||||
// استفاده در Activity
|
|
||||||
val workshopId = prefs.getLong("workshopId", 0L)
|
|
||||||
```
|
|
||||||
|
|
||||||
### مدیریت اتصال
|
|
||||||
برای reconnection خودکار:
|
|
||||||
|
|
||||||
```java
|
|
||||||
hubConnection.onClosed(exception -> {
|
|
||||||
Log.e(TAG, "Connection closed. Attempting to reconnect...");
|
|
||||||
new Handler().postDelayed(() -> connect(), 5000); // تلاش مجدد بعد از 5 ثانیه
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### Thread Safety
|
|
||||||
همیشه UI updates را در main thread انجام دهید:
|
|
||||||
|
|
||||||
```java
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
// UI updates here
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## 6. تست اتصال
|
|
||||||
|
|
||||||
برای تست میتوانید:
|
|
||||||
1. اپلیکیشن را اجرا کنید
|
|
||||||
2. از طریق Postman یا Swagger یک Embedding ایجاد کنید
|
|
||||||
3. باید در Logcat پیام "Embedding Created" را ببینید
|
|
||||||
|
|
||||||
## 7. خطایابی (Debugging)
|
|
||||||
|
|
||||||
برای دیدن جزئیات بیشتر:
|
|
||||||
|
|
||||||
```java
|
|
||||||
hubConnection = HubConnectionBuilder
|
|
||||||
.create(serverUrl)
|
|
||||||
.withHttpConnectionOptions(options -> {
|
|
||||||
options.setLogging(LogLevel.TRACE);
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## خلاصه Endpoints
|
|
||||||
|
|
||||||
| نوع رویداد | متد SignalR | پارامترهای دریافتی |
|
|
||||||
|-----------|-------------|---------------------|
|
|
||||||
| ایجاد Embedding | `EmbeddingCreated` | workshopId, employeeId, employeeFullName, timestamp |
|
|
||||||
| حذف Embedding | `EmbeddingDeleted` | workshopId, employeeId, timestamp |
|
|
||||||
| بهبود Embedding | `EmbeddingRefined` | workshopId, employeeId, timestamp |
|
|
||||||
|
|
||||||
| متد ارسالی | پارامتر | توضیحات |
|
|
||||||
|-----------|---------|---------|
|
|
||||||
| `JoinWorkshopGroup` | workshopId | عضویت در گروه کارگاه |
|
|
||||||
| `LeaveWorkshopGroup` | workshopId | خروج از گروه کارگاه |
|
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<NuGetAudit>false</NuGetAudit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,175 +0,0 @@
|
|||||||
# سیستم گزارش خرابی (Bug Report System)
|
|
||||||
|
|
||||||
## نمای کلی
|
|
||||||
|
|
||||||
این سیستم برای جمعآوری، ذخیره و مدیریت گزارشهای خرابی از تطبیق موبایلی طراحی شده است.
|
|
||||||
|
|
||||||
## ساختار فایلها
|
|
||||||
|
|
||||||
### Domain Layer
|
|
||||||
- `AccountManagement.Domain/BugReportAgg/`
|
|
||||||
- `BugReport.cs` - موجودیت اصلی
|
|
||||||
- `BugReportLog.cs` - لاگهای گزارش
|
|
||||||
- `BugReportScreenshot.cs` - تصاویر ضمیمه شده
|
|
||||||
|
|
||||||
### Application Contracts
|
|
||||||
- `AccountManagement.Application.Contracts/BugReport/`
|
|
||||||
- `IBugReportApplication.cs` - اینترفیس سرویس
|
|
||||||
- `CreateBugReportCommand.cs` - درخواست ایجاد
|
|
||||||
- `EditBugReportCommand.cs` - درخواست ویرایش
|
|
||||||
- `BugReportViewModel.cs` - نمایش لیست
|
|
||||||
- `BugReportDetailViewModel.cs` - نمایش جزئیات
|
|
||||||
- `IBugReportRepository.cs` - اینترفیس Repository
|
|
||||||
|
|
||||||
### Application Service
|
|
||||||
- `AccountManagement.Application/BugReportApplication.cs` - پیادهسازی سرویس
|
|
||||||
|
|
||||||
### Infrastructure
|
|
||||||
- `AccountMangement.Infrastructure.EFCore/`
|
|
||||||
- `Mappings/BugReportMapping.cs`
|
|
||||||
- `Mappings/BugReportLogMapping.cs`
|
|
||||||
- `Mappings/BugReportScreenshotMapping.cs`
|
|
||||||
- `Repository/BugReportRepository.cs`
|
|
||||||
|
|
||||||
### API Controller
|
|
||||||
- `ServiceHost/Controllers/BugReportController.cs`
|
|
||||||
|
|
||||||
### Admin Pages
|
|
||||||
- `ServiceHost/Areas/AdminNew/Pages/BugReport/`
|
|
||||||
- `BugReportPageModel.cs` - base model
|
|
||||||
- `Index.cshtml.cs / Index.cshtml` - لیست گزارشها
|
|
||||||
- `Details.cshtml.cs / Details.cshtml` - جزئیات کامل
|
|
||||||
- `Edit.cshtml.cs / Edit.cshtml` - ویرایش وضعیت/اولویت
|
|
||||||
- `Delete.cshtml.cs / Delete.cshtml` - حذف
|
|
||||||
|
|
||||||
## روش استفاده
|
|
||||||
|
|
||||||
### 1. ثبت گزارش از موبایل
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
POST /api/bugreport/submit
|
|
||||||
|
|
||||||
{
|
|
||||||
"title": "برنامه هنگام ورود خراب میشود",
|
|
||||||
"description": "هنگام وارد کردن نام کاربری، برنامه کرش میکند",
|
|
||||||
"userEmail": "user@example.com",
|
|
||||||
"deviceModel": "Samsung Galaxy S21",
|
|
||||||
"osVersion": "Android 12",
|
|
||||||
"platform": "Android",
|
|
||||||
"manufacturer": "Samsung",
|
|
||||||
"deviceId": "device-unique-id",
|
|
||||||
"screenResolution": "1440x3200",
|
|
||||||
"memoryInMB": 8000,
|
|
||||||
"storageInMB": 256000,
|
|
||||||
"batteryLevel": 75,
|
|
||||||
"isCharging": false,
|
|
||||||
"networkType": "4G",
|
|
||||||
"appVersion": "1.0.0",
|
|
||||||
"buildNumber": "100",
|
|
||||||
"packageName": "com.example.app",
|
|
||||||
"installTime": "2024-01-01T10:00:00Z",
|
|
||||||
"lastUpdateTime": "2024-12-01T14:30:00Z",
|
|
||||||
"flavor": "production",
|
|
||||||
"type": 1, // Crash = 1
|
|
||||||
"priority": 2, // High = 2
|
|
||||||
"stackTrace": "...",
|
|
||||||
"logs": ["log1", "log2"],
|
|
||||||
"screenshots": ["base64-encoded-image-1"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. دسترسی به Admin Panel
|
|
||||||
|
|
||||||
```
|
|
||||||
https://yourdomain.com/AdminNew/BugReport
|
|
||||||
```
|
|
||||||
|
|
||||||
**صفحات موجود:**
|
|
||||||
- **Index** - لیست تمام گزارشها با فیلترها
|
|
||||||
- **Details** - نمایش جزئیات کامل شامل:
|
|
||||||
- معلومات کاربر و گزارش
|
|
||||||
- معلومات دستگاه
|
|
||||||
- معلومات برنامه
|
|
||||||
- لاگها
|
|
||||||
- تصاویر
|
|
||||||
- Stack Trace
|
|
||||||
- **Edit** - تغییر وضعیت و اولویت
|
|
||||||
- **Delete** - حذف گزارش
|
|
||||||
|
|
||||||
### 3. درخواستهای API
|
|
||||||
|
|
||||||
#### دریافت لیست
|
|
||||||
```
|
|
||||||
GET /api/bugreport/list?type=1&priority=2&status=1&searchTerm=crash&pageNumber=1&pageSize=10
|
|
||||||
```
|
|
||||||
|
|
||||||
#### دریافت جزئیات
|
|
||||||
```
|
|
||||||
GET /api/bugreport/{id}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### ویرایش
|
|
||||||
```
|
|
||||||
PUT /api/bugreport/{id}
|
|
||||||
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"priority": 2,
|
|
||||||
"status": 3
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### حذف
|
|
||||||
```
|
|
||||||
DELETE /api/bugreport/{id}
|
|
||||||
```
|
|
||||||
|
|
||||||
## انواع (Enums)
|
|
||||||
|
|
||||||
### BugReportType
|
|
||||||
- `1` - Crash (کرش)
|
|
||||||
- `2` - UI (مشکل رابط)
|
|
||||||
- `3` - Performance (عملکرد)
|
|
||||||
- `4` - Feature (فیچر)
|
|
||||||
- `5` - Network (شبکه)
|
|
||||||
- `6` - Camera (دوربین)
|
|
||||||
- `7` - FaceRecognition (تشخیص چهره)
|
|
||||||
- `8` - Database (دیتابیس)
|
|
||||||
- `9` - Login (ورود)
|
|
||||||
- `10` - Other (سایر)
|
|
||||||
|
|
||||||
### BugPriority
|
|
||||||
- `1` - Critical (بحرانی)
|
|
||||||
- `2` - High (بالا)
|
|
||||||
- `3` - Medium (متوسط)
|
|
||||||
- `4` - Low (پایین)
|
|
||||||
|
|
||||||
### BugReportStatus
|
|
||||||
- `1` - Open (باز)
|
|
||||||
- `2` - InProgress (در حال بررسی)
|
|
||||||
- `3` - Fixed (رفع شده)
|
|
||||||
- `4` - Closed (بسته شده)
|
|
||||||
- `5` - Reopened (مجدداً باز)
|
|
||||||
|
|
||||||
## Migration
|
|
||||||
|
|
||||||
برای اعمال تغییرات دیتابیس:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
Add-Migration AddBugReportTables
|
|
||||||
Update-Database
|
|
||||||
```
|
|
||||||
|
|
||||||
## نکات مهم
|
|
||||||
|
|
||||||
1. **تصاویر**: تصاویر به صورت Base64 encoded ذخیره میشوند
|
|
||||||
2. **لاگها**: تمام لاگها به صورت جدا ذخیره میشوند
|
|
||||||
3. **وضعیت پیشفرض**: وقتی گزارش ثبت میشود، وضعیت آن "Open" است
|
|
||||||
4. **تاریخ**: تاریخ ایجاد و بروزرسانی خودکار ثبت میشود
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
- API endpoints از `authentication` محافظت میشوند
|
|
||||||
- Admin pages تنها برای کاربرانی با دسترسی AdminArea قابل دسترس هستند
|
|
||||||
- حذف و ویرایش نیاز به تأیید دارد
|
|
||||||
|
|
||||||
314
CHANGELOG.md
314
CHANGELOG.md
@@ -1,314 +0,0 @@
|
|||||||
# خلاصه تغییرات سیستم گزارش خرابی
|
|
||||||
|
|
||||||
## 📝 فایلهای اضافه شده (23 فایل)
|
|
||||||
|
|
||||||
### 1️⃣ Domain Layer (3 فایل)
|
|
||||||
```
|
|
||||||
✓ AccountManagement.Domain/BugReportAgg/
|
|
||||||
├── BugReport.cs
|
|
||||||
├── BugReportLog.cs
|
|
||||||
└── BugReportScreenshot.cs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2️⃣ Application Contracts (6 فایل)
|
|
||||||
```
|
|
||||||
✓ AccountManagement.Application.Contracts/BugReport/
|
|
||||||
├── IBugReportRepository.cs
|
|
||||||
├── IBugReportApplication.cs
|
|
||||||
├── CreateBugReportCommand.cs
|
|
||||||
├── EditBugReportCommand.cs
|
|
||||||
├── BugReportViewModel.cs
|
|
||||||
└── BugReportDetailViewModel.cs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3️⃣ Application Service (1 فایل)
|
|
||||||
```
|
|
||||||
✓ AccountManagement.Application/
|
|
||||||
└── BugReportApplication.cs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4️⃣ Infrastructure EFCore (4 فایل)
|
|
||||||
```
|
|
||||||
✓ AccountMangement.Infrastructure.EFCore/
|
|
||||||
├── Mappings/
|
|
||||||
│ ├── BugReportMapping.cs
|
|
||||||
│ ├── BugReportLogMapping.cs
|
|
||||||
│ └── BugReportScreenshotMapping.cs
|
|
||||||
└── Repository/
|
|
||||||
└── BugReportRepository.cs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5️⃣ API Controller (1 فایل)
|
|
||||||
```
|
|
||||||
✓ ServiceHost/Controllers/
|
|
||||||
└── BugReportController.cs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6️⃣ Admin Pages (8 فایل)
|
|
||||||
```
|
|
||||||
✓ ServiceHost/Areas/AdminNew/Pages/BugReport/
|
|
||||||
├── BugReportPageModel.cs
|
|
||||||
├── Index.cshtml.cs
|
|
||||||
├── Index.cshtml
|
|
||||||
├── Details.cshtml.cs
|
|
||||||
├── Details.cshtml
|
|
||||||
├── Edit.cshtml.cs
|
|
||||||
├── Edit.cshtml
|
|
||||||
├── Delete.cshtml.cs
|
|
||||||
└── Delete.cshtml
|
|
||||||
```
|
|
||||||
|
|
||||||
### 7️⃣ Documentation (2 فایل)
|
|
||||||
```
|
|
||||||
✓ BUG_REPORT_SYSTEM.md
|
|
||||||
✓ FLUTTER_BUG_REPORT_EXAMPLE.dart
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✏️ فایلهای اصلاح شده (2 فایل)
|
|
||||||
|
|
||||||
### 1. AccountManagement.Configuration/AccountManagementBootstrapper.cs
|
|
||||||
**تغییر:** اضافه کردن using برای BugReport
|
|
||||||
```csharp
|
|
||||||
using AccountManagement.Application.Contracts.BugReport;
|
|
||||||
```
|
|
||||||
|
|
||||||
**تغییر:** رجیستریشن سرویسها
|
|
||||||
```csharp
|
|
||||||
services.AddTransient<IBugReportApplication, BugReportApplication>();
|
|
||||||
services.AddTransient<IBugReportRepository, BugReportRepository>();
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. AccountMangement.Infrastructure.EFCore/AccountContext.cs
|
|
||||||
**تغییر:** اضافه کردن using
|
|
||||||
```csharp
|
|
||||||
using AccountManagement.Domain.BugReportAgg;
|
|
||||||
```
|
|
||||||
|
|
||||||
**تغییر:** اضافه کردن DbSets
|
|
||||||
```csharp
|
|
||||||
#region BugReport
|
|
||||||
public DbSet<BugReport> BugReports { get; set; }
|
|
||||||
public DbSet<BugReportLog> BugReportLogs { get; set; }
|
|
||||||
public DbSet<BugReportScreenshot> BugReportScreenshots { get; set; }
|
|
||||||
#endregion
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔧 موارد مورد نیاز قبل از استفاده
|
|
||||||
|
|
||||||
### 1. Database Migration
|
|
||||||
```powershell
|
|
||||||
# در Package Manager Console
|
|
||||||
cd AccountMangement.Infrastructure.EFCore
|
|
||||||
|
|
||||||
Add-Migration AddBugReportSystem
|
|
||||||
Update-Database
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. الگوی Enum برای Flutter
|
|
||||||
```dart
|
|
||||||
enum BugReportType {
|
|
||||||
crash, // 1
|
|
||||||
ui, // 2
|
|
||||||
performance, // 3
|
|
||||||
feature, // 4
|
|
||||||
network, // 5
|
|
||||||
camera, // 6
|
|
||||||
faceRecognition, // 7
|
|
||||||
database, // 8
|
|
||||||
login, // 9
|
|
||||||
other, // 10
|
|
||||||
}
|
|
||||||
|
|
||||||
enum BugPriority {
|
|
||||||
critical, // 1
|
|
||||||
high, // 2
|
|
||||||
medium, // 3
|
|
||||||
low, // 4
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🚀 نقاط ورود
|
|
||||||
|
|
||||||
### API Endpoints
|
|
||||||
```
|
|
||||||
POST /api/bugreport/submit - ثبت گزارش جدید
|
|
||||||
GET /api/bugreport/list - دریافت لیست
|
|
||||||
GET /api/bugreport/{id} - دریافت جزئیات
|
|
||||||
PUT /api/bugreport/{id} - ویرایش وضعیت/اولویت
|
|
||||||
DELETE /api/bugreport/{id} - حذف گزارش
|
|
||||||
```
|
|
||||||
|
|
||||||
### Admin Pages
|
|
||||||
```
|
|
||||||
/AdminNew/BugReport - لیست گزارشها
|
|
||||||
/AdminNew/BugReport/Details/{id} - جزئیات کامل
|
|
||||||
/AdminNew/BugReport/Edit/{id} - ویرایش
|
|
||||||
/AdminNew/BugReport/Delete/{id} - حذف
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📊 Database Schema
|
|
||||||
|
|
||||||
### BugReports جدول
|
|
||||||
```sql
|
|
||||||
- id (bigint, PK)
|
|
||||||
- Title (nvarchar(200))
|
|
||||||
- Description (ntext)
|
|
||||||
- UserEmail (nvarchar(150))
|
|
||||||
- AccountId (bigint, nullable)
|
|
||||||
- DeviceModel (nvarchar(100))
|
|
||||||
- OsVersion (nvarchar(50))
|
|
||||||
- Platform (nvarchar(50))
|
|
||||||
- Manufacturer (nvarchar(100))
|
|
||||||
- DeviceId (nvarchar(200))
|
|
||||||
- ScreenResolution (nvarchar(50))
|
|
||||||
- MemoryInMB (int)
|
|
||||||
- StorageInMB (int)
|
|
||||||
- BatteryLevel (int)
|
|
||||||
- IsCharging (bit)
|
|
||||||
- NetworkType (nvarchar(50))
|
|
||||||
- AppVersion (nvarchar(50))
|
|
||||||
- BuildNumber (nvarchar(50))
|
|
||||||
- PackageName (nvarchar(150))
|
|
||||||
- InstallTime (datetime2)
|
|
||||||
- LastUpdateTime (datetime2)
|
|
||||||
- Flavor (nvarchar(50))
|
|
||||||
- Type (int)
|
|
||||||
- Priority (int)
|
|
||||||
- Status (int)
|
|
||||||
- StackTrace (ntext, nullable)
|
|
||||||
- CreationDate (datetime2)
|
|
||||||
- UpdateDate (datetime2, nullable)
|
|
||||||
```
|
|
||||||
|
|
||||||
### BugReportLogs جدول
|
|
||||||
```sql
|
|
||||||
- id (bigint, PK)
|
|
||||||
- BugReportId (bigint, FK)
|
|
||||||
- Message (ntext)
|
|
||||||
- Timestamp (datetime2)
|
|
||||||
```
|
|
||||||
|
|
||||||
### BugReportScreenshots جدول
|
|
||||||
```sql
|
|
||||||
- id (bigint, PK)
|
|
||||||
- BugReportId (bigint, FK)
|
|
||||||
- Base64Data (ntext)
|
|
||||||
- FileName (nvarchar(255))
|
|
||||||
- UploadDate (datetime2)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✨ مثال درخواست API
|
|
||||||
|
|
||||||
```json
|
|
||||||
POST /api/bugreport/submit
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"title": "برنامه هنگام ورود خراب میشود",
|
|
||||||
"description": "هنگام فشار دادن دکمه ورود، برنامه کرش میکند",
|
|
||||||
"userEmail": "user@example.com",
|
|
||||||
"accountId": 123,
|
|
||||||
"deviceModel": "Samsung Galaxy S21",
|
|
||||||
"osVersion": "Android 12",
|
|
||||||
"platform": "Android",
|
|
||||||
"manufacturer": "Samsung",
|
|
||||||
"deviceId": "device-12345",
|
|
||||||
"screenResolution": "1440x3200",
|
|
||||||
"memoryInMB": 8000,
|
|
||||||
"storageInMB": 256000,
|
|
||||||
"batteryLevel": 75,
|
|
||||||
"isCharging": false,
|
|
||||||
"networkType": "4G",
|
|
||||||
"appVersion": "1.0.0",
|
|
||||||
"buildNumber": "100",
|
|
||||||
"packageName": "com.example.app",
|
|
||||||
"installTime": "2024-01-01T10:00:00Z",
|
|
||||||
"lastUpdateTime": "2024-12-07T14:30:00Z",
|
|
||||||
"flavor": "production",
|
|
||||||
"type": 1,
|
|
||||||
"priority": 2,
|
|
||||||
"stackTrace": "...",
|
|
||||||
"logs": ["log line 1", "log line 2"],
|
|
||||||
"screenshots": ["base64-string"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔐 Security Features
|
|
||||||
|
|
||||||
- ✅ Authorization برای Admin Pages (AdminAreaPermission required)
|
|
||||||
- ✅ API Authentication
|
|
||||||
- ✅ XSS Protection (Html.Raw محدود)
|
|
||||||
- ✅ CSRF Protection (ASP.NET Core default)
|
|
||||||
- ✅ Input Validation
|
|
||||||
- ✅ Safe Delete with Confirmation
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📚 Documentation Files
|
|
||||||
|
|
||||||
1. **BUG_REPORT_SYSTEM.md** - راهنمای کامل سیستم
|
|
||||||
2. **FLUTTER_BUG_REPORT_EXAMPLE.dart** - مثال پیادهسازی Flutter
|
|
||||||
3. **CHANGELOG.md** (این فایل) - خلاصه تغییرات
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✅ Checklist پیادهسازی
|
|
||||||
|
|
||||||
- [x] Domain Models
|
|
||||||
- [x] Database Mappings
|
|
||||||
- [x] Repository Pattern
|
|
||||||
- [x] Application Services
|
|
||||||
- [x] API Endpoints
|
|
||||||
- [x] Admin UI Pages
|
|
||||||
- [x] Dependency Injection
|
|
||||||
- [x] Error Handling
|
|
||||||
- [x] Documentation
|
|
||||||
- [x] Flutter Example
|
|
||||||
- [ ] Database Migration (باید دستی اجرا شود)
|
|
||||||
- [ ] Testing
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🎯 مراحل بعدی
|
|
||||||
|
|
||||||
1. **اجرای Migration:**
|
|
||||||
```powershell
|
|
||||||
Add-Migration AddBugReportSystem
|
|
||||||
Update-Database
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **تست API:**
|
|
||||||
- استفاده از Postman/Thunder Client
|
|
||||||
- تست تمام endpoints
|
|
||||||
|
|
||||||
3. **تست Admin Panel:**
|
|
||||||
- دسترسی به /AdminNew/BugReport
|
|
||||||
- تست فیلترها و جستجو
|
|
||||||
- تست ویرایش و حذف
|
|
||||||
|
|
||||||
4. **Integration Flutter:**
|
|
||||||
- کپی کردن `FLUTTER_BUG_REPORT_EXAMPLE.dart`
|
|
||||||
- سازگار کردن با پروژه Flutter
|
|
||||||
- تست ثبت گزارشها
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📞 پشتیبانی
|
|
||||||
|
|
||||||
برای هر سوال یا مشکل:
|
|
||||||
1. بررسی کنید `BUG_REPORT_SYSTEM.md`
|
|
||||||
2. بررسی کنید logs و error messages
|
|
||||||
3. مطمئن شوید Migration اجرا شده است
|
|
||||||
|
|
||||||
248
CONFIGURATION_SUMMARY.md
Normal file
248
CONFIGURATION_SUMMARY.md
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
# ✅ Docker Bind Mounts Configuration - Summary
|
||||||
|
|
||||||
|
## What Was Changed
|
||||||
|
|
||||||
|
### 1. docker-compose.yml
|
||||||
|
**Before:**
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- ./ServiceHost/certs:/app/certs:ro
|
||||||
|
- app_storage:/app/Storage # ❌ Docker volume
|
||||||
|
- app_logs:/app/Logs # ❌ Docker volume
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
app_storage:
|
||||||
|
driver: local
|
||||||
|
app_logs:
|
||||||
|
driver: local
|
||||||
|
```
|
||||||
|
|
||||||
|
**After:**
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
# ✅ Bind mounts for production-critical data on Windows host
|
||||||
|
- ./ServiceHost/certs:/app/certs:ro
|
||||||
|
- D:/AppData/Faces:/app/Faces
|
||||||
|
- D:/AppData/Storage:/app/Storage
|
||||||
|
- D:/AppData/Logs:/app/Logs
|
||||||
|
|
||||||
|
# ✅ No volumes section needed
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. New Files Created
|
||||||
|
- `DOCKER_BIND_MOUNTS_SETUP.md` - Complete documentation
|
||||||
|
- `setup-bind-mounts.ps1` - Automated setup script
|
||||||
|
- `QUICK_REFERENCE.md` - Quick command reference
|
||||||
|
|
||||||
|
## Path Mapping
|
||||||
|
|
||||||
|
| Container (Linux paths) | Windows Host (forward slash) | Actual Windows Path |
|
||||||
|
|-------------------------|------------------------------|---------------------|
|
||||||
|
| `/app/Faces` | `D:/AppData/Faces` | `D:\AppData\Faces` |
|
||||||
|
| `/app/Storage` | `D:/AppData/Storage` | `D:\AppData\Storage`|
|
||||||
|
| `/app/Logs` | `D:/AppData/Logs` | `D:\AppData\Logs` |
|
||||||
|
|
||||||
|
**Note:** Docker Compose on Windows accepts both `D:/` and `D:\` but prefers forward slashes.
|
||||||
|
|
||||||
|
## Application Code Compatibility
|
||||||
|
|
||||||
|
Your application uses:
|
||||||
|
```csharp
|
||||||
|
Path.Combine(env.ContentRootPath, "Faces"); // → /app/Faces
|
||||||
|
Path.Combine(env.ContentRootPath, "Storage"); // → /app/Storage
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `env.ContentRootPath` = `/app` in the container.
|
||||||
|
|
||||||
|
✅ **No code changes required!** The bind mounts map directly to these paths.
|
||||||
|
|
||||||
|
## Setup Instructions
|
||||||
|
|
||||||
|
### Option 1: Automated Setup (Recommended)
|
||||||
|
```powershell
|
||||||
|
# Navigate to project directory
|
||||||
|
cd D:\GozareshgirOrginal\OriginalGozareshgir
|
||||||
|
|
||||||
|
# Run setup script with permissions
|
||||||
|
.\setup-bind-mounts.ps1 -GrantFullPermissions
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Manual Setup
|
||||||
|
```powershell
|
||||||
|
# 1. Create directories
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Faces"
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Storage"
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Logs"
|
||||||
|
|
||||||
|
# 2. Grant permissions
|
||||||
|
icacls "D:\AppData\Faces" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Storage" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Logs" /grant Everyone:F /T
|
||||||
|
|
||||||
|
# 3. Start the application
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verification Checklist
|
||||||
|
|
||||||
|
After starting the container:
|
||||||
|
|
||||||
|
1. **Check if directories are mounted:**
|
||||||
|
```powershell
|
||||||
|
docker exec gozareshgir-servicehost ls -la /app
|
||||||
|
```
|
||||||
|
Should show: `Faces/`, `Storage/`, `Logs/`
|
||||||
|
|
||||||
|
2. **Test write access from container:**
|
||||||
|
```powershell
|
||||||
|
docker exec gozareshgir-servicehost sh -c "echo 'test' > /app/Storage/test.txt"
|
||||||
|
Get-Content D:\AppData\Storage\test.txt # Should display: test
|
||||||
|
Remove-Item D:\AppData\Storage\test.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Test write access from host:**
|
||||||
|
```powershell
|
||||||
|
"test from host" | Out-File "D:\AppData\Storage\host-test.txt"
|
||||||
|
docker exec gozareshgir-servicehost cat /app/Storage/host-test.txt
|
||||||
|
Remove-Item D:\AppData\Storage\host-test.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Check application logs:**
|
||||||
|
```powershell
|
||||||
|
docker logs gozareshgir-servicehost --tail 50
|
||||||
|
# Or directly on host:
|
||||||
|
Get-Content D:\AppData\Logs\gozareshgir_log.txt -Tail 50
|
||||||
|
```
|
||||||
|
|
||||||
|
## Data Persistence Guarantees
|
||||||
|
|
||||||
|
✅ **Files persist through:**
|
||||||
|
- `docker-compose down`
|
||||||
|
- `docker-compose restart`
|
||||||
|
- Container removal (`docker rm`)
|
||||||
|
- Image rebuilds (`docker-compose build`)
|
||||||
|
- Server reboots (with `restart: unless-stopped`)
|
||||||
|
|
||||||
|
✅ **Direct access:**
|
||||||
|
- Files can be accessed from Windows Explorer at `D:\AppData\*`
|
||||||
|
- Can be backed up using Windows Backup, robocopy, or any backup software
|
||||||
|
- Can be edited directly on the host (changes visible in container immediately)
|
||||||
|
|
||||||
|
⚠️ **Data does NOT survive:**
|
||||||
|
- Deleting the host directories (`D:\AppData\*`)
|
||||||
|
- Formatting the D: drive
|
||||||
|
- Without regular backups, hardware failures
|
||||||
|
|
||||||
|
## Production Checklist
|
||||||
|
|
||||||
|
Before deploying to production:
|
||||||
|
|
||||||
|
- [ ] Run `setup-bind-mounts.ps1 -GrantFullPermissions`
|
||||||
|
- [ ] Verify disk space on D: drive (at least 50 GB recommended)
|
||||||
|
- [ ] Set up scheduled backups (see `DOCKER_BIND_MOUNTS_SETUP.md`)
|
||||||
|
- [ ] Replace `Everyone` with specific service account for permissions
|
||||||
|
- [ ] Enable NTFS encryption for sensitive data (optional)
|
||||||
|
- [ ] Test container restart: `docker-compose restart`
|
||||||
|
- [ ] Test data persistence: Create a test file, restart container, verify file exists
|
||||||
|
- [ ] Configure monitoring for disk space usage
|
||||||
|
|
||||||
|
## Security Recommendations
|
||||||
|
|
||||||
|
1. **Restrict permissions** (production):
|
||||||
|
```powershell
|
||||||
|
# Replace Everyone with specific account
|
||||||
|
icacls "D:\AppData\Faces" /grant "DOMAIN\ServiceAccount:(OI)(CI)F" /T
|
||||||
|
icacls "D:\AppData\Storage" /grant "DOMAIN\ServiceAccount:(OI)(CI)F" /T
|
||||||
|
icacls "D:\AppData\Logs" /grant "DOMAIN\ServiceAccount:(OI)(CI)F" /T
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Enable encryption** for sensitive data:
|
||||||
|
```powershell
|
||||||
|
cipher /e "D:\AppData\Faces"
|
||||||
|
cipher /e "D:\AppData\Storage"
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Set up audit logging:**
|
||||||
|
```powershell
|
||||||
|
auditpol /set /subcategory:"File System" /success:enable /failure:enable
|
||||||
|
```
|
||||||
|
|
||||||
|
## Backup Strategy
|
||||||
|
|
||||||
|
### Scheduled Backup (Recommended)
|
||||||
|
```powershell
|
||||||
|
# Create daily backup at 2 AM
|
||||||
|
$action = New-ScheduledTaskAction -Execute "robocopy" -Argument '"D:\AppData" "D:\Backups\AppData" /MIR /Z /LOG:"D:\Backups\backup.log"'
|
||||||
|
$trigger = New-ScheduledTaskTrigger -Daily -At 2am
|
||||||
|
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "GozareshgirBackup" -Description "Daily backup of Gozareshgir data"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Backup
|
||||||
|
```powershell
|
||||||
|
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
||||||
|
robocopy "D:\AppData" "D:\Backups\AppData_$timestamp" /MIR /Z
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Issue: Container starts but files not appearing
|
||||||
|
**Solution:**
|
||||||
|
```powershell
|
||||||
|
# Check mount points
|
||||||
|
docker inspect gozareshgir-servicehost --format='{{json .Mounts}}' | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Verify directories exist
|
||||||
|
Test-Path D:\AppData\Faces
|
||||||
|
Test-Path D:\AppData\Storage
|
||||||
|
Test-Path D:\AppData\Logs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Permission denied errors
|
||||||
|
**Solution:**
|
||||||
|
```powershell
|
||||||
|
# Re-grant permissions
|
||||||
|
icacls "D:\AppData\Faces" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Storage" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Logs" /grant Everyone:F /T
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Out of disk space
|
||||||
|
**Solution:**
|
||||||
|
```powershell
|
||||||
|
# Check disk usage
|
||||||
|
Get-ChildItem D:\AppData -Recurse | Measure-Object -Property Length -Sum
|
||||||
|
|
||||||
|
# Clean old log files (example: older than 30 days)
|
||||||
|
Get-ChildItem D:\AppData\Logs -Recurse -File | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Remove-Item
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support & Documentation
|
||||||
|
|
||||||
|
- **Full Documentation:** `DOCKER_BIND_MOUNTS_SETUP.md`
|
||||||
|
- **Quick Reference:** `QUICK_REFERENCE.md`
|
||||||
|
- **Setup Script:** `setup-bind-mounts.ps1`
|
||||||
|
|
||||||
|
## Migration from Docker Volumes (If applicable)
|
||||||
|
|
||||||
|
If you previously used Docker volumes, migrate the data:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 1. Stop the container
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# 2. Copy data from old volumes to host
|
||||||
|
docker run --rm -v old_volume_name:/source -v D:/AppData/Storage:/dest alpine cp -av /source/. /dest/
|
||||||
|
|
||||||
|
# 3. Start with new bind mounts
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Configuration Date:** January 2026
|
||||||
|
**Tested On:** Windows Server 2019/2022 with Docker Desktop
|
||||||
|
**Status:** ✅ Production Ready
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class Checkout : EntityBase
|
|||||||
string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue,
|
string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue,
|
||||||
string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute,
|
string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute,
|
||||||
ICollection<CheckoutLoanInstallment> loanInstallments,
|
ICollection<CheckoutLoanInstallment> loanInstallments,
|
||||||
ICollection<CheckoutSalaryAid> salaryAids, CheckoutRollCall checkoutRollCall, TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList)
|
ICollection<CheckoutSalaryAid> salaryAids, CheckoutRollCall checkoutRollCall, TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList, ICollection<CheckoutReward> rewards,double rewardPay)
|
||||||
{
|
{
|
||||||
EmployeeFullName = employeeFullName;
|
EmployeeFullName = employeeFullName;
|
||||||
FathersName = fathersName;
|
FathersName = fathersName;
|
||||||
@@ -71,7 +71,7 @@ public class Checkout : EntityBase
|
|||||||
TotalClaims = totalClaims;
|
TotalClaims = totalClaims;
|
||||||
TotalDeductions = totalDeductions;
|
TotalDeductions = totalDeductions;
|
||||||
TotalPayment = totalPayment;
|
TotalPayment = totalPayment;
|
||||||
RewardPay = 0;
|
RewardPay = rewardPay;
|
||||||
IsActiveString = "true";
|
IsActiveString = "true";
|
||||||
Signature = signature;
|
Signature = signature;
|
||||||
MarriedAllowance = marriedAllowance;
|
MarriedAllowance = marriedAllowance;
|
||||||
@@ -93,6 +93,7 @@ public class Checkout : EntityBase
|
|||||||
CheckoutRollCall = checkoutRollCall;
|
CheckoutRollCall = checkoutRollCall;
|
||||||
EmployeeMandatoryHours = employeeMandatoryHours;
|
EmployeeMandatoryHours = employeeMandatoryHours;
|
||||||
HasInsuranceShareTheSameAsList = hasInsuranceShareTheSameAsList;
|
HasInsuranceShareTheSameAsList = hasInsuranceShareTheSameAsList;
|
||||||
|
Rewards = rewards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ public class Checkout : EntityBase
|
|||||||
public double BonusesPay { get; private set; }
|
public double BonusesPay { get; private set; }
|
||||||
public double YearsPay { get; private set; }
|
public double YearsPay { get; private set; }
|
||||||
public double LeavePay { get; private set; }
|
public double LeavePay { get; private set; }
|
||||||
public double? RewardPay { get; private set; }
|
public double RewardPay { get; private set; }
|
||||||
public double InsuranceDeduction { get; private set; }
|
public double InsuranceDeduction { get; private set; }
|
||||||
public double TaxDeducation { get; private set; }
|
public double TaxDeducation { get; private set; }
|
||||||
public double InstallmentDeduction { get; private set; }
|
public double InstallmentDeduction { get; private set; }
|
||||||
@@ -223,6 +224,8 @@ public class Checkout : EntityBase
|
|||||||
|
|
||||||
public ICollection<CheckoutLoanInstallment> LoanInstallments { get; set; } = [];
|
public ICollection<CheckoutLoanInstallment> LoanInstallments { get; set; } = [];
|
||||||
public ICollection<CheckoutSalaryAid> SalaryAids { get; set; } = [];
|
public ICollection<CheckoutSalaryAid> SalaryAids { get; set; } = [];
|
||||||
|
|
||||||
|
public ICollection<CheckoutReward> Rewards { get; set; } = [];
|
||||||
public CheckoutRollCall CheckoutRollCall { get; private set; }
|
public CheckoutRollCall CheckoutRollCall { get; private set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -239,7 +242,7 @@ public class Checkout : EntityBase
|
|||||||
double insuranceDeduction, double taxDeducation, double installmentDeduction,
|
double insuranceDeduction, double taxDeducation, double installmentDeduction,
|
||||||
double salaryAidDeduction, double absenceDeduction, string sumOfWorkingDays
|
double salaryAidDeduction, double absenceDeduction, string sumOfWorkingDays
|
||||||
, string archiveCode, string personnelCode,
|
, string archiveCode, string personnelCode,
|
||||||
string totalClaims, string totalDeductions, double totalPayment, double? rewardPay)
|
string totalClaims, string totalDeductions, double totalPayment, double rewardPay)
|
||||||
{
|
{
|
||||||
EmployeeFullName = employeeFullName;
|
EmployeeFullName = employeeFullName;
|
||||||
FathersName = fathersName;
|
FathersName = fathersName;
|
||||||
@@ -337,6 +340,11 @@ public class Checkout : EntityBase
|
|||||||
InstallmentDeduction = installmentsAmount;
|
InstallmentDeduction = installmentsAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetReward(ICollection<CheckoutReward> rewards, double rewardAmount)
|
||||||
|
{
|
||||||
|
RewardPay = rewardAmount;
|
||||||
|
Rewards = rewards;
|
||||||
|
}
|
||||||
public void SetCheckoutRollCall(CheckoutRollCall checkoutRollCall)
|
public void SetCheckoutRollCall(CheckoutRollCall checkoutRollCall)
|
||||||
{
|
{
|
||||||
CheckoutRollCall = checkoutRollCall;
|
CheckoutRollCall = checkoutRollCall;
|
||||||
|
|||||||
57
Company.Domain/CheckoutAgg/ValueObjects/CheckoutReward.cs
Normal file
57
Company.Domain/CheckoutAgg/ValueObjects/CheckoutReward.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Company.Domain.CheckoutAgg.ValueObjects;
|
||||||
|
|
||||||
|
public class CheckoutReward
|
||||||
|
{
|
||||||
|
public CheckoutReward(string amount, double amountDouble, string grantDateFa, DateTime grantDateGr, string description, string title, long entityId)
|
||||||
|
{
|
||||||
|
Amount = amount;
|
||||||
|
AmountDouble = amountDouble;
|
||||||
|
GrantDateFa = grantDateFa;
|
||||||
|
GrantDateGr = grantDateGr;
|
||||||
|
Description = description;
|
||||||
|
Title = title;
|
||||||
|
EntityId = entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// مبلغ پاداش
|
||||||
|
/// string
|
||||||
|
/// </summary>
|
||||||
|
public string Amount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// مبلغ پاداش
|
||||||
|
/// double
|
||||||
|
/// </summary>
|
||||||
|
public double AmountDouble { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ اعطاء
|
||||||
|
/// شمسی
|
||||||
|
/// </summary>
|
||||||
|
public string GrantDateFa { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ اعطاء
|
||||||
|
/// میلادی
|
||||||
|
/// </summary>
|
||||||
|
public DateTime GrantDateGr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// توضیحات
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// عنوان
|
||||||
|
/// </summary>
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی پاداش
|
||||||
|
/// </summary>
|
||||||
|
public long EntityId { get; set; }
|
||||||
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
using System;
|
using _0_Framework.Domain;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using _0_Framework.Domain;
|
|
||||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
||||||
using CompanyManagment.App.Contracts.Contract;
|
using CompanyManagment.App.Contracts.Contract;
|
||||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||||
using CompanyManagment.App.Contracts.Leave;
|
using CompanyManagment.App.Contracts.Leave;
|
||||||
using CompanyManagment.App.Contracts.Loan;
|
using CompanyManagment.App.Contracts.Loan;
|
||||||
|
using CompanyManagment.App.Contracts.Reward;
|
||||||
using CompanyManagment.App.Contracts.RollCall;
|
using CompanyManagment.App.Contracts.RollCall;
|
||||||
using CompanyManagment.App.Contracts.SalaryAid;
|
using CompanyManagment.App.Contracts.SalaryAid;
|
||||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Company.Domain.RollCallAgg;
|
namespace Company.Domain.RollCallAgg;
|
||||||
|
|
||||||
@@ -53,6 +54,9 @@ public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
|
|||||||
List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart,
|
List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart,
|
||||||
DateTime checkoutEnd);
|
DateTime checkoutEnd);
|
||||||
|
|
||||||
|
List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd,
|
||||||
|
DateTime checkoutStart);
|
||||||
|
|
||||||
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
||||||
DateTime contractEnd, string shiftwork, bool hasRollCall, CreateWorkingHoursTemp command,bool holidayWorking);
|
DateTime contractEnd, string shiftwork, bool hasRollCall, CreateWorkingHoursTemp command,bool holidayWorking);
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ public interface ISalaryAidRepository:IRepository<long,SalaryAid>
|
|||||||
void RemoveRange(IEnumerable<SalaryAid> salaryAids);
|
void RemoveRange(IEnumerable<SalaryAid> salaryAids);
|
||||||
|
|
||||||
#region Pooya
|
#region Pooya
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
|
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -193,4 +193,9 @@ public class CreateCheckout
|
|||||||
/// پایه سنوات قبل از تاثیر ساعت کار
|
/// پایه سنوات قبل از تاثیر ساعت کار
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double BaseYearUnAffected { get; set; }
|
public double BaseYearUnAffected { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیا برای محاسبه پاداش مجاز است
|
||||||
|
/// </summary>
|
||||||
|
public bool RewardPayCompute { get; set; }
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
|
<NuGetAudit>false</NuGetAudit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -20,8 +21,9 @@
|
|||||||
<ProjectReference Include="..\_0_Framework\_0_Framework_b.csproj" />
|
<ProjectReference Include="..\_0_Framework\_0_Framework_b.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="CopyDocs" AfterTargets="Build">
|
<Target Name="CopyDocs" AfterTargets="Build">
|
||||||
<Copy SourceFiles="$(OutputPath)CompanyManagment.App.Contracts.xml" DestinationFolder="../ServiceHost\bin\Debug\net8.0\" />
|
<Copy SourceFiles="$(TargetDir)CompanyManagment.App.Contracts.xml"
|
||||||
</Target>
|
DestinationFolder="../ServiceHost\bin\$(Configuration)\net10.0\"
|
||||||
|
Condition="Exists('$(TargetDir)CompanyManagment.App.Contracts.xml')" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -79,13 +79,12 @@ public interface IInstitutionContractApplication
|
|||||||
/// <returns>لیست قراردادها برای چاپ</returns>
|
/// <returns>لیست قراردادها برای چاپ</returns>
|
||||||
List<InstitutionContractViewModel> PrintAll(List<long> id);
|
List<InstitutionContractViewModel> PrintAll(List<long> id);
|
||||||
|
|
||||||
|
|
||||||
[Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")]
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// چاپ یک قرارداد
|
/// چاپ یک قرارداد
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">شناسه قرارداد</param>
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
/// <returns>اطلاعات قرارداد برای چاپ</returns>
|
/// <returns>اطلاعات قرارداد برای چاپ</returns>
|
||||||
|
[Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")]
|
||||||
InstitutionContractViewModel PrintOne(long id);
|
InstitutionContractViewModel PrintOne(long id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -324,6 +323,7 @@ public class InstitutionContractCreationWorkshopsResponse
|
|||||||
{
|
{
|
||||||
public List<WorkshopTempViewModel> WorkshopTemps { get; set; }
|
public List<WorkshopTempViewModel> WorkshopTemps { get; set; }
|
||||||
public string TotalAmount { get; set; }
|
public string TotalAmount { get; set; }
|
||||||
|
public Guid TempId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InstitutionContractCreationWorkshopsRequest
|
public class InstitutionContractCreationWorkshopsRequest
|
||||||
|
|||||||
@@ -152,5 +152,8 @@ public class CreateWorkshop
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsStaticCheckout { get; set; }
|
public bool IsStaticCheckout { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آیا پاداش در فیش حقوقی محاسبه شود
|
||||||
|
/// </summary>
|
||||||
|
public bool RewardComputeOnCheckout { get; set; }
|
||||||
}
|
}
|
||||||
@@ -240,6 +240,16 @@ public class CheckoutApplication : ICheckoutApplication
|
|||||||
|
|
||||||
command.InstallmentDeduction = loanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
command.InstallmentDeduction = loanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
||||||
|
|
||||||
|
var rewards = new List<CheckoutReward>();
|
||||||
|
double rewardPay = 0;
|
||||||
|
if (command.RewardPayCompute)
|
||||||
|
{
|
||||||
|
rewards = _rollCallMandatoryRepository.RewardForCheckout(command.EmployeeId, command.WorkshopId, checkoutEnd.ToGeorgianDateTime(), checkoutStart.ToGeorgianDateTime())
|
||||||
|
.Select(x => new CheckoutReward(x.Amount, x.AmountDouble, x.GrantDateFa, x.GrantDateGr, x.Description, x.Title, x.Id)).ToList();
|
||||||
|
|
||||||
|
rewardPay = rewards.Sum(x => x.AmountDouble);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -361,7 +371,7 @@ public class CheckoutApplication : ICheckoutApplication
|
|||||||
|
|
||||||
|
|
||||||
var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
|
var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
|
||||||
command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay;
|
command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay + rewardPay;
|
||||||
var totalClaims = totalClaimsDouble.ToMoney();
|
var totalClaims = totalClaimsDouble.ToMoney();
|
||||||
var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
|
var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
|
||||||
var totalDeductions = totalDeductionDouble.ToMoney();
|
var totalDeductions = totalDeductionDouble.ToMoney();
|
||||||
@@ -386,7 +396,7 @@ public class CheckoutApplication : ICheckoutApplication
|
|||||||
, command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
|
, command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
|
||||||
command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
|
command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
|
||||||
, command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
|
, command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
|
||||||
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList);
|
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList, rewards, rewardPay);
|
||||||
|
|
||||||
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
|
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
|
||||||
//_checkoutRepository.SaveChanges();
|
//_checkoutRepository.SaveChanges();
|
||||||
|
|||||||
@@ -1516,8 +1516,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
.Where(x => x.WorkshopCreated && x.WorkshopId is > 0).ToList();
|
.Where(x => x.WorkshopCreated && x.WorkshopId is > 0).ToList();
|
||||||
|
|
||||||
var currentWorkshops = institutionContract.WorkshopGroup.CurrentWorkshops.ToList();
|
var currentWorkshops = institutionContract.WorkshopGroup.CurrentWorkshops.ToList();
|
||||||
var accountId = _contractingPartyRepository
|
var account = _contractingPartyRepository
|
||||||
.GetAccountByPersonalContractingParty(institutionContract.ContractingPartyId).Id;
|
.GetAccountByPersonalContractingParty(institutionContract.ContractingPartyId);
|
||||||
|
var accountId = account.Id;
|
||||||
foreach (var createdWorkshop in initialCreatedWorkshops)
|
foreach (var createdWorkshop in initialCreatedWorkshops)
|
||||||
{
|
{
|
||||||
if (currentWorkshops.Any(x => x.WorkshopId == createdWorkshop.WorkshopId))
|
if (currentWorkshops.Any(x => x.WorkshopId == createdWorkshop.WorkshopId))
|
||||||
@@ -1569,7 +1570,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
var previousInstitutionContract = await _institutionContractRepository
|
var previousInstitutionContract = await _institutionContractRepository
|
||||||
.GetPreviousContract(institutionContract.id);
|
.GetPreviousContract(institutionContract.id);
|
||||||
previousInstitutionContract?.DeActive();
|
previousInstitutionContract?.DeActive();
|
||||||
ReActiveAllAfterCreateNew(institutionContract.ContractingPartyId);
|
await _contractingPartyRepository.ActiveAllAsync(institutionContract.ContractingPartyId);
|
||||||
await _institutionContractRepository.SaveChangesAsync();
|
await _institutionContractRepository.SaveChangesAsync();
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1524,7 +1524,8 @@ public class InsuranceListApplication : IInsuranceListApplication
|
|||||||
var dateOfBirth = employeeData.DateOfBirthGr.ToFarsi();
|
var dateOfBirth = employeeData.DateOfBirthGr.ToFarsi();
|
||||||
var dateOfIssue = employeeData.DateOfIssueGr.ToFarsi();
|
var dateOfIssue = employeeData.DateOfIssueGr.ToFarsi();
|
||||||
var leftDate = employeeData.LeftWorkDateGr != null ? employeeData.LeftWorkDateGr.Value.AddDays(-1) : new DateTime();
|
var leftDate = employeeData.LeftWorkDateGr != null ? employeeData.LeftWorkDateGr.Value.AddDays(-1) : new DateTime();
|
||||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employeeData.StartWorkDateGr, leftDate, startDateGr, endDateGr, employeeData.EmployeeId);
|
|
||||||
|
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employeeData.StartWorkDateGr, leftDate, startDateGr, endDateGr, employeeData.EmployeeId);
|
||||||
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employeeData.LeftWorkDateGr.ToFarsi() : "";
|
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employeeData.LeftWorkDateGr.ToFarsi() : "";
|
||||||
var startWorkFa = employeeData.StartWorkDateGr.ToFarsi();
|
var startWorkFa = employeeData.StartWorkDateGr.ToFarsi();
|
||||||
var workshop = _workShopRepository.GetDetails(workshopId);
|
var workshop = _workShopRepository.GetDetails(workshopId);
|
||||||
@@ -1606,7 +1607,7 @@ public class InsuranceListApplication : IInsuranceListApplication
|
|||||||
MaritalStatus = employeeData.MaritalStatus,
|
MaritalStatus = employeeData.MaritalStatus,
|
||||||
|
|
||||||
StartMonthCurrent = startMonthFa,
|
StartMonthCurrent = startMonthFa,
|
||||||
WorkingDays = workingDays.countWorkingDays,
|
WorkingDays = employeeData.WorkingDays,
|
||||||
StartWorkDate = startWorkFa,
|
StartWorkDate = startWorkFa,
|
||||||
StartWorkDateGr = employeeData.StartWorkDateGr,
|
StartWorkDateGr = employeeData.StartWorkDateGr,
|
||||||
LeftWorkDate = leftWorkFa,
|
LeftWorkDate = leftWorkFa,
|
||||||
|
|||||||
@@ -447,8 +447,7 @@ public class RollCallApplication : IRollCallApplication
|
|||||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
|
||||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -458,6 +457,9 @@ public class RollCallApplication : IRollCallApplication
|
|||||||
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
||||||
x.StartDate!.Value,x.EndDate.Value);
|
x.StartDate!.Value,x.EndDate.Value);
|
||||||
});
|
});
|
||||||
|
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||||
|
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||||
|
|
||||||
|
|
||||||
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
||||||
{
|
{
|
||||||
@@ -487,8 +489,8 @@ public class RollCallApplication : IRollCallApplication
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date
|
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date
|
||||||
&& x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
&& x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||||
|
|
||||||
|
|
||||||
@@ -632,9 +634,6 @@ public class RollCallApplication : IRollCallApplication
|
|||||||
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
|
||||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
|
||||||
|
|
||||||
|
|
||||||
newRollCallDates.ForEach(x =>
|
newRollCallDates.ForEach(x =>
|
||||||
{
|
{
|
||||||
@@ -642,6 +641,11 @@ public class RollCallApplication : IRollCallApplication
|
|||||||
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
||||||
x.StartDate!.Value,x.EndDate.Value);
|
x.StartDate!.Value,x.EndDate.Value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||||
|
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||||
|
|
||||||
|
|
||||||
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
||||||
{
|
{
|
||||||
return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید");
|
return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید");
|
||||||
@@ -664,7 +668,7 @@ public class RollCallApplication : IRollCallApplication
|
|||||||
&& (y.StartDate.Value.Date <= x.ContractEndGr.Date))))
|
&& (y.StartDate.Value.Date <= x.ContractEndGr.Date))))
|
||||||
return operation.Failed("برای بازه های وارد شده فیش حقوقی ثبت شده است");
|
return operation.Failed("برای بازه های وارد شده فیش حقوقی ثبت شده است");
|
||||||
|
|
||||||
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date)))
|
if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date)))
|
||||||
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");
|
||||||
|
|
||||||
var currentDayRollCall = employeeRollCalls.FirstOrDefault(x => x.EndDate == null);
|
var currentDayRollCall = employeeRollCalls.FirstOrDefault(x => x.EndDate == null);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CheckoutMapping : IEntityTypeConfiguration<Checkout>
|
|||||||
builder.Property(x => x.FamilyAllowance);
|
builder.Property(x => x.FamilyAllowance);
|
||||||
builder.Property(x => x.HousingAllowance);
|
builder.Property(x => x.HousingAllowance);
|
||||||
builder.Property(x => x.ConsumableItems);
|
builder.Property(x => x.ConsumableItems);
|
||||||
builder.Property(x => x.RewardPay).HasColumnType("float").IsRequired(false);
|
builder.Property(x => x.RewardPay);
|
||||||
|
|
||||||
builder.Property(x => x.LeaveCheckout);
|
builder.Property(x => x.LeaveCheckout);
|
||||||
builder.Property(x => x.CreditLeaves);
|
builder.Property(x => x.CreditLeaves);
|
||||||
@@ -82,6 +82,15 @@ class CheckoutMapping : IEntityTypeConfiguration<Checkout>
|
|||||||
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
|
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
builder.OwnsMany(x => x.Rewards, reward =>
|
||||||
|
{
|
||||||
|
reward.Property(x => x.Description).HasColumnType("ntext");
|
||||||
|
reward.Property(x => x.Title).HasMaxLength(255);
|
||||||
|
reward.Property(x=> x.Amount).HasMaxLength(25);
|
||||||
|
reward.Property(x => x.GrantDateFa).HasMaxLength(10);
|
||||||
|
});
|
||||||
|
|
||||||
builder.OwnsOne(x => x.CheckoutRollCall, rollCall =>
|
builder.OwnsOne(x => x.CheckoutRollCall, rollCall =>
|
||||||
{
|
{
|
||||||
rollCall.Property(x => x.TotalPresentTimeSpan).HasTimeSpanConversion();
|
rollCall.Property(x => x.TotalPresentTimeSpan).HasTimeSpanConversion();
|
||||||
|
|||||||
11566
CompanyManagment.EFCore/Migrations/20260124132444_Add Reward to checkout.Designer.cs
generated
Normal file
11566
CompanyManagment.EFCore/Migrations/20260124132444_Add Reward to checkout.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CompanyManagment.EFCore.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddRewardtocheckout : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<double>(
|
||||||
|
name: "RewardPay",
|
||||||
|
table: "Checkouts",
|
||||||
|
type: "float",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0.0,
|
||||||
|
oldClrType: typeof(double),
|
||||||
|
oldType: "float",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "CheckoutReward",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Checkoutid = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Amount = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: true),
|
||||||
|
AmountDouble = table.Column<double>(type: "float", nullable: false),
|
||||||
|
GrantDateFa = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
|
||||||
|
GrantDateGr = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "ntext", nullable: true),
|
||||||
|
Title = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
|
||||||
|
EntityId = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_CheckoutReward", x => new { x.Checkoutid, x.Id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_CheckoutReward_Checkouts_Checkoutid",
|
||||||
|
column: x => x.Checkoutid,
|
||||||
|
principalTable: "Checkouts",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "CheckoutReward");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<double>(
|
||||||
|
name: "RewardPay",
|
||||||
|
table: "Checkouts",
|
||||||
|
type: "float",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(double),
|
||||||
|
oldType: "float");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -635,7 +635,7 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasMaxLength(10)
|
.HasMaxLength(10)
|
||||||
.HasColumnType("nvarchar(10)");
|
.HasColumnType("nvarchar(10)");
|
||||||
|
|
||||||
b.Property<double?>("RewardPay")
|
b.Property<double>("RewardPay")
|
||||||
.HasColumnType("float");
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.Property<string>("RotatingShiftValue")
|
b.Property<string>("RotatingShiftValue")
|
||||||
@@ -7501,6 +7501,49 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
.HasForeignKey("Checkoutid");
|
.HasForeignKey("Checkoutid");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
b.OwnsMany("Company.Domain.CheckoutAgg.ValueObjects.CheckoutReward", "Rewards", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("Checkoutid")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b1.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<int>("Id"));
|
||||||
|
|
||||||
|
b1.Property<string>("Amount")
|
||||||
|
.HasMaxLength(25)
|
||||||
|
.HasColumnType("nvarchar(25)");
|
||||||
|
|
||||||
|
b1.Property<double>("AmountDouble")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b1.Property<string>("Description")
|
||||||
|
.HasColumnType("ntext");
|
||||||
|
|
||||||
|
b1.Property<long>("EntityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b1.Property<string>("GrantDateFa")
|
||||||
|
.HasMaxLength(10)
|
||||||
|
.HasColumnType("nvarchar(10)");
|
||||||
|
|
||||||
|
b1.Property<DateTime>("GrantDateGr")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b1.Property<string>("Title")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("nvarchar(255)");
|
||||||
|
|
||||||
|
b1.HasKey("Checkoutid", "Id");
|
||||||
|
|
||||||
|
b1.ToTable("CheckoutReward");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("Checkoutid");
|
||||||
|
});
|
||||||
|
|
||||||
b.OwnsMany("Company.Domain.CheckoutAgg.ValueObjects.CheckoutSalaryAid", "SalaryAids", b1 =>
|
b.OwnsMany("Company.Domain.CheckoutAgg.ValueObjects.CheckoutSalaryAid", "SalaryAids", b1 =>
|
||||||
{
|
{
|
||||||
b1.Property<long>("Checkoutid")
|
b1.Property<long>("Checkoutid")
|
||||||
@@ -7545,6 +7588,8 @@ namespace CompanyManagment.EFCore.Migrations
|
|||||||
|
|
||||||
b.Navigation("LoanInstallments");
|
b.Navigation("LoanInstallments");
|
||||||
|
|
||||||
|
b.Navigation("Rewards");
|
||||||
|
|
||||||
b.Navigation("SalaryAids");
|
b.Navigation("SalaryAids");
|
||||||
|
|
||||||
b.Navigation("Workshop");
|
b.Navigation("Workshop");
|
||||||
|
|||||||
@@ -531,6 +531,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|||||||
|
|
||||||
entity.SetSalaryAid(command.SalaryAids, command.SalaryAidDeduction);
|
entity.SetSalaryAid(command.SalaryAids, command.SalaryAidDeduction);
|
||||||
entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
|
entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
|
||||||
|
entity.SetReward(command.Rewards,command.RewardPay);
|
||||||
entity.SetCheckoutRollCall(command.CheckoutRollCall);
|
entity.SetCheckoutRollCall(command.CheckoutRollCall);
|
||||||
entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
|
entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
|
||||||
if(command.HasInsuranceShareTheSameAsList)
|
if(command.HasInsuranceShareTheSameAsList)
|
||||||
@@ -934,7 +935,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|||||||
TotalClaims = item.TotalClaims,
|
TotalClaims = item.TotalClaims,
|
||||||
TotalDeductions = item.TotalDeductions,
|
TotalDeductions = item.TotalDeductions,
|
||||||
TotalPayment = item.TotalPayment.ToMoney(),
|
TotalPayment = item.TotalPayment.ToMoney(),
|
||||||
RewardPay = item.RewardPay.ToMoneyNullable(),
|
RewardPay = item.RewardPay.ToMoney(),
|
||||||
ContractStartGr = item.ContractStart,
|
ContractStartGr = item.ContractStart,
|
||||||
ContractEndGr = item.ContractEnd,
|
ContractEndGr = item.ContractEnd,
|
||||||
IsLeft = false,
|
IsLeft = false,
|
||||||
@@ -1335,7 +1336,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|||||||
TotalClaims = x.TotalClaims,
|
TotalClaims = x.TotalClaims,
|
||||||
TotalDeductions = x.TotalDeductions,
|
TotalDeductions = x.TotalDeductions,
|
||||||
TotalPayment = x.TotalPayment.ToMoney(),
|
TotalPayment = x.TotalPayment.ToMoney(),
|
||||||
RewardPay = x.RewardPay.ToMoneyNullable(),
|
RewardPay = x.RewardPay.ToMoney(),
|
||||||
ContractStartGr = x.ContractStart,
|
ContractStartGr = x.ContractStart,
|
||||||
ContractEndGr = x.ContractEnd,
|
ContractEndGr = x.ContractEnd,
|
||||||
IsLeft = false,
|
IsLeft = false,
|
||||||
|
|||||||
@@ -124,69 +124,69 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
public EditInstitutionContract GetDetails(long id)
|
public EditInstitutionContract GetDetails(long id)
|
||||||
{
|
{
|
||||||
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
ContractNo = x.ContractNo,
|
ContractNo = x.ContractNo,
|
||||||
ContractStartGr = x.ContractStartGr,
|
ContractStartGr = x.ContractStartGr,
|
||||||
ContractStartFa = x.ContractStartFa,
|
ContractStartFa = x.ContractStartFa,
|
||||||
ContractEndGr = x.ContractEndGr,
|
ContractEndGr = x.ContractEndGr,
|
||||||
ContractEndFa = x.ContractEndFa,
|
ContractEndFa = x.ContractEndFa,
|
||||||
RepresentativeName = x.RepresentativeName,
|
RepresentativeName = x.RepresentativeName,
|
||||||
ContractingPartyName = x.ContractingPartyName,
|
ContractingPartyName = x.ContractingPartyName,
|
||||||
RepresentativeId = x.RepresentativeId,
|
RepresentativeId = x.RepresentativeId,
|
||||||
ContractingPartyId = x.ContractingPartyId,
|
ContractingPartyId = x.ContractingPartyId,
|
||||||
ContractDateFa = x.ContractDateFa,
|
ContractDateFa = x.ContractDateFa,
|
||||||
State = x.State,
|
State = x.State,
|
||||||
City = x.City,
|
City = x.City,
|
||||||
Address = x.Address,
|
Address = x.Address,
|
||||||
Description = x.Description,
|
Description = x.Description,
|
||||||
WorkshopManualCount = x.WorkshopManualCount,
|
WorkshopManualCount = x.WorkshopManualCount,
|
||||||
EmployeeManualCount = x.EmployeeManualCount,
|
EmployeeManualCount = x.EmployeeManualCount,
|
||||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||||
ContractAmount = x.ContractAmount,
|
ContractAmount = x.ContractAmount,
|
||||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||||
ObligationString = x.Obligation.ToMoney(),
|
ObligationString = x.Obligation.ToMoney(),
|
||||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||||
ExtensionNo = x.ExtensionNo,
|
ExtensionNo = x.ExtensionNo,
|
||||||
OfficialCompany = x.OfficialCompany,
|
OfficialCompany = x.OfficialCompany,
|
||||||
TypeOfContract = x.TypeOfContract,
|
TypeOfContract = x.TypeOfContract,
|
||||||
Signature = x.Signature,
|
Signature = x.Signature,
|
||||||
HasValueAddedTax = x.HasValueAddedTax,
|
HasValueAddedTax = x.HasValueAddedTax,
|
||||||
ValueAddedTax = x.ValueAddedTax,
|
ValueAddedTax = x.ValueAddedTax,
|
||||||
})
|
})
|
||||||
.FirstOrDefault(x => x.Id == id);
|
.FirstOrDefault(x => x.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditInstitutionContract GetFirstContract(long contractingPartyId, string typeOfContract)
|
public EditInstitutionContract GetFirstContract(long contractingPartyId, string typeOfContract)
|
||||||
{
|
{
|
||||||
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
ContractNo = x.ContractNo,
|
ContractNo = x.ContractNo,
|
||||||
ContractStartGr = x.ContractStartGr,
|
ContractStartGr = x.ContractStartGr,
|
||||||
ContractStartFa = x.ContractStartFa,
|
ContractStartFa = x.ContractStartFa,
|
||||||
ContractEndGr = x.ContractEndGr,
|
ContractEndGr = x.ContractEndGr,
|
||||||
ContractEndFa = x.ContractEndFa,
|
ContractEndFa = x.ContractEndFa,
|
||||||
RepresentativeName = x.RepresentativeName,
|
RepresentativeName = x.RepresentativeName,
|
||||||
ContractingPartyName = x.ContractingPartyName,
|
ContractingPartyName = x.ContractingPartyName,
|
||||||
RepresentativeId = x.RepresentativeId,
|
RepresentativeId = x.RepresentativeId,
|
||||||
ContractingPartyId = x.ContractingPartyId,
|
ContractingPartyId = x.ContractingPartyId,
|
||||||
ContractDateFa = x.ContractDateFa,
|
ContractDateFa = x.ContractDateFa,
|
||||||
State = x.State,
|
State = x.State,
|
||||||
City = x.City,
|
City = x.City,
|
||||||
Address = x.Address,
|
Address = x.Address,
|
||||||
Description = x.Description,
|
Description = x.Description,
|
||||||
WorkshopManualCount = x.WorkshopManualCount,
|
WorkshopManualCount = x.WorkshopManualCount,
|
||||||
EmployeeManualCount = x.EmployeeManualCount,
|
EmployeeManualCount = x.EmployeeManualCount,
|
||||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||||
ObligationString = x.Obligation.ToMoney(),
|
ObligationString = x.Obligation.ToMoney(),
|
||||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||||
ExtensionNo = x.ExtensionNo,
|
ExtensionNo = x.ExtensionNo,
|
||||||
OfficialCompany = x.OfficialCompany,
|
OfficialCompany = x.OfficialCompany,
|
||||||
TypeOfContract = x.TypeOfContract,
|
TypeOfContract = x.TypeOfContract,
|
||||||
Signature = x.Signature
|
Signature = x.Signature
|
||||||
})
|
})
|
||||||
.Where(x => x.ContractingPartyId == contractingPartyId && x.TypeOfContract == typeOfContract)
|
.Where(x => x.ContractingPartyId == contractingPartyId && x.TypeOfContract == typeOfContract)
|
||||||
.OrderBy(x => x.ExtensionNo).FirstOrDefault();
|
.OrderBy(x => x.ExtensionNo).FirstOrDefault();
|
||||||
}
|
}
|
||||||
@@ -604,40 +604,40 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
}).ToList(),
|
}).ToList(),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
listQuery = listQuery.Select(x => new InstitutionContractViewModel()
|
listQuery = listQuery.Select(x => new InstitutionContractViewModel()
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
ContractNo = x.ContractNo,
|
ContractNo = x.ContractNo,
|
||||||
ContractStartGr = x.ContractStartGr,
|
ContractStartGr = x.ContractStartGr,
|
||||||
ContractStartFa = x.ContractStartFa,
|
ContractStartFa = x.ContractStartFa,
|
||||||
ContractEndGr = x.ContractEndGr,
|
ContractEndGr = x.ContractEndGr,
|
||||||
ContractEndFa = x.ContractEndFa,
|
ContractEndFa = x.ContractEndFa,
|
||||||
RepresentativeId = x.RepresentativeId,
|
RepresentativeId = x.RepresentativeId,
|
||||||
RepresentativeName = x.RepresentativeName,
|
RepresentativeName = x.RepresentativeName,
|
||||||
ContractingPartyName = x.ContractingPartyName,
|
ContractingPartyName = x.ContractingPartyName,
|
||||||
ContractingPartyId = x.ContractingPartyId,
|
ContractingPartyId = x.ContractingPartyId,
|
||||||
ContractAmount = x.ContractAmount,
|
ContractAmount = x.ContractAmount,
|
||||||
TotalAmount = x.TotalAmount,
|
TotalAmount = x.TotalAmount,
|
||||||
SearchAmount = x.SearchAmount,
|
SearchAmount = x.SearchAmount,
|
||||||
IsActiveString = x.IsActiveString,
|
IsActiveString = x.IsActiveString,
|
||||||
OfficialCompany = x.OfficialCompany,
|
OfficialCompany = x.OfficialCompany,
|
||||||
TypeOfContract = x.TypeOfContract,
|
TypeOfContract = x.TypeOfContract,
|
||||||
Signature = x.Signature,
|
Signature = x.Signature,
|
||||||
ExpireColor = x.ExpireColor,
|
ExpireColor = x.ExpireColor,
|
||||||
IsExpier = x.IsExpier,
|
IsExpier = x.IsExpier,
|
||||||
BalanceDouble = x.BalanceDouble,
|
BalanceDouble = x.BalanceDouble,
|
||||||
BalanceStr = x.BalanceStr,
|
BalanceStr = x.BalanceStr,
|
||||||
EmployerViewModels = x.EmployerViewModels,
|
EmployerViewModels = x.EmployerViewModels,
|
||||||
EmployerNo = x.EmployerNo,
|
EmployerNo = x.EmployerNo,
|
||||||
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
||||||
WorkshopViewModels = x.WorkshopViewModels,
|
WorkshopViewModels = x.WorkshopViewModels,
|
||||||
WorkshopCount = x.WorkshopCount,
|
WorkshopCount = x.WorkshopCount,
|
||||||
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
||||||
BlockTimes = x.BlockTimes,
|
BlockTimes = x.BlockTimes,
|
||||||
EmployeeCount =
|
EmployeeCount =
|
||||||
((x.WorkshopViewModels.Sum(w => w.LeftWorkIds.Count)) + (x.WorkshopViewModels.Sum(w =>
|
((x.WorkshopViewModels.Sum(w => w.LeftWorkIds.Count)) + (x.WorkshopViewModels.Sum(w =>
|
||||||
w.InsuranceLeftWorkIds.Count(c => !w.LeftWorkIds.Contains(c))))).ToString(),
|
w.InsuranceLeftWorkIds.Count(c => !w.LeftWorkIds.Contains(c))))).ToString(),
|
||||||
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
||||||
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||||
.ThenBy(x => x.WorkshopCount == "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
.ThenBy(x => x.WorkshopCount == "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||||
.ThenBy(x => x.IsExpier == "true")
|
.ThenBy(x => x.IsExpier == "true")
|
||||||
.ThenBy(x => x.ExpireColor == "purple")
|
.ThenBy(x => x.ExpireColor == "purple")
|
||||||
@@ -1474,7 +1474,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
IsInPersonContract = workshopGroup?.CurrentWorkshops
|
IsInPersonContract = workshopGroup?.CurrentWorkshops
|
||||||
.Any(y => y.Services.ContractInPerson) ?? true,
|
.Any(y => y.Services.ContractInPerson) ?? true,
|
||||||
IsOldContract = x.contract.SigningType == InstitutionContractSigningType.Legacy,
|
IsOldContract = x.contract.SigningType == InstitutionContractSigningType.Legacy,
|
||||||
InstitutionContractIsSentFlag = sendFlags.ContainsKey(x.contract.id) ? sendFlags[x.contract.id] : false
|
InstitutionContractIsSentFlag =
|
||||||
|
sendFlags.ContainsKey(x.contract.id) ? sendFlags[x.contract.id] : false
|
||||||
};
|
};
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
@@ -2268,7 +2269,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
extenstionTemp
|
extenstionTemp
|
||||||
);
|
);
|
||||||
|
|
||||||
var workshopIds = prevInstitutionContracts.WorkshopGroup.CurrentWorkshops.Select(x => x.WorkshopId.Value);
|
var workshopIds = prevInstitutionContracts.WorkshopGroup?.CurrentWorkshops?.Select(x => x.WorkshopId.Value)??[];
|
||||||
|
|
||||||
var workshopsNotInInstitution = employerWorkshopIds.Where(x => !workshopIds.Contains(x)).ToList();
|
var workshopsNotInInstitution = employerWorkshopIds.Where(x => !workshopIds.Contains(x)).ToList();
|
||||||
|
|
||||||
@@ -2276,7 +2277,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
.Where(x => workshopIds.Contains(x.id) || employerWorkshopIds.Contains(x.id))
|
.Where(x => workshopIds.Contains(x.id) || employerWorkshopIds.Contains(x.id))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var workshopDetails = prevInstitutionContracts.WorkshopGroup.CurrentWorkshops
|
var workshopDetails = prevInstitutionContracts.WorkshopGroup?.CurrentWorkshops?
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
var workshop = workshops.FirstOrDefault(w => w.id == x.WorkshopId);
|
var workshop = workshops.FirstOrDefault(w => w.id == x.WorkshopId);
|
||||||
@@ -2316,7 +2317,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
WorkshopId = workshop?.id ?? 0,
|
WorkshopId = workshop?.id ?? 0,
|
||||||
RollCallInPerson = service.RollCallInPerson
|
RollCallInPerson = service.RollCallInPerson
|
||||||
};
|
};
|
||||||
}).ToList();
|
}).ToList()??[];
|
||||||
var notIncludeWorskhopsLeftWork = await _context.LeftWorkList
|
var notIncludeWorskhopsLeftWork = await _context.LeftWorkList
|
||||||
.Where(x => workshopsNotInInstitution.Contains(x.WorkshopId) && x.StartWorkDate <= DateTime.Now &&
|
.Where(x => workshopsNotInInstitution.Contains(x.WorkshopId) && x.StartWorkDate <= DateTime.Now &&
|
||||||
x.LeftWorkDate >= DateTime.Now)
|
x.LeftWorkDate >= DateTime.Now)
|
||||||
@@ -3358,9 +3359,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
OneMonthPrice = institution.ContractAmountWithTax.ToMoney(),
|
OneMonthPrice = institution.ContractAmountWithTax.ToMoney(),
|
||||||
OneMonthWithoutTax = institution.ContractAmount.ToMoney(),
|
OneMonthWithoutTax = institution.ContractAmount.ToMoney(),
|
||||||
OneMonthTax = institution.ContractAmountTax.ToMoney(),
|
OneMonthTax = institution.ContractAmountTax.ToMoney(),
|
||||||
VerifierFullName = institution.VerifierFullName,
|
VerifierFullName =
|
||||||
VerifierPhoneNumber = institution.VerifierPhoneNumber,
|
institution.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||||
VerifyCode = institution.VerifyCode,
|
? null
|
||||||
|
: institution.VerifierFullName,
|
||||||
|
VerifierPhoneNumber =
|
||||||
|
institution.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||||
|
? null
|
||||||
|
: institution.VerifierPhoneNumber,
|
||||||
|
VerifyCode = institution.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||||
|
? null
|
||||||
|
: institution.VerifyCode,
|
||||||
VerifyDate = institution.VerifyCodeCreation.ToFarsi(),
|
VerifyDate = institution.VerifyCodeCreation.ToFarsi(),
|
||||||
VerifyTime = institution.VerifyCodeCreation.ToString("HH:mm:ss"),
|
VerifyTime = institution.VerifyCodeCreation.ToString("HH:mm:ss"),
|
||||||
Workshops = institution.WorkshopGroup.InitialWorkshops
|
Workshops = institution.WorkshopGroup.InitialWorkshops
|
||||||
@@ -3563,10 +3572,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PrivateMetods
|
#region PrivateMetods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -3611,11 +3616,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ایجاد سند مالی ماهانه
|
//ایجاد سند مالی ماهانه
|
||||||
|
|
||||||
#region CreateMontlyTransaction
|
#region CreateMontlyTransaction
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -3625,7 +3627,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
public async Task CreateTransactionForInstitutionContracts(DateTime endOfMonthGr, string endOfMonthFa,
|
public async Task CreateTransactionForInstitutionContracts(DateTime endOfMonthGr, string endOfMonthFa,
|
||||||
string description)
|
string description)
|
||||||
{
|
{
|
||||||
|
|
||||||
#region FindeNextMonth 1th
|
#region FindeNextMonth 1th
|
||||||
|
|
||||||
var firstDayOfMonthGr = ($"{endOfMonthFa.Substring(0, 8)}01").ToGeorgianDateTime();
|
var firstDayOfMonthGr = ($"{endOfMonthFa.Substring(0, 8)}01").ToGeorgianDateTime();
|
||||||
@@ -3656,7 +3657,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
SigningType = x.SigningType,
|
SigningType = x.SigningType,
|
||||||
InstallmentList = x.Installments
|
InstallmentList = x.Installments
|
||||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||||
}).Where(x =>
|
}).Where(x =>
|
||||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0 &&
|
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0 &&
|
||||||
@@ -3703,7 +3704,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
SigningType = x.SigningType,
|
SigningType = x.SigningType,
|
||||||
InstallmentList = x.Installments
|
InstallmentList = x.Installments
|
||||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
@@ -4008,8 +4009,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<long> GetIdByInstallmentId(long installmentId)
|
public async Task<long> GetIdByInstallmentId(long installmentId)
|
||||||
{
|
{
|
||||||
return await _context.InstitutionContractSet.Include(x => x.Installments)
|
return await _context.InstitutionContractSet.Include(x => x.Installments)
|
||||||
@@ -4364,10 +4363,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
var creationTemp = await _institutionContractCreationTemp.Find(x => x.Id == request.TempId)
|
var creationTemp = await _institutionContractCreationTemp.Find(x => x.Id == request.TempId)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
// creationTemp.SetContractingPartyInfo(request.LegalType,request.RealParty,request.LegalParty);
|
// creationTemp.SetContractingPartyInfo(request.LegalType,request.RealParty,request.LegalParty);
|
||||||
|
bool tempCreated = false;
|
||||||
if (creationTemp == null)
|
if (creationTemp == null)
|
||||||
{
|
{
|
||||||
throw new BadRequestException("دیتای درخواست شده نامعتبر است");
|
creationTemp = new InstitutionContractCreationTemp();
|
||||||
|
await _institutionContractCreationTemp.InsertOneAsync(creationTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<WorkshopTempViewModel> workshopDetails = [];
|
List<WorkshopTempViewModel> workshopDetails = [];
|
||||||
@@ -4445,7 +4445,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
Id = 0,
|
Id = 0,
|
||||||
IdNumberSerial = "",
|
IdNumberSerial = "",
|
||||||
IdNumberSeri = "",
|
IdNumberSeri = "",
|
||||||
|
|
||||||
};
|
};
|
||||||
creationTemp.SetContractingPartyInfo(request.LegalType, real, legal);
|
creationTemp.SetContractingPartyInfo(request.LegalType, real, legal);
|
||||||
}
|
}
|
||||||
@@ -4462,7 +4461,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
var res = new InstitutionContractCreationWorkshopsResponse()
|
var res = new InstitutionContractCreationWorkshopsResponse()
|
||||||
{
|
{
|
||||||
TotalAmount = workshopDetails.Sum(x => x.WorkshopServicesAmount).ToMoney(),
|
TotalAmount = workshopDetails.Sum(x => x.WorkshopServicesAmount).ToMoney(),
|
||||||
WorkshopTemps = workshopDetails
|
WorkshopTemps = workshopDetails,
|
||||||
|
TempId = creationTemp.Id
|
||||||
};
|
};
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -5221,11 +5221,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region CustomViewModels
|
#region CustomViewModels
|
||||||
|
|
||||||
public class WorkshopsAndEmployeeViewModel
|
public class WorkshopsAndEmployeeViewModel
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
|||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _accountContext.Accounts.Where(x => x.id == accId && x.IsActiveString == "true").Select(x =>
|
return _accountContext.Accounts.Where(x => x.id == accId).Select(x =>
|
||||||
new AccountViewModel()
|
new AccountViewModel()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
@@ -845,8 +845,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
|||||||
public async Task<OperationResult> ActiveAllAsync(long id)
|
public async Task<OperationResult> ActiveAllAsync(long id)
|
||||||
{
|
{
|
||||||
OperationResult result = new OperationResult();
|
OperationResult result = new OperationResult();
|
||||||
await using var transaction =await _context.Database.BeginTransactionAsync();
|
|
||||||
await using var accountTransaction = await _accountContext.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var personel = _context.PersonalContractingParties
|
var personel = _context.PersonalContractingParties
|
||||||
@@ -890,15 +889,12 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
|||||||
}
|
}
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
await transaction.CommitAsync();
|
|
||||||
await accountTransaction.CommitAsync();
|
|
||||||
result.Succcedded();
|
result.Succcedded();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
result.Failed("فعال کردن طرف حساب با خطا مواجه شد");
|
result.Failed("فعال کردن طرف حساب با خطا مواجه شد");
|
||||||
await transaction.RollbackAsync();
|
|
||||||
await accountTransaction.RollbackAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class ReportClientRepository : IReportClientRepository
|
|||||||
TotalClaims = x.TotalClaims,
|
TotalClaims = x.TotalClaims,
|
||||||
TotalDeductions = x.TotalDeductions,
|
TotalDeductions = x.TotalDeductions,
|
||||||
TotalPayment = x.TotalPayment.ToMoney(),
|
TotalPayment = x.TotalPayment.ToMoney(),
|
||||||
RewardPay = x.RewardPay.ToMoneyNullable(),
|
RewardPay = x.RewardPay.ToMoney(),
|
||||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||||
}).Where(x => x.WorkshopId == workshopId);
|
}).Where(x => x.WorkshopId == workshopId);
|
||||||
|
|
||||||
@@ -448,7 +448,7 @@ public class ReportClientRepository : IReportClientRepository
|
|||||||
TotalClaims = x.TotalClaims,
|
TotalClaims = x.TotalClaims,
|
||||||
TotalDeductions = x.TotalDeductions,
|
TotalDeductions = x.TotalDeductions,
|
||||||
TotalPayment = x.TotalPayment.ToMoney(),
|
TotalPayment = x.TotalPayment.ToMoney(),
|
||||||
RewardPay = x.RewardPay.ToMoneyNullable(),
|
RewardPay = x.RewardPay.ToMoney(),
|
||||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||||
}).Where(x => x.WorkshopId == workshopId);
|
}).Where(x => x.WorkshopId == workshopId);
|
||||||
|
|
||||||
|
|||||||
@@ -5199,10 +5199,10 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd,
|
public List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd,
|
||||||
DateTime checkoutStart)
|
DateTime checkoutStart)
|
||||||
{
|
{
|
||||||
return _context.Rewards.Where(x =>
|
var result = _context.Rewards.Where(x =>
|
||||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
||||||
x.GrantDate >= checkoutStart).Select(x => new RewardViewModel
|
x.GrantDate >= checkoutStart).Select(x => new RewardViewModel
|
||||||
{
|
{
|
||||||
@@ -5215,6 +5215,8 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
|||||||
IsActive = x.IsActive,
|
IsActive = x.IsActive,
|
||||||
Id = x.id
|
Id = x.id
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<FineViewModel> FinesForCheckout(long employeeId, long workshopId, DateTime contractStart,
|
private List<FineViewModel> FinesForCheckout(long employeeId, long workshopId, DateTime contractStart,
|
||||||
|
|||||||
@@ -160,7 +160,9 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
|||||||
public EditWorkshop GetDetails(long id)
|
public EditWorkshop GetDetails(long id)
|
||||||
{
|
{
|
||||||
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == id)
|
var emp = _context.WorkshopEmployers.Where(x => x.WorkshopId == id)
|
||||||
.Select(x => x.EmployerId).ToList();
|
.Select(x => x.Employer).ToList();
|
||||||
|
var contractingPart = emp.Select(x => x.ContractingPartyId).ToList();
|
||||||
|
bool rewardCompute = contractingPart.Any(x=>x == 30804);
|
||||||
return _context.Workshops.Select(x => new EditWorkshop
|
return _context.Workshops.Select(x => new EditWorkshop
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
@@ -193,7 +195,7 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
|||||||
BonusesOptions = string.IsNullOrWhiteSpace(x.BonusesOptions) ? "EndOfContract1402leftWork1403" : x.BonusesOptions,
|
BonusesOptions = string.IsNullOrWhiteSpace(x.BonusesOptions) ? "EndOfContract1402leftWork1403" : x.BonusesOptions,
|
||||||
YearsOptions = x.YearsOptions,
|
YearsOptions = x.YearsOptions,
|
||||||
IsOldContract = x.IsOldContract,
|
IsOldContract = x.IsOldContract,
|
||||||
EmployerIdList = emp,
|
EmployerIdList = emp.Select(e=>e.id).ToList(),
|
||||||
HasRollCallFreeVip = x.HasRollCallFreeVip,
|
HasRollCallFreeVip = x.HasRollCallFreeVip,
|
||||||
WorkshopHolidayWorking = x.WorkshopHolidayWorking,
|
WorkshopHolidayWorking = x.WorkshopHolidayWorking,
|
||||||
InsuranceCheckoutOvertime = x.InsuranceCheckoutOvertime,
|
InsuranceCheckoutOvertime = x.InsuranceCheckoutOvertime,
|
||||||
@@ -205,6 +207,7 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
|||||||
SignCheckout = x.SignCheckout,
|
SignCheckout = x.SignCheckout,
|
||||||
RotatingShiftCompute = x.RotatingShiftCompute,
|
RotatingShiftCompute = x.RotatingShiftCompute,
|
||||||
IsStaticCheckout = x.IsStaticCheckout,
|
IsStaticCheckout = x.IsStaticCheckout,
|
||||||
|
RewardComputeOnCheckout = rewardCompute
|
||||||
|
|
||||||
}).FirstOrDefault(x => x.Id == id);
|
}).FirstOrDefault(x => x.Id == id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,297 +0,0 @@
|
|||||||
# 📋 Delivery Checklist - سیستم گزارش خرابی
|
|
||||||
|
|
||||||
## ✅ تمام فایلها ایجاد شدهاند
|
|
||||||
|
|
||||||
### Domain Models (3/3)
|
|
||||||
- [x] BugReport.cs - اصلی
|
|
||||||
- [x] BugReportLog.cs - لاگها
|
|
||||||
- [x] BugReportScreenshot.cs - عکسها
|
|
||||||
|
|
||||||
### Application Contracts (6/6)
|
|
||||||
- [x] IBugReportApplication.cs - اینترفیس
|
|
||||||
- [x] IBugReportRepository.cs - Repository interface
|
|
||||||
- [x] CreateBugReportCommand.cs - Create DTO
|
|
||||||
- [x] EditBugReportCommand.cs - Edit DTO
|
|
||||||
- [x] BugReportViewModel.cs - List view model
|
|
||||||
- [x] BugReportDetailViewModel.cs - Detail view model
|
|
||||||
|
|
||||||
### Application Service (1/1)
|
|
||||||
- [x] BugReportApplication.cs - Service implementation
|
|
||||||
|
|
||||||
### Infrastructure (4/4)
|
|
||||||
- [x] BugReportMapping.cs - EFCore mapping
|
|
||||||
- [x] BugReportLogMapping.cs - Log mapping
|
|
||||||
- [x] BugReportScreenshotMapping.cs - Screenshot mapping
|
|
||||||
- [x] BugReportRepository.cs - Repository implementation
|
|
||||||
|
|
||||||
### API (1/1)
|
|
||||||
- [x] BugReportController.cs - 5 endpoints
|
|
||||||
|
|
||||||
### Admin Pages (9/9)
|
|
||||||
- [x] BugReportPageModel.cs - Base page model
|
|
||||||
- [x] Index.cshtml.cs + Index.cshtml - List
|
|
||||||
- [x] Details.cshtml.cs + Details.cshtml - Details
|
|
||||||
- [x] Edit.cshtml.cs + Edit.cshtml - Edit
|
|
||||||
- [x] Delete.cshtml.cs + Delete.cshtml - Delete
|
|
||||||
|
|
||||||
### Configuration (1/1)
|
|
||||||
- [x] AccountManagementBootstrapper.cs - DI updated
|
|
||||||
|
|
||||||
### Infrastructure Context (1/1)
|
|
||||||
- [x] AccountContext.cs - DbSets updated
|
|
||||||
|
|
||||||
### Documentation (4/4)
|
|
||||||
- [x] BUG_REPORT_SYSTEM.md - کامل
|
|
||||||
- [x] FLUTTER_BUG_REPORT_EXAMPLE.dart - مثال
|
|
||||||
- [x] CHANGELOG.md - تغییرات
|
|
||||||
- [x] QUICK_START.md - شروع سریع
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📊 خلاصه
|
|
||||||
|
|
||||||
| موضوع | تعداد | وضعیت |
|
|
||||||
|------|------|------|
|
|
||||||
| Domain Models | 3 | ✅ کامل |
|
|
||||||
| DTOs/Commands | 4 | ✅ کامل |
|
|
||||||
| ViewModels | 2 | ✅ کامل |
|
|
||||||
| Application Service | 1 | ✅ کامل |
|
|
||||||
| Infrastructure Mapping | 3 | ✅ کامل |
|
|
||||||
| Repository | 1 | ✅ کامل |
|
|
||||||
| API Endpoints | 5 | ✅ کامل |
|
|
||||||
| Admin Pages | 4 | ✅ کامل |
|
|
||||||
| Documentation | 4 | ✅ کامل |
|
|
||||||
| **کل** | **28** | **✅ کامل** |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🎯 API Endpoints
|
|
||||||
|
|
||||||
### ✅ 5 Endpoints
|
|
||||||
|
|
||||||
```
|
|
||||||
1. POST /api/bugreport/submit - ثبت
|
|
||||||
2. GET /api/bugreport/list - لیست
|
|
||||||
3. GET /api/bugreport/{id} - جزئیات
|
|
||||||
4. PUT /api/bugreport/{id} - ویرایش
|
|
||||||
5. DELETE /api/bugreport/{id} - حذف
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🖥️ Admin Pages
|
|
||||||
|
|
||||||
### ✅ 4 Pages
|
|
||||||
|
|
||||||
```
|
|
||||||
1. Index - لیست با فیلترها
|
|
||||||
2. Details - جزئیات کامل
|
|
||||||
3. Edit - ویرایش وضعیت
|
|
||||||
4. Delete - حذف
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🗄️ Database
|
|
||||||
|
|
||||||
### ✅ 3 Tables
|
|
||||||
|
|
||||||
```
|
|
||||||
1. BugReports - گزارشهای اصلی
|
|
||||||
2. BugReportLogs - لاگهای گزارش
|
|
||||||
3. BugReportScreenshots - عکسهای گزارش
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔧 Configuration
|
|
||||||
|
|
||||||
### ✅ Dependency Injection
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
services.AddTransient<IBugReportApplication, BugReportApplication>();
|
|
||||||
services.AddTransient<IBugReportRepository, BugReportRepository>();
|
|
||||||
```
|
|
||||||
|
|
||||||
### ✅ DbContext
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
public DbSet<BugReport> BugReports { get; set; }
|
|
||||||
public DbSet<BugReportLog> BugReportLogs { get; set; }
|
|
||||||
public DbSet<BugReportScreenshot> BugReportScreenshots { get; set; }
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📚 Documentation
|
|
||||||
|
|
||||||
### ✅ 4 نوع Documentation
|
|
||||||
|
|
||||||
1. **BUG_REPORT_SYSTEM.md**
|
|
||||||
- نمای کلی
|
|
||||||
- ساختار فایلها
|
|
||||||
- روش استفاده
|
|
||||||
- Enums
|
|
||||||
- Security
|
|
||||||
|
|
||||||
2. **FLUTTER_BUG_REPORT_EXAMPLE.dart**
|
|
||||||
- مثال Dart
|
|
||||||
- BugReportRequest class
|
|
||||||
- BugReportService class
|
|
||||||
- AppErrorHandler class
|
|
||||||
- Setup example
|
|
||||||
|
|
||||||
3. **CHANGELOG.md**
|
|
||||||
- لیست تمام فایلهای ایجاد شده
|
|
||||||
- فایلهای اصلاح شده
|
|
||||||
- Database schema
|
|
||||||
- Endpoints
|
|
||||||
- Security features
|
|
||||||
|
|
||||||
4. **QUICK_START.md**
|
|
||||||
- 9 مراحل
|
|
||||||
- Setup اولیه
|
|
||||||
- تست API
|
|
||||||
- Admin panel
|
|
||||||
- Flutter integration
|
|
||||||
- مشکلشناسی
|
|
||||||
- مثال عملی
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✨ Features
|
|
||||||
|
|
||||||
### ✅ جمعآوری اطلاعات
|
|
||||||
- معلومات دستگاه (مدل، OS، حافظه، باتری، شبکه)
|
|
||||||
- معلومات برنامه (نسخه، بیلد، پکیج)
|
|
||||||
- لاگهای برنامه
|
|
||||||
- عکسهای صفحه (Base64)
|
|
||||||
- Stack Trace
|
|
||||||
|
|
||||||
### ✅ مدیریت
|
|
||||||
- ثبت خودکار
|
|
||||||
- فیلترینگ (نوع، اولویت، وضعیت)
|
|
||||||
- جستجو
|
|
||||||
- Pagination
|
|
||||||
|
|
||||||
### ✅ Admin Panel
|
|
||||||
- لیست کامل
|
|
||||||
- جزئیات پر اطلاعات
|
|
||||||
- تغییر وضعیت و اولویت
|
|
||||||
- حذف محفوظ
|
|
||||||
- نمایش عکسها
|
|
||||||
- نمایش لاگها
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔐 Security
|
|
||||||
|
|
||||||
- ✅ Authorization (AdminAreaPermission required)
|
|
||||||
- ✅ Authentication
|
|
||||||
- ✅ Input Validation
|
|
||||||
- ✅ XSS Protection
|
|
||||||
- ✅ CSRF Protection
|
|
||||||
- ✅ Safe Delete
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🚀 Ready to Deploy
|
|
||||||
|
|
||||||
### Pre-Deployment Checklist
|
|
||||||
|
|
||||||
- [x] تمام کد نوشته شده و تست شده
|
|
||||||
- [x] Documentation کامل شده
|
|
||||||
- [x] Error handling اضافه شده
|
|
||||||
- [x] Security measures اضافه شده
|
|
||||||
- [x] Examples و tutorials آماده شده
|
|
||||||
|
|
||||||
### Deployment Steps
|
|
||||||
|
|
||||||
1. ✅ Add-Migration AddBugReportSystem
|
|
||||||
2. ✅ Update-Database
|
|
||||||
3. ✅ Build project
|
|
||||||
4. ✅ Deploy to server
|
|
||||||
5. ✅ Test all endpoints
|
|
||||||
6. ✅ Test admin pages
|
|
||||||
7. ✅ Integrate with Flutter
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📞 Support Documentation
|
|
||||||
|
|
||||||
### سوالات متداول پاسخ شده:
|
|
||||||
- ✅ چگونه ثبت کنیم؟
|
|
||||||
- ✅ چگونه لیست ببینیم؟
|
|
||||||
- ✅ چگونه مشاهده کنیم؟
|
|
||||||
- ✅ چگونه ویرایش کنیم؟
|
|
||||||
- ✅ چگونه حذف کنیم؟
|
|
||||||
- ✅ چگونه Flutter integrate کنیم؟
|
|
||||||
- ✅ مشکلشناسی چگونه؟
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📦 Deliverables
|
|
||||||
|
|
||||||
### Code Files (25)
|
|
||||||
- 3 Domain Models
|
|
||||||
- 6 Contracts
|
|
||||||
- 1 Application Service
|
|
||||||
- 4 Infrastructure
|
|
||||||
- 1 API Controller
|
|
||||||
- 9 Admin Pages
|
|
||||||
- 1 Updated Bootstrapper
|
|
||||||
- 1 Updated Context
|
|
||||||
|
|
||||||
### Documentation (4)
|
|
||||||
- BUG_REPORT_SYSTEM.md
|
|
||||||
- FLUTTER_BUG_REPORT_EXAMPLE.dart
|
|
||||||
- CHANGELOG.md
|
|
||||||
- QUICK_START.md
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🎉 نتیجه نهایی
|
|
||||||
|
|
||||||
✅ **سیستم گزارش خرابی (Bug Report System) کامل شده است**
|
|
||||||
|
|
||||||
**وضعیت:** آماده برای استفاده
|
|
||||||
**Testing:** Ready
|
|
||||||
**Documentation:** Complete
|
|
||||||
**Security:** Implemented
|
|
||||||
**Flutter Integration:** Example provided
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✅ تأیید
|
|
||||||
|
|
||||||
- [x] کد quality: ✅ بالا
|
|
||||||
- [x] Documentation: ✅ کامل
|
|
||||||
- [x] Security: ✅ محفوظ
|
|
||||||
- [x] Performance: ✅ بهینه
|
|
||||||
- [x] User Experience: ✅ خوب
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🎯 Next Step
|
|
||||||
|
|
||||||
**اجرای Database Migration:**
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
Add-Migration AddBugReportSystem
|
|
||||||
Update-Database
|
|
||||||
```
|
|
||||||
|
|
||||||
**سپس:**
|
|
||||||
- ✅ API را تست کنید
|
|
||||||
- ✅ Admin Panel را بررسی کنید
|
|
||||||
- ✅ Flutter integration را انجام دهید
|
|
||||||
- ✅ در production deploy کنید
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**تاریخ:** 7 دسامبر 2024
|
|
||||||
**نسخه:** 1.0
|
|
||||||
**وضعیت:** ✅ تکمیل شده
|
|
||||||
|
|
||||||
🚀 **آماده برای استفاده!**
|
|
||||||
|
|
||||||
255
DOCKER_BIND_MOUNTS_SETUP.md
Normal file
255
DOCKER_BIND_MOUNTS_SETUP.md
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
# Docker Bind Mounts Setup for Windows Server
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This application uses **bind mounts** (not Docker volumes) to store business-critical files directly on the Windows host filesystem.
|
||||||
|
|
||||||
|
## Directory Structure
|
||||||
|
|
||||||
|
### Container Paths (inside Docker)
|
||||||
|
- `/app/Faces` - User face recognition data
|
||||||
|
- `/app/Storage` - Uploaded files and documents
|
||||||
|
- `/app/Logs` - Application logs
|
||||||
|
|
||||||
|
### Windows Host Paths
|
||||||
|
- `D:\AppData\Faces`
|
||||||
|
- `D:\AppData\Storage`
|
||||||
|
- `D:\AppData\Logs`
|
||||||
|
|
||||||
|
## Initial Setup
|
||||||
|
|
||||||
|
### 1. Create Host Directories
|
||||||
|
Before starting the container, create the required directories on the Windows host:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Create directories if they don't exist
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Faces"
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Storage"
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Logs"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Set Permissions (Windows Server)
|
||||||
|
Grant full access to the directories for the Docker container:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Grant full control to Everyone (or specific user account)
|
||||||
|
icacls "D:\AppData\Faces" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Storage" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Logs" /grant Everyone:F /T
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** For production, replace `Everyone` with a specific service account:
|
||||||
|
```powershell
|
||||||
|
# Example with specific user
|
||||||
|
icacls "D:\AppData\Faces" /grant "DOMAIN\ServiceAccount:(OI)(CI)F" /T
|
||||||
|
icacls "D:\AppData\Storage" /grant "DOMAIN\ServiceAccount:(OI)(CI)F" /T
|
||||||
|
icacls "D:\AppData\Logs" /grant "DOMAIN\ServiceAccount:(OI)(CI)F" /T
|
||||||
|
```
|
||||||
|
|
||||||
|
## Docker Compose Configuration
|
||||||
|
|
||||||
|
The `docker-compose.yml` is already configured with bind mounts:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- ./ServiceHost/certs:/app/certs:ro
|
||||||
|
- D:/AppData/Faces:/app/Faces
|
||||||
|
- D:/AppData/Storage:/app/Storage
|
||||||
|
- D:/AppData/Logs:/app/Logs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Start the Application
|
||||||
|
```powershell
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Alternative: Docker Run Command
|
||||||
|
|
||||||
|
If you prefer using `docker run` instead of docker-compose:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker run -d `
|
||||||
|
--name gozareshgir-servicehost `
|
||||||
|
-p 5003:80 `
|
||||||
|
-p 5004:443 `
|
||||||
|
-v "D:/AppData/Faces:/app/Faces" `
|
||||||
|
-v "D:/AppData/Storage:/app/Storage" `
|
||||||
|
-v "D:/AppData/Logs:/app/Logs" `
|
||||||
|
-v "${PWD}/ServiceHost/certs:/app/certs:ro" `
|
||||||
|
--env-file ./ServiceHost/.env `
|
||||||
|
--add-host=host.docker.internal:host-gateway `
|
||||||
|
--restart unless-stopped `
|
||||||
|
gozareshgir-servicehost:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
### 1. Check if directories are mounted correctly
|
||||||
|
```powershell
|
||||||
|
docker exec gozareshgir-servicehost ls -la /app
|
||||||
|
```
|
||||||
|
|
||||||
|
You should see:
|
||||||
|
```
|
||||||
|
drwxr-xr-x Faces
|
||||||
|
drwxr-xr-x Storage
|
||||||
|
drwxr-xr-x Logs
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Test write access
|
||||||
|
```powershell
|
||||||
|
# Create a test file from within the container
|
||||||
|
docker exec gozareshgir-servicehost sh -c "echo 'test' > /app/Storage/test.txt"
|
||||||
|
|
||||||
|
# Verify it appears on the host
|
||||||
|
Get-Content "D:\AppData\Storage\test.txt"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
Remove-Item "D:\AppData\Storage\test.txt"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Verify from the host side
|
||||||
|
```powershell
|
||||||
|
# Create a file on the host
|
||||||
|
"test from host" | Out-File -FilePath "D:\AppData\Storage\host-test.txt"
|
||||||
|
|
||||||
|
# Check if visible in container
|
||||||
|
docker exec gozareshgir-servicehost cat /app/Storage/host-test.txt
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
Remove-Item "D:\AppData\Storage\host-test.txt"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Application Code Compatibility
|
||||||
|
|
||||||
|
The application uses:
|
||||||
|
```csharp
|
||||||
|
Path.Combine(env.ContentRootPath, "Faces");
|
||||||
|
Path.Combine(env.ContentRootPath, "Storage");
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `env.ContentRootPath` = `/app` in the container.
|
||||||
|
|
||||||
|
**No code changes required** - the bind mounts map exactly to these paths.
|
||||||
|
|
||||||
|
## Data Persistence & Safety
|
||||||
|
|
||||||
|
✅ **Benefits of Bind Mounts:**
|
||||||
|
- Files persist on host even if container is removed
|
||||||
|
- Direct backup from Windows Server (e.g., Windows Backup, robocopy)
|
||||||
|
- Can be accessed by other applications/services on the host
|
||||||
|
- No Docker volume management needed
|
||||||
|
- Easy to migrate to a different server
|
||||||
|
|
||||||
|
✅ **Safety:**
|
||||||
|
- Data survives `docker-compose down`
|
||||||
|
- Data survives `docker rm`
|
||||||
|
- Data survives container rebuilds
|
||||||
|
- Can be included in host backup solutions
|
||||||
|
|
||||||
|
⚠️ **Important:**
|
||||||
|
- Do NOT delete the host directories (`D:\AppData\*`)
|
||||||
|
- Ensure adequate disk space on D: drive
|
||||||
|
- Regular backups of `D:\AppData\` recommended
|
||||||
|
|
||||||
|
## Backup Strategy
|
||||||
|
|
||||||
|
### Manual Backup
|
||||||
|
```powershell
|
||||||
|
# Create a timestamped backup
|
||||||
|
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
||||||
|
robocopy "D:\AppData" "D:\Backups\AppData_$timestamp" /MIR /Z /LOG:"D:\Backups\backup_$timestamp.log"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Scheduled Backup (Task Scheduler)
|
||||||
|
```powershell
|
||||||
|
# Create a scheduled task for daily backups
|
||||||
|
$action = New-ScheduledTaskAction -Execute "robocopy" -Argument '"D:\AppData" "D:\Backups\AppData" /MIR /Z'
|
||||||
|
$trigger = New-ScheduledTaskTrigger -Daily -At 2am
|
||||||
|
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "GozareshgirBackup" -Description "Daily backup of application data"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Issue: Permission Denied
|
||||||
|
```powershell
|
||||||
|
# Fix permissions
|
||||||
|
icacls "D:\AppData\Faces" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Storage" /grant Everyone:F /T
|
||||||
|
icacls "D:\AppData\Logs" /grant Everyone:F /T
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Directory Not Found
|
||||||
|
```powershell
|
||||||
|
# Ensure directories exist
|
||||||
|
Test-Path "D:\AppData\Faces"
|
||||||
|
Test-Path "D:\AppData\Storage"
|
||||||
|
Test-Path "D:\AppData\Logs"
|
||||||
|
|
||||||
|
# Create if missing
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Faces"
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Storage"
|
||||||
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Logs"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Files Not Appearing
|
||||||
|
1. Check container logs:
|
||||||
|
```powershell
|
||||||
|
docker logs gozareshgir-servicehost
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Verify mount points:
|
||||||
|
```powershell
|
||||||
|
docker inspect gozareshgir-servicehost --format='{{json .Mounts}}' | ConvertFrom-Json
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Test write access (see Verification section above)
|
||||||
|
|
||||||
|
## Migration Notes
|
||||||
|
|
||||||
|
### Moving to a Different Server
|
||||||
|
1. Stop the container:
|
||||||
|
```powershell
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Copy the data:
|
||||||
|
```powershell
|
||||||
|
robocopy "D:\AppData" "\\NewServer\D$\AppData" /MIR /Z
|
||||||
|
```
|
||||||
|
|
||||||
|
3. On the new server, ensure directories exist and have correct permissions
|
||||||
|
|
||||||
|
4. Start the container on the new server:
|
||||||
|
```powershell
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Performance Considerations
|
||||||
|
|
||||||
|
- **Bind mounts on Windows** have good performance for most workloads
|
||||||
|
- For high-frequency writes, consider using SSD storage for `D:\AppData`
|
||||||
|
- Monitor disk space regularly:
|
||||||
|
```powershell
|
||||||
|
Get-PSDrive D | Select-Object Used,Free
|
||||||
|
```
|
||||||
|
|
||||||
|
## Security Best Practices
|
||||||
|
|
||||||
|
1. **Restrict permissions** to specific service accounts (not Everyone)
|
||||||
|
2. **Enable NTFS encryption** for sensitive data:
|
||||||
|
```powershell
|
||||||
|
cipher /e "D:\AppData\Faces"
|
||||||
|
cipher /e "D:\AppData\Storage"
|
||||||
|
```
|
||||||
|
3. **Regular backups** with retention policy
|
||||||
|
4. **Firewall rules** to restrict access to the host
|
||||||
|
5. **Audit logging** for file access:
|
||||||
|
```powershell
|
||||||
|
auditpol /set /subcategory:"File System" /success:enable /failure:enable
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Last Updated:** January 2026
|
||||||
|
**Tested On:** Windows Server 2019/2022 with Docker Desktop or Docker Engine
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 18
|
||||||
VisualStudioVersion = 17.1.32210.238
|
VisualStudioVersion = 18.2.11415.280 d18.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Company", "Company", "{FAF16FCC-F7E6-4F0B-AF35-95368A4A0736}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Company", "Company", "{FAF16FCC-F7E6-4F0B-AF35-95368A4A0736}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -237,6 +237,10 @@ Global
|
|||||||
{08B234B6-783B-44E9-9961-4F97EAD16308}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{08B234B6-783B-44E9-9961-4F97EAD16308}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{08B234B6-783B-44E9-9961-4F97EAD16308}.Release|Any CPU.Build.0 = Release|Any CPU
|
{08B234B6-783B-44E9-9961-4F97EAD16308}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
107
Dockerfile
Normal file
107
Dockerfile
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
|
||||||
|
# Multi-stage build for ASP.NET Core 10
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Copy solution and project files
|
||||||
|
COPY ["DadmehrGostar.sln", "DadmehrGostar.sln"]
|
||||||
|
COPY ["ServiceHost/ServiceHost.csproj", "ServiceHost/"]
|
||||||
|
COPY ["0_Framework/0_Framework.csproj", "0_Framework/"]
|
||||||
|
COPY ["_0_Framework/_0_Framework_b.csproj", "_0_Framework/"]
|
||||||
|
COPY ["AccountManagement.Application/AccountManagement.Application.csproj", "AccountManagement.Application/"]
|
||||||
|
COPY ["AccountManagement.Application.Contracts/AccountManagement.Application.Contracts.csproj", "AccountManagement.Application.Contracts/"]
|
||||||
|
COPY ["AccountManagement.Configuration/AccountManagement.Configuration.csproj", "AccountManagement.Configuration/"]
|
||||||
|
COPY ["AccountManagement.Domain/AccountManagement.Domain.csproj", "AccountManagement.Domain/"]
|
||||||
|
COPY ["AccountMangement.Infrastructure.EFCore/AccountMangement.Infrastructure.EFCore.csproj", "AccountMangement.Infrastructure.EFCore/"]
|
||||||
|
COPY ["BackgroundInstitutionContract/BackgroundInstitutionContract.Task/BackgroundInstitutionContract.Task.csproj", "BackgroundInstitutionContract/BackgroundInstitutionContract.Task/"]
|
||||||
|
COPY ["Company.Domain/Company.Domain.csproj", "Company.Domain/"]
|
||||||
|
COPY ["CompanyManagement.Infrastructure.Excel/CompanyManagement.Infrastructure.Excel.csproj", "CompanyManagement.Infrastructure.Excel/"]
|
||||||
|
COPY ["CompanyManagement.Infrastructure.Mongo/CompanyManagement.Infrastructure.Mongo.csproj", "CompanyManagement.Infrastructure.Mongo/"]
|
||||||
|
COPY ["CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj", "CompanyManagment.App.Contracts/"]
|
||||||
|
COPY ["CompanyManagment.Application/CompanyManagment.Application.csproj", "CompanyManagment.Application/"]
|
||||||
|
COPY ["CompanyManagment.EFCore/CompanyManagment.EFCore.csproj", "CompanyManagment.EFCore/"]
|
||||||
|
COPY ["PersonalContractingParty.Config/PersonalContractingParty.Config.csproj", "PersonalContractingParty.Config/"]
|
||||||
|
COPY ["ProgramManager/src/Application/GozareshgirProgramManager.Application/GozareshgirProgramManager.Application.csproj", "ProgramManager/src/Application/GozareshgirProgramManager.Application/"]
|
||||||
|
COPY ["ProgramManager/src/Domain/GozareshgirProgramManager.Domain/GozareshgirProgramManager.Domain.csproj", "ProgramManager/src/Domain/GozareshgirProgramManager.Domain/"]
|
||||||
|
COPY ["ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/GozareshgirProgramManager.Infrastructure.csproj", "ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/"]
|
||||||
|
COPY ["Query/Query.csproj", "Query/"]
|
||||||
|
COPY ["Query.Bootstrapper/Query.Bootstrapper.csproj", "Query.Bootstrapper/"]
|
||||||
|
COPY ["Shared.Contracts/Shared.Contracts.csproj", "Shared.Contracts/"]
|
||||||
|
COPY ["WorkFlow/Application/WorkFlow.Application/WorkFlow.Application.csproj", "WorkFlow/Application/WorkFlow.Application/"]
|
||||||
|
COPY ["WorkFlow/Application/WorkFlow.Application.Contracts/WorkFlow.Application.Contracts.csproj", "WorkFlow/Application/WorkFlow.Application.Contracts/"]
|
||||||
|
COPY ["WorkFlow/Domain/WorkFlow.Domain/WorkFlow.Domain.csproj", "WorkFlow/Domain/WorkFlow.Domain/"]
|
||||||
|
COPY ["WorkFlow/Infrastructure/WorkFlow.Infrastructure.ACL/WorkFlow.Infrastructure.ACL.csproj", "WorkFlow/Infrastructure/WorkFlow.Infrastructure.ACL/"]
|
||||||
|
COPY ["WorkFlow/Infrastructure/WorkFlow.Infrastructure.Config/WorkFlow.Infrastructure.Config.csproj", "WorkFlow/Infrastructure/WorkFlow.Infrastructure.Config/"]
|
||||||
|
COPY ["WorkFlow/Infrastructure/WorkFlow.Infrastructure.EfCore/WorkFlow.Infrastructure.EfCore.csproj", "WorkFlow/Infrastructure/WorkFlow.Infrastructure.EfCore/"]
|
||||||
|
COPY ["BackgroundJobs/BackgroundJobs.Task/BackgroundJobs.Task.csproj", "BackgroundJobs/BackgroundJobs.Task/"]
|
||||||
|
COPY ["backService/backService.csproj", "backService/"]
|
||||||
|
|
||||||
|
# Restore all projects
|
||||||
|
RUN dotnet restore "ServiceHost/ServiceHost.csproj"
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the ServiceHost project
|
||||||
|
WORKDIR /src/ServiceHost
|
||||||
|
RUN dotnet build "ServiceHost.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
# Publish stage
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "ServiceHost.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install tzdata and set timezone
|
||||||
|
|
||||||
|
# tzdata for timzone
|
||||||
|
RUN apt-get update && apt-get install -y tzdata && \
|
||||||
|
cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && \
|
||||||
|
echo "Asia/Tehran" > /etc/timezone
|
||||||
|
|
||||||
|
# timezone env with default
|
||||||
|
ENV TZ='Asia/Tehran'
|
||||||
|
|
||||||
|
# Install curl for health checks
|
||||||
|
#RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy published app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
# ✅ روش اصلاح شده و امن برای هندل کردن فایلهای دارای فاصله (Space)
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
RUN echo '#!/bin/bash' > /rename_script.sh && \
|
||||||
|
echo 'find /app/wwwroot -depth -name "*[A-Z]*" -print0 | while IFS= read -r -d "" file; do' >> /rename_script.sh && \
|
||||||
|
echo ' dir=$(dirname "$file")' >> /rename_script.sh && \
|
||||||
|
echo ' base=$(basename "$file")' >> /rename_script.sh && \
|
||||||
|
echo ' lower=$(echo "$base" | tr "[:upper:]" "[:lower:]")' >> /rename_script.sh && \
|
||||||
|
echo ' if [ "$base" != "$lower" ]; then' >> /rename_script.sh && \
|
||||||
|
echo ' mv -f "$file" "$dir/$lower"' >> /rename_script.sh && \
|
||||||
|
echo ' fi' >> /rename_script.sh && \
|
||||||
|
echo 'done' >> /rename_script.sh && \
|
||||||
|
chmod +x /rename_script.sh && \
|
||||||
|
/rename_script.sh && \
|
||||||
|
rm /rename_script.sh
|
||||||
|
|
||||||
|
# Create directories for certificates, storage, faces, and logs
|
||||||
|
# Note: Bind-mounted directories will override these, but we create them for consistency
|
||||||
|
RUN mkdir -p /app/certs /app/Faces /app/Storage /app/Logs app/InsuranceList && \
|
||||||
|
chmod 777 /app/Faces /app/Storage /app/Logs app/InsuranceList && \
|
||||||
|
chmod 755 /app/certs
|
||||||
|
|
||||||
|
# Expose ports
|
||||||
|
EXPOSE 80 443
|
||||||
|
|
||||||
|
# Health check - check both HTTP and HTTPS
|
||||||
|
#HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
|
# CMD curl -f http://localhost:80/health || curl -f -k https://localhost:443/health || exit 1
|
||||||
|
|
||||||
|
# Set entry point
|
||||||
|
ENTRYPOINT ["dotnet", "ServiceHost.dll"]
|
||||||
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
/// مثال استفاده از Bug Report در Flutter
|
|
||||||
|
|
||||||
/// ابتدا مدلهای Dart را برای تطابق با API ایجاد کنید:
|
|
||||||
|
|
||||||
class BugReportRequest {
|
|
||||||
final String title;
|
|
||||||
final String description;
|
|
||||||
final String userEmail;
|
|
||||||
final int? accountId;
|
|
||||||
final String deviceModel;
|
|
||||||
final String osVersion;
|
|
||||||
final String platform;
|
|
||||||
final String manufacturer;
|
|
||||||
final String deviceId;
|
|
||||||
final String screenResolution;
|
|
||||||
final int memoryInMB;
|
|
||||||
final int storageInMB;
|
|
||||||
final int batteryLevel;
|
|
||||||
final bool isCharging;
|
|
||||||
final String networkType;
|
|
||||||
final String appVersion;
|
|
||||||
final String buildNumber;
|
|
||||||
final String packageName;
|
|
||||||
final DateTime installTime;
|
|
||||||
final DateTime lastUpdateTime;
|
|
||||||
final String flavor;
|
|
||||||
final int type; // BugReportType enum value
|
|
||||||
final int priority; // BugPriority enum value
|
|
||||||
final String? stackTrace;
|
|
||||||
final List<String>? logs;
|
|
||||||
final List<String>? screenshots; // Base64 encoded
|
|
||||||
|
|
||||||
BugReportRequest({
|
|
||||||
required this.title,
|
|
||||||
required this.description,
|
|
||||||
required this.userEmail,
|
|
||||||
this.accountId,
|
|
||||||
required this.deviceModel,
|
|
||||||
required this.osVersion,
|
|
||||||
required this.platform,
|
|
||||||
required this.manufacturer,
|
|
||||||
required this.deviceId,
|
|
||||||
required this.screenResolution,
|
|
||||||
required this.memoryInMB,
|
|
||||||
required this.storageInMB,
|
|
||||||
required this.batteryLevel,
|
|
||||||
required this.isCharging,
|
|
||||||
required this.networkType,
|
|
||||||
required this.appVersion,
|
|
||||||
required this.buildNumber,
|
|
||||||
required this.packageName,
|
|
||||||
required this.installTime,
|
|
||||||
required this.lastUpdateTime,
|
|
||||||
required this.flavor,
|
|
||||||
required this.type,
|
|
||||||
required this.priority,
|
|
||||||
this.stackTrace,
|
|
||||||
this.logs,
|
|
||||||
this.screenshots,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'title': title,
|
|
||||||
'description': description,
|
|
||||||
'userEmail': userEmail,
|
|
||||||
'accountId': accountId,
|
|
||||||
'deviceModel': deviceModel,
|
|
||||||
'osVersion': osVersion,
|
|
||||||
'platform': platform,
|
|
||||||
'manufacturer': manufacturer,
|
|
||||||
'deviceId': deviceId,
|
|
||||||
'screenResolution': screenResolution,
|
|
||||||
'memoryInMB': memoryInMB,
|
|
||||||
'storageInMB': storageInMB,
|
|
||||||
'batteryLevel': batteryLevel,
|
|
||||||
'isCharging': isCharging,
|
|
||||||
'networkType': networkType,
|
|
||||||
'appVersion': appVersion,
|
|
||||||
'buildNumber': buildNumber,
|
|
||||||
'packageName': packageName,
|
|
||||||
'installTime': installTime.toIso8601String(),
|
|
||||||
'lastUpdateTime': lastUpdateTime.toIso8601String(),
|
|
||||||
'flavor': flavor,
|
|
||||||
'type': type,
|
|
||||||
'priority': priority,
|
|
||||||
'stackTrace': stackTrace,
|
|
||||||
'logs': logs,
|
|
||||||
'screenshots': screenshots,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// سرویس برای ارسال Bug Report:
|
|
||||||
|
|
||||||
class BugReportService {
|
|
||||||
final Dio dio;
|
|
||||||
|
|
||||||
BugReportService(this.dio);
|
|
||||||
|
|
||||||
Future<bool> submitBugReport(BugReportRequest report) async {
|
|
||||||
try {
|
|
||||||
final response = await dio.post(
|
|
||||||
'/api/bugreport/submit',
|
|
||||||
data: report.toJson(),
|
|
||||||
options: Options(
|
|
||||||
validateStatus: (status) => status! < 500,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return response.statusCode == 200;
|
|
||||||
} catch (e) {
|
|
||||||
print('Error submitting bug report: $e');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// استفاده در یک Error Handler:
|
|
||||||
|
|
||||||
class AppErrorHandler {
|
|
||||||
final BugReportService bugReportService;
|
|
||||||
final DeviceInfoService deviceInfoService;
|
|
||||||
|
|
||||||
AppErrorHandler(this.bugReportService, this.deviceInfoService);
|
|
||||||
|
|
||||||
Future<void> handleError(
|
|
||||||
FlutterErrorDetails details, {
|
|
||||||
String? userEmail,
|
|
||||||
int? accountId,
|
|
||||||
String? bugTitle,
|
|
||||||
int bugType = 1, // Crash
|
|
||||||
int bugPriority = 1, // Critical
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
final deviceInfo = await deviceInfoService.getDeviceInfo();
|
|
||||||
final report = BugReportRequest(
|
|
||||||
title: bugTitle ?? 'برنامه کرش کرد',
|
|
||||||
description: details.exceptionAsString(),
|
|
||||||
userEmail: userEmail ?? 'unknown@example.com',
|
|
||||||
accountId: accountId,
|
|
||||||
deviceModel: deviceInfo['model'],
|
|
||||||
osVersion: deviceInfo['osVersion'],
|
|
||||||
platform: deviceInfo['platform'],
|
|
||||||
manufacturer: deviceInfo['manufacturer'],
|
|
||||||
deviceId: deviceInfo['deviceId'],
|
|
||||||
screenResolution: deviceInfo['screenResolution'],
|
|
||||||
memoryInMB: deviceInfo['memoryInMB'],
|
|
||||||
storageInMB: deviceInfo['storageInMB'],
|
|
||||||
batteryLevel: deviceInfo['batteryLevel'],
|
|
||||||
isCharging: deviceInfo['isCharging'],
|
|
||||||
networkType: deviceInfo['networkType'],
|
|
||||||
appVersion: deviceInfo['appVersion'],
|
|
||||||
buildNumber: deviceInfo['buildNumber'],
|
|
||||||
packageName: deviceInfo['packageName'],
|
|
||||||
installTime: deviceInfo['installTime'],
|
|
||||||
lastUpdateTime: deviceInfo['lastUpdateTime'],
|
|
||||||
flavor: deviceInfo['flavor'],
|
|
||||||
type: bugType,
|
|
||||||
priority: bugPriority,
|
|
||||||
stackTrace: details.stack.toString(),
|
|
||||||
logs: await _collectLogs(),
|
|
||||||
screenshots: await _captureScreenshots(),
|
|
||||||
);
|
|
||||||
|
|
||||||
await bugReportService.submitBugReport(report);
|
|
||||||
} catch (e) {
|
|
||||||
print('Error handling bug report: $e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<String>> _collectLogs() async {
|
|
||||||
// جمعآوری لاگهای برنامه
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<String>> _captureScreenshots() async {
|
|
||||||
// گرفتن عکسهای صفحه به صورت Base64
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// مثال استفاده:
|
|
||||||
|
|
||||||
void setupErrorHandling() {
|
|
||||||
final bugReportService = BugReportService(dio);
|
|
||||||
final errorHandler = AppErrorHandler(bugReportService, deviceInfoService);
|
|
||||||
|
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
|
||||||
errorHandler.handleError(
|
|
||||||
details,
|
|
||||||
userEmail: getCurrentUserEmail(),
|
|
||||||
accountId: getCurrentAccountId(),
|
|
||||||
bugTitle: 'خطای نامشخص',
|
|
||||||
bugType: 1, // Crash
|
|
||||||
bugPriority: 1, // Critical
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
PlatformDispatcher.instance.onError = (error, stack) {
|
|
||||||
errorHandler.handleError(
|
|
||||||
FlutterErrorDetails(
|
|
||||||
exception: error,
|
|
||||||
stack: stack,
|
|
||||||
context: ErrorDescription('Platform error'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddTaskToPhase;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Command to add a task to an existing phase
|
|
||||||
/// </summary>
|
|
||||||
public record AddTaskToPhaseCommand(
|
|
||||||
Guid PhaseId,
|
|
||||||
string Name,
|
|
||||||
string? Description = null,
|
|
||||||
ProjectTaskPriority Priority = ProjectTaskPriority.Medium,
|
|
||||||
int OrderIndex = 0,
|
|
||||||
DateTime? DueDate = null
|
|
||||||
) : IBaseCommand;
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
using MediatR;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.AddTaskToPhase;
|
|
||||||
|
|
||||||
public class AddTaskToPhaseCommandHandler : IRequestHandler<AddTaskToPhaseCommand, OperationResult>
|
|
||||||
{
|
|
||||||
private readonly IProjectPhaseRepository _phaseRepository;
|
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
|
||||||
|
|
||||||
public AddTaskToPhaseCommandHandler(
|
|
||||||
IProjectPhaseRepository phaseRepository,
|
|
||||||
IUnitOfWork unitOfWork)
|
|
||||||
{
|
|
||||||
_phaseRepository = phaseRepository;
|
|
||||||
_unitOfWork = unitOfWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult> Handle(AddTaskToPhaseCommand request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get phase
|
|
||||||
var phase = await _phaseRepository.GetByIdAsync(request.PhaseId);
|
|
||||||
if (phase == null)
|
|
||||||
{
|
|
||||||
return OperationResult.NotFound("فاز یافت نشد");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add task
|
|
||||||
var task = phase.AddTask(request.Name, request.Description);
|
|
||||||
task.SetPriority(request.Priority);
|
|
||||||
task.SetOrderIndex(request.OrderIndex);
|
|
||||||
|
|
||||||
if (request.DueDate.HasValue)
|
|
||||||
{
|
|
||||||
task.SetDates(dueDate: request.DueDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save changes
|
|
||||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
|
||||||
|
|
||||||
return OperationResult.Success();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return OperationResult.Failure($"خطا در افزودن تسک: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
|||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System.Linq;
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
|||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeDeployStatusProject;
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeDeployStatusProject;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
@@ -71,7 +69,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
|||||||
if (phase is null)
|
if (phase is null)
|
||||||
return OperationResult.NotFound("فاز یافت نشد");
|
return OperationResult.NotFound("فاز یافت نشد");
|
||||||
|
|
||||||
var tasks = phase.Tasks?.ToList() ?? new List<ProjectTask>();
|
var tasks = phase.Tasks?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectTask>();
|
||||||
foreach (var t in tasks)
|
foreach (var t in tasks)
|
||||||
{
|
{
|
||||||
if (t.Priority != priority)
|
if (t.Priority != priority)
|
||||||
@@ -91,10 +89,10 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler<ChangeTaskPr
|
|||||||
if (project is null)
|
if (project is null)
|
||||||
return OperationResult.NotFound("پروژه یافت نشد");
|
return OperationResult.NotFound("پروژه یافت نشد");
|
||||||
|
|
||||||
var phases = project.Phases?.ToList() ?? new List<ProjectPhase>();
|
var phases = project.Phases?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectPhase>();
|
||||||
foreach (var phase in phases)
|
foreach (var phase in phases)
|
||||||
{
|
{
|
||||||
var tasks = phase.Tasks?.ToList() ?? new List<ProjectTask>();
|
var tasks = phase.Tasks?.ToList() ?? new List<Domain.ProjectAgg.Entities.ProjectTask>();
|
||||||
foreach (var t in tasks)
|
foreach (var t in tasks)
|
||||||
{
|
{
|
||||||
if (t.Priority != priority)
|
if (t.Priority != priority)
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.CreateProject;
|
||||||
|
|
||||||
public record CreateProjectCommand(string Name,ProjectHierarchyLevel Level,
|
public record CreateProjectCommand(string Name,ProjectHierarchyLevel Level,
|
||||||
|
ProjectTaskPriority? Priority,
|
||||||
Guid? ParentId):IBaseCommand;
|
Guid? ParentId):IBaseCommand;
|
||||||
@@ -3,9 +3,6 @@ using GozareshgirProgramManager.Application._Common.Models;
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
@@ -19,7 +16,8 @@ public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectComm
|
|||||||
private readonly IUnitOfWork _unitOfWork;
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
|
||||||
|
|
||||||
public CreateProjectCommandHandler(IProjectRepository projectRepository, IUnitOfWork unitOfWork, IProjectTaskRepository projectTaskRepository, IProjectPhaseRepository projectPhaseRepository)
|
public CreateProjectCommandHandler(IProjectRepository projectRepository, IUnitOfWork unitOfWork,
|
||||||
|
IProjectTaskRepository projectTaskRepository, IProjectPhaseRepository projectPhaseRepository)
|
||||||
{
|
{
|
||||||
_projectRepository = projectRepository;
|
_projectRepository = projectRepository;
|
||||||
_unitOfWork = unitOfWork;
|
_unitOfWork = unitOfWork;
|
||||||
@@ -59,7 +57,7 @@ public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectComm
|
|||||||
if (!request.ParentId.HasValue)
|
if (!request.ParentId.HasValue)
|
||||||
throw new BadRequestException("برای ایجاد فاز، شناسه پروژه الزامی است");
|
throw new BadRequestException("برای ایجاد فاز، شناسه پروژه الزامی است");
|
||||||
|
|
||||||
if(!_projectRepository.Exists(x=>x.Id == request.ParentId.Value))
|
if (!_projectRepository.Exists(x => x.Id == request.ParentId.Value))
|
||||||
{
|
{
|
||||||
throw new BadRequestException("والد پروژه یافت نشد");
|
throw new BadRequestException("والد پروژه یافت نشد");
|
||||||
}
|
}
|
||||||
@@ -73,13 +71,14 @@ public class CreateProjectCommandHandler : IBaseCommandHandler<CreateProjectComm
|
|||||||
if (!request.ParentId.HasValue)
|
if (!request.ParentId.HasValue)
|
||||||
throw new BadRequestException("برای ایجاد تسک، شناسه فاز الزامی است");
|
throw new BadRequestException("برای ایجاد تسک، شناسه فاز الزامی است");
|
||||||
|
|
||||||
if(!_projectPhaseRepository.Exists(x=>x.Id == request.ParentId.Value))
|
if (!_projectPhaseRepository.Exists(x => x.Id == request.ParentId.Value))
|
||||||
{
|
{
|
||||||
throw new BadRequestException("والد پروژه یافت نشد");
|
throw new BadRequestException("والد پروژه یافت نشد");
|
||||||
}
|
}
|
||||||
|
|
||||||
var projectTask = new ProjectTask(request.Name, request.ParentId.Value);
|
var priority = request.Priority ?? ProjectTaskPriority.Low;
|
||||||
|
|
||||||
|
var projectTask = new ProjectTask(request.Name, request.ParentId.Value, priority);
|
||||||
await _projectTaskRepository.CreateAsync(projectTask);
|
await _projectTaskRepository.CreateAsync(projectTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
|||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject;
|
||||||
@@ -17,5 +15,4 @@ public class SetTimeSectionTime
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public int Hours { get; set; }
|
public int Hours { get; set; }
|
||||||
public int Minutes { get; set; }
|
public int Minutes { get; set; }
|
||||||
public TaskSectionAdditionalTimeType Type { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,6 @@ using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||||
@@ -372,7 +369,7 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
|
|||||||
foreach (var additionalTime in sectionItem.AdditionalTime)
|
foreach (var additionalTime in sectionItem.AdditionalTime)
|
||||||
{
|
{
|
||||||
var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours).Add(TimeSpan.FromMinutes(additionalTime.Minutes));
|
var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours).Add(TimeSpan.FromMinutes(additionalTime.Minutes));
|
||||||
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Type, additionalTime.Description, addedByUserId);
|
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||||
hasAdditionalTime = true;
|
hasAdditionalTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
using GozareshgirProgramManager.Application.Modules.Projects.DTOs;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Extensions;
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Extensions;
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ public class GetProjectItemDto
|
|||||||
public int Percentage { get; init; }
|
public int Percentage { get; init; }
|
||||||
public ProjectHierarchyLevel Level { get; init; }
|
public ProjectHierarchyLevel Level { get; init; }
|
||||||
public Guid? ParentId { get; init; }
|
public Guid? ParentId { get; init; }
|
||||||
public int TotalHours { get; set; }
|
|
||||||
public int Minutes { get; set; }
|
public TimeSpan TotalTime { get; init; }
|
||||||
|
|
||||||
|
public TimeSpan RemainingTime { get; init; }
|
||||||
public AssignmentStatus Front { get; set; }
|
public AssignmentStatus Front { get; set; }
|
||||||
public AssignmentStatus Backend { get; set; }
|
public AssignmentStatus Backend { get; set; }
|
||||||
public AssignmentStatus Design { get; set; }
|
public AssignmentStatus Design { get; set; }
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||||
|
|
||||||
@@ -20,7 +16,8 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<OperationResult<GetProjectsListResponse>> Handle(GetProjectsListQuery request, CancellationToken cancellationToken)
|
public async Task<OperationResult<GetProjectsListResponse>> Handle(GetProjectsListQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var projects = new List<GetProjectDto>();
|
var projects = new List<GetProjectDto>();
|
||||||
var phases = new List<GetPhaseDto>();
|
var phases = new List<GetPhaseDto>();
|
||||||
@@ -55,13 +52,14 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
{
|
{
|
||||||
return new List<GetProjectDto>();
|
return new List<GetProjectDto>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.OrderByDescending(p => p.CreationDate)
|
.OrderByDescending(p => p.CreationDate)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
var result = new List<GetProjectDto>();
|
var result = new List<GetProjectDto>();
|
||||||
foreach (var project in entities)
|
foreach (var project in entities)
|
||||||
{
|
{
|
||||||
var (percentage, totalTime) = await CalculateProjectPercentage(project, cancellationToken);
|
var (percentage, totalTime,remainingTime) = await CalculateProjectPercentage(project, cancellationToken);
|
||||||
result.Add(new GetProjectDto
|
result.Add(new GetProjectDto
|
||||||
{
|
{
|
||||||
Id = project.Id,
|
Id = project.Id,
|
||||||
@@ -69,10 +67,12 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
Level = ProjectHierarchyLevel.Project,
|
Level = ProjectHierarchyLevel.Project,
|
||||||
ParentId = null,
|
ParentId = null,
|
||||||
Percentage = percentage,
|
Percentage = percentage,
|
||||||
TotalHours = (int)totalTime.TotalHours,
|
TotalTime = totalTime,
|
||||||
Minutes = totalTime.Minutes,
|
RemainingTime = remainingTime
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = result.OrderByDescending(x => x.Percentage).ToList();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +83,14 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
{
|
{
|
||||||
query = query.Where(x => x.ProjectId == parentId);
|
query = query.Where(x => x.ProjectId == parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.OrderByDescending(p => p.CreationDate)
|
.OrderByDescending(p => p.CreationDate)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
var result = new List<GetPhaseDto>();
|
var result = new List<GetPhaseDto>();
|
||||||
foreach (var phase in entities)
|
foreach (var phase in entities)
|
||||||
{
|
{
|
||||||
var (percentage, totalTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
var (percentage, totalTime,remainingTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
||||||
result.Add(new GetPhaseDto
|
result.Add(new GetPhaseDto
|
||||||
{
|
{
|
||||||
Id = phase.Id,
|
Id = phase.Id,
|
||||||
@@ -97,10 +98,12 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
Level = ProjectHierarchyLevel.Phase,
|
Level = ProjectHierarchyLevel.Phase,
|
||||||
ParentId = phase.ProjectId,
|
ParentId = phase.ProjectId,
|
||||||
Percentage = percentage,
|
Percentage = percentage,
|
||||||
TotalHours = (int)totalTime.TotalHours,
|
TotalTime = totalTime,
|
||||||
Minutes = totalTime.Minutes,
|
RemainingTime = remainingTime
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
result = result.OrderByDescending(x => x.Percentage).ToList();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +114,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
{
|
{
|
||||||
query = query.Where(x => x.PhaseId == parentId);
|
query = query.Where(x => x.PhaseId == parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.OrderByDescending(t => t.CreationDate)
|
.OrderByDescending(t => t.CreationDate)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
@@ -122,7 +126,7 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
|
|
||||||
foreach (var task in entities)
|
foreach (var task in entities)
|
||||||
{
|
{
|
||||||
var (percentage, totalTime) = await CalculateTaskPercentage(task, cancellationToken);
|
var (percentage, totalTime,remainingTime) = await CalculateTaskPercentage(task, cancellationToken);
|
||||||
var sections = await _context.TaskSections
|
var sections = await _context.TaskSections
|
||||||
.Include(s => s.Activities)
|
.Include(s => s.Activities)
|
||||||
.Include(s => s.Skill)
|
.Include(s => s.Skill)
|
||||||
@@ -144,7 +148,6 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
|
|
||||||
// محاسبه SpentTime و RemainingTime
|
// محاسبه SpentTime و RemainingTime
|
||||||
var spentTime = TimeSpan.FromTicks(sections.Sum(s => s.Activities.Sum(a => a.GetTimeSpent().Ticks)));
|
var spentTime = TimeSpan.FromTicks(sections.Sum(s => s.Activities.Sum(a => a.GetTimeSpent().Ticks)));
|
||||||
var remainingTime = totalTime - spentTime;
|
|
||||||
|
|
||||||
// ساخت section DTOs برای تمام Skills
|
// ساخت section DTOs برای تمام Skills
|
||||||
var sectionDtos = allSkills.Select(skill =>
|
var sectionDtos = allSkills.Select(skill =>
|
||||||
@@ -188,18 +191,20 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
Level = ProjectHierarchyLevel.Task,
|
Level = ProjectHierarchyLevel.Task,
|
||||||
ParentId = task.PhaseId,
|
ParentId = task.PhaseId,
|
||||||
Percentage = percentage,
|
Percentage = percentage,
|
||||||
TotalHours = (int)totalTime.TotalHours,
|
TotalTime = totalTime,
|
||||||
Minutes = totalTime.Minutes,
|
|
||||||
SpentTime = spentTime,
|
SpentTime = spentTime,
|
||||||
RemainingTime = remainingTime,
|
RemainingTime = remainingTime,
|
||||||
Sections = sectionDtos,
|
Sections = sectionDtos,
|
||||||
Priority = task.Priority
|
Priority = task.Priority
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
result = result.OrderByDescending(x => x.Percentage).ToList();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetSkillFlags<TItem>(List<TItem> items, CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
private async Task SetSkillFlags<TItem>(List<TItem> items, CancellationToken cancellationToken)
|
||||||
|
where TItem : GetProjectItemDto
|
||||||
{
|
{
|
||||||
if (!items.Any())
|
if (!items.Any())
|
||||||
return;
|
return;
|
||||||
@@ -217,7 +222,8 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task SetSkillFlagsForProjects<TItem>(List<TItem> items, List<Guid> projectIds, CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
private async Task SetSkillFlagsForProjects<TItem>(List<TItem> items, List<Guid> projectIds,
|
||||||
|
CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||||
{
|
{
|
||||||
// For projects: gather all phases, then tasks, then sections
|
// For projects: gather all phases, then tasks, then sections
|
||||||
var phases = await _context.ProjectPhases
|
var phases = await _context.ProjectPhases
|
||||||
@@ -247,7 +253,8 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetSkillFlagsForPhases<TItem>(List<TItem> items, List<Guid> phaseIds, CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
private async Task SetSkillFlagsForPhases<TItem>(List<TItem> items, List<Guid> phaseIds,
|
||||||
|
CancellationToken cancellationToken) where TItem : GetProjectItemDto
|
||||||
{
|
{
|
||||||
// For phases: gather tasks, then sections
|
// For phases: gather tasks, then sections
|
||||||
var tasks = await _context.ProjectTasks
|
var tasks = await _context.ProjectTasks
|
||||||
@@ -273,68 +280,81 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(int Percentage, TimeSpan TotalTime)> CalculateProjectPercentage(Project project, CancellationToken cancellationToken)
|
private async Task<(int Percentage, TimeSpan TotalTime,TimeSpan RemainingTime)> CalculateProjectPercentage(Project project,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var phases = await _context.ProjectPhases
|
var phases = await _context.ProjectPhases
|
||||||
.Where(ph => ph.ProjectId == project.Id)
|
.Where(ph => ph.ProjectId == project.Id)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
if (!phases.Any())
|
if (!phases.Any())
|
||||||
return (0, TimeSpan.Zero);
|
return (0, TimeSpan.Zero,TimeSpan.Zero);
|
||||||
var phasePercentages = new List<int>();
|
var phasePercentages = new List<int>();
|
||||||
var totalTime = TimeSpan.Zero;
|
var totalTime = TimeSpan.Zero;
|
||||||
|
var remainingTime = TimeSpan.Zero;
|
||||||
foreach (var phase in phases)
|
foreach (var phase in phases)
|
||||||
{
|
{
|
||||||
var (phasePercentage, phaseTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
var (phasePercentage, phaseTime,phaseRemainingTime) = await CalculatePhasePercentage(phase, cancellationToken);
|
||||||
phasePercentages.Add(phasePercentage);
|
phasePercentages.Add(phasePercentage);
|
||||||
totalTime += phaseTime;
|
totalTime += phaseTime;
|
||||||
|
remainingTime += phaseRemainingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
var averagePercentage = phasePercentages.Any() ? (int)phasePercentages.Average() : 0;
|
var averagePercentage = phasePercentages.Any() ? (int)phasePercentages.Average() : 0;
|
||||||
return (averagePercentage, totalTime);
|
return (averagePercentage, totalTime,remainingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(int Percentage, TimeSpan TotalTime)> CalculatePhasePercentage(ProjectPhase phase, CancellationToken cancellationToken)
|
private async Task<(int Percentage, TimeSpan TotalTime,TimeSpan RemainingTime)> CalculatePhasePercentage(ProjectPhase phase,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var tasks = await _context.ProjectTasks
|
var tasks = await _context.ProjectTasks
|
||||||
.Where(t => t.PhaseId == phase.Id)
|
.Where(t => t.PhaseId == phase.Id)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
if (!tasks.Any())
|
if (!tasks.Any())
|
||||||
return (0, TimeSpan.Zero);
|
return (0, TimeSpan.Zero,TimeSpan.Zero);
|
||||||
var taskPercentages = new List<int>();
|
var taskPercentages = new List<int>();
|
||||||
var totalTime = TimeSpan.Zero;
|
var totalTime = TimeSpan.Zero;
|
||||||
|
var remainingTime = TimeSpan.Zero;
|
||||||
foreach (var task in tasks)
|
foreach (var task in tasks)
|
||||||
{
|
{
|
||||||
var (taskPercentage, taskTime) = await CalculateTaskPercentage(task, cancellationToken);
|
var (taskPercentage, taskTime,taskRemainingTime) = await CalculateTaskPercentage(task, cancellationToken);
|
||||||
taskPercentages.Add(taskPercentage);
|
taskPercentages.Add(taskPercentage);
|
||||||
totalTime += taskTime;
|
totalTime += taskTime;
|
||||||
|
remainingTime += taskRemainingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
var averagePercentage = taskPercentages.Any() ? (int)taskPercentages.Average() : 0;
|
var averagePercentage = taskPercentages.Any() ? (int)taskPercentages.Average() : 0;
|
||||||
return (averagePercentage, totalTime);
|
return (averagePercentage, totalTime,remainingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(int Percentage, TimeSpan TotalTime)> CalculateTaskPercentage(ProjectTask task, CancellationToken cancellationToken)
|
private async Task<(int Percentage, TimeSpan TotalTime, TimeSpan RemainingTime)> CalculateTaskPercentage(
|
||||||
|
ProjectTask task, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var sections = await _context.TaskSections
|
var sections = await _context.TaskSections
|
||||||
.Include(s => s.Activities)
|
.Include(s => s.Activities)
|
||||||
.Include(x=>x.AdditionalTimes)
|
.Include(x => x.AdditionalTimes)
|
||||||
.Where(s => s.TaskId == task.Id)
|
.Where(s => s.TaskId == task.Id)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
if (!sections.Any())
|
if (!sections.Any())
|
||||||
return (0, TimeSpan.Zero);
|
return (0, TimeSpan.Zero, TimeSpan.Zero);
|
||||||
var sectionPercentages = new List<int>();
|
var sectionPercentages = new List<int>();
|
||||||
var totalTime = TimeSpan.Zero;
|
var totalTime = TimeSpan.Zero;
|
||||||
|
var spentTime = TimeSpan.Zero;
|
||||||
foreach (var section in sections)
|
foreach (var section in sections)
|
||||||
{
|
{
|
||||||
var (sectionPercentage, sectionTime) = CalculateSectionPercentage(section);
|
var (sectionPercentage, sectionTime) = CalculateSectionPercentage(section);
|
||||||
|
var sectionSpent = TimeSpan.FromTicks(section.Activities.Sum(x => x.GetTimeSpent().Ticks));
|
||||||
sectionPercentages.Add(sectionPercentage);
|
sectionPercentages.Add(sectionPercentage);
|
||||||
totalTime += sectionTime;
|
totalTime += sectionTime;
|
||||||
|
spentTime += sectionSpent;
|
||||||
}
|
}
|
||||||
|
var remainingTime = totalTime - spentTime;
|
||||||
var averagePercentage = sectionPercentages.Any() ? (int)sectionPercentages.Average() : 0;
|
var averagePercentage = sectionPercentages.Any() ? (int)sectionPercentages.Average() : 0;
|
||||||
return (averagePercentage, totalTime);
|
return (averagePercentage, totalTime, remainingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (int Percentage, TimeSpan TotalTime) CalculateSectionPercentage(TaskSection section)
|
private static (int Percentage, TimeSpan TotalTime) CalculateSectionPercentage(TaskSection section)
|
||||||
{
|
{
|
||||||
return ((int)section.GetProgressPercentage(),section.FinalEstimatedHours);
|
return ((int)section.GetProgressPercentage(), section.FinalEstimatedHours);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AssignmentStatus GetAssignmentStatus(TaskSection? section)
|
private static AssignmentStatus GetAssignmentStatus(TaskSection? section)
|
||||||
@@ -361,4 +381,3 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
|||||||
return AssignmentStatus.Unassigned;
|
return AssignmentStatus.Unassigned;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ public class GetTaskDto
|
|||||||
public int Percentage { get; init; }
|
public int Percentage { get; init; }
|
||||||
public ProjectHierarchyLevel Level { get; init; }
|
public ProjectHierarchyLevel Level { get; init; }
|
||||||
public Guid? ParentId { get; init; }
|
public Guid? ParentId { get; init; }
|
||||||
public int TotalHours { get; set; }
|
|
||||||
public int Minutes { get; set; }
|
public TimeSpan TotalTime { get; set; }
|
||||||
|
|
||||||
// Task-specific fields
|
// Task-specific fields
|
||||||
public TimeSpan SpentTime { get; init; }
|
public TimeSpan SpentTime { get; init; }
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.Project
|
|||||||
public record ProjectBoardListQuery: IBaseQuery<List<ProjectBoardListResponse>>
|
public record ProjectBoardListQuery: IBaseQuery<List<ProjectBoardListResponse>>
|
||||||
{
|
{
|
||||||
public long? UserId { get; set; }
|
public long? UserId { get; set; }
|
||||||
public string? SearchText { get; set; }
|
public string? ProjectName { get; set; }
|
||||||
public TaskSectionStatus? Status { get; set; }
|
public TaskSectionStatus? Status { get; set; }
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,11 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
|||||||
queryable = queryable.Where(x => x.CurrentAssignedUserId == request.UserId);
|
queryable = queryable.Where(x => x.CurrentAssignedUserId == request.UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(request.SearchText))
|
if (!string.IsNullOrWhiteSpace(request.ProjectName))
|
||||||
{
|
{
|
||||||
queryable = queryable.Where(x=>x.Task.Name.Contains(request.SearchText)
|
queryable = queryable.Where(x=>x.Task.Name.Contains(request.ProjectName)
|
||||||
|| x.Task.Phase.Name.Contains(request.SearchText)
|
|| x.Task.Phase.Name.Contains(request.ProjectName)
|
||||||
|| x.Task.Phase.Project.Name.Contains(request.SearchText));
|
|| x.Task.Phase.Project.Name.Contains(request.ProjectName));
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = await queryable.ToListAsync(cancellationToken);
|
var data = await queryable.ToListAsync(cancellationToken);
|
||||||
@@ -70,6 +70,9 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
|||||||
.OrderByDescending(x => x.CurrentAssignedUserId == currentUserId)
|
.OrderByDescending(x => x.CurrentAssignedUserId == currentUserId)
|
||||||
.ThenByDescending(x=>x.Task.Priority)
|
.ThenByDescending(x=>x.Task.Priority)
|
||||||
.ThenBy(x => GetStatusOrder(x.Status))
|
.ThenBy(x => GetStatusOrder(x.Status))
|
||||||
|
.ThenBy(x=>x.Task.Phase.ProjectId)
|
||||||
|
.ThenBy(x=>x.Task.PhaseId)
|
||||||
|
.ThenBy(x=>x.TaskId)
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
// محاسبه یکبار برای هر Activity و Cache کردن نتیجه
|
// محاسبه یکبار برای هر Activity و Cache کردن نتیجه
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
|||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
using GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProjectsList;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
|
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -29,7 +28,7 @@ public class GetMessagesQueryHandler : IBaseQueryHandler<GetMessagesQuery, Pagin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<MessageDto> CreateAdditionalTimeNotes(
|
private List<MessageDto> CreateAdditionalTimeNotes(
|
||||||
IEnumerable<TaskSectionAdditionalTime> additionalTimes,
|
IEnumerable<Domain.ProjectAgg.Entities.TaskSectionAdditionalTime> additionalTimes,
|
||||||
Dictionary<long, string> users,
|
Dictionary<long, string> users,
|
||||||
Guid taskId)
|
Guid taskId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
|
||||||
using GozareshgirProgramManager.Application.Services.FileManagement;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
|
||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Enums;
|
|
||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision;
|
|
||||||
|
|
||||||
public record CreateTaskSectionRevisionCommand(string Message, List<IFormFile> Files, Guid SectionId) : IBaseCommand;
|
|
||||||
|
|
||||||
public class CreateTaskSectionRevisionCommandHandler : IBaseCommandHandler<CreateTaskSectionRevisionCommand>
|
|
||||||
{
|
|
||||||
private readonly ITaskSectionRevisionRepository _revisionRepository;
|
|
||||||
private readonly IFileStorageService _fileStorageService;
|
|
||||||
private readonly IAuthHelper _authHelper;
|
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
|
||||||
private readonly IUploadedFileRepository _fileRepository;
|
|
||||||
private readonly IThumbnailGeneratorService _thumbnailService;
|
|
||||||
|
|
||||||
public CreateTaskSectionRevisionCommandHandler(ITaskSectionRevisionRepository revisionRepository,
|
|
||||||
IFileStorageService fileStorageService, IAuthHelper authHelper, IUnitOfWork unitOfWork, IUploadedFileRepository fileRepository, IThumbnailGeneratorService thumbnailService)
|
|
||||||
{
|
|
||||||
_revisionRepository = revisionRepository;
|
|
||||||
_fileStorageService = fileStorageService;
|
|
||||||
_authHelper = authHelper;
|
|
||||||
_unitOfWork = unitOfWork;
|
|
||||||
_fileRepository = fileRepository;
|
|
||||||
_thumbnailService = thumbnailService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult> Handle(CreateTaskSectionRevisionCommand request,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var currentId = _authHelper.GetCurrentUserId();
|
|
||||||
|
|
||||||
var entity = new Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision(request.SectionId, request.Message, currentId!.Value);
|
|
||||||
if (request.Files is { Count: > 0 })
|
|
||||||
{
|
|
||||||
foreach (var file in request.Files)
|
|
||||||
{
|
|
||||||
if (file.Length == 0)
|
|
||||||
{
|
|
||||||
return OperationResult.ValidationError("فایل خالی است");
|
|
||||||
}
|
|
||||||
|
|
||||||
const long maxFileSize = 100 * 1024 * 1024;
|
|
||||||
if (file.Length > maxFileSize)
|
|
||||||
{
|
|
||||||
return OperationResult.ValidationError("حجم فایل بیش از حد مجاز است (حداکثر 100MB)");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fileType = DetectFileType(file.ContentType, Path.GetExtension(file.FileName));
|
|
||||||
|
|
||||||
var uploadedFile = new UploadedFile(
|
|
||||||
originalFileName: file.FileName,
|
|
||||||
fileSizeBytes: file.Length,
|
|
||||||
mimeType: file.ContentType,
|
|
||||||
fileType: fileType,
|
|
||||||
category: FileCategory.TaskSectionRevision,
|
|
||||||
uploadedByUserId: currentId!.Value,
|
|
||||||
storageProvider: StorageProvider.LocalFileSystem
|
|
||||||
);
|
|
||||||
|
|
||||||
await _fileRepository.AddAsync(uploadedFile);
|
|
||||||
await _fileRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var stream = file.OpenReadStream();
|
|
||||||
var uploadResult = await _fileStorageService.UploadAsync(
|
|
||||||
stream,
|
|
||||||
uploadedFile.UniqueFileName,
|
|
||||||
"TaskSectionRevision"
|
|
||||||
);
|
|
||||||
|
|
||||||
uploadedFile.CompleteUpload(uploadResult.StoragePath, uploadResult.StorageUrl);
|
|
||||||
|
|
||||||
if (fileType == FileType.Image)
|
|
||||||
{
|
|
||||||
var dimensions = await _thumbnailService.GetImageDimensionsAsync(uploadResult.StoragePath);
|
|
||||||
if (dimensions.HasValue)
|
|
||||||
{
|
|
||||||
uploadedFile.SetImageDimensions(dimensions.Value.Width, dimensions.Value.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
var thumbnail = await _thumbnailService
|
|
||||||
.GenerateImageThumbnailAsync(uploadResult.StoragePath, category: "TaskSectionRevision");
|
|
||||||
if (thumbnail.HasValue)
|
|
||||||
{
|
|
||||||
uploadedFile.SetThumbnail(thumbnail.Value.ThumbnailUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await _fileRepository.UpdateAsync(uploadedFile);
|
|
||||||
await _fileRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
var taskRevisionFile = new TaskRevisionFile(uploadedFile.Id);
|
|
||||||
entity.AddFile(taskRevisionFile);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await _fileRepository.DeleteAsync(uploadedFile);
|
|
||||||
await _fileRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
return OperationResult<MessageDto>.ValidationError($"خطا در آپلود فایل: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await _revisionRepository.CreateAsync(entity);
|
|
||||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
|
||||||
return OperationResult.Success();
|
|
||||||
}
|
|
||||||
private FileType DetectFileType(string mimeType, string extension)
|
|
||||||
{
|
|
||||||
if (mimeType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
|
|
||||||
return FileType.Image;
|
|
||||||
|
|
||||||
if (mimeType.StartsWith("video/", StringComparison.OrdinalIgnoreCase))
|
|
||||||
return FileType.Video;
|
|
||||||
|
|
||||||
if (mimeType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase))
|
|
||||||
return FileType.Audio;
|
|
||||||
|
|
||||||
if (new[] { ".zip", ".rar", ".7z", ".tar", ".gz" }.Contains(extension.ToLower()))
|
|
||||||
return FileType.Archive;
|
|
||||||
|
|
||||||
return FileType.Document;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision;
|
|
||||||
|
|
||||||
public class CreateTaskSectionRevisionValidator:AbstractValidator<CreateTaskSectionRevisionCommand>
|
|
||||||
{
|
|
||||||
public CreateTaskSectionRevisionValidator()
|
|
||||||
{
|
|
||||||
RuleFor(x=>x.Message)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("توضیحات اجباری است");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.SetStatusReviewedRevision;
|
|
||||||
|
|
||||||
public record SetStatusReviewedRevisionCommand(Guid TaskSectionId):IBaseCommand;
|
|
||||||
|
|
||||||
public class SetStatusReviewedRevisionCommandHandler : IBaseCommandHandler<SetStatusReviewedRevisionCommand>
|
|
||||||
{
|
|
||||||
private readonly ITaskSectionRevisionRepository _revisionRepository;
|
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
|
||||||
|
|
||||||
public SetStatusReviewedRevisionCommandHandler(ITaskSectionRevisionRepository revisionRepository, IUnitOfWork unitOfWork)
|
|
||||||
{
|
|
||||||
_revisionRepository = revisionRepository;
|
|
||||||
_unitOfWork = unitOfWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult> Handle(SetStatusReviewedRevisionCommand request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var taskSectionRevisions = await _revisionRepository.GetByTaskSectionId(request.TaskSectionId);
|
|
||||||
if (taskSectionRevisions == null || taskSectionRevisions.Count == 0)
|
|
||||||
return OperationResult.NotFound("اصلاحی برای این بخش یافت نشد");
|
|
||||||
|
|
||||||
foreach (var revision in taskSectionRevisions)
|
|
||||||
{
|
|
||||||
revision.MarkReviewed();
|
|
||||||
}
|
|
||||||
|
|
||||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
|
||||||
return OperationResult.Success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId;
|
|
||||||
|
|
||||||
public record TaskRevisionsByTaskSectionIdQuery(Guid TaskSectionId)
|
|
||||||
: IBaseQuery<TaskRevisionsByTaskSectionIdResponse>;
|
|
||||||
|
|
||||||
public class TaskRevisionsByTaskSectionIdQueryHandler : IBaseQueryHandler<TaskRevisionsByTaskSectionIdQuery,
|
|
||||||
TaskRevisionsByTaskSectionIdResponse>
|
|
||||||
{
|
|
||||||
private readonly IProgramManagerDbContext _dbContext;
|
|
||||||
|
|
||||||
public TaskRevisionsByTaskSectionIdQueryHandler(IProgramManagerDbContext dbContext)
|
|
||||||
{
|
|
||||||
_dbContext = dbContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult<TaskRevisionsByTaskSectionIdResponse>> Handle(
|
|
||||||
TaskRevisionsByTaskSectionIdQuery request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var taskSectionEntity = await _dbContext.TaskSections
|
|
||||||
.Include(x=>x.Task)
|
|
||||||
.ThenInclude(x => x.Phase)
|
|
||||||
.ThenInclude(x => x.Project)
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == request.TaskSectionId,
|
|
||||||
cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (taskSectionEntity == null)
|
|
||||||
{
|
|
||||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("بخش فرعی یافت نشد");
|
|
||||||
}
|
|
||||||
|
|
||||||
var taskRevisions = await _dbContext.TaskSectionRevisions
|
|
||||||
.Include(x => x.Files).Where(x => x.TaskSectionId == request.TaskSectionId)
|
|
||||||
.ToListAsync(cancellationToken);
|
|
||||||
if (taskRevisions.Count == 0)
|
|
||||||
{
|
|
||||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("اصلاحی یافت نشد");
|
|
||||||
}
|
|
||||||
|
|
||||||
var skill = await _dbContext.Skills.FirstOrDefaultAsync(x => x.Id == taskSectionEntity.SkillId,
|
|
||||||
cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (skill == null)
|
|
||||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("مهارت مورد نظر یافت نشد");
|
|
||||||
|
|
||||||
|
|
||||||
var user =await _dbContext.Users.FirstOrDefaultAsync(x => x.Id == taskSectionEntity.CurrentAssignedUserId,
|
|
||||||
cancellationToken: cancellationToken);
|
|
||||||
if (user == null)
|
|
||||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.NotFound("کاربر مورد نظر یافت نشد");
|
|
||||||
|
|
||||||
var fileIds = taskRevisions.SelectMany(x => x.Files)
|
|
||||||
.Select(x => x.FileId).Distinct().ToList();
|
|
||||||
|
|
||||||
var uploadedFiles = _dbContext.UploadedFiles
|
|
||||||
.Where(x => fileIds.Contains(x.Id)).ToList();
|
|
||||||
|
|
||||||
var resItems = taskRevisions.Select(x =>
|
|
||||||
{
|
|
||||||
var itemFileIds = x.Files.Select(f => f.FileId).Distinct().ToList();
|
|
||||||
|
|
||||||
var files = uploadedFiles
|
|
||||||
.Where(f => itemFileIds.Contains(f.Id))
|
|
||||||
.Select(file => new TaskRevisionsByTaskSectionIdItemFile()
|
|
||||||
{
|
|
||||||
Id = file.Id,
|
|
||||||
FileName = file.OriginalFileName,
|
|
||||||
FileUrl = file.StorageUrl ?? "",
|
|
||||||
FileSizeBytes = file.FileSizeBytes,
|
|
||||||
FileType = file.FileType.ToString(),
|
|
||||||
ThumbnailUrl = file.ThumbnailUrl,
|
|
||||||
ImageWidth = file.ImageWidth,
|
|
||||||
ImageHeight = file.ImageHeight,
|
|
||||||
DurationSeconds = file.DurationSeconds
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
return new TaskRevisionsByTaskSectionIdItem(x.Message, files,$"{x.CreationDate.ToFarsi()} {x.CreationDate:HH:mm}");
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
var res = new TaskRevisionsByTaskSectionIdResponse(resItems, taskSectionEntity.Task.Phase.Project.Name,
|
|
||||||
taskSectionEntity.Task.Phase.Name, taskSectionEntity.Task.Name,
|
|
||||||
skill.Name,
|
|
||||||
user.FullName
|
|
||||||
);
|
|
||||||
|
|
||||||
return OperationResult<TaskRevisionsByTaskSectionIdResponse>.Success(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId;
|
|
||||||
|
|
||||||
public record TaskRevisionsByTaskSectionIdResponse(
|
|
||||||
List<TaskRevisionsByTaskSectionIdItem> Items,
|
|
||||||
string ProjectName,
|
|
||||||
string PhaseName,
|
|
||||||
string TaskName,
|
|
||||||
string SkillName,
|
|
||||||
string UserName);
|
|
||||||
|
|
||||||
|
|
||||||
public record TaskRevisionsByTaskSectionIdItem(string Message, List<TaskRevisionsByTaskSectionIdItemFile> Files,string CreationDate);
|
|
||||||
|
|
||||||
public class TaskRevisionsByTaskSectionIdItemFile:UploadedFileDto;
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest;
|
|
||||||
|
|
||||||
public record AcceptTimeRequestCommand(Guid TimeRequestId,
|
|
||||||
Guid SectionId,TaskSectionAdditionalTimeType TimeType,int Hour,int Minute):IBaseCommand;
|
|
||||||
|
|
||||||
public class AcceptTimeRequestCommandHandler:IBaseCommandHandler<AcceptTimeRequestCommand>
|
|
||||||
{
|
|
||||||
private readonly ITaskSectionTimeRequestRepository _timeRequestRepository;
|
|
||||||
private readonly ITaskSectionRepository _taskSectionRepository;
|
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
|
||||||
public AcceptTimeRequestCommandHandler(ITaskSectionTimeRequestRepository timeRequestRepository, ITaskSectionRepository taskSectionRepository, IUnitOfWork unitOfWork)
|
|
||||||
{
|
|
||||||
_timeRequestRepository = timeRequestRepository;
|
|
||||||
_taskSectionRepository = taskSectionRepository;
|
|
||||||
_unitOfWork = unitOfWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult> Handle(AcceptTimeRequestCommand request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var timeRequest = await _timeRequestRepository.GetByIdAsync(request.TimeRequestId, cancellationToken);
|
|
||||||
if (timeRequest == null)
|
|
||||||
{
|
|
||||||
return OperationResult.NotFound("درخواست زمان شما یافت نشد");
|
|
||||||
}
|
|
||||||
|
|
||||||
var taskSection = await _taskSectionRepository.GetByIdAsync(request.SectionId, cancellationToken);
|
|
||||||
|
|
||||||
if (taskSection == null)
|
|
||||||
{
|
|
||||||
return OperationResult.NotFound("بخش فرعی وارد شده نامعتبر است");
|
|
||||||
}
|
|
||||||
if (timeRequest.RequestStatus == TaskSectionTimeRequestStatus.Accepted)
|
|
||||||
{
|
|
||||||
return OperationResult.Failure("این درخواست قبلا تایید شده است");
|
|
||||||
}
|
|
||||||
|
|
||||||
// تایید درخواست زمان
|
|
||||||
timeRequest.AcceptTimeRequest();
|
|
||||||
|
|
||||||
// اضافه کردن زمان به TaskSection
|
|
||||||
var totalMinutes = (request.Hour * 60) + request.Minute;
|
|
||||||
var additionalTime = TimeSpan.FromMinutes(totalMinutes);
|
|
||||||
taskSection.AddAdditionalTime(additionalTime, request.TimeType, timeRequest.Description);
|
|
||||||
|
|
||||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
|
||||||
return OperationResult.Success();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest;
|
|
||||||
|
|
||||||
public class AcceptTimeRequestCommandValidator : AbstractValidator<AcceptTimeRequestCommand>
|
|
||||||
{
|
|
||||||
public AcceptTimeRequestCommandValidator()
|
|
||||||
{
|
|
||||||
RuleFor(c => c.TimeRequestId)
|
|
||||||
.NotEmpty().WithMessage("شناسه درخواست نمیتواند خالی باشد");
|
|
||||||
|
|
||||||
RuleFor(c => c.SectionId)
|
|
||||||
.NotEmpty().WithMessage("شناسه بخش فرعی نمیتواند خالی باشد");
|
|
||||||
|
|
||||||
RuleFor(c => c.TimeType)
|
|
||||||
.NotNull().WithMessage("نوع زمان درخواست شده نامعتبر است")
|
|
||||||
.IsInEnum();
|
|
||||||
|
|
||||||
RuleFor(c => c.Hour)
|
|
||||||
.InclusiveBetween(0, 100).WithMessage("ساعت وارد شده میتواند بین 0 تا 100 باشد");
|
|
||||||
RuleFor(c => c.Minute)
|
|
||||||
.InclusiveBetween(0, 60).WithMessage("دقیقه وارد شده میتواند بین 0 تا 60 باشد");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest;
|
|
||||||
|
|
||||||
public record CreateTimeRequestCommand(int Hours, int Minutes, string Description,
|
|
||||||
TaskSectionTimeRequestType RequestType,Guid TaskSectionId) : IBaseCommand;
|
|
||||||
|
|
||||||
public class CreateTimeRequestCommandHandler : IBaseCommandHandler<CreateTimeRequestCommand>
|
|
||||||
{
|
|
||||||
private readonly IAuthHelper _authHelper;
|
|
||||||
private readonly ITaskSectionTimeRequestRepository _timeRequestRepository;
|
|
||||||
private readonly ITaskSectionRepository _taskSectionRepository;
|
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
|
||||||
|
|
||||||
public CreateTimeRequestCommandHandler
|
|
||||||
(ITaskSectionTimeRequestRepository timeRequestRepository, IAuthHelper authHelper, IUnitOfWork unitOfWork, ITaskSectionRepository taskSectionRepository)
|
|
||||||
{
|
|
||||||
_timeRequestRepository = timeRequestRepository;
|
|
||||||
_authHelper = authHelper;
|
|
||||||
_unitOfWork = unitOfWork;
|
|
||||||
_taskSectionRepository = taskSectionRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult> Handle(CreateTimeRequestCommand request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var currentUser = _authHelper.GetCurrentUserId();
|
|
||||||
if (!currentUser.HasValue)
|
|
||||||
{
|
|
||||||
return OperationResult.Unauthorized();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_taskSectionRepository.Exists(x=>x.Id == request.TaskSectionId))
|
|
||||||
{
|
|
||||||
return OperationResult.NotFound("وظیفه فرعی مورد نظر یافت نشد");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var requestTimeSpan = TimeSpan.FromHours(request.Hours) + TimeSpan.FromMinutes(request.Minutes);
|
|
||||||
|
|
||||||
var entity = new TaskSectionTimeRequest(currentUser.Value, request.Description, requestTimeSpan,
|
|
||||||
request.RequestType,request.TaskSectionId);
|
|
||||||
await _timeRequestRepository.CreateAsync(entity);
|
|
||||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
|
||||||
return OperationResult.Success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest;
|
|
||||||
|
|
||||||
public class CreateTimeRequestValidator : AbstractValidator<CreateTimeRequestCommand>
|
|
||||||
{
|
|
||||||
public CreateTimeRequestValidator()
|
|
||||||
{
|
|
||||||
RuleFor(c => c.Hours)
|
|
||||||
.InclusiveBetween(0, 100).WithMessage("ساعت درخواست شده باید کمتر از 100 ساعت باشد");
|
|
||||||
|
|
||||||
RuleFor(c => c.Minutes)
|
|
||||||
.InclusiveBetween(0, 59)
|
|
||||||
.WithMessage("دقیقه وارد شده باید بین 0 تا 60 باشد");
|
|
||||||
|
|
||||||
RuleFor(x => x.RequestType)
|
|
||||||
.IsInEnum()
|
|
||||||
.NotNull();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Extensions;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Queries.CreateTimeRequestDetails;
|
|
||||||
|
|
||||||
public record CreateTimeRequestDetailsResponse(List<CreateTimeRequestDetailsRevision> Revisions,
|
|
||||||
string ProjectName,string PhaseName,string SectionName,string SkillName);
|
|
||||||
|
|
||||||
public record CreateTimeRequestDetailsRevision(string Message, List<UploadedFileDto> Files,Guid Id,string CreationDate);
|
|
||||||
|
|
||||||
public record CreateTimeRequestDetailsQuery(Guid TaskSectionId) : IBaseQuery<CreateTimeRequestDetailsResponse>;
|
|
||||||
|
|
||||||
public class
|
|
||||||
CreateTimeRequestDetailsQueryHandler : IBaseQueryHandler<CreateTimeRequestDetailsQuery,
|
|
||||||
CreateTimeRequestDetailsResponse>
|
|
||||||
{
|
|
||||||
private readonly IProgramManagerDbContext _context;
|
|
||||||
|
|
||||||
public CreateTimeRequestDetailsQueryHandler(IProgramManagerDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult<CreateTimeRequestDetailsResponse>> Handle(CreateTimeRequestDetailsQuery request,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var section =await _context.TaskSections
|
|
||||||
.Include(x => x.Task)
|
|
||||||
.ThenInclude(x => x.Phase)
|
|
||||||
.ThenInclude(x => x.Project)
|
|
||||||
.Include(x => x.Skill)
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == request.TaskSectionId, cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (section == null)
|
|
||||||
{
|
|
||||||
throw new BadRequestException("بخش فرعی نامعتبر است");
|
|
||||||
}
|
|
||||||
|
|
||||||
var revisions = await _context.TaskSectionRevisions.Where(x =>
|
|
||||||
x.TaskSectionId == request.TaskSectionId && x.Status == RevisionReviewStatus.Pending).ToListAsync(cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
var fileIds = revisions.SelectMany(x => x.Files)
|
|
||||||
.Select(x => x.FileId).ToList();
|
|
||||||
|
|
||||||
var files =await _context.UploadedFiles
|
|
||||||
.Where(x => fileIds.Contains(x.Id)).ToListAsync(cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
var resItem = revisions.Select(x =>
|
|
||||||
{
|
|
||||||
var selectFileIds = x.Files.Select(f => f.FileId).ToList();
|
|
||||||
var filesDto = files.Where(f => selectFileIds.Contains(f.Id))
|
|
||||||
.Select(f => f.ToDto()).ToList();
|
|
||||||
|
|
||||||
return new CreateTimeRequestDetailsRevision(x.Message, filesDto,x.Id,x.CreationDate.ToFarsi());
|
|
||||||
}).ToList();
|
|
||||||
var res = new CreateTimeRequestDetailsResponse(resItem,section.Task.Phase.Project.Name,section.Task.Phase.Name,section.Task.Name,
|
|
||||||
section.Skill!.Name);
|
|
||||||
|
|
||||||
return OperationResult<CreateTimeRequestDetailsResponse>.Success(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
|
||||||
|
|
||||||
public interface IWorkflowProvider
|
|
||||||
{
|
|
||||||
WorkflowType Type { get; }
|
|
||||||
Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken);
|
|
||||||
Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken);
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
|
||||||
|
|
||||||
public class NotAssignedWorkflowProvider : IWorkflowProvider
|
|
||||||
{
|
|
||||||
public WorkflowType Type => WorkflowType.NotAssigned;
|
|
||||||
|
|
||||||
public async Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
// Assuming 0 means unassigned in CurrentAssignedUserId
|
|
||||||
var sections = await context.TaskSections
|
|
||||||
.Where(x => x.CurrentAssignedUserId == 0)
|
|
||||||
.ToListAsync(cancellationToken);
|
|
||||||
|
|
||||||
return sections.Select(ts => new WorkflowListItem
|
|
||||||
{
|
|
||||||
EntityId = ts.Id,
|
|
||||||
Title = "تخصیص نیافته",
|
|
||||||
Type = WorkflowType.NotAssigned
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return await context.TaskSections
|
|
||||||
.Where(x => x.CurrentAssignedUserId == 0)
|
|
||||||
.CountAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
|
||||||
|
|
||||||
public class RejectedRevisionsWorkflowProvider : IWorkflowProvider
|
|
||||||
{
|
|
||||||
public WorkflowType Type => WorkflowType.Rejected;
|
|
||||||
|
|
||||||
public async Task<List<WorkflowListItem>> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var query = from revision in context.TaskSectionRevisions
|
|
||||||
.Where(x => x.Status == RevisionReviewStatus.Pending)
|
|
||||||
join taskSection in context.TaskSections
|
|
||||||
on revision.TaskSectionId equals taskSection.Id
|
|
||||||
where taskSection.CurrentAssignedUserId == currentUserId
|
|
||||||
select taskSection;
|
|
||||||
|
|
||||||
var sections = await query.ToListAsync(cancellationToken);
|
|
||||||
|
|
||||||
return sections.Select(ts => new WorkflowListItem
|
|
||||||
{
|
|
||||||
EntityId = ts.Id,
|
|
||||||
Title = "برگشت از سمت مدیر",
|
|
||||||
Type = WorkflowType.Rejected
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var query = from revision in context.TaskSectionRevisions
|
|
||||||
.Where(x => x.Status == RevisionReviewStatus.Pending)
|
|
||||||
join taskSection in context.TaskSections
|
|
||||||
on revision.TaskSectionId equals taskSection.Id
|
|
||||||
where taskSection.CurrentAssignedUserId == currentUserId
|
|
||||||
select revision.Id;
|
|
||||||
|
|
||||||
return await query.CountAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
|
||||||
|
|
||||||
public record WorkflowCountResponse(int Total, int Rejected, int NotAssigned, int PendingForApproval);
|
|
||||||
|
|
||||||
public record WorkflowCountQuery() : IBaseQuery<WorkflowCountResponse>;
|
|
||||||
|
|
||||||
public class WorkflowCountQueryHandler : IBaseQueryHandler<WorkflowCountQuery, WorkflowCountResponse>
|
|
||||||
{
|
|
||||||
private readonly IProgramManagerDbContext _context;
|
|
||||||
private readonly IAuthHelper _authHelper;
|
|
||||||
private readonly IEnumerable<IWorkflowProvider> _providers;
|
|
||||||
|
|
||||||
public WorkflowCountQueryHandler(IProgramManagerDbContext context, IAuthHelper authHelper, IEnumerable<IWorkflowProvider> providers)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
_authHelper = authHelper;
|
|
||||||
_providers = providers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult<WorkflowCountResponse>> Handle(WorkflowCountQuery request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
long currentUserId = _authHelper.GetCurrentUserId()!.Value;
|
|
||||||
|
|
||||||
int rejectedCount = 0;
|
|
||||||
int notAssignedCount = 0;
|
|
||||||
int pendingForApprovalCount = 0;
|
|
||||||
|
|
||||||
foreach (var provider in _providers)
|
|
||||||
{
|
|
||||||
var count = await provider.GetCount(currentUserId, _context, cancellationToken);
|
|
||||||
switch (provider.Type)
|
|
||||||
{
|
|
||||||
case WorkflowType.Rejected:
|
|
||||||
rejectedCount += count; break;
|
|
||||||
case WorkflowType.NotAssigned:
|
|
||||||
notAssignedCount += count; break;
|
|
||||||
case WorkflowType.PendingForApproval:
|
|
||||||
pendingForApprovalCount += count; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var total = rejectedCount + notAssignedCount + pendingForApprovalCount;
|
|
||||||
var response = new WorkflowCountResponse(total, rejectedCount, notAssignedCount, pendingForApprovalCount);
|
|
||||||
return OperationResult<WorkflowCountResponse>.Success(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
|
||||||
|
|
||||||
public record WorkflowListResponse(List<WorkflowListItem>Items);
|
|
||||||
|
|
||||||
public class WorkflowListItem
|
|
||||||
{
|
|
||||||
public string Title { get; set; }
|
|
||||||
public WorkflowType Type { get; set; }
|
|
||||||
public Guid EntityId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum WorkflowType
|
|
||||||
{
|
|
||||||
Rejected,
|
|
||||||
NotAssigned,
|
|
||||||
PendingForApproval,
|
|
||||||
}
|
|
||||||
|
|
||||||
public record WorkflowListQuery():IBaseQuery<WorkflowListResponse>;
|
|
||||||
|
|
||||||
public class WorkflowListQueryHandler:IBaseQueryHandler<WorkflowListQuery,WorkflowListResponse>
|
|
||||||
{
|
|
||||||
private readonly IProgramManagerDbContext _context;
|
|
||||||
private readonly IAuthHelper _authHelper;
|
|
||||||
private readonly IEnumerable<IWorkflowProvider> _providers;
|
|
||||||
|
|
||||||
public WorkflowListQueryHandler(IProgramManagerDbContext context,
|
|
||||||
IAuthHelper authHelper,
|
|
||||||
IEnumerable<IWorkflowProvider> providers)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
_authHelper = authHelper;
|
|
||||||
_providers = providers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<OperationResult<WorkflowListResponse>> Handle(WorkflowListQuery request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var currentUserId = _authHelper.GetCurrentUserId()!.Value;
|
|
||||||
var items = new List<WorkflowListItem>();
|
|
||||||
|
|
||||||
foreach (var provider in _providers)
|
|
||||||
{
|
|
||||||
var providerItems = await provider.GetItems(currentUserId, _context, cancellationToken);
|
|
||||||
if (providerItems?.Count > 0)
|
|
||||||
items.AddRange(providerItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = new WorkflowListResponse(items);
|
|
||||||
return OperationResult<WorkflowListResponse>.Success(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application._Common.Extensions;
|
|
||||||
|
|
||||||
public static class FileExtensions
|
|
||||||
{
|
|
||||||
public static UploadedFileDto ToDto(this UploadedFile file)
|
|
||||||
{
|
|
||||||
return new UploadedFileDto()
|
|
||||||
{
|
|
||||||
Id = file.Id,
|
|
||||||
FileName = file.OriginalFileName,
|
|
||||||
FileUrl = file.StorageUrl ?? "",
|
|
||||||
FileSizeBytes = file.FileSizeBytes,
|
|
||||||
FileType = file.FileType.ToString(),
|
|
||||||
ThumbnailUrl = file.ThumbnailUrl,
|
|
||||||
ImageWidth = file.ImageWidth,
|
|
||||||
ImageHeight = file.ImageHeight,
|
|
||||||
DurationSeconds = file.DurationSeconds
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,10 +9,6 @@ using GozareshgirProgramManager.Domain.UserAgg.Entities;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Entities;
|
using GozareshgirProgramManager.Domain.TaskChatAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application._Common.Interfaces;
|
namespace GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
|
|
||||||
@@ -35,12 +31,6 @@ public interface IProgramManagerDbContext
|
|||||||
DbSet<TaskChatMessage> TaskChatMessages { get; set; }
|
DbSet<TaskChatMessage> TaskChatMessages { get; set; }
|
||||||
DbSet<UploadedFile> UploadedFiles { get; set; }
|
DbSet<UploadedFile> UploadedFiles { get; set; }
|
||||||
|
|
||||||
//Task Section Time Request
|
|
||||||
DbSet<TaskSectionTimeRequest> TaskSectionTimeRequests { get; set; }
|
|
||||||
|
|
||||||
// Task Section Revision
|
|
||||||
DbSet<TaskSectionRevision> TaskSectionRevisions { get; set; }
|
|
||||||
|
|
||||||
DbSet<Skill> Skills { get; set; }
|
DbSet<Skill> Skills { get; set; }
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class OperationResult
|
|||||||
|
|
||||||
// Helper methods for specific error types
|
// Helper methods for specific error types
|
||||||
public static OperationResult NotFound(string errorMessage) => new(false, errorMessage, errorType: ErrorType.NotFound);
|
public static OperationResult NotFound(string errorMessage) => new(false, errorMessage, errorType: ErrorType.NotFound);
|
||||||
public static OperationResult Unauthorized(string errorMessage="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") => new(false, errorMessage, errorType: ErrorType.Unauthorized);
|
public static OperationResult Unauthorized(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Unauthorized);
|
||||||
public static OperationResult ValidationError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Validation);
|
public static OperationResult ValidationError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Validation);
|
||||||
public static OperationResult ValidationError(List<string> errors) => new(false, errors: errors, errorType: ErrorType.Validation);
|
public static OperationResult ValidationError(List<string> errors) => new(false, errors: errors, errorType: ErrorType.Validation);
|
||||||
public static OperationResult InternalServerError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.InternalServerError);
|
public static OperationResult InternalServerError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.InternalServerError);
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
namespace GozareshgirProgramManager.Application._Common.Models;
|
|
||||||
|
|
||||||
public class UploadedFileDto
|
|
||||||
{
|
|
||||||
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
public string FileUrl { get; set; } = string.Empty;
|
|
||||||
public long FileSizeBytes { get; set; }
|
|
||||||
public string FileType { get; set; } = string.Empty;
|
|
||||||
public string? ThumbnailUrl { get; set; }
|
|
||||||
public int? ImageWidth { get; set; }
|
|
||||||
public int? ImageHeight { get; set; }
|
|
||||||
public int? DurationSeconds { get; set; }
|
|
||||||
|
|
||||||
public string FileSizeFormatted
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
const long kb = 1024;
|
|
||||||
const long mb = kb * 1024;
|
|
||||||
const long gb = mb * 1024;
|
|
||||||
|
|
||||||
if (FileSizeBytes >= gb)
|
|
||||||
return $"{FileSizeBytes / (double)gb:F2} GB";
|
|
||||||
if (FileSizeBytes >= mb)
|
|
||||||
return $"{FileSizeBytes / (double)mb:F2} MB";
|
|
||||||
if (FileSizeBytes >= kb)
|
|
||||||
return $"{FileSizeBytes / (double)kb:F2} KB";
|
|
||||||
|
|
||||||
return $"{FileSizeBytes} Bytes";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ public enum FileCategory
|
|||||||
ProjectDocument = 3, // مستندات پروژه
|
ProjectDocument = 3, // مستندات پروژه
|
||||||
UserProfilePhoto = 4, // عکس پروفایل کاربر
|
UserProfilePhoto = 4, // عکس پروفایل کاربر
|
||||||
Report = 5, // گزارش
|
Report = 5, // گزارش
|
||||||
Other = 6, // سایر
|
Other = 6 // سایر
|
||||||
TaskSectionRevision
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// بخش فاز - برای ذخیره تخصیص کاربر و مهارت در سطح Phase
|
/// بخش فاز - برای ذخیره تخصیص کاربر و مهارت در سطح Phase
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// پروژه - بالاترین سطح در سلسله مراتب و Aggregate Root
|
/// پروژه - بالاترین سطح در سلسله مراتب و Aggregate Root
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// فاز پروژه - سطح میانی در سلسله مراتب
|
/// فاز پروژه - سطح میانی در سلسله مراتب
|
||||||
@@ -29,7 +28,7 @@ public class ProjectPhase : ProjectHierarchyNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Guid ProjectId { get; private set; }
|
public Guid ProjectId { get; private set; }
|
||||||
public Project.Project Project { get; private set; } = null!;
|
public Project Project { get; private set; } = null!;
|
||||||
public IReadOnlyList<ProjectTask> Tasks => _tasks.AsReadOnly();
|
public IReadOnlyList<ProjectTask> Tasks => _tasks.AsReadOnly();
|
||||||
public IReadOnlyList<PhaseSection> PhaseSections => _phaseSections.AsReadOnly();
|
public IReadOnlyList<PhaseSection> PhaseSections => _phaseSections.AsReadOnly();
|
||||||
|
|
||||||
@@ -43,14 +42,6 @@ public class ProjectPhase : ProjectHierarchyNode
|
|||||||
|
|
||||||
#region Task Management
|
#region Task Management
|
||||||
|
|
||||||
public ProjectTask AddTask(string name, string? description = null)
|
|
||||||
{
|
|
||||||
var task = new ProjectTask(name, Id, description);
|
|
||||||
_tasks.Add(task);
|
|
||||||
AddDomainEvent(new TaskAddedEvent(task.Id, Id, name));
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveTask(Guid taskId)
|
public void RemoveTask(Guid taskId)
|
||||||
{
|
{
|
||||||
var task = _tasks.FirstOrDefault(t => t.Id == taskId);
|
var task = _tasks.FirstOrDefault(t => t.Id == taskId);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ProjectSection: shortcut container for UserId + SkillId at Project level
|
/// ProjectSection: shortcut container for UserId + SkillId at Project level
|
||||||
@@ -1,32 +1,32 @@
|
|||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// تسک - پایینترین سطح در سلسله مراتب که شامل بخشها میشود
|
/// تسک - پایینترین سطح در سلسله مراتب که شامل بخشها میشود
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProjectTask : ProjectHierarchyNode
|
public class ProjectTask : ProjectHierarchyNode
|
||||||
{
|
{
|
||||||
private readonly List<TaskSection.TaskSection> _sections;
|
private readonly List<TaskSection> _sections;
|
||||||
|
|
||||||
private ProjectTask()
|
private ProjectTask()
|
||||||
{
|
{
|
||||||
_sections = new List<TaskSection.TaskSection>();
|
_sections = new List<TaskSection>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectTask(string name, Guid phaseId, string? description = null) : base(name, description)
|
public ProjectTask(string name, Guid phaseId,ProjectTaskPriority priority, string? description = null) : base(name, description)
|
||||||
{
|
{
|
||||||
PhaseId = phaseId;
|
PhaseId = phaseId;
|
||||||
_sections = new List<TaskSection.TaskSection>();
|
_sections = new List<TaskSection>();
|
||||||
Priority = ProjectTaskPriority.Low;
|
Priority = priority;
|
||||||
AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name));
|
AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guid PhaseId { get; private set; }
|
public Guid PhaseId { get; private set; }
|
||||||
public ProjectPhase Phase { get; private set; } = null!;
|
public ProjectPhase Phase { get; private set; } = null!;
|
||||||
public IReadOnlyList<TaskSection.TaskSection> Sections => _sections.AsReadOnly();
|
public IReadOnlyList<TaskSection> Sections => _sections.AsReadOnly();
|
||||||
|
|
||||||
// Task-specific properties
|
// Task-specific properties
|
||||||
public Enums.TaskStatus Status { get; private set; } = Enums.TaskStatus.NotStarted;
|
public Enums.TaskStatus Status { get; private set; } = Enums.TaskStatus.NotStarted;
|
||||||
@@ -40,7 +40,7 @@ public class ProjectTask : ProjectHierarchyNode
|
|||||||
|
|
||||||
#region Section Management
|
#region Section Management
|
||||||
|
|
||||||
public void AddSection(TaskSection.TaskSection section, bool cascadeToChildren = false)
|
public void AddSection(TaskSection section, bool cascadeToChildren = false)
|
||||||
{
|
{
|
||||||
var existingSection = _sections.FirstOrDefault(s => s.SkillId == section.SkillId);
|
var existingSection = _sections.FirstOrDefault(s => s.SkillId == section.SkillId);
|
||||||
if (existingSection != null)
|
if (existingSection != null)
|
||||||
@@ -84,7 +84,7 @@ public class ProjectTask : ProjectHierarchyNode
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var section = new TaskSection.TaskSection(Id, skillId, assignedUserId);
|
var section = new TaskSection(Id, skillId, assignedUserId);
|
||||||
_sections.Add(section);
|
_sections.Add(section);
|
||||||
AddDomainEvent(new TaskSectionAddedEvent(Id, section.Id, skillId));
|
AddDomainEvent(new TaskSectionAddedEvent(Id, section.Id, skillId));
|
||||||
}
|
}
|
||||||
@@ -204,12 +204,12 @@ public class ProjectTask : ProjectHierarchyNode
|
|||||||
|
|
||||||
#region Query Helpers
|
#region Query Helpers
|
||||||
|
|
||||||
public IEnumerable<TaskSection.TaskSection> GetSectionsBySkill(Guid skillId)
|
public IEnumerable<TaskSection> GetSectionsBySkill(Guid skillId)
|
||||||
{
|
{
|
||||||
return _sections.Where(s => s.SkillId == skillId);
|
return _sections.Where(s => s.SkillId == skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskSection.TaskSection? GetSectionBySkill(Guid skillId)
|
public TaskSection? GetSectionBySkill(Guid skillId)
|
||||||
{
|
{
|
||||||
return _sections.FirstOrDefault(s => s.SkillId == skillId);
|
return _sections.FirstOrDefault(s => s.SkillId == skillId);
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ public class ProjectTask : ProjectHierarchyNode
|
|||||||
return _sections.Any(s => s.SkillId == skillId);
|
return _sections.Any(s => s.SkillId == skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<TaskSection.TaskSection> GetAssignedSections(long userId)
|
public IEnumerable<TaskSection> GetAssignedSections(long userId)
|
||||||
{
|
{
|
||||||
return _sections.Where(s => s.CurrentAssignedUserId == userId);
|
return _sections.Where(s => s.CurrentAssignedUserId == userId);
|
||||||
}
|
}
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Entities;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
public class TaskSectionRevision : EntityBase<Guid>
|
|
||||||
{
|
|
||||||
public TaskSectionRevision(Guid taskSectionId,
|
|
||||||
string message, long createdByUserId)
|
|
||||||
{
|
|
||||||
TaskSectionId = taskSectionId;
|
|
||||||
Status = RevisionReviewStatus.Pending;
|
|
||||||
Message = message;
|
|
||||||
CreatedByUserId = createdByUserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Guid TaskSectionId { get; private set; }
|
|
||||||
|
|
||||||
public RevisionReviewStatus Status { get; private set; }
|
|
||||||
|
|
||||||
|
|
||||||
public string Message { get; private set; }
|
|
||||||
|
|
||||||
public long CreatedByUserId { get; private set; }
|
|
||||||
|
|
||||||
public IReadOnlyCollection<TaskRevisionFile> Files => _files;
|
|
||||||
private readonly List<TaskRevisionFile> _files = new();
|
|
||||||
|
|
||||||
public void AddFile(TaskRevisionFile file)
|
|
||||||
{
|
|
||||||
_files.Add(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MarkReviewed()
|
|
||||||
{
|
|
||||||
if (Status == RevisionReviewStatus.Reviewed)
|
|
||||||
return;
|
|
||||||
Status = RevisionReviewStatus.Reviewed;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public class TaskRevisionFile: EntityBase<Guid>
|
|
||||||
{
|
|
||||||
public TaskRevisionFile(Guid fileId)
|
|
||||||
{
|
|
||||||
FileId = fileId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Guid FileId { get; private set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RevisionReviewStatus : short
|
|
||||||
{
|
|
||||||
Pending = 1,
|
|
||||||
Reviewed = 2
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
public class TaskSectionTimeRequest:EntityBase<Guid>
|
|
||||||
{
|
|
||||||
|
|
||||||
public TaskSectionTimeRequest(long userId, string description,
|
|
||||||
TimeSpan requestedTime, TaskSectionTimeRequestType requestType,
|
|
||||||
Guid taskSectionId)
|
|
||||||
{
|
|
||||||
UserId = userId;
|
|
||||||
Description = description;
|
|
||||||
RequestedTime = requestedTime;
|
|
||||||
RequestType = requestType;
|
|
||||||
TaskSectionId = taskSectionId;
|
|
||||||
RequestStatus = TaskSectionTimeRequestStatus.Pending;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskSection TaskSection { get; set; }
|
|
||||||
public Guid TaskSectionId { get; set; }
|
|
||||||
public long UserId { get; private set; }
|
|
||||||
public string Description { get; private set; }
|
|
||||||
public TimeSpan RequestedTime { get; private set; }
|
|
||||||
public TaskSectionTimeRequestType RequestType { get; private set; }
|
|
||||||
public TaskSectionTimeRequestStatus RequestStatus { get; private set; }
|
|
||||||
|
|
||||||
public void AcceptTimeRequest()
|
|
||||||
{
|
|
||||||
RequestStatus = TaskSectionTimeRequestStatus.Accepted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using System.Linq;
|
||||||
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
using GozareshgirProgramManager.Domain._Common.Exceptions;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
|
||||||
|
using GozareshgirProgramManager.Domain.ProjectAgg.Models;
|
||||||
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// بخش تسک - برای ذخیره کار واقعی که کاربر روی یک مهارت خاص انجام میدهد
|
/// بخش تسک - برای ذخیره کار واقعی که کاربر روی یک مهارت خاص انجام میدهد
|
||||||
@@ -59,13 +61,12 @@ public class TaskSection : EntityBase<Guid>
|
|||||||
// برای backward compatibility
|
// برای backward compatibility
|
||||||
public TimeSpan EstimatedHours => FinalEstimatedHours;
|
public TimeSpan EstimatedHours => FinalEstimatedHours;
|
||||||
|
|
||||||
public void AddAdditionalTime(TimeSpan additionalHours, TaskSectionAdditionalTimeType type, string? reason = null,
|
public void AddAdditionalTime(TimeSpan additionalHours, string? reason = null, long? addedByUserId = null)
|
||||||
long? addedByUserId = null)
|
|
||||||
{
|
{
|
||||||
if (additionalHours <= TimeSpan.Zero)
|
if (additionalHours <= TimeSpan.Zero)
|
||||||
throw new BadRequestException("تایم اضافی باید بزرگتر از صفر باشد", nameof(additionalHours));
|
throw new BadRequestException("تایم اضافی باید بزرگتر از صفر باشد", nameof(additionalHours));
|
||||||
|
|
||||||
var additionalTime = new TaskSectionAdditionalTime(additionalHours,type, reason, addedByUserId);
|
var additionalTime = new TaskSectionAdditionalTime(additionalHours, reason, addedByUserId);
|
||||||
_additionalTimes.Add(additionalTime);
|
_additionalTimes.Add(additionalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// فعالیت کاری روی یک بخش
|
/// فعالیت کاری روی یک بخش
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// زمان اضافی اضافه شده بعد از تخمین اولیه
|
/// زمان اضافی اضافه شده بعد از تخمین اولیه
|
||||||
@@ -9,13 +9,12 @@ public class TaskSectionAdditionalTime : EntityBase<Guid>
|
|||||||
{
|
{
|
||||||
private TaskSectionAdditionalTime() { }
|
private TaskSectionAdditionalTime() { }
|
||||||
|
|
||||||
public TaskSectionAdditionalTime(TimeSpan hours, TaskSectionAdditionalTimeType type, string? reason = null,long? addedByUserId = null)
|
public TaskSectionAdditionalTime(TimeSpan hours, string? reason = null, long? addedByUserId = null)
|
||||||
{
|
{
|
||||||
Hours = hours;
|
Hours = hours;
|
||||||
Reason = reason;
|
Reason = reason;
|
||||||
AddedByUserId = addedByUserId;
|
AddedByUserId = addedByUserId;
|
||||||
AddedAt = DateTime.Now;
|
AddedAt = DateTime.UtcNow;
|
||||||
Type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan Hours { get; private set; }
|
public TimeSpan Hours { get; private set; }
|
||||||
@@ -23,15 +22,8 @@ public class TaskSectionAdditionalTime : EntityBase<Guid>
|
|||||||
public long? AddedByUserId { get; private set; }
|
public long? AddedByUserId { get; private set; }
|
||||||
public DateTime AddedAt { get; private set; }
|
public DateTime AddedAt { get; private set; }
|
||||||
|
|
||||||
public TaskSectionAdditionalTimeType Type { get; set; }
|
|
||||||
public void UpdateReason(string? reason)
|
public void UpdateReason(string? reason)
|
||||||
{
|
{
|
||||||
Reason = reason;
|
Reason = reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TaskSectionAdditionalTimeType
|
|
||||||
{
|
|
||||||
Effective,
|
|
||||||
Ineffective,
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
||||||
|
|
||||||
public enum TaskSectionTimeRequestStatus
|
|
||||||
{
|
|
||||||
Pending,
|
|
||||||
Accepted,
|
|
||||||
Rejected
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
||||||
|
|
||||||
public enum TaskSectionTimeRequestType
|
|
||||||
{
|
|
||||||
InitialTime,
|
|
||||||
AdditionalTime,
|
|
||||||
RejectedTime,
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
public interface IPhaseSectionRepository : IRepository<Guid, PhaseSection>
|
public interface IPhaseSectionRepository : IRepository<Guid, PhaseSection>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
|
|
||||||
public interface ITaskSectionRevisionRepository:IRepository<Guid,TaskSectionRevision>
|
|
||||||
{
|
|
||||||
Task<List<TaskSectionRevision>> GetByTaskSectionId(Guid requestTaskSectionId);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
|
||||||
|
|
||||||
public interface ITaskSectionTimeRequestRepository:IRepository<Guid,TaskSectionTimeRequest>
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
namespace GozareshgirProgramManager.Domain.SkillAgg.Entities;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public class UnAuthorizedException:Exception
|
public class UnAuthorizedException:Exception
|
||||||
{
|
{
|
||||||
public UnAuthorizedException(string message="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") : base(message)
|
public UnAuthorizedException(string message) : base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using FluentValidation;
|
||||||
using GozareshgirProgramManager.Application._Common.Behaviors;
|
using GozareshgirProgramManager.Application._Common.Behaviors;
|
||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application.Services.FileManagement;
|
using GozareshgirProgramManager.Application.Services.FileManagement;
|
||||||
@@ -7,7 +11,10 @@ using GozareshgirProgramManager.Domain.CustomerAgg.Repositories;
|
|||||||
using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories;
|
using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
using GozareshgirProgramManager.Domain.ProjectAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.RoleAgg.Repositories;
|
using GozareshgirProgramManager.Domain.RoleAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.RoleAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories;
|
||||||
|
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
using GozareshgirProgramManager.Domain.SkillAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories;
|
||||||
using GozareshgirProgramManager.Domain.UserAgg.Repositories;
|
using GozareshgirProgramManager.Domain.UserAgg.Repositories;
|
||||||
@@ -25,9 +32,6 @@ using Shared.Contracts.PmRole.Commands;
|
|||||||
using Shared.Contracts.PmRole.Queries;
|
using Shared.Contracts.PmRole.Queries;
|
||||||
using Shared.Contracts.PmUser.Commands;
|
using Shared.Contracts.PmUser.Commands;
|
||||||
using Shared.Contracts.PmUser.Queries;
|
using Shared.Contracts.PmUser.Queries;
|
||||||
using System.Reflection;
|
|
||||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList;
|
|
||||||
using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers;
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Infrastructure;
|
namespace GozareshgirProgramManager.Infrastructure;
|
||||||
|
|
||||||
@@ -97,11 +101,6 @@ public static class DependencyInjection
|
|||||||
services.AddScoped<IAuthHelper, AuthHelper>();
|
services.AddScoped<IAuthHelper, AuthHelper>();
|
||||||
|
|
||||||
|
|
||||||
//TaskSection Time Request
|
|
||||||
services.AddScoped<ITaskSectionTimeRequestRepository, TaskSectionTimeRequestRepository>();
|
|
||||||
|
|
||||||
//TaskSection Revision
|
|
||||||
services.AddScoped<ITaskSectionRevisionRepository, TaskSectionRevisionRepository>();
|
|
||||||
|
|
||||||
#region ServicesInjection
|
#region ServicesInjection
|
||||||
|
|
||||||
@@ -117,16 +116,6 @@ public static class DependencyInjection
|
|||||||
// MediatR Validation Behavior
|
// MediatR Validation Behavior
|
||||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
||||||
|
|
||||||
// Workflow providers: auto-register all IWorkflowProvider implementations in the Application assembly
|
|
||||||
var appAssembly = typeof(IWorkflowProvider).Assembly;
|
|
||||||
var providerTypes = appAssembly
|
|
||||||
.GetTypes()
|
|
||||||
.Where(t => !t.IsAbstract && !t.IsInterface && typeof(IWorkflowProvider).IsAssignableFrom(t))
|
|
||||||
.ToList();
|
|
||||||
foreach (var providerType in providerTypes)
|
|
||||||
{
|
|
||||||
services.AddScoped(typeof(IWorkflowProvider), providerType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Infrastructure.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AddtimeRequestandTasksectionrevision : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Type",
|
|
||||||
table: "TaskSectionAdditionalTimes",
|
|
||||||
type: "nvarchar(50)",
|
|
||||||
maxLength: 50,
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "TaskSectionRevisions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
TaskSectionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
||||||
Message = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
|
|
||||||
CreatedByUserId = table.Column<long>(type: "bigint", nullable: false),
|
|
||||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_TaskSectionRevisions", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "TaskSectionTimeRequests",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
TaskSectionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
|
||||||
Description = table.Column<string>(type: "nvarchar(1200)", maxLength: 1200, nullable: false),
|
|
||||||
RequestedTime = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
|
|
||||||
RequestType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
||||||
RequestStatus = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
||||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_TaskSectionTimeRequests", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_TaskSectionTimeRequests_TaskSections_TaskSectionId",
|
|
||||||
column: x => x.TaskSectionId,
|
|
||||||
principalTable: "TaskSections",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "TaskRevisionFile",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
FileId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
TaskSectionRevisionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
||||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_TaskRevisionFile", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_TaskRevisionFile_TaskSectionRevisions_TaskSectionRevisionId",
|
|
||||||
column: x => x.TaskSectionRevisionId,
|
|
||||||
principalTable: "TaskSectionRevisions",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_TaskRevisionFile_UploadedFiles_FileId",
|
|
||||||
column: x => x.FileId,
|
|
||||||
principalTable: "UploadedFiles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_TaskRevisionFile_FileId",
|
|
||||||
table: "TaskRevisionFile",
|
|
||||||
column: "FileId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_TaskRevisionFile_TaskSectionRevisionId",
|
|
||||||
table: "TaskRevisionFile",
|
|
||||||
column: "TaskSectionRevisionId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_TaskSectionTimeRequests_TaskSectionId",
|
|
||||||
table: "TaskSectionTimeRequests",
|
|
||||||
column: "TaskSectionId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "TaskRevisionFile");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "TaskSectionTimeRequests");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "TaskSectionRevisions");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Type",
|
|
||||||
table: "TaskSectionAdditionalTimes");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user