diff --git a/.dockerignore b/.dockerignore
index 3729ff0c..8bf65212 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -22,4 +22,12 @@
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
-README.md
\ No newline at end of file
+README.md
+.git
+**/bin/
+**/obj/
+.vscode/
+.dockerignore
+.gitignore
+README.md
+*.md
\ No newline at end of file
diff --git a/.forgejo/workflows/build-checkin.yml b/.forgejo/workflows/build-checkin.yml
new file mode 100644
index 00000000..3971e9df
--- /dev/null
+++ b/.forgejo/workflows/build-checkin.yml
@@ -0,0 +1,83 @@
+name: Build & Deploy Checkin Service
+
+on:
+ push:
+ tags:
+ - "checkin-dev[0-9]+.[0-9]+.[0-9]+"
+ - "checkin-dev[0-9]+.[0-9]+.[0-9]+*"
+ workflow_dispatch:
+
+env:
+ REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
+ REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
+ REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
+ CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
+ IMAGE_VERSION: latest
+ SERVICE_NAME: hrms-api-checkin
+ DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Tag Version
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "push" ]]; then
+ VERSION=$(echo "${{ github.ref_name }}" | sed 's/checkin-dev//g')
+ echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
+ else
+ echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
+ fi
+ - name: Login in to registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ env.REGISTRY_USERNAME }}
+ password: ${{ env.REGISTRY_PASSWORD }}
+
+ - name: Build and push docker image
+ uses: docker/build-push-action@v5
+ with:
+ platforms: linux/amd64
+ context: .
+ file: ./BMA.EHR.CheckInConsumer/Dockerfile
+ tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
+ push: true
+
+ - name: Remote Deploy
+ uses: appleboy/ssh-action@v1.2.1
+ with:
+ host: ${{ vars.SSH_DEPLOY_HOST }}
+ port: ${{ vars.SSH_DEPLOY_PORT }}
+ username: ${{ secrets.SSH_DEPLOY_USER }}
+ password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
+ script: |
+ cd ~/repo
+ ./replace-env.sh API_CHECKIN "${{ env.IMAGE_VERSION }}"
+ ./deploy.sh ${{ env.SERVICE_NAME }}
+
+ - name: Discord Notification
+ if: always()
+ run: |
+ STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
+ COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
+ TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d "{
+ \"embeds\": [{
+ \"title\": \"$STATUS\",
+ \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
+ \"color\": $COLOR,
+ \"footer\": {
+ \"text\": \"Release Notification\",
+ \"icon_url\": \"https://example.com/success-icon.png\"
+ },
+ \"timestamp\": \"$TIMESTAMP\"
+ }]
+ }" \
+ ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-discipline.yml b/.forgejo/workflows/build-discipline.yml
new file mode 100644
index 00000000..767d775b
--- /dev/null
+++ b/.forgejo/workflows/build-discipline.yml
@@ -0,0 +1,83 @@
+name: Build & Deploy Discipline Service
+
+on:
+ push:
+ tags:
+ - "discipline-dev[0-9]+.[0-9]+.[0-9]+"
+ - "discipline-dev[0-9]+.[0-9]+.[0-9]+*"
+ workflow_dispatch:
+
+env:
+ REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
+ REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
+ REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
+ CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
+ IMAGE_VERSION: latest
+ SERVICE_NAME: hrms-api-discipline
+ DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Tag Version
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "push" ]]; then
+ VERSION=$(echo "${{ github.ref_name }}" | sed 's/discipline-dev//g')
+ echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
+ else
+ echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
+ fi
+ - name: Login in to registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ env.REGISTRY_USERNAME }}
+ password: ${{ env.REGISTRY_PASSWORD }}
+
+ - name: Build and push docker image
+ uses: docker/build-push-action@v5
+ with:
+ platforms: linux/amd64
+ context: .
+ file: ./BMA.EHR.Discipline.Service/Dockerfile
+ tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
+ push: true
+
+ - name: Remote Deploy
+ uses: appleboy/ssh-action@v1.2.1
+ with:
+ host: ${{ vars.SSH_DEPLOY_HOST }}
+ port: ${{ vars.SSH_DEPLOY_PORT }}
+ username: ${{ secrets.SSH_DEPLOY_USER }}
+ password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
+ script: |
+ cd ~/repo
+ ./replace-env.sh API_DISCIPLINE "${{ env.IMAGE_VERSION }}"
+ ./deploy.sh ${{ env.SERVICE_NAME }}
+
+ - name: Discord Notification
+ if: always()
+ run: |
+ STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
+ COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
+ TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d "{
+ \"embeds\": [{
+ \"title\": \"$STATUS\",
+ \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
+ \"color\": $COLOR,
+ \"footer\": {
+ \"text\": \"Release Notification\",
+ \"icon_url\": \"https://example.com/success-icon.png\"
+ },
+ \"timestamp\": \"$TIMESTAMP\"
+ }]
+ }" \
+ ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-insignia.yml b/.forgejo/workflows/build-insignia.yml
new file mode 100644
index 00000000..7ddcbdbd
--- /dev/null
+++ b/.forgejo/workflows/build-insignia.yml
@@ -0,0 +1,83 @@
+name: Build & Deploy Insignia Service
+
+on:
+ push:
+ tags:
+ - "insignia-dev[0-9]+.[0-9]+.[0-9]+"
+ - "insignia-dev[0-9]+.[0-9]+.[0-9]+*"
+ workflow_dispatch:
+
+env:
+ REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
+ REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
+ REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
+ CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
+ IMAGE_VERSION: latest
+ SERVICE_NAME: hrms-api-insignia
+ DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Tag Version
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "push" ]]; then
+ VERSION=$(echo "${{ github.ref_name }}" | sed 's/insignia-dev//g')
+ echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
+ else
+ echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
+ fi
+ - name: Login in to registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ env.REGISTRY_USERNAME }}
+ password: ${{ env.REGISTRY_PASSWORD }}
+
+ - name: Build and push docker image
+ uses: docker/build-push-action@v5
+ with:
+ platforms: linux/amd64
+ context: .
+ file: ./BMA.EHR.Insignia/Dockerfile
+ tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
+ push: true
+
+ - name: Remote Deploy
+ uses: appleboy/ssh-action@v1.2.1
+ with:
+ host: ${{ vars.SSH_DEPLOY_HOST }}
+ port: ${{ vars.SSH_DEPLOY_PORT }}
+ username: ${{ secrets.SSH_DEPLOY_USER }}
+ password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
+ script: |
+ cd ~/repo
+ ./replace-env.sh API_INSIGNIA "${{ env.IMAGE_VERSION }}"
+ ./deploy.sh ${{ env.SERVICE_NAME }}
+
+ - name: Discord Notification
+ if: always()
+ run: |
+ STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
+ COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
+ TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d "{
+ \"embeds\": [{
+ \"title\": \"$STATUS\",
+ \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
+ \"color\": $COLOR,
+ \"footer\": {
+ \"text\": \"Release Notification\",
+ \"icon_url\": \"https://example.com/success-icon.png\"
+ },
+ \"timestamp\": \"$TIMESTAMP\"
+ }]
+ }" \
+ ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-leave.yml b/.forgejo/workflows/build-leave.yml
new file mode 100644
index 00000000..b1c9c168
--- /dev/null
+++ b/.forgejo/workflows/build-leave.yml
@@ -0,0 +1,83 @@
+name: Build & Deploy Leave Service
+
+on:
+ push:
+ tags:
+ - "leave-dev[0-9]+.[0-9]+.[0-9]+"
+ - "leave-dev[0-9]+.[0-9]+.[0-9]+*"
+ workflow_dispatch:
+
+env:
+ REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
+ REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
+ REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
+ CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
+ IMAGE_VERSION: latest
+ SERVICE_NAME: hrms-api-leave
+ DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Tag Version
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "push" ]]; then
+ VERSION=$(echo "${{ github.ref_name }}" | sed 's/leave-dev//g')
+ echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
+ else
+ echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
+ fi
+ - name: Login in to registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ env.REGISTRY_USERNAME }}
+ password: ${{ env.REGISTRY_PASSWORD }}
+
+ - name: Build and push docker image
+ uses: docker/build-push-action@v5
+ with:
+ platforms: linux/amd64
+ context: .
+ file: ./BMA.EHR.Leave/Dockerfile
+ tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
+ push: true
+
+ - name: Remote Deploy
+ uses: appleboy/ssh-action@v1.2.1
+ with:
+ host: ${{ vars.SSH_DEPLOY_HOST }}
+ port: ${{ vars.SSH_DEPLOY_PORT }}
+ username: ${{ secrets.SSH_DEPLOY_USER }}
+ password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
+ script: |
+ cd ~/repo
+ ./replace-env.sh API_LEAVE "${{ env.IMAGE_VERSION }}"
+ ./deploy.sh ${{ env.SERVICE_NAME }}
+
+ - name: Discord Notification
+ if: always()
+ run: |
+ STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
+ COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
+ TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d "{
+ \"embeds\": [{
+ \"title\": \"$STATUS\",
+ \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
+ \"color\": $COLOR,
+ \"footer\": {
+ \"text\": \"Release Notification\",
+ \"icon_url\": \"https://example.com/success-icon.png\"
+ },
+ \"timestamp\": \"$TIMESTAMP\"
+ }]
+ }" \
+ ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-placement.yml b/.forgejo/workflows/build-placement.yml
new file mode 100644
index 00000000..351b1e59
--- /dev/null
+++ b/.forgejo/workflows/build-placement.yml
@@ -0,0 +1,83 @@
+name: Build & Deploy Placement Service
+
+on:
+ push:
+ tags:
+ - "placement-dev[0-9]+.[0-9]+.[0-9]+"
+ - "placement-dev[0-9]+.[0-9]+.[0-9]+*"
+ workflow_dispatch:
+
+env:
+ REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
+ REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
+ REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
+ CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
+ IMAGE_VERSION: latest
+ SERVICE_NAME: hrms-api-placement
+ DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Tag Version
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "push" ]]; then
+ VERSION=$(echo "${{ github.ref_name }}" | sed 's/placement-dev//g')
+ echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
+ else
+ echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
+ fi
+ - name: Login in to registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ env.REGISTRY_USERNAME }}
+ password: ${{ env.REGISTRY_PASSWORD }}
+
+ - name: Build and push docker image
+ uses: docker/build-push-action@v5
+ with:
+ platforms: linux/amd64
+ context: .
+ file: ./BMA.EHR.Placement.Service/Dockerfile
+ tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
+ push: true
+
+ - name: Remote Deploy
+ uses: appleboy/ssh-action@v1.2.1
+ with:
+ host: ${{ vars.SSH_DEPLOY_HOST }}
+ port: ${{ vars.SSH_DEPLOY_PORT }}
+ username: ${{ secrets.SSH_DEPLOY_USER }}
+ password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
+ script: |
+ cd ~/repo
+ ./replace-env.sh API_PLACEMENT "${{ env.IMAGE_VERSION }}"
+ ./deploy.sh ${{ env.SERVICE_NAME }}
+
+ - name: Discord Notification
+ if: always()
+ run: |
+ STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
+ COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
+ TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d "{
+ \"embeds\": [{
+ \"title\": \"$STATUS\",
+ \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
+ \"color\": $COLOR,
+ \"footer\": {
+ \"text\": \"Release Notification\",
+ \"icon_url\": \"https://example.com/success-icon.png\"
+ },
+ \"timestamp\": \"$TIMESTAMP\"
+ }]
+ }" \
+ ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-retirement.yml b/.forgejo/workflows/build-retirement.yml
new file mode 100644
index 00000000..257f68f2
--- /dev/null
+++ b/.forgejo/workflows/build-retirement.yml
@@ -0,0 +1,83 @@
+name: Build & Deploy Retirement Service
+
+on:
+ push:
+ tags:
+ - "retirement-dev[0-9]+.[0-9]+.[0-9]+"
+ - "retirement-dev[0-9]+.[0-9]+.[0-9]+*"
+ workflow_dispatch:
+
+env:
+ REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
+ REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
+ REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
+ CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
+ IMAGE_VERSION: latest
+ SERVICE_NAME: hrms-api-retirement
+ DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Tag Version
+ shell: bash
+ run: |
+ if [[ "${{ github.event_name }}" == "push" ]]; then
+ VERSION=$(echo "${{ github.ref_name }}" | sed 's/retirement-dev//g')
+ echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
+ else
+ echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
+ fi
+ - name: Login in to registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ env.REGISTRY_USERNAME }}
+ password: ${{ env.REGISTRY_PASSWORD }}
+
+ - name: Build and push docker image
+ uses: docker/build-push-action@v5
+ with:
+ platforms: linux/amd64
+ context: .
+ file: ./BMA.EHR.Retirement.Service/Dockerfile
+ tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
+ push: true
+
+ - name: Remote Deploy
+ uses: appleboy/ssh-action@v1.2.1
+ with:
+ host: ${{ vars.SSH_DEPLOY_HOST }}
+ port: ${{ vars.SSH_DEPLOY_PORT }}
+ username: ${{ secrets.SSH_DEPLOY_USER }}
+ password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
+ script: |
+ cd ~/repo
+ ./replace-env.sh API_RETIREMENT "${{ env.IMAGE_VERSION }}"
+ ./deploy.sh ${{ env.SERVICE_NAME }}
+
+ - name: Discord Notification
+ if: always()
+ run: |
+ STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
+ COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
+ TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d "{
+ \"embeds\": [{
+ \"title\": \"$STATUS\",
+ \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
+ \"color\": $COLOR,
+ \"footer\": {
+ \"text\": \"Release Notification\",
+ \"icon_url\": \"https://example.com/success-icon.png\"
+ },
+ \"timestamp\": \"$TIMESTAMP\"
+ }]
+ }" \
+ ${{ env.DISCORD_WEBHOOK }}
diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml
new file mode 100644
index 00000000..ce4ee51d
--- /dev/null
+++ b/.github/workflows/discord-notify.yml
@@ -0,0 +1,22 @@
+name: Discord PR Notify
+
+on:
+ pull_request:
+ types: [opened]
+
+jobs:
+ discord:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Send Discord
+ run: |
+ curl -X POST "${{ secrets.DISCORD_WEBHOOK_PULLREQUEST }}" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "embeds": [{
+ "title": "🔔 **Service:** ${{ github.repository }}",
+ "description": "👤 **Author:** ${{ github.event.pull_request.user.login }}\n🌿 **Branch:** ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}\n📦 **Pull Request:** [#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})",
+ "color": 5814783,
+ "timestamp": "${{ github.event.pull_request.created_at }}"
+ }]
+ }'
diff --git a/.github/workflows/dockerhub-release-checkin.yaml b/.github/workflows/dockerhub-release-checkin.yaml
new file mode 100644
index 00000000..b80c44f7
--- /dev/null
+++ b/.github/workflows/dockerhub-release-checkin.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - CheckIn Consumer
+run-name: DockerHub Release - CheckIn Consumer by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "checkin-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-checkin
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.CheckInConsumer/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR CheckIn Consumer
+ org.opencontainers.image.description=HRMS CheckIn Consumer Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-command.yaml b/.github/workflows/dockerhub-release-command.yaml
new file mode 100644
index 00000000..571fd6c9
--- /dev/null
+++ b/.github/workflows/dockerhub-release-command.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - Command Service
+run-name: DockerHub Release - Command Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "command-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-command
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Command.Service/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR Command Service
+ org.opencontainers.image.description=HRMS Command API Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-discipline.yaml b/.github/workflows/dockerhub-release-discipline.yaml
new file mode 100644
index 00000000..f4642bd8
--- /dev/null
+++ b/.github/workflows/dockerhub-release-discipline.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - Discipline Service
+run-name: DockerHub Release - Discipline Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "discipline-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-discipline
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Discipline.Service/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR Discipline Service
+ org.opencontainers.image.description=HRMS Discipline API Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-insignia.yaml b/.github/workflows/dockerhub-release-insignia.yaml
new file mode 100644
index 00000000..79d89963
--- /dev/null
+++ b/.github/workflows/dockerhub-release-insignia.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - Insignia Service
+run-name: DockerHub Release - Insignia Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "insignia-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-insignia
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Insignia/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR Insignia Service
+ org.opencontainers.image.description=HRMS Insignia API Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-leave.yaml b/.github/workflows/dockerhub-release-leave.yaml
new file mode 100644
index 00000000..f9c2e0ba
--- /dev/null
+++ b/.github/workflows/dockerhub-release-leave.yaml
@@ -0,0 +1,119 @@
+name: DockerHub Release - Leave Service
+run-name: DockerHub Release - Leave Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "leave-[0-9]+.[0-9]+.[0-9]+"
+ # branches:
+ # - main
+ # - develop
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-leave
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ elif [[ $GITHUB_REF == 'refs/heads/'* ]]; then
+ BRANCH_NAME=${GITHUB_REF#refs/heads/}
+ IMAGE_VER="${BRANCH_NAME}-latest"
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Extract metadata for Docker
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
+ tags: |
+ type=ref,event=tag
+ type=ref,event=branch
+ type=raw,value=${{ steps.gen_ver.outputs.image_ver }}
+ type=raw,value=latest,enable={{is_default_branch}}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Leave/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Image digest
+ run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}"
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-placement.yaml b/.github/workflows/dockerhub-release-placement.yaml
new file mode 100644
index 00000000..d4e3dade
--- /dev/null
+++ b/.github/workflows/dockerhub-release-placement.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - Placement Service
+run-name: DockerHub Release - Placement Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "placement-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-placement
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Placement.Service/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR Placement Service
+ org.opencontainers.image.description=HRMS Placement API Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-reportv2.yaml b/.github/workflows/dockerhub-release-reportv2.yaml
new file mode 100644
index 00000000..4dc73f3f
--- /dev/null
+++ b/.github/workflows/dockerhub-release-reportv2.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - Report Service
+run-name: DockerHub Release - Report Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "reportv2-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-reportv2
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Report.Service/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR Report Service
+ org.opencontainers.image.description=HRMS Report API Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-retirement.yaml b/.github/workflows/dockerhub-release-retirement.yaml
new file mode 100644
index 00000000..50ace5cd
--- /dev/null
+++ b/.github/workflows/dockerhub-release-retirement.yaml
@@ -0,0 +1,101 @@
+name: DockerHub Release - Retirement Service
+run-name: DockerHub Release - Retirement Service by ${{ github.actor }}
+on:
+ push:
+ tags:
+ - "retirement-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
+ inputs:
+ IMAGE_VER:
+ description: "Image version (e.g., latest, v1.0.0)"
+ required: false
+ default: "latest"
+
+env:
+ DOCKERHUB_REGISTRY: docker.io
+ IMAGE_NAME: hrms-api-retirement
+ DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
+
+jobs:
+ release-to-dockerhub:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+
+ - name: Generate version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
+ echo "Generated version: ${IMAGE_VER}"
+
+ - name: Display version
+ run: |
+ echo "Git Ref: $GITHUB_REF"
+ echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{env.DOCKERHUB_REGISTRY}}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: BMA.EHR.Retirement.Service/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
+ labels: |
+ org.opencontainers.image.title=BMA EHR Retirement Service
+ org.opencontainers.image.description=HRMS Retirement API Service
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Notify Discord on success
+ if: success()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
+
+ - name: Notify Discord on failure
+ if: failure()
+ env:
+ IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
+ run: |
+ TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
+ REF_INFO="Ref: ${GITHUB_REF}"
+ ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
+ MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
+ curl -s -H "Content-Type: application/json" \
+ -X POST \
+ -d "{\"content\":\"${MSG}\"}" \
+ "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/release_Retirement.yaml b/.github/workflows/release_Retirement.yaml
index 4d644cb3..3fd5bedf 100644
--- a/.github/workflows/release_Retirement.yaml
+++ b/.github/workflows/release_Retirement.yaml
@@ -1,107 +1,107 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- push:
- tags:
- - "retirement-[0-9]+.[0-9]+.[0-9]+"
+ # push:
+ # tags:
+ # - "retirement-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
- REGISTRY: docker.frappet.com
- IMAGE_NAME: ehr/bma-ehr-retirement-service
- DEPLOY_HOST: frappet.com
- DEPLOY_PORT: 10102
- # COMPOSE_PATH: /home/frappet/docker/bma-ehr
- COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-retirement
- TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-retirement-service
+ DEPLOY_HOST: frappet.com
+ DEPLOY_PORT: 10102
+ # COMPOSE_PATH: /home/frappet/docker/bma-ehr
+ COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-retirement
+ TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
- # act workflow_dispatch -W .github/workflows/release_retirement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
- release-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- - name: Gen Version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo '::set-output name=image_ver::'$IMAGE_VER
- - name: Check Version
- run: |
- echo $GITHUB_REF
- echo ${{ steps.gen_ver.outputs.image_ver }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login in to registry
- uses: docker/login-action@v2
- with:
- registry: ${{env.REGISTRY}}
- username: ${{secrets.DOCKER_USER}}
- password: ${{secrets.DOCKER_PASS}}
- - name: Build and load local docker image
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- file: BMA.EHR.Retirement.Service/Dockerfile
- push: true
- tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+ # act workflow_dispatch -W .github/workflows/release_retirement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Check Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ file: BMA.EHR.Retirement.Service/Dockerfile
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- - name: Reload docker compose
- uses: appleboy/ssh-action@v0.1.8
- with:
- host: ${{env.DEPLOY_HOST}}
- username: frappet
- password: ${{ secrets.SSH_PASSWORD }}
- port: ${{env.DEPLOY_PORT}}
- script: |
- cd "${{env.COMPOSE_PATH}}"
- docker compose pull
- docker compose up -d
- echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- - name: Notify Discord Success
- if: success()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "✅ Deployment Success!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
- "color": 3066993,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/success-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: ${{env.DEPLOY_PORT}}
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker compose pull
+ docker compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
+ - name: Notify Discord Success
+ if: success()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "✅ Deployment Success!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
+ "color": 3066993,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/success-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
- - name: Notify Discord Failure
- if: failure()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "❌ Deployment Failed!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
- "color": 15158332,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/failure-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Notify Discord Failure
+ if: failure()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "❌ Deployment Failed!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
+ "color": 15158332,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/failure-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
diff --git a/.github/workflows/release_checkin_consumer.yaml b/.github/workflows/release_checkin_consumer.yaml
index 31b015e6..f9081264 100644
--- a/.github/workflows/release_checkin_consumer.yaml
+++ b/.github/workflows/release_checkin_consumer.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- push:
- tags:
- - "consumer-[0-9]+.[0-9]+.[0-9]+"
+ # push:
+ # tags:
+ # - "consumer-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_command.yaml b/.github/workflows/release_command.yaml
index ed19e8ca..dba3012e 100644
--- a/.github/workflows/release_command.yaml
+++ b/.github/workflows/release_command.yaml
@@ -1,89 +1,107 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - 'v[0-9]+.[0-9]+.[0-9]+'
- # tags-ignore:
- # - '2.*'
- # Allow run workflow manually from Action tab
- workflow_dispatch:
+ # push:
+ # tags:
+ # - "command-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
env:
- REGISTRY: docker.frappet.com
- IMAGE_NAME: ehr/bma-ehr-command-service
- DEPLOY_HOST: frappet.com
- DEPLOY_PORT: 10102
- # COMPOSE_PATH: /home/frappet/docker/bma-ehr
- COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-command
- TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-command-service
+ DEPLOY_HOST: frappet.com
+ DEPLOY_PORT: 10102
+ # COMPOSE_PATH: /home/frappet/docker/bma-ehr
+ COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-command
+ TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
- # act workflow_dispatch -W .github/workflows/release_command.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
- release-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- # skip Set up QEMU because it fail on act and container
- - name: Gen Version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo '::set-output name=image_ver::'$IMAGE_VER
- - name: Test Version
- run: |
- echo $GITHUB_REF
- echo ${{ steps.gen_ver.outputs.image_ver }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login in to registry
- uses: docker/login-action@v2
- with:
- registry: ${{env.REGISTRY}}
- username: ${{secrets.DOCKER_USER}}
- password: ${{secrets.DOCKER_PASS}}
- - name: Build and load local docker image
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- file: BMA.EHR.Command.Service/Dockerfile
- push: true
- tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+ # act workflow_dispatch -W .github/workflows/release_command.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Check Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ file: BMA.EHR.Command.Service/Dockerfile
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- - name: Reload docker compose
- uses: appleboy/ssh-action@v0.1.8
- with:
- host: ${{env.DEPLOY_HOST}}
- username: frappet
- password: ${{ secrets.SSH_PASSWORD }}
- port: ${{env.DEPLOY_PORT}}
- script: |
- cd "${{env.COMPOSE_PATH}}"
- docker compose pull
- docker compose up -d
- echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- - uses: snow-actions/line-notify@v1.1.0
- if: success()
- with:
- access_token: ${{ env.TOKEN_LINE }}
- message: |
- -Success✅✅✅
- Image: ${{env.IMAGE_NAME}}
- Version: ${{ github.event.inputs.IMAGE_VER }}
- By: ${{secrets.DOCKER_USER}}
- - uses: snow-actions/line-notify@v1.1.0
- if: failure()
- with:
- access_token: ${{ env.TOKEN_LINE }}
- message: |
- -Failure❌❌❌
- Image: ${{env.IMAGE_NAME}}
- Version: ${{ github.event.inputs.IMAGE_VER }}
- By: ${{secrets.DOCKER_USER}}
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: ${{env.DEPLOY_PORT}}
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker compose pull
+ docker compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
+ - name: Notify Discord Success
+ if: success()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "✅ Deployment Success!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
+ "color": 3066993,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/success-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
+
+ - name: Notify Discord Failure
+ if: failure()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "❌ Deployment Failed!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
+ "color": 15158332,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/failure-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
diff --git a/.github/workflows/release_discipline.yaml b/.github/workflows/release_discipline.yaml
index 80639a84..f4cb42da 100644
--- a/.github/workflows/release_discipline.yaml
+++ b/.github/workflows/release_discipline.yaml
@@ -1,107 +1,107 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- push:
- tags:
- - "discipline-[0-9]+.[0-9]+.[0-9]+"
+ # push:
+ # tags:
+ # - "discipline-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
- REGISTRY: docker.frappet.com
- IMAGE_NAME: ehr/bma-ehr-discipline-service
- DEPLOY_HOST: frappet.com
- DEPLOY_PORT: 10102
- # COMPOSE_PATH: /home/frappet/docker/bma-ehr
- COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-discipline
- TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-discipline-service
+ DEPLOY_HOST: frappet.com
+ DEPLOY_PORT: 10102
+ # COMPOSE_PATH: /home/frappet/docker/bma-ehr
+ COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-discipline
+ TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
- # act workflow_dispatch -W .github/workflows/release_discipline.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
- release-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- - name: Gen Version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo '::set-output name=image_ver::'$IMAGE_VER
- - name: Check Version
- run: |
- echo $GITHUB_REF
- echo ${{ steps.gen_ver.outputs.image_ver }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login in to registry
- uses: docker/login-action@v2
- with:
- registry: ${{env.REGISTRY}}
- username: ${{secrets.DOCKER_USER}}
- password: ${{secrets.DOCKER_PASS}}
- - name: Build and load local docker image
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- file: BMA.EHR.Discipline.Service/Dockerfile
- push: true
- tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+ # act workflow_dispatch -W .github/workflows/release_discipline.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Check Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ file: BMA.EHR.Discipline.Service/Dockerfile
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- - name: Reload docker compose
- uses: appleboy/ssh-action@v0.1.8
- with:
- host: ${{env.DEPLOY_HOST}}
- username: frappet
- password: ${{ secrets.SSH_PASSWORD }}
- port: ${{env.DEPLOY_PORT}}
- script: |
- cd "${{env.COMPOSE_PATH}}"
- docker compose pull
- docker compose up -d
- echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- - name: Notify Discord Success
- if: success()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "✅ Deployment Success!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
- "color": 3066993,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/success-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: ${{env.DEPLOY_PORT}}
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker compose pull
+ docker compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
+ - name: Notify Discord Success
+ if: success()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "✅ Deployment Success!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
+ "color": 3066993,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/success-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
- - name: Notify Discord Failure
- if: failure()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "❌ Deployment Failed!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
- "color": 15158332,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/failure-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Notify Discord Failure
+ if: failure()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "❌ Deployment Failed!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
+ "color": 15158332,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/failure-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
diff --git a/.github/workflows/release_insignia.yaml b/.github/workflows/release_insignia.yaml
index 124d1e9c..af497b37 100644
--- a/.github/workflows/release_insignia.yaml
+++ b/.github/workflows/release_insignia.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- push:
- tags:
- - "insignia-[0-9]+.[0-9]+.[0-9]+"
+ # push:
+ # tags:
+ # - "insignia-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_leave.yaml b/.github/workflows/release_leave.yaml
index b017222d..9b5e0014 100644
--- a/.github/workflows/release_leave.yaml
+++ b/.github/workflows/release_leave.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- push:
- tags:
- - "leave-[0-9]+.[0-9]+.[0-9]+"
+ # push:
+ # tags:
+ # - "leave-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
@@ -57,7 +57,7 @@ jobs:
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Remote Deployment
- uses: appleboy/ssh-action@v0.1.8
+ uses: appleboy/ssh-action@v1
with:
host: ${{env.DEPLOY_HOST}}
username: frappet
diff --git a/.github/workflows/release_placement.yaml b/.github/workflows/release_placement.yaml
index e1af3041..377cbaf4 100644
--- a/.github/workflows/release_placement.yaml
+++ b/.github/workflows/release_placement.yaml
@@ -1,107 +1,107 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- push:
- tags:
- - "placement-[0-9]+.[0-9]+.[0-9]+"
+ # push:
+ # tags:
+ # - "placement-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
- REGISTRY: docker.frappet.com
- IMAGE_NAME: ehr/bma-ehr-placement-service
- DEPLOY_HOST: frappet.com
- DEPLOY_PORT: 10102
- # COMPOSE_PATH: /home/frappet/docker/bma-ehr
- COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-placement
- TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-placement-service
+ DEPLOY_HOST: frappet.com
+ DEPLOY_PORT: 10102
+ # COMPOSE_PATH: /home/frappet/docker/bma-ehr
+ COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-placement
+ TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
- # act workflow_dispatch -W .github/workflows/release_placement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
- release-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- - name: Gen Version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo '::set-output name=image_ver::'$IMAGE_VER
- - name: Check Version
- run: |
- echo $GITHUB_REF
- echo ${{ steps.gen_ver.outputs.image_ver }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login in to registry
- uses: docker/login-action@v2
- with:
- registry: ${{env.REGISTRY}}
- username: ${{secrets.DOCKER_USER}}
- password: ${{secrets.DOCKER_PASS}}
- - name: Build and load local docker image
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- file: BMA.EHR.Placement.Service/Dockerfile
- push: true
- tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+ # act workflow_dispatch -W .github/workflows/release_placement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Check Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ file: BMA.EHR.Placement.Service/Dockerfile
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- - name: Reload docker compose
- uses: appleboy/ssh-action@v0.1.8
- with:
- host: ${{env.DEPLOY_HOST}}
- username: frappet
- password: ${{ secrets.SSH_PASSWORD }}
- port: ${{env.DEPLOY_PORT}}
- script: |
- cd "${{env.COMPOSE_PATH}}"
- docker compose pull
- docker compose up -d
- echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- - name: Notify Discord Success
- if: success()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "✅ Deployment Success!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
- "color": 3066993,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/success-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: ${{env.DEPLOY_PORT}}
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker compose pull
+ docker compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
+ - name: Notify Discord Success
+ if: success()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "✅ Deployment Success!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
+ "color": 3066993,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/success-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
- - name: Notify Discord Failure
- if: failure()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "❌ Deployment Failed!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
- "color": 15158332,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/failure-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Notify Discord Failure
+ if: failure()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "❌ Deployment Failed!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
+ "color": 15158332,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/failure-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
diff --git a/.github/workflows/release_report.yaml b/.github/workflows/release_report.yaml
index 6dbacca1..e529729b 100644
--- a/.github/workflows/release_report.yaml
+++ b/.github/workflows/release_report.yaml
@@ -1,89 +1,107 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - 'v[0-9]+.[0-9]+.[0-9]+'
- # tags-ignore:
- # - '2.*'
- # Allow run workflow manually from Action tab
- workflow_dispatch:
+ # push:
+ # tags:
+ # - "reportv2-[0-9]+.[0-9]+.[0-9]+"
+ workflow_dispatch:
env:
- REGISTRY: docker.frappet.com
- IMAGE_NAME: ehr/bma-ehr-report-v2-service
- DEPLOY_HOST: frappet.com
- DEPLOY_PORT: 10102
- # COMPOSE_PATH: /home/frappet/docker/bma-ehr
- COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2
- TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-report-v2-service
+ DEPLOY_HOST: frappet.com
+ DEPLOY_PORT: 10102
+ # COMPOSE_PATH: /home/frappet/docker/bma-ehr
+ COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2
+ TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
- # act workflow_dispatch -W .github/workflows/release_report.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
- release-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- # skip Set up QEMU because it fail on act and container
- - name: Gen Version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo '::set-output name=image_ver::'$IMAGE_VER
- - name: Test Version
- run: |
- echo $GITHUB_REF
- echo ${{ steps.gen_ver.outputs.image_ver }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login in to registry
- uses: docker/login-action@v2
- with:
- registry: ${{env.REGISTRY}}
- username: ${{secrets.DOCKER_USER}}
- password: ${{secrets.DOCKER_PASS}}
- - name: Build and load local docker image
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- file: BMA.EHR.Report.Service/Dockerfile
- push: true
- tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+ # act workflow_dispatch -W .github/workflows/release_report.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Check Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ file: BMA.EHR.Report.Service/Dockerfile
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- - name: Reload docker compose
- uses: appleboy/ssh-action@v0.1.8
- with:
- host: ${{env.DEPLOY_HOST}}
- username: frappet
- password: ${{ secrets.SSH_PASSWORD }}
- port: ${{env.DEPLOY_PORT}}
- script: |
- cd "${{env.COMPOSE_PATH}}"
- docker compose pull
- docker compose up -d
- echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- - uses: snow-actions/line-notify@v1.1.0
- if: success()
- with:
- access_token: ${{ env.TOKEN_LINE }}
- message: |
- -Success✅✅✅
- Image: ${{env.IMAGE_NAME}}
- Version: ${{ github.event.inputs.IMAGE_VER }}
- By: ${{secrets.DOCKER_USER}}
- - uses: snow-actions/line-notify@v1.1.0
- if: failure()
- with:
- access_token: ${{ env.TOKEN_LINE }}
- message: |
- -Failure❌❌❌
- Image: ${{env.IMAGE_NAME}}
- Version: ${{ github.event.inputs.IMAGE_VER }}
- By: ${{secrets.DOCKER_USER}}
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: ${{env.DEPLOY_PORT}}
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker compose pull
+ docker compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
+ - name: Notify Discord Success
+ if: success()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "✅ Deployment Success!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
+ "color": 3066993,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/success-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
+
+ - name: Notify Discord Failure
+ if: failure()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "❌ Deployment Failed!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
+ "color": 15158332,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/failure-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
diff --git a/.gitignore b/.gitignore
index 88bfb4ba..f60d8ec1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,19 @@
# Mono auto generated files
mono_crash.*
+# JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+.idea/
+*.iml
+*.ipr
+*.iws
+out/
+.idea_modules/
+atlassian-ide-plugin.xml
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
# Build results
[Dd]ebug/
[Dd]ebugPublic/
@@ -360,4 +373,10 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+
+# VS Code C# Dev Kit cache
+*.lscache
+
+# Claude Code
+.claude/
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/.name b/.idea/.idea.BMA.EHR.Solution/.idea/.name
deleted file mode 100644
index 888d8763..00000000
--- a/.idea/.idea.BMA.EHR.Solution/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-BMA.EHR.Solution
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml b/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml
deleted file mode 100644
index df87cf95..00000000
--- a/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml b/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml
deleted file mode 100644
index 7b08163c..00000000
--- a/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/projectSettingsUpdater.xml b/.idea/.idea.BMA.EHR.Solution/.idea/projectSettingsUpdater.xml
deleted file mode 100644
index 4bb9f4d2..00000000
--- a/.idea/.idea.BMA.EHR.Solution/.idea/projectSettingsUpdater.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml b/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml
deleted file mode 100644
index 35eb1ddf..00000000
--- a/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/workspace.xml b/.idea/.idea.BMA.EHR.Solution/.idea/workspace.xml
deleted file mode 100644
index 3a284eaf..00000000
--- a/.idea/.idea.BMA.EHR.Solution/.idea/workspace.xml
+++ /dev/null
@@ -1,552 +0,0 @@
-
-
-
- BMA.EHR.CheckInConsumer/BMA.EHR.CheckInConsumer.csproj
- BMA.EHR.CheckInConsumer/BMA.EHR.CheckInConsumer.csproj
- BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj
- BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj
- BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj
- BMA.EHR.Discipline.Service/BMA.EHR.Discipline.Service.csproj
- BMA.EHR.Discipline.Service/BMA.EHR.Discipline.Service.csproj
- BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
- BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
- BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
- BMA.EHR.Leave/BMA.EHR.Leave.csproj
- BMA.EHR.Leave/BMA.EHR.Leave.csproj
- BMA.EHR.Leave/BMA.EHR.Leave.csproj
- BMA.EHR.MetaData.Service/BMA.EHR.MetaData.Service.csproj
- BMA.EHR.MetaData.Service/BMA.EHR.MetaData.Service.csproj
- BMA.EHR.MetaData.Service/BMA.EHR.MetaData.Service.csproj
- BMA.EHR.OrganizationEmployee.Service/BMA.EHR.OrganizationEmployee.Service.csproj
- BMA.EHR.OrganizationEmployee.Service/BMA.EHR.OrganizationEmployee.Service.csproj
- BMA.EHR.OrganizationEmployee.Service/BMA.EHR.OrganizationEmployee.Service.csproj
- BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj
- BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj
- BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj
- BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
- BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
- BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
- BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
- BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
- BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj
- BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj
- BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1724638841465
-
-
- 1724638841465
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- file://$PROJECT_DIR$/BMA.EHR.Leave/Controllers/LeaveController.cs
- 1152
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml
index 91d7f220..bd58b796 100644
--- a/.onedev-buildspec.yml
+++ b/.onedev-buildspec.yml
@@ -1,6 +1,6 @@
version: 37
jobs:
-- name: CI for Checkin [UAT]
+- name: CI for UAT
steps:
- !CheckoutStep
name: checkout code
@@ -33,32 +33,44 @@ jobs:
dotnet test -l trx --collect:"XPlat Code Coverage"
#/root/.dotnet/tools/roslynator analyze -o roslynator-analysis.xml
useTTY: true
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
+ condition: NEVER
- !PublishTRXReportStep
name: publish unit test report
reportName: Unit Test
filePatterns: '**/*.trx'
- condition: ALWAYS
+ condition: NEVER
- !PublishCoberturaReportStep
name: publish code coverage report
reportName: Code Coverage
filePatterns: '**/coverage.cobertura.xml'
- condition: ALWAYS
+ condition: NEVER
- !PublishRoslynatorReportStep
name: publish code problem report
reportName: Code Problems
filePatterns: roslynator-analysis.xml
failThreshold: HIGH
- condition: ALWAYS
+ condition: NEVER
- !SetBuildVersionStep
name: set build version
buildVersion: '@tag@'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !BuildImageStep
- name: build docker image
+ name: build docker image - Leave
+ dockerfile: ./BMA.EHR.Leave/Dockerfile
+ output: !RegistryOutput
+ tags: hrms-git.chin.in.th/bma-hrms/hrms-api-leave:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-leave:latest
+ condition: NEVER
+ - !BuildImageStep
+ name: build docker image - Checkin
dockerfile: ./BMA.EHR.CheckInConsumer/Dockerfile
output: !RegistryOutput
tags: hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:latest
+ condition: NEVER
+ - !BuildImageStep
+ name: build docker image - Insignia
+ dockerfile: ./BMA.EHR.Insignia/Dockerfile
+ output: !RegistryOutput
+ tags: hrms-git.chin.in.th/bma-hrms/hrms-api-insignia:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-insignia:latest
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !TagCreateTrigger
@@ -68,53 +80,3 @@ jobs:
maxRetries: 3
retryDelay: 30
timeout: 14400
-- name: CI for PROD
- steps:
- - !CheckoutStep
- name: checkout code
- cloneCredential: !DefaultCredential {}
- withLfs: false
- withSubmodules: false
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- - !GenerateChecksumStep
- name: generate package checksum
- files: package-lock.json yarn.lock
- targetFile: checksum
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- - !SetupCacheStep
- name: set up npm cache
- key: node_modules_@file:checksum@
- loadKeys:
- - node_modules
- paths:
- - node_modules
- uploadStrategy: UPLOAD_IF_NOT_HIT
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- - !SetBuildVersionStep
- name: set build version
- buildVersion: '@tag@'
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- - !CommandStep
- name: build & test
- runInContainer: true
- image: node
- interpreter: !DefaultInterpreter
- commands: |
- npm install
- npm run build
- useTTY: true
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- - !BuildImageStep
- name: build docker image
- dockerfile: ./docker/Dockerfile
- output: !RegistryOutput
- tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-checkin:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-checkin:latest
- condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- triggers:
- - !TagCreateTrigger
- tags: prod-*
- branches: main
- retryCondition: never
- maxRetries: 3
- retryDelay: 30
- timeout: 14400
diff --git a/.vscode/launch.json b/.vscode/launch.json
index fd9cf53a..6be3e592 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,35 +1,60 @@
{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
- "name": ".NET Core Launch (web)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/BMA.EHR.Leave.Service/bin/Debug/net7.0/BMA.EHR.Leave.Service.dll",
- "args": [],
- "cwd": "${workspaceFolder}/BMA.EHR.Leave.Service",
- "stopAtEntry": false,
- // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
- "serverReadyAction": {
- "action": "openExternally",
- "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
- },
- "env": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "sourceFileMap": {
- "/Views": "${workspaceFolder}/Views"
- }
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/BMA.EHR.Leave/bin/Debug/net7.0/BMA.EHR.Leave.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/BMA.EHR.Leave",
+ "stopAtEntry": false,
+ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
+ "name": ".NET Core Launch (web) - Insignia",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/BMA.EHR.Insignia/bin/Debug/net7.0/BMA.EHR.Insignia.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/BMA.EHR.Insignia",
+ "stopAtEntry": false,
+ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
diff --git a/BMA.EHR.Application/ApplicationServicesRegistration.cs b/BMA.EHR.Application/ApplicationServicesRegistration.cs
index aa47f71f..0b99a7b6 100644
--- a/BMA.EHR.Application/ApplicationServicesRegistration.cs
+++ b/BMA.EHR.Application/ApplicationServicesRegistration.cs
@@ -23,11 +23,12 @@ namespace BMA.EHR.Application
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
+ //services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -52,12 +53,16 @@ namespace BMA.EHR.Application
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+
return services;
}
diff --git a/BMA.EHR.Application/BMA.EHR.Application.csproj b/BMA.EHR.Application/BMA.EHR.Application.csproj
index b3262e4b..7a12c4b5 100644
--- a/BMA.EHR.Application/BMA.EHR.Application.csproj
+++ b/BMA.EHR.Application/BMA.EHR.Application.csproj
@@ -4,6 +4,9 @@
net6.0
enable
enable
+ false
+ $(NoWarn);$(WarningsNotAsErrors)
+
diff --git a/BMA.EHR.Application/Messaging/EmailSenderService.cs b/BMA.EHR.Application/Messaging/EmailSenderService.cs
index c02670bb..9a718c2e 100644
--- a/BMA.EHR.Application/Messaging/EmailSenderService.cs
+++ b/BMA.EHR.Application/Messaging/EmailSenderService.cs
@@ -51,7 +51,7 @@ namespace BMA.EHR.Application.Messaging
}
catch
{
- throw;
+ //throw;
}
}
diff --git a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs
index bc1ca83a..7db52edd 100644
--- a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs
+++ b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs
@@ -99,11 +99,11 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionLevel = p.posLevelName == null ? "" : p.posLevelName,
PositionType = p.posTypeName == null ? "" : p.posTypeName,
PositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(),
@@ -138,12 +138,6 @@ namespace BMA.EHR.Application.Repositories.Commands
join p in _dbContext.Set()
.Include(x => x.PlacementEducations)
.Include(x => x.Placement)
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.Organization)
- .Include(x => x.PositionPath)
- .Include(x => x.PositionLevel)
- .Include(x => x.PositionNumber)
- .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType01Response
@@ -158,11 +152,11 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionLevel = p.posLevelName == null ? "" : p.posLevelName,
PositionType = p.posTypeName == null ? "" : p.posTypeName,
PositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
Salary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
ExamNumber = p.ExamNumber == null ? "" : p.ExamNumber.Value.ToString().ToThaiNumber(),
@@ -196,12 +190,6 @@ namespace BMA.EHR.Application.Repositories.Commands
join p in _dbContext.Set()
.Include(x => x.PlacementEducations)
.Include(x => x.Placement)
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.Organization)
- .Include(x => x.PositionPath)
- .Include(x => x.PositionLevel)
- .Include(x => x.PositionNumber)
- .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType03Response
@@ -218,11 +206,11 @@ namespace BMA.EHR.Application.Repositories.Commands
OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld,
OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld,
OldPositionNumber = p.posMasterNoOld == null ? "" :
- p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "",
+ p.nodeOld == "4" ? $"{p.child4ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "3" ? $"{p.child3ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "2" ? $"{p.child2ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "1" ? $"{p.child1ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "0" ? $"{p.rootShortNameOld} {p.posMasterNoOld}".ToThaiNumber() : "",
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.root == null ? "" : p.root,
@@ -230,11 +218,11 @@ namespace BMA.EHR.Application.Repositories.Commands
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
RemarkHorizontal = p.RemarkHorizontal,
@@ -267,12 +255,6 @@ namespace BMA.EHR.Application.Repositories.Commands
join p in _dbContext.Set()
.Include(x => x.PlacementEducations)
.Include(x => x.Placement)
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.Organization)
- .Include(x => x.PositionPath)
- .Include(x => x.PositionLevel)
- .Include(x => x.PositionNumber)
- .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType03Response
@@ -287,22 +269,22 @@ namespace BMA.EHR.Application.Repositories.Commands
OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld,
OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld,
OldPositionNumber = p.posMasterNoOld == null ? "" :
- p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "",
+ p.nodeOld == "4" ? $"{p.child4ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "3" ? $"{p.child3ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "2" ? $"{p.child2ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "1" ? $"{p.child1ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "0" ? $"{p.rootShortNameOld} {p.posMasterNoOld}".ToThaiNumber() : "",
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.root == null ? "" : p.root,
NewPositionName = p.positionName == null ? "" : p.positionName,
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber()
})
@@ -333,12 +315,6 @@ namespace BMA.EHR.Application.Repositories.Commands
join p in _dbContext.Set()
.Include(x => x.PlacementEducations)
.Include(x => x.Placement)
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.Organization)
- .Include(x => x.PositionPath)
- .Include(x => x.PositionLevel)
- .Include(x => x.PositionNumber)
- .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType03Response
@@ -353,22 +329,22 @@ namespace BMA.EHR.Application.Repositories.Commands
OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld,
OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld,
OldPositionNumber = p.posMasterNoOld == null ? "" :
- p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
- p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "",
+ p.nodeOld == "4" ? $"{p.child4ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "3" ? $"{p.child3ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "2" ? $"{p.child2ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "1" ? $"{p.child1ShortNameOld} {p.posMasterNoOld}".ToThaiNumber() :
+ p.nodeOld == "0" ? $"{p.rootShortNameOld} {p.posMasterNoOld}".ToThaiNumber() : "",
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.root == null ? "" : p.root,
NewPositionName = p.positionName == null ? "" : p.positionName,
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber()
})
@@ -431,11 +407,11 @@ namespace BMA.EHR.Application.Repositories.Commands
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
@@ -501,11 +477,11 @@ namespace BMA.EHR.Application.Repositories.Commands
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
@@ -774,11 +750,11 @@ namespace BMA.EHR.Application.Repositories.Commands
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
@@ -1197,11 +1173,11 @@ namespace BMA.EHR.Application.Repositories.Commands
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName.ToThaiNumber(),
// NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
@@ -1331,11 +1307,11 @@ namespace BMA.EHR.Application.Repositories.Commands
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
// NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
NewPositionNumber = p.posMasterNo == null ? "" :
- p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
- p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
+ p.node == 4 ? $"{p.child4ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 3 ? $"{p.child3ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 2 ? $"{p.child2ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 1 ? $"{p.child1ShortName} {p.posMasterNo}".ToThaiNumber() :
+ p.node == 0 ? $"{p.rootShortName} {p.posMasterNo}".ToThaiNumber() : "",
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
index c8d51fca..d306b3e9 100644
--- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
+++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
@@ -248,7 +248,7 @@ namespace BMA.EHR.Application.Repositories.Commands
.Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN")
.Where(x => x.Draft! == true)
.Where(x => x.Placement!.PlacementType!.Name == "สอบแข่งขัน")
- .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED")
+ .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINT")
.OrderBy(x => x.ExamNumber)
.ToListAsync();
@@ -307,7 +307,7 @@ namespace BMA.EHR.Application.Repositories.Commands
.Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN")
.Where(x => x.Draft! == true)
.Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน")
- .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED")
+ .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINT")
.OrderBy(x => x.ExamNumber)
.ToListAsync();
@@ -919,7 +919,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -934,7 +934,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -986,7 +986,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1001,7 +1001,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1423,7 +1423,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1440,7 +1440,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1534,7 +1534,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1550,7 +1550,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1603,7 +1603,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1832,7 +1832,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1849,7 +1849,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1905,7 +1905,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1922,7 +1922,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1978,7 +1978,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1995,7 +1995,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2051,7 +2051,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2068,7 +2068,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2124,7 +2124,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2141,7 +2141,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2197,7 +2197,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2214,7 +2214,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2270,7 +2270,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2287,7 +2287,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2340,7 +2340,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2355,7 +2355,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2409,7 +2409,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2462,7 +2462,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2515,7 +2515,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2568,7 +2568,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2621,7 +2621,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2673,7 +2673,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2725,7 +2725,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2981,37 +2981,8 @@ namespace BMA.EHR.Application.Repositories.Commands
var placementProfile = await _dbContext.Set()
.Include(x => x.PlacementProfileDocs)
.ThenInclude(x => x.Document)
- .Include(x => x.PositionPath)
- .Include(x => x.PositionPathSide)
- .Include(x => x.PositionType)
- .Include(x => x.PositionLine)
- .Include(x => x.PositionLevel)
- .Include(x => x.PositionNumber)
-
.Include(x => x.PlacementCertificates)
.Include(x => x.PlacementEducations)
- .ThenInclude(x => x.EducationLevel)
-
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.Organization)
- .ThenInclude(x => x.OrganizationShortName)
-
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.PositionMaster)
- .ThenInclude(x => x.PositionExecutive)
-
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.PositionMaster)
- .ThenInclude(x => x.PositionExecutiveSide)
-
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.PositionMaster)
- .ThenInclude(x => x.PositionLine)
-
- .Include(x => x.OrganizationPosition)
- .ThenInclude(x => x.Organization)
- .ThenInclude(x => x.OrganizationOrganization)
-
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (placementProfile == null)
@@ -3023,7 +2994,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -3075,7 +3046,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
foreach (var edu in placementProfile.PlacementEducations)
{
var _res = await client.PostAsJsonAsync(apiUrlEdu, new
@@ -3093,7 +3064,7 @@ namespace BMA.EHR.Application.Repositories.Commands
other = edu.Other == null ? string.Empty : edu.Other,
startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate,
endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate,
- educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name,
+ educationLevel = edu.EducationLevelName,
educationLevelId = string.Empty,
positionPath = edu.PositionPath == null ? null : edu.PositionPath,
positionPathId = string.Empty,
@@ -3112,7 +3083,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
foreach (var cer in placementProfile.PlacementCertificates)
{
var _res = await client.PostAsJsonAsync(apiUrlCer, new
@@ -3133,7 +3104,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = profileId,
@@ -3142,11 +3113,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = placementProfile.PositionSalaryAmount,
mouthSalaryAmount = placementProfile.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
positionLine = string.Empty,
positionPathSide = string.Empty,
@@ -3164,7 +3135,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3316,7 +3287,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3326,11 +3297,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.positionName,
positionLine = "",
positionPathSide = "",
@@ -3348,7 +3319,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3497,7 +3468,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3507,11 +3478,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.positionName,
positionLine = "",
positionPathSide = "",
@@ -3529,7 +3500,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3678,7 +3649,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3688,11 +3659,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.positionName,
positionLine = "",
positionPathSide = "",
@@ -3710,7 +3681,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3861,7 +3832,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3871,11 +3842,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.position,
positionLine = "",
positionPathSide = "",
@@ -3893,7 +3864,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -4046,7 +4017,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4056,11 +4027,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.position,
positionLine = "",
positionPathSide = "",
@@ -4078,7 +4049,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -4228,7 +4199,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4238,11 +4209,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.position,
positionLine = "",
positionPathSide = "",
@@ -4260,7 +4231,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -4411,7 +4382,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4438,7 +4409,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
@@ -4589,7 +4560,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4616,7 +4587,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
@@ -4957,7 +4928,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -5114,7 +5085,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -5291,7 +5262,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5469,7 +5440,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5479,11 +5450,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName} {placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName} {placementProfile.posMasterNo}" : "",
position = placementProfile.position,
positionLine = "",
positionPathSide = "",
@@ -5501,7 +5472,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -5655,7 +5626,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5834,7 +5805,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6015,7 +5986,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6030,7 +6001,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6211,7 +6182,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6226,7 +6197,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6400,7 +6371,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6481,7 +6452,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend });
var result = await res.Content.ReadAsStringAsync();
@@ -6578,7 +6549,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6659,7 +6630,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend });
var result = await res.Content.ReadAsStringAsync();
@@ -6748,7 +6719,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -6906,7 +6877,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6916,11 +6887,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = data.posMasterNo == null ? "" :
- data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" :
- data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" :
- data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" :
- data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" :
- data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "",
+ data.node == 4 ? $"{data.child4ShortName} {data.posMasterNo}" :
+ data.node == 3 ? $"{data.child3ShortName} {data.posMasterNo}" :
+ data.node == 2 ? $"{data.child2ShortName} {data.posMasterNo}" :
+ data.node == 1 ? $"{data.child1ShortName} {data.posMasterNo}" :
+ data.node == 0 ? $"{data.rootShortName} {data.posMasterNo}" : "",
position = data.position,
positionType = data.posTypeName,
positionLevel = data.posLevelName,
@@ -6935,7 +6906,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -7091,7 +7062,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Put, apiUrl);
var _res = await client.PutAsJsonAsync(apiUrl, new
{
@@ -7244,7 +7215,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -7254,11 +7225,11 @@ namespace BMA.EHR.Application.Repositories.Commands
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = data.posMasterNo == null ? "" :
- data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" :
- data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" :
- data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" :
- data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" :
- data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "",
+ data.node == 4 ? $"{data.child4ShortName} {data.posMasterNo}" :
+ data.node == 3 ? $"{data.child3ShortName} {data.posMasterNo}" :
+ data.node == 2 ? $"{data.child2ShortName} {data.posMasterNo}" :
+ data.node == 1 ? $"{data.child1ShortName} {data.posMasterNo}" :
+ data.node == 0 ? $"{data.rootShortName} {data.posMasterNo}" : "",
position = data.position,
positionType = data.posTypeName,
positionLevel = data.posLevelName,
@@ -7273,7 +7244,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -7414,7 +7385,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7440,7 +7411,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -7573,7 +7544,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7599,7 +7570,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -7733,7 +7704,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7759,7 +7730,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -7893,7 +7864,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7919,7 +7890,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8053,7 +8024,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8079,7 +8050,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8213,7 +8184,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8239,7 +8210,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8373,7 +8344,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8399,7 +8370,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8533,7 +8504,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8559,7 +8530,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8692,7 +8663,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8835,7 +8806,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8978,7 +8949,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -9120,7 +9091,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -9263,7 +9234,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -9641,7 +9612,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrl, new
@@ -9657,7 +9628,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -10162,13 +10133,12 @@ namespace BMA.EHR.Application.Repositories.Commands
var data = await (from r in _dbContext.Set()
.Include(x => x.Command)
join pf in _dbContext.Set()
- .Include(x => x.PositionPath)
on r.RefPlacementProfileId equals pf.Id
where r.Command.Id == id
select new
{
r.RefPlacementProfileId,
- Position = pf.PositionPath!.Name
+ Position = pf.positionName
}).ToListAsync();
if (data.Count > 0)
@@ -10678,27 +10648,6 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
- public async Task> GetPlacementPositionPath(Guid id)
- {
- try
- {
- var data = await _dbContext.Set()
- .Include(x => x.PositionPath)
- .Include(x => x.Placement)
- .Where(x => x.Placement!.Id == id)
- .Where(x => x.PositionPath != null)
- .Select(x => x.PositionPath)
- .Distinct()
- .ToListAsync();
-
- return data!;
- }
- catch
- {
- throw;
- }
- }
-
#endregion
#region " Command Info "
@@ -10964,7 +10913,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
try
{
- var orgIdSend = new List() { Guid.Parse("08dc31bb-0707-4ce0-82fd-7e76903e9fca"), Guid.Parse("08dc30ee-2be8-40d0-81bf-b3f2f52dc0ad") };
+ var orgIdSend = new List() { Guid.Parse("") };
var profiles = await _dbContext.Set()
.Include(x => x.Prefix)
.Include(x => x.Gender)
@@ -11439,7 +11388,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
foreach (var insignia in Insignias)
{
var _res = await client.PostAsJsonAsync(apiUrlInsig, new
diff --git a/BMA.EHR.Application/Repositories/DisciplineRepository.cs b/BMA.EHR.Application/Repositories/DisciplineRepository.cs
index 47a4f22d..1933a2ce 100644
--- a/BMA.EHR.Application/Repositories/DisciplineRepository.cs
+++ b/BMA.EHR.Application/Repositories/DisciplineRepository.cs
@@ -1,9 +1,14 @@
-using BMA.EHR.Application.Common.Interfaces;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Domain.Models.Discipline;
using BMA.EHR.Domain.Models.Retirement;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
+using Newtonsoft.Json;
+using Microsoft.Extensions.Configuration;
+using BMA.EHR.Application.Requests;
namespace BMA.EHR.Application.Repositories
{
@@ -13,33 +18,60 @@ namespace BMA.EHR.Application.Repositories
private readonly IDisciplineDbContext _dbDisContext;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly NotificationRepository _repositoryNoti;
+ private readonly IConfiguration _configuration;
public DisciplineRepository(IApplicationDBContext dbContext,
IDisciplineDbContext dbDisContext,
NotificationRepository repositoryNoti,
+ IConfiguration configuration,
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_dbDisContext = dbDisContext;
_httpContextAccessor = httpContextAccessor;
_repositoryNoti = repositoryNoti;
+ _configuration = configuration;
}
//เรื่องร้องเรียน
public async Task NotifyDisciplineComplaint()
{
var cronjobNotis = await _dbDisContext.Set()
+ .Include(x => x.DisciplineComplaint_Profiles)
.Where(x => x.DateNotification != null)
.Where(x => x.DateNotification.Value.Date == DateTime.Now.Date)
.AsQueryable()
.ToListAsync();
foreach (var cronjobNoti in cronjobNotis)
{
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
+ var refId = new List();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ refId = cronjobNoti.DisciplineComplaint_Profiles.Select(x => x.PersonId),
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ var org = JsonConvert.DeserializeObject(_result);
+ if (_res.IsSuccessStatusCode)
+ {
+ refId = org.result.Select(x => Guid.Parse(x.id)).ToList();
+ }
+ }
+ await _repositoryNoti.PushNotificationsAsync(
+ refId.ToArray(),
$"แจ้งเตือนบันทึกข้อมูลร้องเรียนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}",
- $"แจ้งเตือนบันทึกข้อมูลร้องเรียนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}"
- );
+ $"แจ้งเตือนบันทึกข้อมูลร้องเรียนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}",
+ "",
+ "",
+ true,
+ true
+ );
}
+
await _dbContext.SaveChangesAsync();
}
@@ -47,16 +79,39 @@ namespace BMA.EHR.Application.Repositories
public async Task NotifyDisciplineInvestigate()
{
var cronjobNotis = await _dbDisContext.Set()
+ .Include(x => x.DisciplineInvestigate_ProfileComplaints)
.Where(x => x.InvestigationDateEnd != null && x.InvestigationDateEnd.Value.Date.AddDays(-7) == DateTime.Now.Date)
.AsQueryable()
.ToListAsync();
foreach (var cronjobNoti in cronjobNotis)
{
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
+ var refId = new List();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ refId = cronjobNoti.DisciplineInvestigate_ProfileComplaints.Select(x => x.PersonId),
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ var org = JsonConvert.DeserializeObject(_result);
+ if (_res.IsSuccessStatusCode)
+ {
+ refId = org.result.Select(x => Guid.Parse(x.id)).ToList();
+ }
+ }
+ await _repositoryNoti.PushNotificationsAsync(
+ refId.ToArray(),
$"แจ้งเตือนบันทึกข้อมูลสืบสวนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}",
- $"แจ้งเตือนบันทึกข้อมูลสืบสวนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}"
- );
+ $"แจ้งเตือนบันทึกข้อมูลสืบสวนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}",
+ "",
+ "",
+ true,
+ true
+ );
}
await _dbContext.SaveChangesAsync();
}
@@ -65,16 +120,39 @@ namespace BMA.EHR.Application.Repositories
public async Task NotifyDisciplineDisciplinary()
{
var cronjobNotis = await _dbDisContext.Set()
+ .Include(x => x.DisciplineDisciplinary_ProfileComplaintInvestigates)
.Where(x => x.DisciplinaryDateEnd != null && x.DisciplinaryDateEnd.Value.Date.AddDays(-7) == DateTime.Now.Date)
.AsQueryable()
.ToListAsync();
foreach (var cronjobNoti in cronjobNotis)
{
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
+ var refId = new List();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ refId = cronjobNoti.DisciplineDisciplinary_ProfileComplaintInvestigates.Select(x => x.PersonId),
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ var org = JsonConvert.DeserializeObject(_result);
+ if (_res.IsSuccessStatusCode)
+ {
+ refId = org.result.Select(x => Guid.Parse(x.id)).ToList();
+ }
+ }
+ await _repositoryNoti.PushNotificationsAsync(
+ refId.ToArray(),
$"แจ้งเตือนบันทึกข้อมูลสอบสวนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}",
- $"แจ้งเตือนบันทึกข้อมูลสอบสวนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}"
- );
+ $"แจ้งเตือนบันทึกข้อมูลสอบสวนก่อนวันสิ้นสุดเรื่อง {cronjobNoti.Title}",
+ "",
+ "",
+ true,
+ true
+ );
}
await _dbContext.SaveChangesAsync();
}
diff --git a/BMA.EHR.Application/Repositories/GenericRepository.cs b/BMA.EHR.Application/Repositories/GenericRepository.cs
index 1d562581..d825ccaf 100644
--- a/BMA.EHR.Application/Repositories/GenericRepository.cs
+++ b/BMA.EHR.Application/Repositories/GenericRepository.cs
@@ -1,15 +1,16 @@
-using Amazon.S3.Model.Internal.MarshallTransformations;
+using Amazon.Runtime.Internal.Endpoints.StandardLibrary;
+using Amazon.S3.Model.Internal.MarshallTransformations;
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.HR;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
-using Newtonsoft.Json.Linq;
+using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text;
-using Microsoft.Extensions.Configuration;
namespace BMA.EHR.Application.Repositories
{
@@ -52,15 +53,18 @@ namespace BMA.EHR.Application.Repositories
#region " For Call External API "
- protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey)
+ protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey, CancellationToken cancellationToken = default)
{
try
{
+ // กำหนด timeout เป็น 30 นาที
+ using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
+ using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", apiKey);
- var _res = await client.GetAsync(apiPath);
+ client.DefaultRequestHeaders.Add("api-key", apiKey);
+ var _res = await client.GetAsync(apiPath,cancellationToken: combinedCts.Token);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
@@ -76,19 +80,25 @@ namespace BMA.EHR.Application.Repositories
}
}
- protected async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey)
+ protected async Task SendExternalAPIAsync(HttpMethod method, string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
{
try
{
+ // กำหนด timeout เป็น 30 นาที
+ using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
+ using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
+ // สร้าง request message
+ var request = new HttpRequestMessage(method, apiPath);
+
+
var json = JsonConvert.SerializeObject(body);
- var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ request.Content = new StringContent(json, Encoding.UTF8, "application/json");
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", apiKey);
- var _res = await client.PostAsync(apiPath, stringContent);
+ client.DefaultRequestHeaders.Add("api-key", apiKey);
+ var _res = await client.SendAsync(request, combinedCts.Token);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
@@ -104,10 +114,45 @@ namespace BMA.EHR.Application.Repositories
}
}
- protected async Task PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body, string apiKey)
+
+ public async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
{
try
{
+ // กำหนด timeout เป็น 30 นาที
+ using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
+ using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
+ var json = JsonConvert.SerializeObject(body);
+ var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
+ //stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", apiKey);
+ var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token);
+ if (_res.IsSuccessStatusCode)
+ {
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ return _result;
+ }
+ return string.Empty;
+ }
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ protected async Task PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
+ {
+ try
+ {
+ // กำหนด timeout เป็น 30 นาที
+ using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
+ using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
var json = JsonConvert.SerializeObject(body);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
@@ -115,8 +160,8 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", apiKey);
- var _res = await client.PostAsync(apiPath, stringContent);
+ client.DefaultRequestHeaders.Add("api-key", apiKey);
+ var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token);
return _res.IsSuccessStatusCode;
}
}
diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs
index 7edb2d48..1c0741cb 100644
--- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs
+++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs
@@ -1,16 +1,19 @@
+using Amazon.S3.Model.Internal.MarshallTransformations;
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Requests;
+using BMA.EHR.Application.Responses.Profiles;
+using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.OrganizationEmployee;
-using BMA.EHR.Domain.Shared;
-using BMA.EHR.Domain.Extensions;
-using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore;
-using Newtonsoft.Json;
using BMA.EHR.Domain.Models.Organizations;
-using Amazon.S3.Model.Internal.MarshallTransformations;
-using BMA.EHR.Application.Responses.Profiles;
+using BMA.EHR.Domain.Shared;
+using GreatFriends.ThaiBahtText;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using Nest;
+using Newtonsoft.Json;
using ProfileInsignia = BMA.EHR.Domain.Models.HR.ProfileInsignia;
namespace BMA.EHR.Application.Repositories
@@ -87,8 +90,8 @@ namespace BMA.EHR.Application.Repositories
Id = i.Id,
Name = i.Name,
ShortName = i.ShortName,
- Level = i.InsigniaType.Name,
- LevelId = i.InsigniaType.Id
+ Level = i.InsigniaType?.Name ?? "",
+ LevelId = i.InsigniaType?.Id ?? null
})
.FirstOrDefault();
@@ -148,6 +151,17 @@ namespace BMA.EHR.Application.Repositories
}
}
+ private static bool IsHigherLevel(BMA.EHR.Application.Responses.Profiles.ProfileInsignia? last, string request)
+ {
+ if (last == null)
+ return true;
+ else
+ {
+ var last_ins = last.Insignia?.ToLower().Trim() ?? "";
+ return IsHigherLevel(last_ins, request);
+ }
+ }
+
private static bool IsHigherLevel(string last, string request)
{
if (request.Contains("ตริตาภรณ์ช้างเผือก"))
@@ -243,6 +257,7 @@ namespace BMA.EHR.Application.Repositories
{
try
{
+ Console.WriteLine(ocId);
var period = await _dbContext.Set().FirstOrDefaultAsync(p => p.Id == periodId);
if (period == null)
@@ -264,9 +279,9 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -282,17 +297,36 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
- PositionSalaryAmount = p.PositionSalaryAmount,
- Amount = p.Amount,
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ ProfileInsignia = p.ProfileInsignia,
+ Amount = p.Amount ?? 0,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
- });
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
+ });
// check วันที่บรรจะต้องน้อยกว่า 29/5/ปี-8 ขอ บม.
var s1 = ((from p in inst_profile
@@ -325,7 +359,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
RequestInsignia = GetInsigniaByName("เบญจมาภรณ์มงกุฎไทย"),
Seq = 1,
Gender = p.Gender,
@@ -340,9 +387,15 @@ namespace BMA.EHR.Application.Repositories
{
Condition =
$"2.ได้รับอัตราค่าจ้างตั้งแต่อัตราเงินเดือนขั้นต่ำของข้าราขการพลเรือนระดับปฏิบัติการ (8,340) แต่ไม่ถึงขั้นต่ำของอัตราเงินเดือนข้าราชการพลเรือนระดับชำนาญการ (15,050)",
- Result = $"อัตราค่าจ้าง {p.SalaryCondition.Value.ToString("#,##0")}"
+ Result = $"อัตราค่าจ้าง {p?.SalaryCondition?.ToString("#,##0")??""}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})).ToList();
var bcpRoyal = await _dbContext.Set()
@@ -353,63 +406,85 @@ namespace BMA.EHR.Application.Repositories
var jtmRoyal = await _dbContext.Set()
.FirstOrDefaultAsync(x => x.Name.Contains("จัตุรถาภรณ์มงกุฎไทย"));
- var s2 = (from p in allProfilesByRoot
- where p.ProfileInsignia != null
- && p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
- x.InsigniaId.Value == bcpRoyal.Id)
- .ToList()
- .Count() == 0)
- select new
- {
- ProfileId = p.Id,
- p.CitizenId,
- p.FirstName,
- p.LastName,
- p.BirthDate,
- p.DateAppoint,
- Prefix = p.Prefix ?? "",
- FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
- Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- PosNo = p.PosNo,
- PositionLevelId = p.PosLevelId,
- PositionLevelName = p.PosLevel,
- PositionTypeId = p.PosTypeId,
- PositionTypeName = p.PosType,
- Gender = p.Gender ?? "",
- PositionSalaryAmount = p.PositionSalaryAmount,
- Amount = p.Amount,
- RootId = p.RootId,
- Root = p.Root,
- LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
- ? null
- : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!
- .Insignia,
- LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
- ? Guid.Parse("00000000-0000-0000-0000-000000000000")
- : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
- Salary = p.Amount,
- SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
- p.Amount,
- IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.Value != coinInsignia.Id)
- .OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
- "เบญจมาภรณ์ช้างเผือก"),
- FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault().Year,
- })
- .ToList()
+ var s2_a = (from p in allProfilesByRoot
+ where p.ProfileInsignia != null
+ && p.ProfileInsignia.Count > 0
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
+ x.InsigniaId.Value == bcpRoyal.Id)
+ .ToList()
+ .Count() == 0)
+ select new
+ {
+ ProfileId = p.Id,
+ p.CitizenId,
+ p.FirstName,
+ p.LastName,
+ p.BirthDate,
+ p.DateAppoint,
+ Prefix = p.Prefix ?? "",
+ FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
+ Position = p.Position ?? "",
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ PosNo = p.PosNo,
+ PositionLevelId = p.PosLevelId,
+ PositionLevelName = p.PosLevel,
+ PositionTypeId = p.PosTypeId,
+ PositionTypeName = p.PosType,
+ Gender = p.Gender ?? "",
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ Amount = p.Amount ?? 0,
+ RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
+ Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
+ ? null
+ : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!
+ .Insignia,
+ LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
+ ? Guid.Parse("00000000-0000-0000-0000-000000000000")
+ : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
+ Salary = p.Amount,
+ SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ p.Amount,
+ IsHigherLevel =
+ IsHigherLevel(p.ProfileInsignia.ToList()
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
+ .OrderByDescending(x => x.Year)
+ .FirstOrDefault(),
+ "เบญจมาภรณ์ช้างเผือก"),
+ FirstRecvInsigniaYear = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? 0 :
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault() == null ? 0 :
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault()?.Year,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
+ })
+ .ToList();
+
+ var s2 = s2_a
.Where(x => (x.SalaryCondition >= 8340 && x.SalaryCondition < 10150) && !x.IsHigherLevel)
.Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 5)
.Select(p => new InsigniaResultSet
@@ -435,7 +510,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
RequestInsignia = GetInsigniaByName("เบญจมาภรณ์ช้างเผือก"),
Seq = 2,
Gender = p.Gender,
@@ -445,7 +533,7 @@ namespace BMA.EHR.Application.Repositories
{
Condition =
$"1.ได้รับอัตราค่าจ้างตั้งแต่อัตราเงินเดือนขั้นต่ำของข้าราขการพลเรือนระดับปฏิบัติการ (8,340) แต่ไม่ถึงขั้นต่ำของอัตราเงินเดือนข้าราชการพลเรือนระดับชำนาญการ (15,050)",
- Result = $"อัตราค่าจ้าง {p.SalaryCondition.Value.ToString("#,##0")}"
+ Result = $"อัตราค่าจ้าง {p?.SalaryCondition?.ToString("#,##0")??""}"
},
new MatchingCondition
{
@@ -453,7 +541,13 @@ namespace BMA.EHR.Application.Repositories
$"2.ได้ บ.ม. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้รับ บ.ม. ก่อนวันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ บ.ม. ในปี {p.FirstRecvInsigniaYear}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -461,7 +555,7 @@ namespace BMA.EHR.Application.Repositories
var s3 = (from p in allProfilesByRoot
where p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
x.InsigniaId.Value == jtmRoyal.Id)
.ToList()
.Count() == 0)
@@ -476,9 +570,9 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevel == null
? Guid.Parse("00000000-0000-0000-0000-000000000000")
@@ -496,25 +590,44 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.Value != coinInsignia.Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"จัตุรถาภรณ์มงกุฎไทย"),
FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
.FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault().Year,
- PositionSalaryAmount = p.PositionSalaryAmount,
- Amount = p.Amount,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault()?.Year,
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ Amount = p.Amount ?? 0,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => (x.SalaryCondition >= 8340 && x.SalaryCondition < 10150) && !x.IsHigherLevel)
@@ -548,7 +661,7 @@ namespace BMA.EHR.Application.Repositories
{
Condition =
$"1.ได้รับอัตราค่าจ้างตั้งแต่อัตราเงินเดือนขั้นต่ำของข้าราขการพลเรือนระดับปฏิบัติการ (8,340) แต่ไม่ถึงขั้นต่ำของอัตราเงินเดือนข้าราชการพลเรือนระดับชำนาญการ (15,050)",
- Result = $"อัตราค่าจ้าง {p.SalaryCondition.Value.ToString("#,##0")}"
+ Result = $"อัตราค่าจ้าง {p?.SalaryCondition?.ToString("#,##0")??""}"
},
new MatchingCondition
{
@@ -560,7 +673,26 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -661,9 +793,9 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -679,15 +811,35 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
- PositionSalaryAmount = p.PositionSalaryAmount,
- Amount = p.Amount,
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ ProfileInsignia = p.ProfileInsignia,
+ Amount = p.Amount ?? 0,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
});
var s1 = ((from p in inst_profile
@@ -716,13 +868,26 @@ namespace BMA.EHR.Application.Repositories
LastInsignia = p.LastInsignia,
LastInsigniaId = p.LastInsigniaId,
Salary = p.Salary,
- RequestInsignia = GetInsigniaByName("เบญจมาภรณ์มงกุฎไทย"),
+ RequestInsignia = GetInsigniaByName("เบญจมาภรณ์ช้างเผือก"),
Seq = 1,
Gender = p.Gender,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -734,9 +899,15 @@ namespace BMA.EHR.Application.Repositories
{
Condition =
$"2.ได้รับอัตราค่าจ้างตั้งแต่อัตราเงินเดือนขั้นต่ำของข้าราขการพลเรือนระดับชำนาญการขึ้นไป (15,050)",
- Result = $"อัตราค่าจ้าง {p.SalaryCondition.Value.ToString("#,##0")}"
+ Result = $"อัตราค่าจ้าง {p?.SalaryCondition?.ToString("#,##0")??""}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})).ToList();
var bcpRoyal = await _dbContext.Set()
@@ -752,7 +923,7 @@ namespace BMA.EHR.Application.Repositories
var s2 = (from p in allProfilesByRoot
where p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
x.InsigniaId.Value == jtmRoyal.Id)
.ToList()
.Count() == 0)
@@ -767,9 +938,9 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -785,25 +956,44 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.Value != coinInsignia.Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"จัตุรถาภรณ์มงกุฎไทย"),
FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
.FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault().Year,
- PositionSalaryAmount = p.PositionSalaryAmount,
- Amount = p.Amount,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault()?.Year,
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ Amount = p.Amount ?? 0,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => (x.SalaryCondition >= 10150) && !x.IsHigherLevel)
@@ -834,14 +1024,27 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
{
Condition =
$"1.ได้รับอัตราค่าจ้างตั้งแต่อัตราเงินเดือนขั้นต่ำของข้าราขการพลเรือนระดับชำนาญการขึ้นไป (15,050)",
- Result = $"อัตราค่าจ้าง {p.SalaryCondition.Value.ToString("#,##0")}"
+ Result = $"อัตราค่าจ้าง {p?.SalaryCondition?.ToString("#,##0")??""}"
},
new MatchingCondition
{
@@ -849,14 +1052,20 @@ namespace BMA.EHR.Application.Repositories
$"2.ได้ บ.ช. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้รับ บ.ช. ก่อนวันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ บ.ช. ในปี {p.FirstRecvInsigniaYear}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
var s3 = (from p in allProfilesByRoot
where p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
x.InsigniaId.Value == jtcRoyal.Id)
.ToList()
.Count() == 0)
@@ -871,9 +1080,9 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -889,25 +1098,44 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.Value != coinInsignia.Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"จัตุรถาภรณ์ช้างเผือก"),
FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
.FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault().Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => (x.SalaryCondition >= 10150) && !x.IsHigherLevel)
@@ -935,17 +1163,30 @@ namespace BMA.EHR.Application.Repositories
RequestInsignia = GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก"),
Seq = 2,
Gender = p.Gender,
- PositionSalaryAmount = p.PositionSalaryAmount,
- Amount = p.Amount,
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ Amount = p.Amount ?? 0,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
{
Condition =
$"1.ได้รับอัตราค่าจ้างตั้งแต่อัตราเงินเดือนขั้นต่ำของข้าราขการพลเรือนระดับชำนาญการขึ้นไป (15,050)",
- Result = $"อัตราค่าจ้าง {p.SalaryCondition.Value.ToString("#,##0")}"
+ Result = $"อัตราค่าจ้าง {p?.SalaryCondition?.ToString("#,##0")??""}"
},
new MatchingCondition
{
@@ -953,7 +1194,13 @@ namespace BMA.EHR.Application.Repositories
$"2.ได้ จ.ม. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้รับ จ.ม. ก่อนวันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ จ.ม. ในปี {p.FirstRecvInsigniaYear}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1053,10 +1300,10 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- PosNo = p.PosNo,
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ PosNo = p.PosNo ?? "",
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
@@ -1064,30 +1311,49 @@ namespace BMA.EHR.Application.Repositories
Gender = p.Gender ?? "",
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
ProfileInsignia = p.ProfileInsignia,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
});
// check วันที่บรรจะต้องน้อยกว่า 29/5/ปี-5
@@ -1113,7 +1379,7 @@ namespace BMA.EHR.Application.Repositories
FullName = p.FullName,
Position = p.Position,
PosNo = p.PosNo,
- Rank = p.Rank,
+ Rank = p.Rank ?? "",
GovAge = p.GovAge,
LastInsignia = p.LastInsignia,
LastInsigniaId = p.LastInsigniaId,
@@ -1124,7 +1390,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1132,7 +1411,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.รับราชการก่อน {new DateTime(period.Year - 5, 5, 29).ToThaiFullDate3()}",
Result = $"วันที่บรรจุเข้ารับราชการ {p.ProfileDateAppoint.ToThaiFullDate3()}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})).ToList();
var s2 = (from p in allProfilesByRoot
@@ -1141,8 +1426,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1153,48 +1439,67 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
- PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ PosNo = p.PosNo ?? "",
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"เบญจมาภรณ์ช้างเผือก"),
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.SalaryCondition < 10190 && !x.IsHigherLevel)
@@ -1225,7 +1530,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1240,7 +1558,13 @@ namespace BMA.EHR.Application.Repositories
$"2.ดำรงตำแหน่งมาแล้วไม่น้อยกว่า 10 ปี บริบูรณ์ (รับราชการก่อน {new DateTime(period.Year - 10, 5, 29).ToThaiFullDate3()})",
Result = $"วันที่บรรจุเข้ารับราชการ {p.ProfileDateAppoint.ToThaiFullDate3()}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1250,8 +1574,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1262,54 +1587,73 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
- PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ PosNo = p.PosNo ?? "",
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"จัตุรถาภรณ์มงกุฎไทย"),
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.SalaryCondition >= 10190 && !x.IsHigherLevel)
@@ -1339,7 +1683,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1348,7 +1705,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้รับเงินเดือนไม่ต่ำกว่าขั้นต่ำของระดับชำนาญงาน (เงินเดือน ณ วันที่ {(new DateTime(period.Year, 4, 29)).ToThaiFullDate3()} 10,190 บาทขึ้นไป)",
Result = $"ได้รับเงินเดือน {p.SalaryCondition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1358,8 +1721,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1370,54 +1734,73 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
- PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ PosNo = p.PosNo ?? "",
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"จัตุรถาภรณ์ช้างเผือก"),
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.SalaryCondition >= 10190 && !x.IsHigherLevel)
@@ -1448,7 +1831,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1463,7 +1859,13 @@ namespace BMA.EHR.Application.Repositories
$"2.ดำรงตำแหน่งมาแล้วไม่น้อยกว่า 10 ปี บริบูรณ์ (รับราชการก่อน {new DateTime(period.Year - 10, 5, 29).ToThaiFullDate3()})",
Result = $"วันที่บรรจุเข้ารับราชการ {p.ProfileDateAppoint.ToThaiFullDate3()}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1573,8 +1975,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1588,29 +1991,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -1620,21 +2023,40 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ตริตาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -1663,7 +2085,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1671,7 +2106,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับชำนาญงาน",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1681,8 +2122,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1696,29 +2138,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -1728,14 +2170,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ตริตาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -1743,11 +2185,30 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญงาน").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญงาน").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.FirstPositonLevelDate < new DateTime(period.Year - 5, 5, 29))
@@ -1777,7 +2238,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1787,7 +2261,13 @@ namespace BMA.EHR.Application.Repositories
Result =
$"ดำรงตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel} ตั้งแต่วันที่ {(p.FirstPositonLevelDate == null ? "-" : p.FirstPositonLevelDate.Value.ToThaiFullDate3())}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1861,8 +2341,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1876,29 +2357,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -1908,14 +2389,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -1923,11 +2404,30 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -1956,7 +2456,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -1964,7 +2477,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับอาวุโส",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -1974,8 +2493,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -1989,29 +2509,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2021,14 +2541,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2036,11 +2556,30 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.FirstPositonLevelDate < new DateTime(period.Year - 5, 5, 29))
@@ -2070,7 +2609,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -2080,7 +2632,13 @@ namespace BMA.EHR.Application.Repositories
Result =
$"ดำรงตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel} ตั้งแต่วันที่ {(p.FirstPositonLevelDate == null ? "-" : p.FirstPositonLevelDate.Value.ToThaiFullDate3())}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -2155,8 +2713,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -2170,29 +2729,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2202,14 +2761,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2217,11 +2776,30 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -2250,7 +2828,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -2258,7 +2849,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับทักษะพิเศษ",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -2269,8 +2866,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -2284,29 +2882,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2316,14 +2914,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2331,18 +2929,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 3)
@@ -2372,7 +2989,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -2381,7 +3011,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ท.ช. มาแล้วไม่น้อยกว่า 3 ปี บริบูรณ์ (ได้รับ ท.ช. ก่อนวันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ ท.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -2392,8 +3028,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -2407,29 +3044,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2439,14 +3076,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2454,18 +3091,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 5)
@@ -2495,7 +3151,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -2504,7 +3173,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ป.ม. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้รับ ป.ม. ก่อนวันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ ป.ม. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -2600,8 +3275,9 @@ namespace BMA.EHR.Application.Repositories
where p.PosType == "วิชาการ"
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -2615,29 +3291,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2647,14 +3323,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ตริตาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2662,18 +3338,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -2702,7 +3397,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -2710,7 +3418,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.รับราชการก่อน {new DateTime(period.Year - 5, 5, 29).ToThaiFullDate3()}",
Result = $"วันที่บรรจุเข้ารับราชการ {p.ProfileDateAppoint.ToThaiFullDate3()}"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -2767,8 +3481,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -2782,29 +3497,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2814,14 +3529,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ตริตาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2829,18 +3544,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -2869,7 +3603,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -2877,7 +3624,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับชำนาญการ",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -2887,8 +3640,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -2902,29 +3656,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2934,14 +3688,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2949,18 +3703,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.SalaryCondition >= 22140)
@@ -2990,7 +3763,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -3000,7 +3786,13 @@ namespace BMA.EHR.Application.Repositories
Result =
$"เงินเดือน ณ วันที่ {(new DateTime(period.Year, 4, 29)).ToThaiFullDate3()} เป็นเงิน {p.SalaryCondition} บาท"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3010,8 +3802,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3025,29 +3818,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3057,14 +3850,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3072,18 +3865,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.SalaryCondition >= 22140)
@@ -3113,7 +3925,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -3123,7 +3948,13 @@ namespace BMA.EHR.Application.Repositories
Result =
$"เงินเดือนก่อนวันที่ {(new DateTime(period.Year - 5, 4, 29)).ToThaiFullDate3()} เป็นเงิน {p.SalaryCondition} บาท"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3217,8 +4048,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3232,29 +4064,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3264,14 +4096,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3279,18 +4111,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -3323,7 +4174,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับชำนาญการพิเศษ",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3333,8 +4190,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3348,29 +4206,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3380,14 +4238,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
@@ -3396,18 +4254,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.SalaryCondition >= 58390)
@@ -3438,7 +4315,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -3454,7 +4344,13 @@ namespace BMA.EHR.Application.Repositories
$"2.ได้ ท.ช. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้ ท.ช. วันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ท.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3529,8 +4425,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3544,29 +4441,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3576,14 +4473,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3591,18 +4488,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -3631,7 +4547,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -3639,7 +4568,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับเชี่ยวชาญ",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3650,8 +4585,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3665,29 +4601,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3697,14 +4633,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
@@ -3713,18 +4649,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -3754,7 +4709,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -3763,7 +4731,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ท.ช. มาแล้วไม่น้อยกว่า 3 ปี บริบูรณ์ (ได้ ท.ช. ก่อนวันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ ท.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3773,8 +4747,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3788,29 +4763,29 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3820,14 +4795,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3835,18 +4810,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 5)
@@ -3876,7 +4870,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -3885,7 +4892,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ป.ม. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้ ท.ช. ก่อนวันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()})",
Result = $"ได้รับ ป.ม. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -3978,8 +4991,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -3993,30 +5007,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4026,14 +5040,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4041,18 +5055,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 3)
@@ -4083,7 +5116,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -4097,7 +5143,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 13,000 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -4107,8 +5159,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.ToList()
.Count() == 0)
select new
@@ -4122,30 +5175,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo == null ? "" : p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4155,14 +5208,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4170,18 +5223,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -4212,7 +5284,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -4226,7 +5311,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 13,000 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -4236,8 +5327,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -4251,30 +5343,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
@@ -4285,14 +5377,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาปรมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
@@ -4301,16 +5393,36 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
+
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 5)
@@ -4341,7 +5453,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -4355,7 +5480,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 13,000 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -4446,8 +5577,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -4461,30 +5593,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4494,14 +5626,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4509,18 +5641,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 3)
@@ -4551,7 +5702,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -4565,7 +5729,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 15,600 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -4575,8 +5745,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.ToList()
.Count() == 0)
select new
@@ -4590,30 +5761,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4623,14 +5794,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4638,18 +5809,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -4680,7 +5870,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -4694,7 +5897,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 15,600 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -4704,8 +5913,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -4719,30 +5929,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4752,14 +5962,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาปรมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4767,16 +5977,35 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault().Date,
+ .FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -4807,7 +6036,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -4821,7 +6063,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 15,600 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -4911,8 +6159,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -4923,50 +6172,50 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo == null ? "" : p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4974,16 +6223,35 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Select(p => new InsigniaResultSet
@@ -5012,7 +6280,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5020,7 +6301,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"1.เป็นระดับอำนวยการ/ต้น",
Result = $"ตำแหน่ง {p.Position} ประเภท {p.PositionType} ระดับ {p.PositionLevel}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5030,8 +6317,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5042,50 +6330,50 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5093,18 +6381,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.SalaryCondition >= 58390)
@@ -5135,7 +6442,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5151,7 +6471,13 @@ namespace BMA.EHR.Application.Repositories
$"2.ได้ ท.ช. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้ ท.ช. วันที่ {(new DateTime(period.Year - 5, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ท.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5220,8 +6546,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5232,50 +6559,50 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5283,18 +6610,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -5324,7 +6670,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5333,7 +6692,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ท.ช. มาแล้วไม่น้อยกว่า 3 ปี บริบูรณ์ (ได้ ท.ช. วันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ท.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5343,8 +6708,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5355,50 +6721,50 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
- Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Position = p.Position == null ? "" : p.Position,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5406,18 +6772,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -5447,7 +6832,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5456,7 +6854,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ป.ม. มาแล้วไม่น้อยกว่า 3 ปี บริบูรณ์ (ได้ ป.ม. วันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ป.ม. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5467,8 +6871,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5479,50 +6884,50 @@ namespace BMA.EHR.Application.Repositories
p.LastName,
p.BirthDate,
p.DateAppoint,
- Prefix = p.Prefix == null ? null : p.Prefix,
+ Prefix = p.Prefix == null ? "" : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
- Gender = p.Gender == null ? null : p.Gender,
+ Gender = p.Gender == null ? "" : p.Gender,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5530,18 +6935,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 5)
@@ -5571,7 +6995,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5580,7 +7017,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ป.ช. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้ ป.ช. วันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ป.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5670,8 +7113,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5685,30 +7129,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5718,14 +7162,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5733,18 +7177,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -5774,7 +7237,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5783,7 +7259,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ท.ช. มาแล้วไม่น้อยกว่า 3 ปี บริบูรณ์ (ได้ ท.ช. วันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ท.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5793,8 +7275,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5808,30 +7291,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5841,14 +7324,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5856,18 +7339,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -5897,7 +7399,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -5906,7 +7421,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ป.ม. มาแล้วไม่น้อยกว่า 3 ปี บริบูรณ์ (ได้ ป.ม. วันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ป.ม. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -5916,8 +7437,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.ToList()
.Count() == 0)
select new
@@ -5931,30 +7453,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5964,14 +7486,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5979,18 +7501,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 5)
@@ -6020,7 +7561,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -6029,7 +7583,13 @@ namespace BMA.EHR.Application.Repositories
$"1.ได้ ป.ช. มาแล้วไม่น้อยกว่า 5 ปี บริบูรณ์ (ได้ ป.ช. วันที่ {(new DateTime(period.Year - 3, 7, 28)).ToThaiFullDate3()} หรือก่อนหน้านั้น)",
Result = $"ได้รับ ป.ช. ในปี {p.FirstRecvInsigniaYear.Value.ToThaiYear()}"
},
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -6090,8 +7650,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -6105,30 +7666,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -6138,14 +7699,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6153,18 +7714,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -6195,7 +7775,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -6209,7 +7802,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 14,500 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -6219,8 +7818,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.ToList()
.Count() == 0)
select new
@@ -6234,30 +7834,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -6267,14 +7867,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6282,18 +7882,37 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 3)
@@ -6324,7 +7943,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -6338,7 +7970,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 14,500 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -6348,8 +7986,9 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id)
+ x.InsigniaId.HasValue &&
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id)
.ToList()
.Count() == 0)
select new
@@ -6363,30 +8002,30 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix == null ? null : p.Prefix,
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
- Rank = p.PosLevel,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint.Value,
+ Rank = p.PosLevel ?? "",
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint!.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -6396,14 +8035,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault().Insignia,
+ .FirstOrDefault(),
"มหาปรมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6411,16 +8050,35 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault().Date,
+ .OrderBy(p => p.Date).FirstOrDefault()?.Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
- .OrderBy(x => x.Year).FirstOrDefault().Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ .OrderBy(x => x.Year).FirstOrDefault()?.Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList()
.Where(p => p.FirstRecvInsigniaYear != 0 && p.FirstRecvInsigniaYear <= period.Year - 5)
@@ -6451,7 +8109,20 @@ namespace BMA.EHR.Application.Repositories
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
MatchingConditions = new List
{
new MatchingCondition
@@ -6465,7 +8136,13 @@ namespace BMA.EHR.Application.Repositories
Condition = $"ได้รับเงินประจำตำแหน่ง 14,500 บาท",
Result = $"ได้รับเงินประจำตำแหน่ง {p.SalaryPosition} บาท"
}
- }
+ },
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
})
.ToList();
@@ -6516,6 +8193,219 @@ namespace BMA.EHR.Application.Repositories
#region " Public "
+ ///
+ /// ประมวลผลรายชื่อผู้ได้รับเครื่องราชย์ของแต่ละหน่วยงาน
+ ///
+ /// รหัสรอบการขอ
+ /// รหัสหน่วยงาน
+ /// officer or employee
+ /// ผลการคำนวนการขอพระราชทานเครื่องราชย์
+ public async Task> GetInsigniaCandidateBKKByTypeAsync(Guid periodId, Guid ocId, string type = "officer")
+ {
+ try
+ {
+ var result_candidate = new List();
+
+ var period = await _dbContext.Set().Include(x => x.InsigniaEmployees).FirstOrDefaultAsync(p => p.Id == periodId);
+ if (period == null)
+ {
+ throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
+ }
+
+ if (type.ToLower().Trim() == "officer")
+ {
+ var allOfficerProfilesByRoot = (await _userProfileRepository.GetOfficerProfileByRootIdAsync(ocId, AccessToken));
+ if (allOfficerProfilesByRoot != null)
+ {
+ // calculate ตามแต่ละชั้น
+ var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level1 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level2 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level3 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level4 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level5 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level6 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level7 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level8 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level9_1 =
+ allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level9_2 =
+ allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type3_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type3_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type4_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type4_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+
+
+ // union result
+ foreach (var r in type_coin)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type4_level11)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type4_level10)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type3_level11)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type3_level10)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level9_2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level9_1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level8)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level7)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level6)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level5)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level4)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level3)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ // ย้ายที่ตามที่ มอสแจ้ง
+ if (period.Round != 1)
+ {
+ var insigniaIdList = await _dbContext.Set()
+ .Include(x => x.InsigniaType)
+ .Where(x => x.InsigniaType!.Name == "ชั้นสายสะพาย")
+ .Select(x => x.Id)
+ .ToListAsync();
+
+
+ result_candidate = result_candidate.Where(x => insigniaIdList.Contains(x.RequestInsignia.Id)).ToList();
+ }
+ }
+ }
+ else if (type.ToLower().Trim() == "employee")
+ {
+ var allEmployeeProfileByRoot = new List();
+ if (period != null && period.InsigniaEmployees != null)
+ {
+ allEmployeeProfileByRoot = (await _userProfileRepository.GetEmployeeProfileByPositionAsync(ocId, period.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), AccessToken));
+ }
+
+ if (allEmployeeProfileByRoot != null)
+ {
+ var type_coin = allEmployeeProfileByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allEmployeeProfileByRoot) : new List();
+
+ var employee_type1 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot) : new List();
+ var employee_type2 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot) : new List();
+
+ // union result
+ foreach (var r in type_coin)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in employee_type2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in employee_type1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+ }
+ }
+ else
+ throw new Exception(GlobalMessages.CalculateTypeNotValid);
+
+ return result_candidate.OrderBy(x => x.Seq).ThenBy(x => x.Gender).ThenBy(x => x.ProfileId).ToList();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
///
/// ประมวลผลรายชื่อผู้ได้รับเครื่องราชย์ของแต่ละหน่วยงาน
///
@@ -6529,26 +8419,36 @@ namespace BMA.EHR.Application.Repositories
var result_candidate = new List();
var allOfficerProfilesByRoot =
(await _userProfileRepository.GetOfficerProfileByRootIdAsync(ocId, AccessToken));
- //var allEmployeeProfileByRoot =
- // (await _userProfileRepository.GetEmployeeProfileByRootIdAsync(ocId, AccessToken));
- var type_coin = await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot);
- var type1_level1 = await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot);
- var type1_level2 = await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot);
- var type1_level3 = await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot);
- var type1_level4 = await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot);
- var type2_level5 = await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot);
- var type2_level6 = await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot);
- var type2_level7 = await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot);
- var type2_level8 = await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot);
+ var period = await _dbContext.Set().Include(x => x.InsigniaEmployees).FirstOrDefaultAsync(p => p.Id == periodId);
+ var allEmployeeProfileByRoot = new List();
+ if (period != null && period.InsigniaEmployees != null)
+ {
+ allEmployeeProfileByRoot =
+ (await _userProfileRepository.GetEmployeeProfileByPositionAsync(ocId, period.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), AccessToken));
+ }
+
+ var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level1 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level2 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level3 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level4 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level5 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level6 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level7 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level8 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot) : new List();
var type2_level9_1 =
- await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot);
+ allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot) : new List();
var type2_level9_2 =
- await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot);
- var type3_level10 = await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot);
- var type3_level11 = await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot);
- var type4_level10 = await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot);
- var type4_level11 = await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot);
+ allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type3_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type3_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type4_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type4_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+
+
+ var employee_type1 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot) : new List();
+ var employee_type2 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot) : new List();
// union result
foreach (var r in type_coin)
@@ -6656,20 +8556,32 @@ namespace BMA.EHR.Application.Repositories
result_candidate.Add(r);
}
- // TODO : Remove for Test Error
- //foreach (var r in employee_type2)
- //{
- // var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- // if (old == null)
- // result_candidate.Add(r);
- //}
+ // ย้ายที่ตามที่ มอสแจ้ง
+ if (period.Round != 1)
+ {
+ var insigniaIdList = await _dbContext.Set()
+ .Include(x => x.InsigniaType)
+ .Where(x => x.InsigniaType!.Name == "ชั้นสายสะพาย")
+ .Select(x => x.Id)
+ .ToListAsync();
- //foreach (var r in employee_type1)
- //{
- // var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- // if (old == null)
- // result_candidate.Add(r);
- //}
+
+ result_candidate = result_candidate.Where(x => insigniaIdList.Contains(x.RequestInsignia.Id)).ToList();
+ }
+
+ foreach (var r in employee_type2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in employee_type1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
//foreach (var r in type)
@@ -6679,6 +8591,8 @@ namespace BMA.EHR.Application.Repositories
// result_candidate.Add(r);
//}
+
+
return result_candidate.OrderBy(x => x.Seq).ThenBy(x => x.Gender).ThenBy(x => x.ProfileId).ToList();
}
catch
@@ -6698,7 +8612,7 @@ namespace BMA.EHR.Application.Repositories
if (period == null)
throw new Exception(GlobalMessages.CoinPeriodNotFound);
- var inst_profile = allProfilesByRoot.Where(x => x.DateAppoint != null)
+ var inst_profile = allProfilesByRoot.Where(x => x.DateAppoint.HasValue && x.DateAppoint != null)
.Select(p => new
{
ProfileId = p.Id,
@@ -6710,9 +8624,9 @@ namespace BMA.EHR.Application.Repositories
Prefix = p.Prefix ?? "",
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
- Rank = p.PosLevel,
- ProfileDateAppoint = p.DateAppoint.Value,
- GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -6721,26 +8635,49 @@ namespace BMA.EHR.Application.Repositories
Gender = p.Gender ?? "",
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
- .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
+ .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
p.Amount,
PositionSalaryAmount = p.PositionSalaryAmount,
+ ProfileInsignia = p.ProfileInsignia,
+ Amount = p.Amount,
+ RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
+ Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
});
// check วันที่บรรจะต้องมากกว่า 25 ปี
@@ -6763,7 +8700,7 @@ namespace BMA.EHR.Application.Repositories
FullName = p.FullName,
Position = p.Position,
PosNo = p.PosNo,
- Rank = p.Rank,
+ Rank = p.Rank ?? "",
GovAge = p.GovAge,
LastInsignia = p.LastInsignia,
LastInsigniaId = p.LastInsigniaId,
@@ -6772,6 +8709,31 @@ namespace BMA.EHR.Application.Repositories
Seq = 1,
Gender = p.Gender,
MatchingConditions = new List(),
+
+
+ Amount = p.Amount,
+ RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
+ Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ ProfileType = p.ProfileType,
+
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
+
})).ToList();
var result_candidate = new List();
@@ -6802,6 +8764,9 @@ namespace BMA.EHR.Application.Repositories
}
}
+
+
+
#endregion
#region " From Ming "
@@ -6835,6 +8800,23 @@ namespace BMA.EHR.Application.Repositories
}
}
+ public async Task GetRequestIdByTypeAsync(Guid period, Guid ocId, string type = "officer")
+ {
+ try
+ {
+ var req = await _dbContext.Set()
+ .Where(x => x.OrganizationId != null)
+ .FirstOrDefaultAsync(x => x.Period.Id == period && x.OrganizationId == ocId && x.ProfileType.ToLower() == type.ToLower());
+ if (req == null)
+ return null;
+ return req.Id;
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
// Save Aprove
public async Task SaveAprove(Guid period, Guid ocId)
{
@@ -6861,6 +8843,31 @@ namespace BMA.EHR.Application.Repositories
}
}
+ public async Task SaveApproveByTypeAsync(Guid period, Guid ocId, string type = "officer")
+ {
+ try
+ {
+ var req = await GetRequestIdByTypeAsync(period, ocId, type);
+
+ if (req != null)
+ {
+ var insigniaRequestProfiles = await _dbContext.Set()
+ .Where(x => x.Request.Id == req)
+ .ToListAsync();
+ foreach (var insigniaRequestProfile in insigniaRequestProfiles)
+ {
+ insigniaRequestProfile.IsApprove = true;
+ }
+ }
+
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
// เช็คข้อมูล ใน table insignia_request_new
public async Task GetInsigniaRequest(Guid id, Guid ocId)
{
@@ -6910,12 +8917,60 @@ namespace BMA.EHR.Application.Repositories
}
}
- // Get Data Table insignai_has_profile
- public async Task> InsigniaHasProfile(Guid period, Guid ocId, string status)
+ public async Task GetInsigniaRequestByTypeAsync(Guid id, Guid ocId, string type = "officer")
{
try
{
- var id = await GetRequestId(period, ocId);
+ var period = await _dbContext.Set()
+ .Select(p => new
+ {
+ Id = p.Id,
+ Name = p.Name,
+ Round = p.Round,
+ Year = p.Year,
+ IsLock = p.IsLock,
+ })
+ .FirstOrDefaultAsync(x => x.Id == id);
+
+ if (period == null)
+ return null;
+ else
+ {
+ var request = await _dbContext.Set()
+ .Include(x => x.Document)
+ .FirstOrDefaultAsync(x => x.Period.Id == period.Id && x.OrganizationId == ocId && x.ProfileType.ToLower() == type.ToLower());
+
+ return new InsigniaResults
+ {
+ PeriodId = period.Id,
+ Year = period.Year,
+ Round = period.Round,
+ Name = period.Name,
+ IsLock = period.IsLock,
+ RequestId = request == null ? null : request.Id,
+ RequestNote = request == null ? "" : request.RequestNote,
+ RequestStatus = request == null ? null : request.RequestStatus,
+ OrganizationName = request == null ? "" : request.Organization,
+ Document = request == null
+ ? null
+ : (request.Document == null
+ ? null
+ : await _documentService.ImagesPath(request.Document.Id)),
+ };
+ }
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ // Get Data Table insignai_has_profile
+ public async Task> InsigniaHasProfile(Guid period, Guid ocId, string status, string type = "officer")
+ {
+ try
+ {
+ var id = await GetRequestIdByTypeAsync(period, ocId, type);
if (id != null)
{
var raw_result = _dbContext.Set()
@@ -6952,6 +9007,7 @@ namespace BMA.EHR.Application.Repositories
MarkDiscipline = h.MarkDiscipline,
MarkLeave = h.MarkLeave,
MarkRate = h.MarkRate,
+ MarkInsignia = h.MarkInsignia,
MatchingConditions = h.MatchingConditions == null || h.MatchingConditions == ""
? null
: JsonConvert.DeserializeObject>(h.MatchingConditions)
@@ -7064,14 +9120,109 @@ namespace BMA.EHR.Application.Repositories
// }
// insert candidate list
- public async Task InsertCandidate(Guid periodId, Guid ocId, string oc, List items)
+
+ public async Task UpdateCandidateAsync(Guid periodId, Guid ocId, string oc, List items, string type = "officer")
{
try
{
var period = await _dbContext.Set().FirstOrDefaultAsync(p => p.Id == periodId);
if (period == null)
- throw new Exception(GlobalMessages.CoinPeriodNotFound);
+ throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
+
+ var req = await _dbContext.Set()
+ .Include(x => x.RequestProfiles)
+ .Include(x => x.Period)
+ .Where(x => x.Period.Id == periodId)
+ .Where(x => x.OrganizationId == ocId)
+ .Where(x => x.ProfileType.ToLower() == type.ToLower())
+ .FirstOrDefaultAsync();
+
+ if (req != null)
+ {
+ foreach (var item in items)
+ {
+ var reqInsignia = await _dbContext.Set()
+ .FirstOrDefaultAsync(i => i.Id == item.RequestInsignia.Id);
+
+ if (reqInsignia == null) throw new Exception(GlobalMessages.InsigniaNotFound);
+
+ var pf = req.RequestProfiles.FirstOrDefault(x => x.ProfileId == item.ProfileId);
+ if (pf != null) continue; // มีอยู่แล้วข้ามไป
+
+ req.RequestProfiles.Add(new InsigniaRequestProfile
+ {
+ Status = "PENDING",
+ ProfileId = item.ProfileId,
+ RequestInsignia = reqInsignia,
+ Salary = item.Salary,
+ RequestDate = DateTime.Now,
+ MatchingConditions =
+ System.Text.Json.JsonSerializer.Serialize(item.MatchingConditions),
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ CreatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+
+ // Add Information for reused in API Call
+ ProfileType = item.ProfileType != null && item.ProfileType != "" ? item.ProfileType.ToLower() : "officer",
+ Prefix = item.Prefix,
+ FirstName = item.FirstName,
+ LastName = item.LastName,
+ CitizenId = item.CitizenId,
+ BirthDate = item.BirthDate,
+ DateAppoint = item.DateAppoint,
+ Position = item.Position,
+ Gender = item.Gender,
+ PosTypeName = item.PosTypeName,
+ PosLevelName = item.PosLevelName,
+ PosNo = item.PosNo,
+ Amount = item.Salary,
+ PositionSalaryAmount = item.PositionSalary,
+ LastInsigniaName = item.LastInsignia,
+ Root = item.Root,
+ RootId = item.RootId,
+ RootDnaId = item.RootDnaId,
+ Child1 = item.Child1,
+ Child1Id = item.Child1Id,
+ Child1DnaId = item.Child1DnaId,
+ Child2 = item.Child2,
+ Child2Id = item.Child2Id,
+ Child2DnaId = item.Child2DnaId,
+ Child3 = item.Child3,
+ Child3Id = item.Child3Id,
+ Child3DnaId = item.Child3DnaId,
+ Child4 = item.Child4,
+ Child4Id = item.Child4Id,
+ Child4DnaId = item.Child4DnaId,
+
+ MarkDiscipline = item.MarkDiscipline,
+ MarkInsignia = item.MarkInsignia,
+ MarkLeave = item.MarkLeave,
+ MarkRate = item.MarkRate
+ });
+ }
+
+ await _dbContext.SaveChangesAsync();
+ }
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+
+ public async Task InsertCandidate(Guid periodId, Guid ocId, string oc, List items, string type = "officer")
+ {
+ try
+ {
+ var period = await _dbContext.Set().FirstOrDefaultAsync(p => p.Id == periodId);
+
+ if (period == null)
+ throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
var periodOlds = await _dbContext.Set().Where(p => p.Year == period.Year).ToListAsync();
foreach (var periodOld in periodOlds)
@@ -7099,6 +9250,7 @@ namespace BMA.EHR.Application.Repositories
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
+ ProfileType = type
};
foreach (var item in items)
@@ -7125,7 +9277,7 @@ namespace BMA.EHR.Application.Repositories
LastUpdatedAt = DateTime.Now,
// Add Information for reused in API Call
- ProfileType = item.ProfileType ?? "officer",
+ ProfileType = item.ProfileType != null && item.ProfileType != "" ? item.ProfileType.ToLower() : "officer",
Prefix = item.Prefix,
FirstName = item.FirstName,
LastName = item.LastName,
@@ -7142,6 +9294,24 @@ namespace BMA.EHR.Application.Repositories
LastInsigniaName = item.LastInsignia,
Root = item.Root,
RootId = item.RootId,
+ RootDnaId = item.RootDnaId,
+ Child1 = item.Child1,
+ Child1Id = item.Child1Id,
+ Child1DnaId = item.Child1DnaId,
+ Child2 = item.Child2,
+ Child2Id = item.Child2Id,
+ Child2DnaId = item.Child2DnaId,
+ Child3 = item.Child3,
+ Child3Id = item.Child3Id,
+ Child3DnaId = item.Child3DnaId,
+ Child4 = item.Child4,
+ Child4Id = item.Child4Id,
+ Child4DnaId = item.Child4DnaId,
+
+ MarkDiscipline = item.MarkDiscipline,
+ MarkInsignia = item.MarkInsignia,
+ MarkLeave = item.MarkLeave,
+ MarkRate = item.MarkRate
});
}
@@ -7154,6 +9324,53 @@ namespace BMA.EHR.Application.Repositories
}
}
+ public async Task UpdateInsigniaRequestProfile(string[] items, string type)
+ {
+ try
+ {
+ var allProfiles = await _userProfileRepository.GetInsigniaRequestsProfileAsync(items, type, AccessToken);
+
+ if (allProfiles != null && allProfiles.Count > 0)
+ {
+ var insigniaRequestProfiles = await _dbContext.Set()
+ .Where(x => allProfiles.Select(x => x.Id).ToList().Contains(x.ProfileId))
+ .ToListAsync();
+
+ foreach (var insigniaRequestProfile in insigniaRequestProfiles)
+ {
+ var profile = allProfiles.FirstOrDefault(p => p.Id == insigniaRequestProfile.ProfileId);
+
+ if (profile != null)
+ {
+ insigniaRequestProfile.MarkDiscipline = profile?.MarkDiscipline;
+ insigniaRequestProfile.MarkLeave = profile?.MarkLeave;
+ insigniaRequestProfile.MarkRate = profile?.MarkRate;
+ insigniaRequestProfile.MarkInsignia = profile?.MarkInsignia;
+ insigniaRequestProfile.APR1 = profile?.APR1;
+ insigniaRequestProfile.APR2 = profile?.APR2;
+ insigniaRequestProfile.APR3 = profile?.APR3;
+ insigniaRequestProfile.APR4 = profile?.APR4;
+ insigniaRequestProfile.APR5 = profile?.APR5;
+ insigniaRequestProfile.OCT1 = profile?.OCT1;
+ insigniaRequestProfile.OCT2 = profile?.OCT2;
+ insigniaRequestProfile.OCT3 = profile?.OCT3;
+ insigniaRequestProfile.OCT4 = profile?.OCT4;
+ insigniaRequestProfile.OCT5 = profile?.OCT5;
+ insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
+ insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
+ }
+ }
+ }
+
+ await _dbContext.SaveChangesAsync();
+
+ }
+ catch
+ {
+ throw;
+ }
+ }
#endregion
}
}
\ No newline at end of file
diff --git a/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs b/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs
index 5fbbb8a1..2e550d71 100644
--- a/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs
@@ -2,8 +2,11 @@
using BMA.EHR.Domain.Models.Base;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
+using Newtonsoft.Json;
using System.IO.Pipes;
+using System.Net.Http.Headers;
using System.Security.Claims;
+using System.Text;
namespace BMA.EHR.Application.Repositories.Leaves
{
@@ -43,6 +46,38 @@ namespace BMA.EHR.Application.Repositories.Leaves
#region " Methods "
+ public async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
+ {
+ try
+ {
+ // กำหนด timeout เป็น 30 นาที
+ using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
+ using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
+ var json = JsonConvert.SerializeObject(body);
+ var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
+ //stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", apiKey);
+ var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token);
+ if (_res.IsSuccessStatusCode)
+ {
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ return _result;
+ }
+ return string.Empty;
+ }
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+
public virtual async Task> GetAllAsync()
{
return await _dbSet.ToListAsync();
@@ -68,6 +103,24 @@ namespace BMA.EHR.Application.Repositories.Leaves
return entity;
}
+ public virtual async Task> AddRangeAsync(List entities)
+ {
+ foreach (var entity in entities)
+ {
+ if (entity is EntityBase)
+ {
+ (entity as EntityBase).CreatedUserId = UserId ?? "";
+ (entity as EntityBase).CreatedFullName = FullName ?? "System Administrator";
+ (entity as EntityBase).CreatedAt = DateTime.Now;
+ }
+ }
+
+ await _dbSet.AddRangeAsync(entities);
+ await _dbContext.SaveChangesAsync();
+
+ return entities;
+ }
+
public virtual async Task UpdateAsync(T entity)
{
if (entity is EntityBase)
diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs
new file mode 100644
index 00000000..add1361b
--- /dev/null
+++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs
@@ -0,0 +1,587 @@
+using Amazon.S3.Model;
+using BMA.EHR.Application.Common.Interfaces;
+using BMA.EHR.Application.Messaging;
+using BMA.EHR.Application.Responses.Profiles;
+using BMA.EHR.Domain.Extensions;
+using BMA.EHR.Domain.Models.Leave.Commons;
+using BMA.EHR.Domain.Models.Leave.Requests;
+using BMA.EHR.Domain.Shared;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using System.Collections.Concurrent;
+
+namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
+{
+ public class LeaveBeginningRepository : GenericLeaveRepository
+ {
+ #region " Fields "
+
+ private readonly ILeaveDbContext _dbContext;
+ private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly OrganizationCommonRepository _organizationCommonRepository;
+ private readonly UserProfileRepository _userProfileRepository;
+ private readonly IConfiguration _configuration;
+ private readonly EmailSenderService _emailSenderService;
+
+ ///
+ /// Keyed locks to serialize get-or-create for LeaveBeginning rows by (ProfileId, LeaveYear, LeaveTypeId).
+ /// Prevents duplicate inserts when concurrent requests (e.g. UI calling /user/check twice) hit the same key.
+ ///
+ private static readonly ConcurrentDictionary _getOrAddLocks = new();
+
+ #endregion
+
+ #region " Constructor and Destuctor "
+
+ public LeaveBeginningRepository(ILeaveDbContext dbContext,
+ IHttpContextAccessor httpContextAccessor,
+ OrganizationCommonRepository organizationCommonRepository,
+ UserProfileRepository userProfileRepository,
+ IConfiguration configuration,
+ EmailSenderService emailSenderService) : base(dbContext, httpContextAccessor)
+ {
+ _dbContext = dbContext;
+ _httpContextAccessor = httpContextAccessor;
+ _organizationCommonRepository = organizationCommonRepository;
+ _userProfileRepository = userProfileRepository;
+ _configuration = configuration;
+ _emailSenderService = emailSenderService;
+ }
+
+ #endregion
+
+ #region " Properties "
+
+ protected Guid UserOrganizationId
+ {
+ get
+ {
+ if (UserId != null || UserId != "")
+ return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
+ else
+ return Guid.Empty;
+ }
+ }
+
+ #endregion
+
+ public async Task> GetAllByYearAsync(int year)
+ {
+ return await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .Where(x => x.LeaveYear == year)
+ .ToListAsync();
+ }
+
+ public async Task GetByYearAndTypeIdAsync(int year, Guid typeId)
+ {
+ var data = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId);
+
+
+ return data;
+ }
+
+ public async Task UpdateLeaveUsageAsync(int year, Guid typeId, Guid userId, double day)
+ {
+ // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ if (pf == null)
+ {
+ throw new Exception(GlobalMessages.DataNotFound);
+ }
+
+ var data = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ if (data == null)
+ {
+ throw new Exception(GlobalMessages.DataNotFound);
+ }
+ data.LeaveDaysUsed += day;
+
+ await _dbContext.SaveChangesAsync();
+ }
+
+ public async Task UpdateLeaveCountAsync(int year, Guid typeId, Guid userId, int count)
+ {
+ // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ if (pf == null)
+ {
+ throw new Exception(GlobalMessages.DataNotFound);
+ }
+
+ var data = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ if (data == null)
+ {
+ throw new Exception(GlobalMessages.DataNotFound);
+ }
+ data.LeaveCount += count;
+
+ await _dbContext.SaveChangesAsync();
+ }
+
+ public async Task ProcessEarlyLeaveRequest(int year)
+ {
+ // Get Early Leave Request (กรองตามปีงบประมาณ: 1 ต.ค. (year-1) – 30 ก.ย. (year))
+ var fiscalStart = new DateTime(year - 1, 10, 1);
+ var fiscalEnd = new DateTime(year, 9, 30);
+
+ var leaveReq = await _dbContext.Set()
+ .Include(x => x.Type)
+ .Where(x => x.LeaveStatus == "APPROVE")
+ .Where(x => x.LeaveStartDate.Date <= fiscalEnd && x.LeaveEndDate.Date >= fiscalStart)
+ .ToListAsync();
+
+ foreach (var leave in leaveReq)
+ {
+ await GetByYearAndTypeIdForUserWithUpdateAsync(year, leave.Type.Id, leave.KeycloakUserId);
+ }
+ }
+
+ public async Task ProcessEarlyLeaveRequestSchedule()
+ {
+ int year = DateTime.Now.Year;
+ await ProcessEarlyLeaveRequest(year);
+ }
+
+ public async Task GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
+ {
+ // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ if (pf == null)
+ {
+ throw new Exception(GlobalMessages.DataNotFound);
+ }
+
+ var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
+
+ var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
+
+ LeaveBeginning Factory()
+ {
+ var limit = 0.0;
+
+ var prev = _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ // คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
+ var isCurrentYear = DateTime.Now.Year == year;
+
+
+ var prevRemain = 0.0;
+ if (prev != null)
+ {
+ prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
+ }
+
+ if (govAge >= 180)
+ {
+ if (govAge >= 3650)
+ {
+ limit = 10 + prevRemain;
+ if (limit > 30) limit = 30;
+ }
+ else
+ {
+ limit = 10 + prevRemain;
+ if (limit > 20) limit = 20;
+ }
+ }
+ else
+ {
+ limit = 0.0;
+ }
+
+ return new LeaveBeginning
+ {
+ LeaveYear = year,
+ LeaveTypeId = typeId,
+ ProfileId = pf.Id,
+ Prefix = pf.Prefix,
+ FirstName = pf.FirstName,
+ LastName = pf.LastName,
+ LeaveDaysUsed = 0,
+ LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
+ RootDnaId = pf.RootDnaId,
+ Child1DnaId = pf.Child1DnaId,
+ Child2DnaId = pf.Child2DnaId,
+ Child3DnaId = pf.Child3DnaId,
+ Child4DnaId = pf.Child4DnaId
+ };
+ }
+
+ return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
+ }
+
+ public async Task GetByYearAndTypeIdForUserWithUpdateAsync(int year, Guid typeId, Guid userId)
+ {
+ // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ if (pf == null)
+ {
+ throw new Exception(GlobalMessages.DataNotFound);
+ }
+
+ var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
+
+ var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
+
+
+ var limit = 0.0;
+
+ var prev = _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ var prevRemain = 0.0;
+
+
+
+ if (prev != null)
+ {
+ prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
+ }
+
+ if (govAge >= 180)
+ {
+ if (govAge >= 3650)
+ {
+ limit = 10 + prevRemain;
+ if (limit > 30) limit = 30;
+ }
+ else
+ {
+ limit = 10 + prevRemain;
+ if (limit > 20) limit = 20;
+ }
+ }
+ else
+ {
+ limit = 0.0;
+ }
+
+ var data = await _dbContext.Set()
+ .Where(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id)
+ .FirstOrDefaultAsync();
+
+ if (data != null)
+ {
+ data.LeaveDays = leaveType?.Code == "LV-005" ? limit : 0;
+ await _dbContext.SaveChangesAsync();
+ }
+
+ // return new LeaveBeginning
+ // {
+ // LeaveYear = year,
+ // LeaveTypeId = typeId,
+ // ProfileId = pf.Id,
+ // Prefix = pf.Prefix,
+ // FirstName = pf.FirstName,
+ // LastName = pf.LastName,
+ // LeaveDaysUsed = 0,
+ // LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
+ // RootDnaId = pf.RootDnaId,
+ // Child1DnaId = pf.Child1DnaId,
+ // Child2DnaId = pf.Child2DnaId,
+ // Child3DnaId = pf.Child3DnaId,
+ // Child4DnaId = pf.Child4DnaId
+ // };
+ return data;
+
+ }
+
+
+ public async Task GetByYearAndTypeIdForUser(int year, Guid typeId, GetProfileByKeycloakIdDto? pf)
+ {
+ var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
+
+ var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
+
+ LeaveBeginning Factory()
+ {
+ var limit = 0.0;
+
+ var prev = _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ // คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
+ var isCurrentYear = DateTime.Now.Year == year;
+
+ var prevRemain = 0.0;
+ if (prev != null)
+ {
+ prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
+ }
+
+ if (govAge >= 180)
+ {
+ if (govAge >= 3650)
+ {
+ limit = 10 + prevRemain;
+ if (limit > 30) limit = 30;
+ }
+ else
+ {
+ limit = 10 + prevRemain;
+ if (limit > 20) limit = 20;
+ }
+ }
+ else
+ {
+ limit = 0.0;
+ }
+
+ return new LeaveBeginning
+ {
+ LeaveYear = year,
+ LeaveTypeId = typeId,
+ ProfileId = pf.Id,
+ Prefix = pf.Prefix,
+ FirstName = pf.FirstName,
+ LastName = pf.LastName,
+ LeaveDaysUsed = 0,
+ LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
+ RootDnaId = pf.RootDnaId,
+ Child1DnaId = pf.Child1DnaId,
+ Child2DnaId = pf.Child2DnaId,
+ Child3DnaId = pf.Child3DnaId,
+ Child4DnaId = pf.Child4DnaId
+ };
+ }
+
+ return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
+ }
+
+ public async Task GetByYearAndTypeIdForUser2Async(int year, Guid typeId, Guid userId)
+ {
+ // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ if (pf == null)
+ {
+ return null;
+ }
+
+ var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
+
+ var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
+
+ LeaveBeginning Factory()
+ {
+ var limit = 0.0;
+
+ var prev = _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ // คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
+ var isCurrentYear = DateTime.Now.Year == year;
+
+ var prevRemain = 0.0;
+ if (prev != null)
+ {
+ prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
+ }
+
+ if (govAge >= 180)
+ {
+ if (govAge >= 3650)
+ {
+ limit = 10 + prevRemain;
+ if (limit > 30) limit = 30;
+ }
+ else
+ {
+ limit = 10 + prevRemain;
+ if (limit > 20) limit = 20;
+ }
+ }
+ else
+ {
+ limit = 0.0;
+ }
+
+ return new LeaveBeginning
+ {
+ LeaveYear = year,
+ LeaveTypeId = typeId,
+ ProfileId = pf.Id,
+ Prefix = pf.Prefix,
+ FirstName = pf.FirstName,
+ LastName = pf.LastName,
+ LeaveDaysUsed = 0,
+ LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
+ RootDnaId = pf.RootDnaId,
+ Child1DnaId = pf.Child1DnaId,
+ Child2DnaId = pf.Child2DnaId,
+ Child3DnaId = pf.Child3DnaId,
+ Child4DnaId = pf.Child4DnaId
+ };
+ }
+
+ return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
+ }
+
+ ///
+ /// Get-or-create a LeaveBeginning row for (ProfileId, LeaveYear, LeaveTypeId) with concurrency protection.
+ /// Uses a keyed SemaphoreSlim to serialize within-process requests, and re-queries after acquiring the lock.
+ /// If a cross-process insert wins (unique index violation), the duplicate key exception is caught and the row
+ /// created by the winner is returned.
+ ///
+ private async Task GetOrAddForUserAsync(int year, Guid typeId, Guid profileId, Func factory)
+ {
+ var key = $"{profileId}_{year}_{typeId}";
+ var semaphore = _getOrAddLocks.GetOrAdd(key, _ => new SemaphoreSlim(1, 1));
+ await semaphore.WaitAsync();
+ try
+ {
+ // Re-query inside the lock — another thread may have created it while we waited.
+ var existing = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == profileId);
+ if (existing != null)
+ {
+ return existing;
+ }
+
+ var entity = factory();
+ _dbContext.Set().Add(entity);
+ try
+ {
+ await _dbContext.SaveChangesAsync();
+ return entity;
+ }
+ catch (DbUpdateException)
+ {
+ // Cross-process/cross-server race hit the unique index (IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId).
+ // Detach the failed insert and return the row created by the winner.
+ _dbContext.Detach(entity);
+ var winner = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == profileId);
+ return winner;
+ }
+ }
+ finally
+ {
+ semaphore.Release();
+ }
+ }
+
+ public async Task> GetAllByYearAndTypeAsync(int year, Guid typeId, List userIdList)
+ {
+
+ var updateList = new List();
+ var result = new List();
+
+ var beginningList = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .Where(x => x.LeaveYear == year && x.LeaveTypeId == typeId)
+ .ToListAsync();
+
+ foreach (var pf in userIdList)
+ {
+ //var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(id, AccessToken);
+ //if (pf == null)
+ //{
+ // continue; // Goto Next Id
+ //}
+
+ var profile = await _userProfileRepository.GetProfileByProfileIdAsync(pf.Id, AccessToken);
+ if (profile == null)
+ {
+ return null;
+ }
+
+ var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
+
+ var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
+
+ var data = beginningList.FirstOrDefault(x => x.ProfileId == pf.Id);
+
+ if (data == null)
+ {
+ var limit = 0.0;
+
+ var prev = await _dbContext.Set()
+ .Include(x => x.LeaveType)
+ .FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
+
+ var prevRemain = 0.0;
+ if (prev != null)
+ {
+ prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
+ }
+
+ if (govAge >= 180)
+ {
+ if (govAge >= 3650)
+ {
+ limit = 10 + prevRemain;
+ if (limit > 30) limit = 30;
+ }
+ else
+ {
+ limit = 10 + prevRemain;
+ if (limit > 20) limit = 20;
+ }
+ }
+ else
+ {
+ limit = 0.0;
+ }
+
+ data = new LeaveBeginning
+ {
+ LeaveYear = year,
+ LeaveTypeId = typeId,
+ ProfileId = pf.Id,
+ Prefix = pf.Prefix,
+ FirstName = pf.FirstName,
+ LastName = pf.LastName,
+ LeaveDaysUsed = 0,
+ LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
+ RootDnaId = profile.RootDnaId,
+ Child1DnaId = profile.Child1DnaId,
+ Child2DnaId = profile.Child2DnaId,
+ Child3DnaId = profile.Child3DnaId,
+ Child4DnaId = profile.Child4DnaId
+ };
+
+ updateList.Add(data);
+ }
+ result.Add(data);
+ }
+ if (!updateList.Any())
+ {
+ await _dbContext.Set().AddRangeAsync(updateList);
+ await _dbContext.SaveChangesAsync();
+ }
+ return result;
+ }
+ }
+
+ public class ProfileData
+ {
+ public Guid Id { get; set; } = Guid.Empty;
+
+ public string Prefix { get; set; } = string.Empty;
+
+ public string FirstName { get; set; } = string.Empty;
+
+ public string LastName { get; set; } = string.Empty;
+
+ public DateTime? DateStart { get; set; } = null;
+
+ public DateTime? DateAppoint { get; set; } = null;
+ }
+}
diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs
index 909764e2..54a80a41 100644
--- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs
@@ -1,10 +1,6 @@
-using System.Drawing;
-using System.Net.Http.Headers;
-using System.Net.Http.Json;
-using BMA.EHR.Application.Common.Interfaces;
+using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Messaging;
using BMA.EHR.Application.Responses.Leaves;
-using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Leave.Commons;
using BMA.EHR.Domain.Models.Leave.Requests;
using BMA.EHR.Domain.Models.Notifications;
@@ -12,6 +8,11 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
+using System.IO.Compression;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
+using BMA.EHR.Domain.Models.Leave.TimeAttendants;
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
{
@@ -27,6 +28,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
private readonly EmailSenderService _emailSenderService;
private readonly IApplicationDBContext _appDbContext;
+ private readonly MinIOLeaveService _minIOService;
+
+ private readonly LeaveBeginningRepository _leaveBeginningRepository;
+ private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository;
+
+ private readonly UserDutyTimeRepository _userDutyTimeRepository;
+ private readonly DutyTimeRepository _dutyTimeRepository;
+
+ private readonly string URL = string.Empty;
#endregion
@@ -38,7 +48,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
UserProfileRepository userProfileRepository,
IConfiguration configuration,
EmailSenderService emailSenderService,
- IApplicationDBContext appDbContext) : base(dbContext, httpContextAccessor)
+ IApplicationDBContext appDbContext,
+ MinIOLeaveService minIOService,
+ LeaveBeginningRepository leaveBeginningRepository,
+ ProcessUserTimeStampRepository processUserTimeStampRepository,
+ UserDutyTimeRepository userDutyTimeRepository,
+ DutyTimeRepository dutyTimeRepository) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
@@ -47,6 +62,16 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
_configuration = configuration;
_emailSenderService = emailSenderService;
_appDbContext = appDbContext;
+
+ _userDutyTimeRepository = userDutyTimeRepository;
+ _dutyTimeRepository = dutyTimeRepository;
+
+
+ URL = (_configuration["VITE_URL_MGT"]).Replace("/api/v1", "");
+ Console.WriteLine($"URL : {URL}");
+ _minIOService = minIOService;
+ _leaveBeginningRepository = leaveBeginningRepository;
+ _processUserTimeStampRepository = processUserTimeStampRepository;
}
#endregion
@@ -74,6 +99,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
{
var data = await _dbContext.Set().AsQueryable()
//.AsNoTracking()
+ .Include(x => x.Approvers)
.Include(x => x.LeaveDocument)
.ThenInclude(x => x.Document)
.Include(x => x.LeaveDraftDocument)
@@ -86,8 +112,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public override async Task GetByIdAsync(Guid id)
{
- var data = await _dbContext.Set().AsQueryable()
+ try
+ {
+ var data = await _dbContext.Set().AsQueryable()
.AsNoTracking()
+ .Include(x => x.Approvers)
.Include(x => x.LeaveDocument)
.ThenInclude(x => x.Document)
.Include(x => x.LeaveDraftDocument)
@@ -95,7 +124,13 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
.FirstOrDefaultAsync(x => x.Id == id);
- return data;
+ return data;
+ }
+ catch
+ {
+ throw;
+ }
+
}
public override async Task AddAsync(LeaveRequest entity)
@@ -183,10 +218,70 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
#endregion
- public async Task> GetLeaveRequestByYearAsync(int year)
+ public async Task AddLeaveDocumentAsync(Guid id, LeaveDocument doc)
{
+ try
+ {
+ var req = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == id);
+ req!.LeaveDocument.Add(doc);
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ public async Task AddApproversAsync(Guid id, List approvers)
+ {
+ try
+ {
+ var req = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == id);
+ req!.Approvers.AddRange(approvers);
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ public async Task RemoveApproversAsync(Guid id, string type)
+ {
+ try
+ {
+ var data = await _dbContext.Set()
+ .Where(x => x.LeaveRequest.Id == id && x.ApproveType.ToUpper() == type.ToUpper())
+ .ToListAsync();
+
+ _dbContext.Set().RemoveRange(data);
+
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+
+ public async Task> GetLeaveRequestByYearAsync(int year, Guid userId)
+ {
+ // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+
+ if (profile == null)
+ {
+ throw new Exception("ไม่พบข้อมูลผู้ใช้งานในระบบทะเบียนประวัติ!!");
+ }
+
var data = await _dbContext.Set().AsQueryable().AsNoTracking()
.Include(x => x.Type)
+ .Where(x => x.RootId == profile.RootId &&
+ x.Child1Id == profile.Child1Id &&
+ x.Child2Id == profile.Child2Id &&
+ x.Child3Id == profile.Child3Id &&
+ x.Child4Id == profile.Child4Id)
.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.ToListAsync();
@@ -194,6 +289,57 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
+ public async Task> GetLeaveRequestByYearForAdminAsync(int year, string role, string? nodeId, int? node)
+ {
+ var rawData = _dbContext.Set().AsQueryable().AsNoTracking()
+ .Include(x => x.Type)
+ .Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE");
+ //.ToListAsync();
+ if (year != 0)
+ {
+ var startFiscalDate = new DateTime(year - 1, 10, 1);
+ var endFiscalDate = new DateTime(year, 9, 30);
+ rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
+ }
+
+ if (role == "OWNER")
+ {
+ node = null;
+ }
+ if (role == "OWNER" || role == "CHILD")
+ {
+ rawData = rawData
+ .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
+ }
+ else if (role == "BROTHER")
+ {
+ rawData = rawData
+ .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
+ }
+ else if (role == "ROOT")
+ {
+ rawData = rawData
+ .Where(x => x.RootDnaId == Guid.Parse(nodeId!));
+ }
+ // else if (role == "PARENT")
+ // {
+ // rawData = rawData
+ // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
+ // }
+ else if (role == "NORMAL")
+ {
+ rawData = rawData
+ .Where(x =>
+ node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
+ node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
+ node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
+ node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
+ node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
+ }
+
+ return await rawData.ToListAsync();
+ }
+
public async Task> GetLeaveRequestByUserIdAsync(Guid keycloakUserId, int year, Guid type, string status)
{
var rawData = _dbContext.Set().AsQueryable().AsNoTracking()
@@ -201,7 +347,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId);
if (year != 0)
- rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
+ {
+ var startFiscalDate = new DateTime(year - 1, 10, 1);
+ var endFiscalDate = new DateTime(year, 9, 30);
+ rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
+ }
+ //rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
if (type != Guid.Empty)
rawData = rawData.Where(x => x.Type.Id == type);
@@ -217,7 +368,100 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var rawData = _dbContext.Set().AsNoTracking()
.Include(x => x.Type)
.Where(x => x.LeaveStatus != "DRAFT")
- .OrderByDescending(x => x.CreatedAt.Date)
+ .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt))
+ .AsQueryable();
+
+ if (year != 0)
+ rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
+
+ if (type != Guid.Empty)
+ rawData = rawData.Where(x => x.Type.Id == type);
+
+ if (status.Trim().ToUpper() != "ALL")
+ rawData = rawData.Where(x => x.LeaveStatus == status);
+
+ if (startDate != DateTime.MinValue)
+ rawData = rawData.Where(x => x.LeaveStartDate >= startDate);
+
+ if (endDate != DateTime.MinValue)
+ rawData = rawData.Where(x => x.LeaveEndDate <= endDate);
+
+ return await rawData.ToListAsync();
+ }
+
+ public async Task> GetListLeaveRequestForAdminAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, string role, string? nodeId, int? node)
+ {
+ var rawData = _dbContext.Set().AsNoTracking()
+ .Include(x => x.Type)
+ .Where(x => x.LeaveStatus != "DRAFT")
+ .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt))
+ .AsQueryable();
+ // fix issue : 1830
+ if (year != 0)
+ {
+ var startFiscalDate = new DateTime(year - 1, 10, 1);
+ var endFiscalDate = new DateTime(year, 9, 30);
+ rawData = rawData.Where(x => x.LeaveStartDate >= startFiscalDate && x.LeaveStartDate <= endFiscalDate);
+ }
+
+ if (type != Guid.Empty)
+ rawData = rawData.Where(x => x.Type.Id == type);
+
+ if (status.Trim().ToUpper() != "ALL")
+ rawData = rawData.Where(x => x.LeaveStatus == status);
+
+ if (startDate != DateTime.MinValue)
+ rawData = rawData.Where(x => x.LeaveStartDate >= startDate);
+
+ if (endDate != DateTime.MinValue)
+ rawData = rawData.Where(x => x.LeaveEndDate <= endDate);
+
+ if (role == "OWNER")
+ {
+ node = null;
+ }
+ if (role == "OWNER" || role == "CHILD")
+ {
+ rawData = rawData
+ .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
+ }
+ else if (role == "BROTHER")
+ {
+ rawData = rawData
+ .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
+ }
+ else if (role == "ROOT")
+ {
+ rawData = rawData
+ .Where(x => x.RootDnaId == Guid.Parse(nodeId!));
+ }
+ // else if (role == "PARENT")
+ // {
+ // rawData = rawData
+ // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
+ // }
+ else if (role == "NORMAL")
+ {
+ rawData = rawData
+ .Where(x =>
+ node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
+ node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
+ node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
+ node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
+ node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
+ }
+
+
+ return await rawData.ToListAsync();
+ }
+
+ public async Task> GetLeaveRequestForAdminWithAuthAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, List keycloakIdList)
+ {
+ var rawData = _dbContext.Set().AsNoTracking()
+ .Include(x => x.Type)
+ .Where(x => keycloakIdList.Contains(x.KeycloakUserId))
+ .Where(x => x.LeaveStatus != "DRAFT")
+ .OrderByDescending(x =>(x.DateSendLeave ?? x.CreatedAt))
.AsQueryable();
if (year != 0)
@@ -240,6 +484,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public async Task GetRestDayTotalByYearForUserAsync(Guid keycloakUserId, int year)
{
+ var startFiscalDate = new DateTime(year - 1, 10, 1);
+ var endFiscalDate = new DateTime(year, 9, 30);
+
+
var leaveType = await _dbContext.Set().AsQueryable().AsNoTracking()
.FirstOrDefaultAsync(l => l.Code.Trim().ToUpper() == "LV-005");
@@ -252,8 +500,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveType.Id)
- .Where(x => x.LeaveStartDate.Year == year)
- .Where(x => x.LeaveStatus == "APPROVE")
+ //.Where(x => x.LeaveStartDate.Year == year)
+ .Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.Sum(x => x.LeaveTotal);
return data;
@@ -261,16 +510,33 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public async Task GetSumLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
{
+ // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(keycloakUserId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(keycloakUserId, AccessToken);
+ if (pf == null)
+ throw new Exception(GlobalMessages.DataNotFound);
+
+ var beginningLeave = await _dbContext.Set().AsNoTracking()
+ .Where(x => x.ProfileId == pf.Id)
+ .Where(x => x.LeaveYear == year)
+ .Where(x => x.LeaveTypeId == leaveTypeId)
+ .FirstOrDefaultAsync();
+
+
+
+ var startFiscalDate = new DateTime(year - 1, 10, 1);
+ var endFiscalDate = new DateTime(year, 9, 30);
+
var data = await _dbContext.Set().AsQueryable().AsNoTracking()
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
- .Where(x => x.LeaveStartDate.Year == year)
- .Where(x => x.LeaveStatus == "APPROVE")
+ //.Where(x => x.LeaveStartDate.Year == year)
+ .Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.ToListAsync();
- return data.Sum(x => x.LeaveTotal);
+ return data.Sum(x => x.LeaveTotal) + (beginningLeave == null ? 0 : (beginningLeave.LeaveDaysUsed ?? 0.0));
}
//public async Task GetSumApproveLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
@@ -292,7 +558,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
- .Where(x => x.LeaveStatus == "APPROVE")
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.OrderByDescending(x => x.LeaveStartDate.Date)
.Select(x => x.LeaveStartDate.Date)
@@ -301,13 +567,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
- public async Task GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId)
+ public async Task GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
{
var data = await _dbContext.Set().AsQueryable().AsNoTracking()
.Include(x => x.Type)
+ .Where(x => x.LeaveStartDate.Date < beforeDate.Date)
+ //.Where(x => x.CreatedAt < beforeDate)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
- .Where(x => x.LeaveStatus == "APPROVE")
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.OrderByDescending(x => x.LeaveStartDate.Date)
.FirstOrDefaultAsync();
@@ -315,15 +583,37 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
- public async Task> GetCancelLeaveRequestForAdminAsync(int year, Guid type, string status)
+ public async Task GetLastLeaveRequestByTypeForUserAsync2(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
+ {
+ var data = await _dbContext.Set().AsQueryable().AsNoTracking()
+ .Include(x => x.Type)
+ //.Where(x => x.LeaveStartDate.Date < beforeDate.Date)
+ .Where(x => (x.DateSendLeave ?? x.CreatedAt) < beforeDate)
+ .Where(x => x.KeycloakUserId == keycloakUserId)
+ .Where(x => x.Type.Id == leaveTypeId)
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
+ //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
+ .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt))
+ .FirstOrDefaultAsync();
+
+ return data;
+ }
+
+ public async Task> GetCancelLeaveRequestForAdminAsync(int year, Guid type, string status, string role, string? nodeId, int? node)
{
var rawData = _dbContext.Set().AsNoTracking()
.Include(x => x.Type)
- .Where(x => x.LeaveStatus == "DELETE")
+ .Where(x => x.LeaveStatus == "DELETE" || x.LeaveStatus == "DELETING")
.AsQueryable();
+ // if (year != 0)
+ // rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
if (year != 0)
- rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
+ {
+ var startFiscalDate = new DateTime(year - 1, 10, 1);
+ var endFiscalDate = new DateTime(year, 9, 30);
+ rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
+ }
if (type != Guid.Empty)
rawData = rawData.Where(x => x.Type.Id == type);
@@ -331,22 +621,96 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
if (status.Trim().ToUpper() != "ALL")
rawData = rawData.Where(x => x.LeaveCancelStatus == status);
+
+ if (role == "OWNER")
+ {
+ node = null;
+ }
+ if (role == "OWNER" || role == "CHILD")
+ {
+ rawData = rawData
+ .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
+ }
+ else if (role == "BROTHER")
+ {
+ rawData = rawData
+ .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
+ }
+ else if (role == "ROOT")
+ {
+ rawData = rawData
+ .Where(x => x.RootDnaId == Guid.Parse(nodeId!));
+ }
+ // else if (role == "PARENT")
+ // {
+ // rawData = rawData
+ // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
+ // }
+ else if (role == "NORMAL")
+ {
+ rawData = rawData
+ .Where(x =>
+ node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
+ node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
+ node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
+ node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
+ node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
+ }
+
return await rawData.ToListAsync();
}
- public async Task ApproveCancelLeaveRequestAsync(LeaveRequest data, string Reason)
+ public async Task ApproveCancelLeaveRequestAsync(LeaveRequest data, string Reason, string LeaveReason)
{
try
{
- var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken ?? "");
+ // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken ?? "");
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
+ // ปรับสถานะ จาก DELETING มาเป็น DELETE
+ data.LeaveStatus = "DELETE";
+
data.LeaveCancelStatus = "APPROVE";
- data.LeaveCancelComment = Reason;
+ data.LeaveDirectorComment = Reason;
+ data.LeaveCancelComment = LeaveReason;
+
+ // TODO : Update ไปตาราง beginning
+ if (data.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
+ {
+
+ var toDay = data.LeaveStartDate.Date;
+ var thisYear = data.LeaveStartDate.Year;
+ if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
+ {
+ thisYear = thisYear + 1;
+ }
+ await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1 * data.LeaveTotal);
+ // update leave count ลดลง 1 ครั้ง
+ await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1);
+
+
+ var _baseAPI = _configuration["API"];
+ var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{data.Id}";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+
+ var request = new HttpRequestMessage(HttpMethod.Patch, apiUrlSalary);
+
+ // ส่ง request
+ var _res = await client.SendAsync(request);
+ if (!_res.IsSuccessStatusCode)
+ throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
+ //var _result = await _res.Content.ReadAsStringAsync();
+ }
+ }
+
// Send Noti
var noti = new Notification
@@ -377,20 +741,55 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception(GlobalMessages.DataNotFound);
}
- var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
+ // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken ?? "");
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
- rawData.LeaveCancelStatus = "APPROVE";
- rawData.LeaveCancelComment = Reason;
+ rawData.LeaveStatus = "DELETE";
- await UpdateAsync(rawData);
+ rawData.LeaveCancelStatus = "APPROVE";
+ rawData.LeaveDirectorComment = Reason;
+
+ await UpdateWithTrackingAsync(rawData);
+
+ // TODO : Update ไปตาราง beginning
+ if (rawData.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
+ {
+
+ var toDay = rawData.LeaveStartDate.Date;
+ var thisYear = rawData.LeaveStartDate.Year;
+ if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
+ {
+ thisYear = thisYear + 1;
+ }
+
+ await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1 * rawData.LeaveTotal);
+ // update leave count ลดลง 1 ครั้ง
+ await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1);
+
+ var _baseAPI = _configuration["API"];
+ var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{rawData.Id}";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+
+ var request = new HttpRequestMessage(HttpMethod.Patch, apiUrlSalary);
+
+ // ส่ง request
+ var _res = await client.SendAsync(request);
+ if (!_res.IsSuccessStatusCode)
+ throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
+ //var _result = await _res.Content.ReadAsStringAsync();
+ }
+ }
// TODO: remove วันลา
- // Send Noti
+ // Send Noti หาเจ้าของใบลา
var noti = new Notification
{
Body = $"การขอยกเลิกใบลาของคุณได้รับการอนุมัติ",
@@ -399,7 +798,28 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
Payload = "",
};
_appDbContext.Set().Add(noti);
+
+ var commanders = rawData.Approvers
+ .Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
+ .OrderBy(x => x.Seq)
+ .ToList();
+
+ foreach (var commander in commanders)
+ {
+ var noti1 = new Notification
+ {
+ Body = $"การขอยกเลิกใบลาของ {rawData.FirstName} {rawData.LastName} ได้รับการอนุมัติแล้ว",
+ ReceiverUserId = commander.ProfileId,
+ Type = "",
+ Payload = "",
+ };
+ _appDbContext.Set().Add(noti1);
+ }
+
+
await _appDbContext.SaveChangesAsync();
+
+
}
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
@@ -410,36 +830,45 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception(GlobalMessages.DataNotFound);
}
- var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
+ // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken ?? "");
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
rawData.LeaveCancelStatus = "REJECT";
- rawData.LeaveCancelComment = Reason;
+ rawData.LeaveDirectorComment = Reason;
+
+ // fix issue : ระบบลา (User) >> กรณีขอยกเลิกการลา แต่ผู้บังคับบัญชาไม่อนุมัติ (สถานะการลาไม่อัปเดต) #846
+ if (rawData.ApproveStep == "st4")
+ {
+ rawData.LeaveStatus = "APPROVE";
+ }
+ else
+ {
+ rawData.LeaveStatus = "NEW";
+ }
await UpdateAsync(rawData);
+ // fix issue : SIT ระบบบันทึกการลา>>รายการลา (กรณีขอยกเลิกการลา) #935
// TODO: remove วันลา
- var leaveType = await _appDbContext.Set()
- .FirstOrDefaultAsync(x => x.Name == rawData.Type.Name);
-
+ //var leaveType = await _appDbContext.Set()
+ // .FirstOrDefaultAsync(x => x.Name == rawData.Type.Name);
// insert to profile leave
- var profileLeave = await _appDbContext.Set()
- .Where(x => x.TypeLeave.Id == leaveType.Id)
- .Where(x => x.ProfileId == profile.Id)
- .Where(x => x.DateStartLeave == rawData.LeaveStartDate && x.DateEndLeave == rawData.LeaveEndDate)
- .FirstOrDefaultAsync();
- if (profileLeave != null)
- {
- _appDbContext.Set().Remove(profileLeave);
- await _appDbContext.SaveChangesAsync();
- }
-
- // insert into process timestamp
+ //var profileLeave = await _appDbContext.Set()
+ // .Where(x => x.TypeLeave.Id == leaveType.Id)
+ // .Where(x => x.ProfileId == profile.Id)
+ // .Where(x => x.DateStartLeave == rawData.LeaveStartDate && x.DateEndLeave == rawData.LeaveEndDate)
+ // .FirstOrDefaultAsync();
+ //if (profileLeave != null)
+ //{
+ // _appDbContext.Set().Remove(profileLeave);
+ // await _appDbContext.SaveChangesAsync();
+ //}
// Send Noti
@@ -451,6 +880,25 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
Payload = "",
};
_appDbContext.Set().Add(noti);
+
+ var commanders = rawData.Approvers
+ .Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
+ .OrderBy(x => x.Seq)
+ .ToList();
+
+ foreach (var commander in commanders)
+ {
+ var noti1 = new Notification
+ {
+ Body = $"การขอยกเลิกใบลาของ {rawData.FirstName} {rawData.LastName} ไม่ได้รับการอนุมัติ \r\nเนืองจาก {Reason}",
+ ReceiverUserId = commander.ProfileId,
+ Type = "",
+ Payload = "",
+ };
+ _appDbContext.Set().Add(noti1);
+ }
+
+
await _appDbContext.SaveChangesAsync();
}
@@ -470,6 +918,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData.LeaveStatus = "NEW";
+ rawData.DateSendLeave = DateTime.Now; // Update วันที่ยื่นลาเป็นวันที่ปัจจุบัน
//rawData.ApproveStep = "st2";
await UpdateAsync(rawData);
@@ -487,11 +936,56 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData.ApproveStep = "st2";
await UpdateAsync(rawData);
+
+ // TODO: Send notification to 1st Commander
+ var firstCommander = rawData.Approvers
+ .Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
+ .OrderBy(x => x.Seq)
+ .FirstOrDefault();
+
+ // fix: If no commander, skip notification
+ if (firstCommander != null)
+ {
+ // Send Notification
+ var noti1 = new Notification
+ {
+ Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
+ ReceiverUserId = firstCommander!.ProfileId,
+ Type = "",
+ Payload = $"{URL}/leave/detail/{id}",
+ };
+ _appDbContext.Set().Add(noti1);
+ }
+ else
+ {
+ // มีแต่ approver อย่างเดียว
+ var firstApprover = rawData.Approvers
+ .Where(x => x.ApproveType!.ToUpper() == "APPROVER")
+ .OrderBy(x => x.Seq)
+ .FirstOrDefault();
+ if(firstApprover != null)
+ {
+ // Send Notification
+ var noti2 = new Notification
+ {
+ Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
+ ReceiverUserId = firstApprover!.ProfileId,
+ Type = "",
+ Payload = $"{URL}/leave/detail/{id}",
+ };
+ _appDbContext.Set().Add(noti2);
+ }
+ }
+ await _appDbContext.SaveChangesAsync();
}
public async Task CommanderApproveLeaveRequest(Guid id, string reason)
{
- var rawData = await GetByIdAsync(id);
+ // Get UserId from token
+ var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
+
+
+ var rawData = await GetByIdWithTrackingAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -499,160 +993,587 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
if (rawData.ApproveStep != "st2")
{
- throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากเจ้าหน้าที่ ไม่สามารถทำรายการได้");
+ throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
}
- rawData.LeaveStatus = "PENDING";
- rawData.LeaveComment = reason;
- rawData.ApproveStep = "st3";
+ // check commander approve
+ //var approvers = await _dbContext.Set()
+ // //.AsNoTracking()
+ // .Include(x => x.LeaveRequest)
+ // .Where(x => x.LeaveRequest.Id == id && x.ApproveType == "COMMANDER")
+ // .OrderBy(x => x.Seq)
+ // .ToListAsync();
+
+ var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
+
+ var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
+ if (approver == null)
+ {
+ throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาในขั้นตอนนี้");
+ }
+
+ // check prev approver มี action แล้วหรือไม่?
+ var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
+
+ if (prevApprover != null)
+ {
+ if (prevApprover.ApproveStatus == "PENDING")
+ {
+ throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
+ }
+ }
+
+ var maxSeq = approvers.Max(x => x.Seq);
+
+ //var data = await _dbContext.Set()
+ // .AsNoTracking()
+ // .Include(x => x.LeaveRequest)
+ // .Where(x => x.LeaveRequest.Id == id && x.KeycloakId == userId && x.ApproveType == "COMMANDER")
+ // .FirstOrDefaultAsync();
+
+ //if(data != null)
+ //{
+ // data.ApproveStatus = "APPROVE";
+ // data.Comment = reason;
+
+ // data.LastUpdatedAt = DateTime.Now;
+ // data.LastUpdateUserId = userId.ToString("D");
+ // data.LastUpdateFullName = FullName ?? "";
+
+ // await _appDbContext.SaveChangesAsync();
+ //}
+
+ approver.ApproveStatus = "APPROVE";
+ approver.Comment = reason;
+ approver.LastUpdateFullName = FullName ?? "";
+ approver.LastUpdateUserId = userId.ToString("D");
+ approver.LastUpdatedAt = DateTime.Now;
+ //await _dbContext.SaveChangesAsync();
+
+ if (approver.Seq != maxSeq)
+ {
+ rawData.LeaveStatus = "PENDING";
+ await UpdateWithTrackingAsync(rawData);
+
+ var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
+
+ // Send Noti
+ var noti = new Notification
+ {
+ Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
+ ReceiverUserId = nextApprover!.ProfileId,
+ Type = "",
+ Payload = $"{URL}/leave/detail/{id}",
+ };
+ _appDbContext.Set().Add(noti);
+ await _appDbContext.SaveChangesAsync();
+ }
+ else
+ {
+ rawData.LeaveStatus = "PENDING";
+ rawData.LeaveComment = reason;
+ rawData.ApproveStep = "st3";
+
+ await UpdateWithTrackingAsync(rawData);
+
+ // TODO: Send notification to 1st Approver
+ var firstCommander = rawData.Approvers
+ .Where(x => x.ApproveType!.ToUpper() == "APPROVER")
+ .OrderBy(x => x.Seq)
+ .FirstOrDefault();
+
+ // Send Notification
+ var noti1 = new Notification
+ {
+ Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
+ ReceiverUserId = firstCommander!.ProfileId,
+ Type = "",
+ Payload = $"{URL}/leave/detail/{id}",
+ };
+ _appDbContext.Set