Compare commits
20 Commits
140ece8080
...
invoice-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4782bd3a89 | ||
|
|
81f6d83fd0 | ||
|
|
f31176cfc9 | ||
|
|
437d6d8f42 | ||
| 2b7ed3e451 | |||
| a631cd6b3e | |||
| cef0f73dbb | |||
|
|
9e15afc1c2 | ||
|
|
36dc42239a | ||
|
|
decc72c554 | ||
|
|
e086a919c3 | ||
|
|
da43860c61 | ||
|
|
5441e280e0 | ||
|
|
8fd8a79d75 | ||
|
|
04174fff3b | ||
|
|
27433d1bd5 | ||
|
|
bc3a76b82b | ||
|
|
41c18590d8 | ||
|
|
1be0866c69 | ||
|
|
730eb6c3b7 |
@@ -1,63 +0,0 @@
|
|||||||
# Build artifacts
|
|
||||||
**/bin/
|
|
||||||
**/obj/
|
|
||||||
**/out/
|
|
||||||
**/publish/
|
|
||||||
|
|
||||||
# IDE and editor files
|
|
||||||
**/.vs/
|
|
||||||
**/.vscode/
|
|
||||||
**/.idea/
|
|
||||||
**/.DS_Store
|
|
||||||
**/*.user
|
|
||||||
**/*.suo
|
|
||||||
**/*.userosscache
|
|
||||||
**/*.sln.docstates
|
|
||||||
**/*.userprefs
|
|
||||||
**/.fleet/
|
|
||||||
|
|
||||||
# Database files
|
|
||||||
**/*.dbmdl
|
|
||||||
**/*.jfm
|
|
||||||
**/*.mdf
|
|
||||||
**/*.ldf
|
|
||||||
|
|
||||||
# Temp and swap files
|
|
||||||
**/*.swp
|
|
||||||
**/*.swo
|
|
||||||
**/*~
|
|
||||||
**/*.tmp
|
|
||||||
**/*.temp
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
**/*.log
|
|
||||||
|
|
||||||
# Node modules (if any frontend dependencies)
|
|
||||||
**/node_modules/
|
|
||||||
|
|
||||||
# Git files
|
|
||||||
.git/
|
|
||||||
.gitignore
|
|
||||||
.gitattributes
|
|
||||||
.git-crypt/
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
README.md
|
|
||||||
**/*.md
|
|
||||||
LICENSE
|
|
||||||
|
|
||||||
# Docker files
|
|
||||||
docker-compose.yml
|
|
||||||
docker-compose.*.yml
|
|
||||||
**/Dockerfile
|
|
||||||
**/.dockerignore
|
|
||||||
|
|
||||||
# Development databases
|
|
||||||
docker/
|
|
||||||
|
|
||||||
# Test results
|
|
||||||
**/TestResults/
|
|
||||||
**/*.trx
|
|
||||||
|
|
||||||
# macOS
|
|
||||||
.DS_Store
|
|
||||||
4
.git-crypt/.gitattributes
vendored
4
.git-crypt/.gitattributes
vendored
@@ -1,4 +0,0 @@
|
|||||||
# Do not edit this file. To specify the files to encrypt, create your own
|
|
||||||
# .gitattributes file in the directory where your files are.
|
|
||||||
* !filter !diff
|
|
||||||
*.gpg binary
|
|
||||||
Binary file not shown.
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1,3 +0,0 @@
|
|||||||
BimAI.API/appsettings.Development.json filter=git-crypt diff=git-crypt
|
|
||||||
BimAI.UI.Web/appsettings.Development.json filter=git-crypt diff=git-crypt
|
|
||||||
BimAI.UI.Mobile/appsettings.Development.json filter=git-crypt diff=git-crypt
|
|
||||||
72
.gitea/scripts/replaceTokens.js
Normal file
72
.gitea/scripts/replaceTokens.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// .gitea/scripts/replaceTokens.js
|
||||||
|
// Skanuje:
|
||||||
|
// - artifacts/api/appsettings.Production.json (jeśli jest)
|
||||||
|
// - artifacts/ui/appsettings.Production.json (jeśli jest)
|
||||||
|
// Tokeny: #{NAME}# -> wartość z VARIABLES/SECRETS (NAME: uppercased, '-'->'_')
|
||||||
|
// Dodatkowo: #{BUILDID}# -> RUN_ID (z ENV)
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
function replaceInFile(file, mapToken) {
|
||||||
|
let data = fs.readFileSync(file, 'utf8');
|
||||||
|
const re = /#\{(.*?)\}#/g;
|
||||||
|
let changed = false;
|
||||||
|
data = data.replace(re, (_, raw) => {
|
||||||
|
const token = (raw || '').replace(/-/g, '_').toUpperCase();
|
||||||
|
const val = mapToken(token);
|
||||||
|
if (val == null || val === '') return `#{${raw}}#`; // zostaw bez zmian, podbijemy błąd później
|
||||||
|
changed = true;
|
||||||
|
return String(val);
|
||||||
|
});
|
||||||
|
fs.writeFileSync(file, data, 'utf8');
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const secrets = JSON.parse(process.env.SECRETS || '{}');
|
||||||
|
const variables = JSON.parse(process.env.VARIABLES || '{}');
|
||||||
|
const RUN_ID = process.env.RUN_ID || process.env.GITHUB_RUN_ID || '';
|
||||||
|
|
||||||
|
const mapToken = (token) => {
|
||||||
|
if (token === 'BUILDID') return RUN_ID;
|
||||||
|
return (variables[token] != null ? variables[token] : secrets[token]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const beRoot = path.resolve('artifacts');
|
||||||
|
const beFiles = [];
|
||||||
|
['api/appsettings.Production.json', 'ui/appsettings.Production.json'].forEach((name) => {
|
||||||
|
const p = path.join(beRoot, name);
|
||||||
|
if (fs.existsSync(p)) beFiles.push(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
const files = beFiles;
|
||||||
|
|
||||||
|
if (files.length === 0) {
|
||||||
|
console.error('❌ No candidate files found to tokenize (artifacts/api or artifacts/ui appsettings.Production.json).');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`🔎 Tokenizing ${files.length} file(s)`);
|
||||||
|
const missing = new Set();
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
replaceInFile(file, mapToken);
|
||||||
|
}
|
||||||
|
for (const file of files) {
|
||||||
|
const content = fs.readFileSync(file, 'utf8');
|
||||||
|
const reLeft = /#\{(.*?)\}#/g;
|
||||||
|
let m;
|
||||||
|
while ((m = reLeft.exec(content))) {
|
||||||
|
const token = (m[1] || '').replace(/-/g, '_').toUpperCase();
|
||||||
|
missing.add(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missing.size > 0) {
|
||||||
|
console.error(`❌ Missing values for tokens: ${Array.from(missing).join(', ')}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ Tokenization complete.');
|
||||||
|
})();
|
||||||
@@ -24,30 +24,42 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login code.bim-it.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login code.bim-it.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
- name: Build and push API image (build artifacts)
|
- name: Build and push API image
|
||||||
run: |
|
run: |
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
|
--label "org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI" \
|
||||||
-f BimAI.API/Dockerfile \
|
-f BimAI.API/Dockerfile \
|
||||||
-t code.bim-it.pl/bimai/bimai-api:build-${{ github.run_id }} \
|
-t code.bim-it.pl/mz/bimai-api:latest \
|
||||||
|
-t code.bim-it.pl/mz/bimai-api:build-${{ github.run_id }} \
|
||||||
--push \
|
--push \
|
||||||
.
|
.
|
||||||
|
|
||||||
- name: Build and push UI image (build artifacts)
|
- name: Build and push UI image
|
||||||
run: |
|
run: |
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
|
--label "org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI" \
|
||||||
-f BimAI.UI.Web/Dockerfile \
|
-f BimAI.UI.Web/Dockerfile \
|
||||||
-t code.bim-it.pl/bimai/bimai-ui:build-${{ github.run_id }} \
|
-t code.bim-it.pl/mz/bimai-ui:latest \
|
||||||
|
-t code.bim-it.pl/mz/bimai-ui:build-${{ github.run_id }} \
|
||||||
--push \
|
--push \
|
||||||
.
|
.
|
||||||
|
|
||||||
- name: Output build info
|
- name: Output build info
|
||||||
run: |
|
run: |
|
||||||
echo "## 🏗️ Docker Images Built" >> $GITHUB_STEP_SUMMARY
|
echo "## ️ Docker Images Built" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Build ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
echo "**Build ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Images pushed with tag: \`build-${{ github.run_id }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "### Images pushed:" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "# Latest (for release)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-api:latest" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-ui:latest" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Use **Release** workflow to tokenize and tag as \`:prod\`" >> $GITHUB_STEP_SUMMARY
|
echo "# Specific build (for rollback)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-api:build-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-ui:build-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
116
.gitea/workflows/release.yml
Normal file
116
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
name: Release Docker Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: https://github.com/actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login code.bim-it.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Pull latest build artifacts (images)
|
||||||
|
run: |
|
||||||
|
echo "Pulling latest build images..."
|
||||||
|
docker pull code.bim-it.pl/mz/bimai-api:latest
|
||||||
|
docker pull code.bim-it.pl/mz/bimai-ui:latest
|
||||||
|
|
||||||
|
- name: Extract appsettings from images
|
||||||
|
run: |
|
||||||
|
mkdir -p artifacts/api artifacts/ui
|
||||||
|
|
||||||
|
# Extract from API image
|
||||||
|
docker create --name temp-api code.bim-it.pl/mz/bimai-api:latest
|
||||||
|
docker cp temp-api:/app/appsettings.Production.json artifacts/api/
|
||||||
|
docker rm temp-api
|
||||||
|
|
||||||
|
# Extract from UI image
|
||||||
|
docker create --name temp-ui code.bim-it.pl/mz/bimai-ui:latest
|
||||||
|
docker cp temp-ui:/app/appsettings.Production.json artifacts/ui/
|
||||||
|
docker rm temp-ui
|
||||||
|
|
||||||
|
- name: Show extracted configs (before tokenization)
|
||||||
|
run: |
|
||||||
|
echo "::group::API appsettings.Production.json (with placeholders)"
|
||||||
|
cat artifacts/api/appsettings.Production.json
|
||||||
|
echo "::endgroup::"
|
||||||
|
echo "::group::UI appsettings.Production.json (with placeholders)"
|
||||||
|
cat artifacts/ui/appsettings.Production.json
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Tokenize appsettings
|
||||||
|
env:
|
||||||
|
SECRETS: ${{ toJson(secrets) }}
|
||||||
|
VARIABLES: ${{ toJson(vars) }}
|
||||||
|
RUN_ID: ${{ github.run_id }}
|
||||||
|
run: |
|
||||||
|
node .gitea/scripts/replaceTokens.js
|
||||||
|
|
||||||
|
- name: Show tokenized configs (after tokenization)
|
||||||
|
run: |
|
||||||
|
echo "::group::API appsettings.Production.json (tokenized, passwords hidden)"
|
||||||
|
cat artifacts/api/appsettings.Production.json | sed 's/Password=[^;]*/Password=***/g' | sed 's/"SecretKey":"[^"]*"/"SecretKey":"***"/g'
|
||||||
|
echo "::endgroup::"
|
||||||
|
echo "::group::UI appsettings.Production.json (tokenized)"
|
||||||
|
cat artifacts/ui/appsettings.Production.json
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Rebuild images with tokenized configs
|
||||||
|
run: |
|
||||||
|
# API
|
||||||
|
cat > Dockerfile.release.api <<'EOF'
|
||||||
|
FROM code.bim-it.pl/mz/bimai-api:latest
|
||||||
|
LABEL org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI
|
||||||
|
COPY artifacts/api/appsettings.Production.json /app/
|
||||||
|
EOF
|
||||||
|
docker build -f Dockerfile.release.api \
|
||||||
|
-t code.bim-it.pl/mz/bimai-api:prod \
|
||||||
|
-t code.bim-it.pl/mz/bimai-api:release-${{ github.run_id }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
# UI
|
||||||
|
cat > Dockerfile.release.ui <<'EOF'
|
||||||
|
FROM code.bim-it.pl/mz/bimai-ui:latest
|
||||||
|
LABEL org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI
|
||||||
|
COPY artifacts/ui/appsettings.Production.json /app/
|
||||||
|
EOF
|
||||||
|
docker build -f Dockerfile.release.ui \
|
||||||
|
-t code.bim-it.pl/mz/bimai-ui:prod \
|
||||||
|
-t code.bim-it.pl/mz/bimai-ui:release-${{ github.run_id }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Push final images
|
||||||
|
run: |
|
||||||
|
docker push code.bim-it.pl/mz/bimai-api:prod
|
||||||
|
docker push code.bim-it.pl/mz/bimai-api:release-${{ github.run_id }}
|
||||||
|
docker push code.bim-it.pl/mz/bimai-ui:prod
|
||||||
|
docker push code.bim-it.pl/mz/bimai-ui:release-${{ github.run_id }}
|
||||||
|
|
||||||
|
- name: Output release info
|
||||||
|
run: |
|
||||||
|
echo "## Docker Images Released" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Release ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### 🚀 Production images ready to deploy:" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "# Production (latest release)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-api:prod" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-ui:prod" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "# Specific release (for rollback)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-api:release-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull code.bim-it.pl/mz/bimai-ui:release-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -24,10 +24,6 @@ Generated/
|
|||||||
*.db-shm
|
*.db-shm
|
||||||
*.db-wal
|
*.db-wal
|
||||||
|
|
||||||
# Visual Studio Code
|
|
||||||
.vscode/
|
|
||||||
.vscode/*
|
|
||||||
|
|
||||||
# MAUI / Mobile (Xcode/iOS)
|
# MAUI / Mobile (Xcode/iOS)
|
||||||
**/bin/
|
**/bin/
|
||||||
**/obj/
|
**/obj/
|
||||||
@@ -86,3 +82,8 @@ nunit-*.xml
|
|||||||
.idea/indexLayout.xml
|
.idea/indexLayout.xml
|
||||||
.idea/tasks.xml
|
.idea/tasks.xml
|
||||||
.idea/.idea_modules
|
.idea/.idea_modules
|
||||||
|
|
||||||
|
# VSCode - ignore personal settings but keep shared configs
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/tasks.json
|
||||||
47
.vscode/launch.json
vendored
Normal file
47
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "API",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build-api",
|
||||||
|
"program": "${workspaceFolder}/BimAI.API/bin/Debug/net10.0/BimAI.API.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/BimAI.API",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"env": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Web",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build-web",
|
||||||
|
"program": "${workspaceFolder}/BimAI.UI.Web/bin/Debug/net10.0/BimAI.UI.Web.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/BimAI.UI.Web",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"serverReadyAction": {
|
||||||
|
"action": "openExternally",
|
||||||
|
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
|
||||||
|
"uriFormat": "%s"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"launchBrowser": {
|
||||||
|
"enabled": true,
|
||||||
|
"args": "${auto-detect-url}",
|
||||||
|
"browser": [
|
||||||
|
{
|
||||||
|
"osx": "Google Chrome",
|
||||||
|
"linux": "chrome",
|
||||||
|
"windows": "chrome"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
77
.vscode/tasks.json
vendored
Normal file
77
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build-api",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/BimAI.API/BimAI.API.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "build-web",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/BimAI.UI.Web/BimAI.UI.Web.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish-api",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/BimAI.API/BimAI.API.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish-web",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/BimAI.UI.Web/BimAI.UI.Web.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch-api",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/BimAI.API/BimAI.API.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch-web",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/BimAI.UI.Web/BimAI.UI.Web.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,29 +1,27 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Google.Apis.Auth" Version="1.70.0" />
|
<PackageReference Include="Google.Apis.Auth" Version="1.70.0" />
|
||||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.21" />
|
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.21" />
|
||||||
<PackageReference Include="Hangfire.Core" Version="1.8.21" />
|
<PackageReference Include="Hangfire.Core" Version="1.8.21" />
|
||||||
<PackageReference Include="Hangfire.SqlServer" Version="1.8.21" />
|
<PackageReference Include="Hangfire.SqlServer" Version="1.8.21" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.17" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0-rc.1.25451.107">
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.17">
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
</PackageReference>
|
||||||
</PackageReference>
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0-rc.1.25451.107" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
|
</ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
|
||||||
</ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
|
||||||
<ItemGroup>
|
<ProjectReference Include="..\BimAI.Infrastructure\BimAI.Infrastructure.csproj" />
|
||||||
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
|
</ItemGroup>
|
||||||
<ProjectReference Include="..\BimAI.Infrastructure\BimAI.Infrastructure.csproj" />
|
|
||||||
</ItemGroup>
|
</Project>
|
||||||
|
|
||||||
</Project>
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@BimAI.API_HostAddress = http://localhost:5090
|
@BimAI.API_HostAddress = http://localhost:5090
|
||||||
|
|
||||||
GET {{BimAI.API_HostAddress}}/weatherforecast/
|
GET {{BimAI.API_HostAddress}}/weatherforecast/
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|||||||
108
BimAI.API/Controllers/InvoiceController.cs
Normal file
108
BimAI.API/Controllers/InvoiceController.cs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
using BimAI.Application.DTOModels;
|
||||||
|
using BimAI.Application.DTOModels.Common;
|
||||||
|
using BimAI.Infrastructure.Data;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BimAI.API.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class InvoiceController(BimAIDbContext context) : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly BimAIDbContext _context = context;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<PagedResult<InvoiceDto>>> GetInvoices([FromQuery] InvoiceFilterRequest request)
|
||||||
|
{
|
||||||
|
var query = _context.Invoices.AsQueryable();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Search))
|
||||||
|
{
|
||||||
|
var searchTerm = request.Search.ToLower();
|
||||||
|
query = query.Where(x =>
|
||||||
|
x.DocumentNo.ToLower().Contains(searchTerm) ||
|
||||||
|
x.ClientName.ToLower().Contains(searchTerm)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.DocumentNo))
|
||||||
|
{
|
||||||
|
query = query.Where(x => x.DocumentNo.ToLower().Contains(request.DocumentNo.ToLower()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.ClientName))
|
||||||
|
{
|
||||||
|
query = query.Where(x => x.ClientName.ToLower().Contains(request.ClientName.ToLower()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Type))
|
||||||
|
{
|
||||||
|
query = query.Where(x => x.Type.ToLower().Contains(request.Type.ToLower()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Source))
|
||||||
|
{
|
||||||
|
query = query.Where(x => x.Source.ToLower().Contains(request.Source.ToLower()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.RegisterDateFrom.HasValue)
|
||||||
|
{
|
||||||
|
var from = request.RegisterDateFrom.Value.Date;
|
||||||
|
query = query.Where(x => x.RegisterDate >= from);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.RegisterDateTo.HasValue)
|
||||||
|
{
|
||||||
|
var toExclusive = request.RegisterDateTo.Value.Date.AddDays(1);
|
||||||
|
query = query.Where(x => x.RegisterDate < toExclusive);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.SellDateFrom.HasValue)
|
||||||
|
{
|
||||||
|
var from = request.SellDateFrom.Value.Date;
|
||||||
|
query = query.Where(x => x.SellDate >= from);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.SellDateTo.HasValue)
|
||||||
|
{
|
||||||
|
var toExclusive = request.SellDateTo.Value.Date.AddDays(1);
|
||||||
|
query = query.Where(x => x.SellDate < toExclusive);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalCount = await query.CountAsync();
|
||||||
|
|
||||||
|
var items = await query
|
||||||
|
.OrderByDescending(x => x.RegisterDate)
|
||||||
|
.Skip((request.Page - 1) * request.PageSize)
|
||||||
|
.Take(request.PageSize)
|
||||||
|
.Select(x => new InvoiceDto
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
DocumentNo = x.DocumentNo,
|
||||||
|
Type = x.Type,
|
||||||
|
RegisterDate = x.RegisterDate,
|
||||||
|
SellDate = x.SellDate,
|
||||||
|
ClientName = x.ClientName,
|
||||||
|
ClientId = x.ClientId,
|
||||||
|
ClientNip = x.ClientNip,
|
||||||
|
ClientAddress = x.ClientAddress,
|
||||||
|
Currency = x.Currency,
|
||||||
|
TotalNetto = x.TotalNetto,
|
||||||
|
TotalBrutto = x.TotalBrutto,
|
||||||
|
TotalVat = x.TotalVat,
|
||||||
|
Source = x.Source,
|
||||||
|
CreatedAt = x.CreatedAt,
|
||||||
|
UpdatedAt = x.UpdatedAt
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Ok(new PagedResult<InvoiceDto>
|
||||||
|
{
|
||||||
|
Items = items,
|
||||||
|
TotalCount = totalCount,
|
||||||
|
Page = request.Page,
|
||||||
|
PageSize = request.PageSize,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,9 @@ namespace BimAI.API.Controllers;
|
|||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class SyncController(ProductSyncService productSyncService) : ControllerBase
|
public class SyncController(
|
||||||
|
ProductSyncService productSyncService,
|
||||||
|
InvoiceSyncService invoiceSyncService) : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpPost("run-product-sync")]
|
[HttpPost("run-product-sync")]
|
||||||
public async Task<IActionResult> RunProductSync()
|
public async Task<IActionResult> RunProductSync()
|
||||||
@@ -13,4 +15,11 @@ public class SyncController(ProductSyncService productSyncService) : ControllerB
|
|||||||
await productSyncService.RunAsync();
|
await productSyncService.RunAsync();
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("run-invoice-sync")]
|
||||||
|
public async Task<IActionResult> RunInvoiceSync()
|
||||||
|
{
|
||||||
|
await invoiceSyncService.RunAsync();
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Stage 1: Build
|
# Stage 1: Build
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Copy solution and all project files for restore
|
# Copy solution and all project files for restore
|
||||||
@@ -20,9 +20,12 @@ WORKDIR /src/BimAI.API
|
|||||||
RUN dotnet publish -c Release -o /app/publish --no-restore
|
RUN dotnet publish -c Release -o /app/publish --no-restore
|
||||||
|
|
||||||
# Stage 2: Runtime
|
# Stage 2: Runtime
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install wget for health checks
|
||||||
|
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set timezone
|
# Set timezone
|
||||||
ENV TZ=Europe/Warsaw
|
ENV TZ=Europe/Warsaw
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|||||||
@@ -1,118 +1,151 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using BimAI.API.Services;
|
using BimAI.API.Services;
|
||||||
using BimAI.Infrastructure.Data;
|
using BimAI.Infrastructure.Data;
|
||||||
using BimAI.Infrastructure.Jobs;
|
using BimAI.Infrastructure.Jobs;
|
||||||
using BimAI.Infrastructure.Sync;
|
using BimAI.Infrastructure.Sync;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Hangfire.SqlServer;
|
using Hangfire.SqlServer;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||||
builder.Services.AddDbContext<BimAIDbContext>(options => options.UseSqlServer(connectionString));
|
builder.Services.AddDbContext<BimAIDbContext>(options => options.UseSqlServer(connectionString));
|
||||||
builder.Services.AddScoped<ProductSyncService>();
|
builder.Services.AddScoped<ProductSyncService>();
|
||||||
|
builder.Services.AddScoped<InvoiceSyncService>();
|
||||||
builder.Services.AddHttpClient();
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddHttpClient();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddControllers();
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
// Start Hangfire section
|
||||||
// Start Hangfire section
|
builder.Services.AddHangfire(configuration => configuration
|
||||||
builder.Services.AddHangfire(configuration => configuration
|
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
|
||||||
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
|
.UseSimpleAssemblyNameTypeSerializer()
|
||||||
.UseSimpleAssemblyNameTypeSerializer()
|
.UseRecommendedSerializerSettings()
|
||||||
.UseRecommendedSerializerSettings()
|
.UseSqlServerStorage(builder.Configuration.GetConnectionString("HangfireConnection"),
|
||||||
.UseSqlServerStorage(builder.Configuration.GetConnectionString("HangfireConnection"),
|
new SqlServerStorageOptions
|
||||||
new SqlServerStorageOptions
|
{
|
||||||
{
|
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
|
||||||
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
|
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
|
||||||
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
|
QueuePollInterval = TimeSpan.Zero,
|
||||||
QueuePollInterval = TimeSpan.Zero,
|
UseRecommendedIsolationLevel = true,
|
||||||
UseRecommendedIsolationLevel = true,
|
DisableGlobalLocks = true,
|
||||||
DisableGlobalLocks = true,
|
SchemaName = "Hangfire"
|
||||||
SchemaName = "Hangfire"
|
}
|
||||||
}
|
)
|
||||||
)
|
);
|
||||||
);
|
builder.Services.AddHangfireServer(options =>
|
||||||
builder.Services.AddHangfireServer(options =>
|
{
|
||||||
{
|
options.ServerName = builder.Configuration["Hangfire:ServerName"];
|
||||||
options.ServerName = builder.Configuration["Hangfire:ServerName"];
|
options.WorkerCount = builder.Configuration.GetValue<int>("Hangfire:WorkerCount", 5);
|
||||||
options.WorkerCount = builder.Configuration.GetValue<int>("Hangfire:WorkerCount", 5);
|
});
|
||||||
});
|
// End Hangfire section
|
||||||
// End Hangfire section
|
// Start auth section
|
||||||
// Start auth section
|
var jwtSettings = builder.Configuration.GetSection("JwtSettings");
|
||||||
var jwtSettings = builder.Configuration.GetSection("JwtSettings");
|
var secretKey = jwtSettings["SecretKey"];
|
||||||
var secretKey = jwtSettings["SecretKey"];
|
var issuer = jwtSettings["Issuer"];
|
||||||
var issuer = jwtSettings["Issuer"];
|
var audience = jwtSettings["Audience"];
|
||||||
var audience = jwtSettings["Audience"];
|
|
||||||
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
.AddJwtBearer(options =>
|
||||||
.AddJwtBearer(options =>
|
{
|
||||||
{
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
options.TokenValidationParameters = new TokenValidationParameters
|
{
|
||||||
{
|
ValidateIssuer = true,
|
||||||
ValidateIssuer = true,
|
ValidateAudience = true,
|
||||||
ValidateAudience = true,
|
ValidateLifetime = true,
|
||||||
ValidateLifetime = true,
|
ValidateIssuerSigningKey = true,
|
||||||
ValidateIssuerSigningKey = true,
|
ValidIssuer = issuer,
|
||||||
ValidIssuer = issuer,
|
ValidAudience = audience,
|
||||||
ValidAudience = audience,
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)),
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)),
|
ClockSkew = TimeSpan.Zero,
|
||||||
ClockSkew = TimeSpan.Zero,
|
};
|
||||||
};
|
});
|
||||||
});
|
builder.Services.AddAuthentication();
|
||||||
builder.Services.AddAuthentication();
|
|
||||||
|
builder.Services.AddScoped<GoogleAuthService>();
|
||||||
builder.Services.AddScoped<GoogleAuthService>();
|
builder.Services.AddScoped<JwtTokenService>();
|
||||||
builder.Services.AddScoped<JwtTokenService>();
|
|
||||||
|
builder.Services.AddCors(options =>
|
||||||
builder.Services.AddCors(options =>
|
{
|
||||||
{
|
options.AddPolicy("AllowAll", policy =>
|
||||||
options.AddPolicy("AllowAll", policy =>
|
{
|
||||||
{
|
policy.AllowAnyOrigin()
|
||||||
policy.AllowAnyOrigin()
|
.AllowAnyMethod()
|
||||||
.AllowAnyMethod()
|
.AllowAnyHeader();
|
||||||
.AllowAnyHeader();
|
});
|
||||||
});
|
});
|
||||||
});
|
// End auth section
|
||||||
// End auth section
|
|
||||||
|
var app = builder.Build();
|
||||||
var app = builder.Build();
|
|
||||||
|
// Auto-apply migrations on startup
|
||||||
if (app.Environment.IsDevelopment())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
var db = scope.ServiceProvider.GetRequiredService<BimAIDbContext>();
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
try
|
||||||
|
{
|
||||||
app.UseHttpsRedirection();
|
var pending = await db.Database.GetPendingMigrationsAsync();
|
||||||
app.UseCors("AllowAll");
|
if (pending.Any())
|
||||||
app.UseHangfireDashboard(builder.Configuration["Hangfire:DashboardPath"] ?? "/hangfire", new DashboardOptions
|
{
|
||||||
{
|
app.Logger.LogWarning("Applying {Count} pending migrations: {List}",
|
||||||
AsyncAuthorization = new[] { new HangfireAuthorizationFilter() },
|
pending.Count(), string.Join(", ", pending));
|
||||||
DashboardTitle = "BimAI - Job Dashboard"
|
await db.Database.MigrateAsync();
|
||||||
});
|
app.Logger.LogInformation("Migrations applied successfully.");
|
||||||
app.UseAuthorization();
|
}
|
||||||
app.UseAuthorization();
|
else
|
||||||
app.MapControllers();
|
{
|
||||||
|
app.Logger.LogInformation("No pending migrations.");
|
||||||
app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow }))
|
}
|
||||||
.AllowAnonymous();
|
}
|
||||||
|
catch (Exception ex)
|
||||||
RecurringJob.AddOrUpdate<ProductSyncJob>(
|
{
|
||||||
"product-sync",
|
app.Logger.LogCritical(ex, "Migration failed - application will not start.");
|
||||||
job => job.ExecuteAsync(),
|
throw; // stop startup
|
||||||
Cron.Daily(2, 0), // Every day at 2:00 AM
|
}
|
||||||
new RecurringJobOptions
|
}
|
||||||
{
|
|
||||||
TimeZone = TimeZoneInfo.Local,
|
|
||||||
MisfireHandling = app.Environment.IsDevelopment()
|
app.UseHttpsRedirection();
|
||||||
? MisfireHandlingMode.Relaxed
|
app.UseCors("AllowAll");
|
||||||
: MisfireHandlingMode.Strict
|
app.UseHangfireDashboard(builder.Configuration["Hangfire:DashboardPath"] ?? "/hangfire", new DashboardOptions
|
||||||
});
|
{
|
||||||
|
AsyncAuthorization = new[] { new HangfireAuthorizationFilter() },
|
||||||
|
DashboardTitle = "BimAI - Job Dashboard"
|
||||||
|
});
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow }))
|
||||||
|
.AllowAnonymous();
|
||||||
|
|
||||||
|
RecurringJob.AddOrUpdate<ProductSyncJob>(
|
||||||
|
"product-sync",
|
||||||
|
job => job.ExecuteAsync(),
|
||||||
|
Cron.Daily(2, 0), // Every day at 2:00 AM
|
||||||
|
new RecurringJobOptions
|
||||||
|
{
|
||||||
|
TimeZone = TimeZoneInfo.Local,
|
||||||
|
MisfireHandling = app.Environment.IsDevelopment()
|
||||||
|
? MisfireHandlingMode.Relaxed
|
||||||
|
: MisfireHandlingMode.Strict
|
||||||
|
});
|
||||||
|
|
||||||
|
RecurringJob.AddOrUpdate<InvoiceSyncJob>(
|
||||||
|
"invoice-sync",
|
||||||
|
job => job.ExecuteAsync(),
|
||||||
|
Cron.Daily(2, 30), // Every day at 2:30 AM
|
||||||
|
new RecurringJobOptions
|
||||||
|
{
|
||||||
|
TimeZone = TimeZoneInfo.Local,
|
||||||
|
MisfireHandling = app.Environment.IsDevelopment()
|
||||||
|
? MisfireHandlingMode.Relaxed
|
||||||
|
: MisfireHandlingMode.Strict
|
||||||
|
});
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"dev": {
|
"dev": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:7142;http://0.0.0.0:7142",
|
"applicationUrl": "http://localhost:7142;http://0.0.0.0:7142",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,14 +7,14 @@ public class HangfireAuthorizationFilter: IDashboardAsyncAuthorizationFilter
|
|||||||
public Task<bool> AuthorizeAsync(DashboardContext context)
|
public Task<bool> AuthorizeAsync(DashboardContext context)
|
||||||
{
|
{
|
||||||
var httpContext = context.GetHttpContext();
|
var httpContext = context.GetHttpContext();
|
||||||
|
|
||||||
var env = httpContext.RequestServices.GetService<IWebHostEnvironment>();
|
var env = httpContext.RequestServices.GetService<IWebHostEnvironment>();
|
||||||
if (env.IsDevelopment())
|
if (env != null && env.IsDevelopment())
|
||||||
{
|
{
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false;
|
var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false;
|
||||||
return Task.FromResult(isAuthenticated);
|
return Task.FromResult(isAuthenticated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -1,38 +1,25 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"ConnectionStrings": {
|
||||||
"LogLevel": {
|
"DefaultConnection": "",
|
||||||
"Default": "Information",
|
"HangfireConnection": ""
|
||||||
"Microsoft.AspNetCore": "Warning",
|
},
|
||||||
"Microsoft.EntityFrameworkCore": "Warning"
|
"E5_CRM": {
|
||||||
}
|
"ApiKey": ""
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"GoogleAuth": {
|
||||||
"ConnectionStrings": {
|
"ClientId": ""
|
||||||
"DefaultConnection": "#{db-connection-string}#",
|
},
|
||||||
"HangfireConnection": "#{hangfire-connection-string}#"
|
"JwtSettings": {
|
||||||
},
|
"SecretKey": ""
|
||||||
"E5_CRM": {
|
},
|
||||||
"ApiKey": "#{e5-crm-api-key}#"
|
"Hangfire": {
|
||||||
},
|
"ServerName": "BimAI-Production"
|
||||||
"GoogleAuth": {
|
},
|
||||||
"ClientId": "#{google-auth-client-id}#"
|
"Kestrel": {
|
||||||
},
|
"Endpoints": {
|
||||||
"JwtSettings": {
|
"Http": {
|
||||||
"SecretKey": "#{jwt-secret-key}#",
|
"Url": "http://0.0.0.0:7142"
|
||||||
"Issuer": "#{jwt-issuer}#",
|
}
|
||||||
"Audience": "#{jwt-audience}#",
|
}
|
||||||
"ExpiryDays": 7
|
}
|
||||||
},
|
}
|
||||||
"Hangfire": {
|
|
||||||
"ServerName": "#{hangfire-server-name}#",
|
|
||||||
"WorkerCount": 5,
|
|
||||||
"DashboardPath": "/hangfire"
|
|
||||||
},
|
|
||||||
"Kestrel": {
|
|
||||||
"Endpoints": {
|
|
||||||
"Http": {
|
|
||||||
"Url": "http://0.0.0.0:7142"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
21
BimAI.API/appsettings.json
Normal file
21
BimAI.API/appsettings.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"JwtSettings": {
|
||||||
|
"Issuer": "BimAI.API",
|
||||||
|
"Audience": "BimAI.Clients",
|
||||||
|
"ExpiryDays": 7
|
||||||
|
},
|
||||||
|
"Hangfire": {
|
||||||
|
"WorkerCount": 5,
|
||||||
|
"DashboardPath": "/hangfire"
|
||||||
|
},
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning",
|
||||||
|
"Microsoft.EntityFrameworkCore": "Warning",
|
||||||
|
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
|
||||||
|
"Microsoft.EntityFrameworkCore.Infrastructure": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
|
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
37
BimAI.Application/DTOModels/InvoiceDto.cs
Normal file
37
BimAI.Application/DTOModels/InvoiceDto.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
namespace BimAI.Application.DTOModels;
|
||||||
|
|
||||||
|
|
||||||
|
public class InvoiceDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string DocumentNo { get; set; } = string.Empty;
|
||||||
|
public string Type { get; set; } = string.Empty;
|
||||||
|
public DateTime RegisterDate { get; set; }
|
||||||
|
public DateTime SellDate { get; set; }
|
||||||
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
public string? ClientId { get; set; }
|
||||||
|
public string? ClientNip { get; set; }
|
||||||
|
public string? ClientAddress { get; set; }
|
||||||
|
public string Currency { get; set; } = string.Empty;
|
||||||
|
public decimal TotalNetto { get; set; }
|
||||||
|
public decimal TotalBrutto { get; set; }
|
||||||
|
public decimal TotalVat { get; set; }
|
||||||
|
public string Source { get; set; } = string.Empty;
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InvoiceFilterRequest
|
||||||
|
{
|
||||||
|
public string? Search { get; set; }
|
||||||
|
public string? DocumentNo { get; set; }
|
||||||
|
public string? ClientName { get; set; }
|
||||||
|
public string? Type { get; set; }
|
||||||
|
public string? Source { get; set; }
|
||||||
|
public DateTime? RegisterDateFrom { get; set; }
|
||||||
|
public DateTime? RegisterDateTo { get; set; }
|
||||||
|
public DateTime? SellDateFrom { get; set; }
|
||||||
|
public DateTime? SellDateTo { get; set; }
|
||||||
|
public int Page { get; set; } = 1;
|
||||||
|
public int PageSize { get; set; } = 20;
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
18
BimAI.Domain/Entities/Invoice.cs
Normal file
18
BimAI.Domain/Entities/Invoice.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace BimAI.Domain.Entities;
|
||||||
|
|
||||||
|
public class Invoice: BaseEntity
|
||||||
|
{
|
||||||
|
public required string DocumentNo { get; set; }
|
||||||
|
public required string Type { get; set; }
|
||||||
|
public DateTime RegisterDate { get; set; }
|
||||||
|
public DateTime SellDate { get; set; }
|
||||||
|
public required string ClientName { get; set; }
|
||||||
|
public string? ClientId { get; set; }
|
||||||
|
public string? ClientNip { get; set; }
|
||||||
|
public string? ClientAddress { get; set; }
|
||||||
|
public required string Currency { get; set; }
|
||||||
|
public decimal TotalNetto { get; set; }
|
||||||
|
public decimal TotalBrutto { get; set; }
|
||||||
|
public decimal TotalVat { get; set; }
|
||||||
|
public required string Source { get; set; }
|
||||||
|
}
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
|
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
|
||||||
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
|
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.17" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0-rc.1.25451.107" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.17" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.0-rc.1.25451.107" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.17">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.0-rc.1.25451.107">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace BimAI.Infrastructure.Data;
|
|||||||
public class BimAIDbContext(DbContextOptions<BimAIDbContext> options) : DbContext(options)
|
public class BimAIDbContext(DbContextOptions<BimAIDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
public DbSet<Product> Products { get; set; }
|
public DbSet<Product> Products { get; set; }
|
||||||
|
public DbSet<Invoice> Invoices { get; set; }
|
||||||
public DbSet<SyncState> SyncStates { get; set; }
|
public DbSet<SyncState> SyncStates { get; set; }
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
@@ -20,6 +21,21 @@ public class BimAIDbContext(DbContextOptions<BimAIDbContext> options) : DbContex
|
|||||||
modelBuilder.Entity<Product>().Property(x => x.Ean).IsRequired().HasMaxLength(50);
|
modelBuilder.Entity<Product>().Property(x => x.Ean).IsRequired().HasMaxLength(50);
|
||||||
modelBuilder.Entity<Product>().Property(x => x.StockAddresses).IsRequired().HasMaxLength(512);
|
modelBuilder.Entity<Product>().Property(x => x.StockAddresses).IsRequired().HasMaxLength(512);
|
||||||
|
|
||||||
|
// Invoice properties
|
||||||
|
modelBuilder.Entity<Invoice>().HasKey(x => x.Id);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.DocumentNo).IsRequired().HasMaxLength(100);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.Type).IsRequired().HasMaxLength(50);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.ClientName).IsRequired().HasMaxLength(255);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.ClientId).HasMaxLength(100);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.ClientNip).HasMaxLength(50);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.ClientAddress).HasMaxLength(500);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.Currency).IsRequired().HasMaxLength(10);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.Source).IsRequired().HasMaxLength(50);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.TotalNetto).HasPrecision(18, 2);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.TotalBrutto).HasPrecision(18, 2);
|
||||||
|
modelBuilder.Entity<Invoice>().Property(x => x.TotalVat).HasPrecision(18, 2);
|
||||||
|
modelBuilder.Entity<Invoice>().HasIndex(x => new { x.DocumentNo, x.Source }).IsUnique().HasDatabaseName("IX_Invoices_DocumentNo_Source");
|
||||||
|
|
||||||
// SyncState properties
|
// SyncState properties
|
||||||
modelBuilder.Entity<SyncState>().HasKey((x => x.Entity));
|
modelBuilder.Entity<SyncState>().HasKey((x => x.Entity));
|
||||||
|
|
||||||
|
|||||||
31
BimAI.Infrastructure/Jobs/InvoiceSyncJob.cs
Normal file
31
BimAI.Infrastructure/Jobs/InvoiceSyncJob.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using BimAI.Infrastructure.Sync;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BimAI.Infrastructure.Jobs;
|
||||||
|
|
||||||
|
public class InvoiceSyncJob
|
||||||
|
{
|
||||||
|
private readonly InvoiceSyncService _invoiceSyncService;
|
||||||
|
private readonly ILogger<InvoiceSyncJob> _logger;
|
||||||
|
|
||||||
|
public InvoiceSyncJob(InvoiceSyncService invoiceSyncService, ILogger<InvoiceSyncJob> logger)
|
||||||
|
{
|
||||||
|
_invoiceSyncService = invoiceSyncService;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ExecuteAsync()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Starting invoice sync...");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _invoiceSyncService.RunAsync();
|
||||||
|
_logger.LogInformation("Invoice sync finished.");
|
||||||
|
} catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during invoice sync.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
151
BimAI.Infrastructure/Sync/InvoiceSyncService.cs
Normal file
151
BimAI.Infrastructure/Sync/InvoiceSyncService.cs
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Web;
|
||||||
|
using BimAI.Domain.Entities;
|
||||||
|
using BimAI.Infrastructure.Data;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace BimAI.Infrastructure.Sync;
|
||||||
|
|
||||||
|
public class InvoiceSyncService(HttpClient httpClient, BimAIDbContext db, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
private string DecodeHtmlEntities(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
return text;
|
||||||
|
|
||||||
|
return HttpUtility.HtmlDecode(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RunAsync()
|
||||||
|
{
|
||||||
|
var apiKey = configuration["TWINPOL_CRM:ApiKey"];
|
||||||
|
var syncState = db.SyncStates.FirstOrDefault(x => x.Entity == "Invoice") ?? new SyncState { Entity = "Invoice", LastSynced = 0 };
|
||||||
|
|
||||||
|
var url = $"https://crm.twinpol.com/REST/index.php?key={apiKey}&action=bimai.export.ecommerce&since=0";
|
||||||
|
var response = await httpClient.GetStringAsync(url);
|
||||||
|
|
||||||
|
var jsonDoc = JsonSerializer.Deserialize<JsonElement>(response);
|
||||||
|
if (!jsonDoc.TryGetProperty("data", out var dataElement))
|
||||||
|
{
|
||||||
|
Console.WriteLine("[SYNC] No 'data' property in response");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var invoices = dataElement.EnumerateArray();
|
||||||
|
var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||||
|
var processedCount = 0;
|
||||||
|
var batchSize = 20;
|
||||||
|
|
||||||
|
foreach (var invoiceJson in invoices)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var e5Id = invoiceJson.GetProperty("e5Id").GetString() ?? "";
|
||||||
|
var documentNo = DecodeHtmlEntities(invoiceJson.GetProperty("documentNo").GetString() ?? "");
|
||||||
|
var type = DecodeHtmlEntities(invoiceJson.GetProperty("type").GetString() ?? "");
|
||||||
|
var registerDateStr = invoiceJson.GetProperty("registerDate").GetString() ?? "";
|
||||||
|
var sellDateStr = invoiceJson.GetProperty("sellDate").GetString() ?? "";
|
||||||
|
var clientName = DecodeHtmlEntities(invoiceJson.GetProperty("clientName").GetString() ?? "");
|
||||||
|
var clientId = DecodeHtmlEntities(invoiceJson.GetProperty("clientId").GetString() ?? "");
|
||||||
|
var clientNip = DecodeHtmlEntities(invoiceJson.GetProperty("clientNip").GetString() ?? "");
|
||||||
|
var clientAddress = DecodeHtmlEntities(invoiceJson.GetProperty("clientAddress").GetString() ?? "");
|
||||||
|
var currency = invoiceJson.GetProperty("currency").GetString() ?? "PLN";
|
||||||
|
var totalNettoStr = invoiceJson.GetProperty("totalNetto").GetString() ?? "0";
|
||||||
|
var totalBruttoStr = invoiceJson.GetProperty("totalBrutto").GetString() ?? "0";
|
||||||
|
var totalVatStr = invoiceJson.GetProperty("totalVat").GetString() ?? "0";
|
||||||
|
var source = invoiceJson.GetProperty("source").GetString() ?? "";
|
||||||
|
|
||||||
|
if (!DateTime.TryParse(registerDateStr, out var registerDate))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[SYNC] Invalid registerDate for invoice {documentNo}: {registerDateStr}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DateTime.TryParse(sellDateStr, out var sellDate))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[SYNC] Invalid sellDate for invoice {documentNo}: {sellDateStr}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!decimal.TryParse(totalNettoStr, out var totalNetto))
|
||||||
|
totalNetto = 0;
|
||||||
|
|
||||||
|
if (!decimal.TryParse(totalBruttoStr, out var totalBrutto))
|
||||||
|
totalBrutto = 0;
|
||||||
|
|
||||||
|
if (!decimal.TryParse(totalVatStr, out var totalVat))
|
||||||
|
totalVat = 0;
|
||||||
|
|
||||||
|
var existing = db.Invoices.FirstOrDefault(x => x.DocumentNo == documentNo && x.Source == source);
|
||||||
|
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
|
var invoice = new Invoice
|
||||||
|
{
|
||||||
|
DocumentNo = documentNo,
|
||||||
|
Type = type,
|
||||||
|
RegisterDate = registerDate,
|
||||||
|
SellDate = sellDate,
|
||||||
|
ClientName = clientName,
|
||||||
|
ClientId = string.IsNullOrWhiteSpace(clientId) ? null : clientId,
|
||||||
|
ClientNip = string.IsNullOrWhiteSpace(clientNip) ? null : clientNip,
|
||||||
|
ClientAddress = string.IsNullOrWhiteSpace(clientAddress) ? null : clientAddress,
|
||||||
|
Currency = currency,
|
||||||
|
TotalNetto = totalNetto,
|
||||||
|
TotalBrutto = totalBrutto,
|
||||||
|
TotalVat = totalVat,
|
||||||
|
Source = source,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
db.Invoices.Add(invoice);
|
||||||
|
Console.WriteLine($"[SYNC] Added invoice: {documentNo} from {source}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
existing.Type = type;
|
||||||
|
existing.RegisterDate = registerDate;
|
||||||
|
existing.SellDate = sellDate;
|
||||||
|
existing.ClientName = clientName;
|
||||||
|
existing.ClientId = string.IsNullOrWhiteSpace(clientId) ? null : clientId;
|
||||||
|
existing.ClientNip = string.IsNullOrWhiteSpace(clientNip) ? null : clientNip;
|
||||||
|
existing.ClientAddress = string.IsNullOrWhiteSpace(clientAddress) ? null : clientAddress;
|
||||||
|
existing.Currency = currency;
|
||||||
|
existing.TotalNetto = totalNetto;
|
||||||
|
existing.TotalBrutto = totalBrutto;
|
||||||
|
existing.TotalVat = totalVat;
|
||||||
|
existing.UpdatedAt = DateTime.UtcNow;
|
||||||
|
Console.WriteLine($"[SYNC] Updated invoice: {documentNo} from {source}");
|
||||||
|
}
|
||||||
|
|
||||||
|
processedCount++;
|
||||||
|
|
||||||
|
if (processedCount % batchSize == 0)
|
||||||
|
{
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
Console.WriteLine($"[SYNC] Saved batch of {batchSize} invoices. Total processed: {processedCount}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[SYNC] Error processing invoice: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
Console.WriteLine($"[SYNC] Saved remaining invoices. Total processed: {processedCount}");
|
||||||
|
|
||||||
|
syncState.LastSynced = now;
|
||||||
|
if (db.SyncStates.FirstOrDefault(x => x.Entity == "Invoice") == null)
|
||||||
|
{
|
||||||
|
db.SyncStates.Add(syncState);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
db.SyncStates.Update(syncState);
|
||||||
|
}
|
||||||
|
Console.WriteLine("Before final SaveChangesAsync");
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
Console.WriteLine("[SYNC] Invoice sync completed");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-ios</TargetFramework>
|
<TargetFramework>net10.0-ios</TargetFramework>
|
||||||
<GenerateXcodeProject>true</GenerateXcodeProject>
|
<GenerateXcodeProject>true</GenerateXcodeProject>
|
||||||
|
|
||||||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
|
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
|
||||||
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
|
<!-- <TargetFrameworks>$(TargetFrameworks);net10.0-tizen</TargetFrameworks> -->
|
||||||
|
|
||||||
<!-- Note for MacCatalyst:
|
<!-- Note for MacCatalyst:
|
||||||
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
|
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
|
||||||
@@ -70,14 +70,14 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.9"/>
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.9"/>
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.9"/>
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.9"/>
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
|
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
|
||||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
|
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)"/>
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1"/>
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0"/>
|
||||||
<PackageReference Include="MudBlazor" Version="8.8.0"/>
|
<PackageReference Include="MudBlazor" Version="8.8.0"/>
|
||||||
<PackageReference Include="ZXing.Net.MAUI" Version="0.4.0"/>
|
<PackageReference Include="ZXing.Net.MAUI" Version="0.4.0"/>
|
||||||
<PackageReference Include="ZXing.Net.MAUI.Controls" Version="0.4.0"/>
|
<PackageReference Include="ZXing.Net.MAUI.Controls" Version="0.4.0"/>
|
||||||
|
|||||||
Binary file not shown.
@@ -1,30 +1,30 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<SupportedPlatform Include="browser" />
|
<SupportedPlatform Include="browser" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.17" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="10.0.0-rc.1.25451.107" />
|
||||||
<PackageReference Include="MudBlazor" Version="8.8.0" />
|
<PackageReference Include="MudBlazor" Version="8.8.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="10.0.0-rc.1.25451.107" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0-rc.1.25451.107" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
|
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
|
||||||
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
|
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="wwwroot\images\" />
|
<Folder Include="wwwroot\images\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
160
BimAI.UI.Shared/Components/InvoiceListComponent.razor
Normal file
160
BimAI.UI.Shared/Components/InvoiceListComponent.razor
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
@using MudBlazor.Internal
|
||||||
|
@using System.Data
|
||||||
|
<MudText Typo="Typo.h4" Class="mb-4">Lista Faktur</MudText>
|
||||||
|
|
||||||
|
<MudExpansionPanels Class="mb-4">
|
||||||
|
<MudExpansionPanel Icon="@Icons.Material.Filled.FilterList"
|
||||||
|
Text="Filtry"
|
||||||
|
Expanded="true">
|
||||||
|
<MudGrid>
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudTextField @bind-Value="filterRequest.Search"
|
||||||
|
Label="Szukaj"
|
||||||
|
Placeholder="Numer dokumentu, klient..."
|
||||||
|
Immediate="true"
|
||||||
|
DebounceInterval="500"
|
||||||
|
OnDebounceIntervalElapsed="SearchInvoices"
|
||||||
|
Clearable="true" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudTextField @bind-Value="filterRequest.DocumentNo"
|
||||||
|
Label="Numer dokumentu"
|
||||||
|
Immediate="true"
|
||||||
|
DebounceInterval="500"
|
||||||
|
OnDebounceIntervalElapsed="SearchInvoices"
|
||||||
|
Clearable="true" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudTextField @bind-Value="filterRequest.Type"
|
||||||
|
Label="Typ dokumentu"
|
||||||
|
Immediate="true"
|
||||||
|
DebounceInterval="500"
|
||||||
|
OnDebounceIntervalElapsed="SearchInvoices"
|
||||||
|
Clearable="true" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudTextField @bind-Value="filterRequest.ClientName"
|
||||||
|
Label="Nazwa klienta"
|
||||||
|
Immediate="true"
|
||||||
|
DebounceInterval="500"
|
||||||
|
OnDebounceIntervalElapsed="SearchInvoices"
|
||||||
|
Clearable="true" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudDatePicker @bind-Date="filterRequest.RegisterDateFrom"
|
||||||
|
Label="Data rejestracji od"
|
||||||
|
DateFormat="dd.MM.yyyy"
|
||||||
|
Editable="true"
|
||||||
|
Clearable="true"
|
||||||
|
Immediate="true"
|
||||||
|
@bind-Date:after="OnFilterChanged" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudDatePicker @bind-Date="filterRequest.RegisterDateTo"
|
||||||
|
Label="Data rejestracji do"
|
||||||
|
DateFormat="d.MM.yyyy"
|
||||||
|
Editable="true"
|
||||||
|
Clearable="true"
|
||||||
|
Immediate="true"
|
||||||
|
@bind-Date:after="OnFilterChanged" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudDatePicker @bind-Date="filterRequest.SellDateFrom"
|
||||||
|
Label="Data sprzedaży od"
|
||||||
|
DateFormat="d.MM.yyyy"
|
||||||
|
Editable="true"
|
||||||
|
Clearable="true"
|
||||||
|
Immediate="true"
|
||||||
|
@bind-Date:after="OnFilterChanged" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudDatePicker @bind-Date="filterRequest.SellDateTo"
|
||||||
|
Label="Data sprzedaży do"
|
||||||
|
DateFormat="d.MM.yyyy"
|
||||||
|
Editable="true"
|
||||||
|
Clearable="true"
|
||||||
|
Immediate="true"
|
||||||
|
@bind-Date:after="OnFilterChanged" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudButton Variant="Variant.Outlined"
|
||||||
|
OnClick="ClearFilters"
|
||||||
|
StartIcon="Icons.Material.Filled.Clear">
|
||||||
|
Wyczyść filtry
|
||||||
|
</MudButton>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
</MudExpansionPanel>
|
||||||
|
</MudExpansionPanels>
|
||||||
|
|
||||||
|
|
||||||
|
<MudDivider Class="my-4"></MudDivider>
|
||||||
|
|
||||||
|
<MudTable Items="invoices.Items"
|
||||||
|
Dense="true"
|
||||||
|
Hover="true"
|
||||||
|
Loading="isLoading"
|
||||||
|
LoadingProgressColor="Color.Info">
|
||||||
|
<HeaderContent>
|
||||||
|
<MudTh>Numer dokumentu</MudTh>
|
||||||
|
<MudTh>Typ</MudTh>
|
||||||
|
<MudTh>Klient</MudTh>
|
||||||
|
<MudTh>Data rejestracji</MudTh>
|
||||||
|
<MudTh>Data sprzedaży</MudTh>
|
||||||
|
<MudTh>Wartość brutto</MudTh>
|
||||||
|
<MudTh>Akcje</MudTh>
|
||||||
|
</HeaderContent>
|
||||||
|
<RowTemplate>
|
||||||
|
<MudTd DataLabel="Numer dokumentu">@context.DocumentNo</MudTd>
|
||||||
|
<MudTd DataLabel="Typ">@context.Type</MudTd>
|
||||||
|
<MudTd DataLabel="Klient">@context.ClientName</MudTd>
|
||||||
|
<MudTd DataLabel="Data rejestracji">@context.RegisterDate.ToShortDateString()</MudTd>
|
||||||
|
<MudTd DataLabel="Data sprzedaży">@context.SellDate.ToShortDateString()</MudTd>
|
||||||
|
<MudTd DataLabel="Wartość brutto">@context.TotalBrutto.ToString("C2")</MudTd>
|
||||||
|
<MudTd DataLabel="Akcje">
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.Visibility"
|
||||||
|
Size="Size.Small"
|
||||||
|
OnClick="() => ViewInvoice(context.Id)"/>
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
||||||
|
Size="Size.Small"
|
||||||
|
OnClick="() => EditInvoice(context.Id)"/>
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||||
|
Size="Size.Small"
|
||||||
|
Color="Color.Error"
|
||||||
|
OnClick="() => DeleteInvoice(context.Id)"/>
|
||||||
|
</MudTd>
|
||||||
|
</RowTemplate>
|
||||||
|
<NoRecordsContent>
|
||||||
|
<MudText>Brak faktur do wyświetlenia</MudText>
|
||||||
|
</NoRecordsContent>
|
||||||
|
<LoadingContent>
|
||||||
|
Ładowanie...
|
||||||
|
</LoadingContent>
|
||||||
|
</MudTable>
|
||||||
|
|
||||||
|
@if (invoices.TotalCount > 0)
|
||||||
|
{
|
||||||
|
<MudGrid Class="mt-4" AlignItems="Center">
|
||||||
|
<MudItem xs="12" sm="6">
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
Wyniki @((invoices.Page - 1) * invoices.PageSize + 1) - @Math.Min(invoices.Page * invoices.PageSize, invoices.TotalCount)
|
||||||
|
z @invoices.TotalCount
|
||||||
|
</MudText>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6" Class="d-flex justify-end">
|
||||||
|
<MudPagination Count="invoices.TotalPages"
|
||||||
|
Selected="invoices.Page"
|
||||||
|
SelectedChanged="OnPageChanged"
|
||||||
|
ShowFirstButton="true"
|
||||||
|
ShowLastButton="true"/>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
}
|
||||||
85
BimAI.UI.Shared/Components/InvoiceListComponent.razor.cs
Normal file
85
BimAI.UI.Shared/Components/InvoiceListComponent.razor.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using BimAI.UI.Shared.Services;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using BimAI.Application.DTOModels;
|
||||||
|
using BimAI.Application.DTOModels.Common;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace BimAI.UI.Shared.Components;
|
||||||
|
|
||||||
|
public partial class InvoiceListComponent : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private InvoiceService InvoiceService { get; set; } = default!;
|
||||||
|
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
||||||
|
|
||||||
|
private PagedResult<InvoiceDto> invoices = new();
|
||||||
|
private InvoiceFilterRequest filterRequest = new();
|
||||||
|
private bool isLoading = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadInvoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadInvoices()
|
||||||
|
{
|
||||||
|
isLoading = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await InvoiceService.GetInvoiceAsync(filterRequest);
|
||||||
|
invoices = result ?? new PagedResult<InvoiceDto>();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Loading invoices failed: {ex.Message}");
|
||||||
|
Console.WriteLine($"Stack trace: {ex.StackTrace}");
|
||||||
|
Snackbar.Add($"Błąd podczas ładowania faktur: {ex.Message}", Severity.Error);
|
||||||
|
invoices = new PagedResult<InvoiceDto>();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SearchInvoices()
|
||||||
|
{
|
||||||
|
filterRequest.Page = 1;
|
||||||
|
await LoadInvoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnPageChanged(int page)
|
||||||
|
{
|
||||||
|
filterRequest.Page = page;
|
||||||
|
await LoadInvoices();
|
||||||
|
}
|
||||||
|
private async Task OnFilterChanged()
|
||||||
|
{
|
||||||
|
filterRequest.Page = 1;
|
||||||
|
await SearchInvoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ClearFilters()
|
||||||
|
{
|
||||||
|
filterRequest = new InvoiceFilterRequest();
|
||||||
|
await LoadInvoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ViewInvoice(Guid invoiceId)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Console.WriteLine($"Zobacz fakturę: {invoiceId}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task EditInvoice(Guid invoiceId)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Console.WriteLine($"Edytuj fakturę: {invoiceId}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteInvoice(Guid invoiceId)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Console.WriteLine($"Usuń fakturę: {invoiceId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,12 @@ public static class ServiceCollectionExtensions
|
|||||||
{
|
{
|
||||||
client.BaseAddress = new Uri(apiBaseUrl);
|
client.BaseAddress = new Uri(apiBaseUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddHttpClient<InvoiceService>(client =>
|
||||||
|
{
|
||||||
|
client.BaseAddress = new Uri(apiBaseUrl);
|
||||||
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
<MudThemeProvider/>
|
<MudThemeProvider/>
|
||||||
<MudDialogProvider/>
|
<MudDialogProvider/>
|
||||||
<MudSnackbarProvider/>
|
<MudSnackbarProvider/>
|
||||||
|
<MudPopoverProvider />
|
||||||
|
|
||||||
<MudLayout>
|
<MudLayout>
|
||||||
<MudBreakpointProvider OnBreakpointChanged="OnBreakpointChanged"></MudBreakpointProvider>
|
<MudBreakpointProvider OnBreakpointChanged="OnBreakpointChanged"></MudBreakpointProvider>
|
||||||
<MudAppBar Elevation="0">
|
<MudAppBar Elevation="0">
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
<MudNavMenu>
|
<MudNavMenu>
|
||||||
<MudNavLink Href="/dashboard" Icon="@Icons.Material.Filled.Dashboard">Dashboard</MudNavLink>
|
<MudNavLink Href="/dashboard" Icon="@Icons.Material.Filled.Dashboard">Dashboard</MudNavLink>
|
||||||
<MudNavLink Href="/products" Icon="@Icons.Material.Filled.Inventory">Products</MudNavLink>
|
<MudNavLink Href="/products" Icon="@Icons.Material.Filled.Inventory">Products</MudNavLink>
|
||||||
|
<MudNavLink Href="/invoices" Icon="@Icons.Material.Filled.FilePresent">Invoices</MudNavLink>
|
||||||
</MudNavMenu>
|
</MudNavMenu>
|
||||||
</MudDrawer>
|
</MudDrawer>
|
||||||
|
|
||||||
|
|||||||
8
BimAI.UI.Shared/Pages/InvoiceListPage.razor
Normal file
8
BimAI.UI.Shared/Pages/InvoiceListPage.razor
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
@page "/invoices"
|
||||||
|
@using BimAI.UI.Shared.Components
|
||||||
|
|
||||||
|
<PageTitle>Faktury</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.ExtraExtraLarge">
|
||||||
|
<InvoiceListComponent />
|
||||||
|
</MudContainer>
|
||||||
73
BimAI.UI.Shared/Services/InvoiceService.cs
Normal file
73
BimAI.UI.Shared/Services/InvoiceService.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using BimAI.Application.DTOModels;
|
||||||
|
using BimAI.Application.DTOModels.Common;
|
||||||
|
using Microsoft.AspNetCore.WebUtilities;
|
||||||
|
|
||||||
|
namespace BimAI.UI.Shared.Services;
|
||||||
|
|
||||||
|
public class InvoiceService(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
private readonly HttpClient _httpClient = httpClient;
|
||||||
|
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task<PagedResult<InvoiceDto>> GetInvoiceAsync(InvoiceFilterRequest request)
|
||||||
|
{
|
||||||
|
var queryParams = new Dictionary<string, string?>
|
||||||
|
{
|
||||||
|
["page"] = request.Page.ToString(),
|
||||||
|
["pageSize"] = request.PageSize.ToString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Search))
|
||||||
|
{
|
||||||
|
queryParams["search"] = request.Search;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.ClientName))
|
||||||
|
{
|
||||||
|
queryParams["clientName"] = request.ClientName;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.Type))
|
||||||
|
{
|
||||||
|
queryParams["type"] = request.Type;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.DocumentNo))
|
||||||
|
{
|
||||||
|
queryParams["documentNo"] = request.DocumentNo;
|
||||||
|
}
|
||||||
|
if (request.RegisterDateFrom.HasValue)
|
||||||
|
{
|
||||||
|
queryParams["registerDateFrom"] = request.RegisterDateFrom.Value.ToString("yyyy-MM-dd");;
|
||||||
|
}
|
||||||
|
if (request.RegisterDateTo.HasValue)
|
||||||
|
{
|
||||||
|
queryParams["registerDateTo"] = request.RegisterDateTo.Value.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
if (request.SellDateFrom.HasValue)
|
||||||
|
{
|
||||||
|
queryParams["sellDateFrom"] = request.SellDateFrom.Value.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
if (request.SellDateTo.HasValue)
|
||||||
|
{
|
||||||
|
queryParams["sellDateTo"] = request.SellDateTo.Value.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
var uri = QueryHelpers.AddQueryString("api/invoice", queryParams);
|
||||||
|
|
||||||
|
var response = await _httpClient.GetAsync(uri);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var errorContent = await response.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var json = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
var result = JsonSerializer.Deserialize<PagedResult<InvoiceDto>>(json, _jsonOptions);
|
||||||
|
|
||||||
|
return result ?? new PagedResult<InvoiceDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
@using System.Net.Http
|
@using System.Net.Http
|
||||||
@using System.Net.Http.Json
|
@using System.Net.Http.Json
|
||||||
@using Microsoft.AspNetCore.Components.Forms
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
@using Microsoft.AspNetCore.Components.Web
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
@using BimAI.UI.Shared
|
@using BimAI.UI.Shared
|
||||||
@using MudBlazor@using BimAI.Application.DTOModels
|
@using MudBlazor@using BimAI.Application.DTOModels
|
||||||
@using BimAI.Application.DTOModels.Common
|
@using BimAI.Application.DTOModels.Common
|
||||||
@using BimAI.UI.Shared.Components
|
@using BimAI.UI.Shared.Components
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ async function handleAuthError(error, context = '') {
|
|||||||
const errorMessage = error?.message || error?.type || error?.toString() || 'Unknown error';
|
const errorMessage = error?.message || error?.type || error?.toString() || 'Unknown error';
|
||||||
const fullError = `${context}: ${errorMessage}`;
|
const fullError = `${context}: ${errorMessage}`;
|
||||||
console.error('Google Auth Error:', { context, error, fullError });
|
console.error('Google Auth Error:', { context, error, fullError });
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError', fullError);
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError', fullError);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUserInfo(accessToken) {
|
async function fetchUserInfo(accessToken) {
|
||||||
@@ -39,7 +39,7 @@ async function fetchUserInfo(accessToken) {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorText = await response.text();
|
const errorText = await response.text();
|
||||||
console.error('Failed to fetch user info:', errorText);
|
console.error('Failed to fetch user info:', errorText);
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
|
||||||
`Failed to fetch user info: HTTP ${response.status}`);
|
`Failed to fetch user info: HTTP ${response.status}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ window.initGoogleSignIn = async function(clientId) {
|
|||||||
try {
|
try {
|
||||||
if (tokenResponse.error) {
|
if (tokenResponse.error) {
|
||||||
console.error('Token response error:', tokenResponse.error);
|
console.error('Token response error:', tokenResponse.error);
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
|
||||||
tokenResponse.error);
|
tokenResponse.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ window.initGoogleSignIn = async function(clientId) {
|
|||||||
const userInfo = await fetchUserInfo(tokenResponse.access_token);
|
const userInfo = await fetchUserInfo(tokenResponse.access_token);
|
||||||
if (!userInfo) return;
|
if (!userInfo) return;
|
||||||
|
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInSuccess',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInSuccess',
|
||||||
tokenResponse.access_token,
|
tokenResponse.access_token,
|
||||||
userInfo.name || '',
|
userInfo.name || '',
|
||||||
userInfo.email || '',
|
userInfo.email || '',
|
||||||
@@ -78,7 +78,7 @@ window.initGoogleSignIn = async function(clientId) {
|
|||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Callback error:', error);
|
console.error('Callback error:', error);
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
|
||||||
error.message || 'Unknown callback error');
|
error.message || 'Unknown callback error');
|
||||||
} finally {
|
} finally {
|
||||||
isSigningIn = false;
|
isSigningIn = false;
|
||||||
@@ -86,7 +86,7 @@ window.initGoogleSignIn = async function(clientId) {
|
|||||||
},
|
},
|
||||||
error_callback: async (error) => {
|
error_callback: async (error) => {
|
||||||
console.error('OAuth flow error:', error);
|
console.error('OAuth flow error:', error);
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
|
||||||
error.type || 'OAuth flow error');
|
error.type || 'OAuth flow error');
|
||||||
isSigningIn = false;
|
isSigningIn = false;
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ window.initGoogleSignIn = async function(clientId) {
|
|||||||
return googleClient;
|
return googleClient;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Initiaxcrun xctrace list deviceslization error:', error);
|
console.error('Initiaxcrun xctrace list deviceslization error:', error);
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
|
||||||
error.message || 'Failed to initialize Google Sign-In');
|
error.message || 'Failed to initialize Google Sign-In');
|
||||||
isSigningIn = false;
|
isSigningIn = false;
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ window.requestGoogleSignIn = async function() {
|
|||||||
|
|
||||||
if (!googleClient) {
|
if (!googleClient) {
|
||||||
console.error('Google Sign-In not initialized');
|
console.error('Google Sign-In not initialized');
|
||||||
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
|
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
|
||||||
'Google Sign-In not initialized. Call initGoogleSignIn first.');
|
'Google Sign-In not initialized. Call initGoogleSignIn first.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Stage 1: Build
|
# Stage 1: Build
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Copy solution and all project files for restore
|
# Copy solution and all project files for restore
|
||||||
@@ -20,9 +20,12 @@ WORKDIR /src/BimAI.UI.Web
|
|||||||
RUN dotnet publish -c Release -o /app/publish --no-restore
|
RUN dotnet publish -c Release -o /app/publish --no-restore
|
||||||
|
|
||||||
# Stage 2: Runtime
|
# Stage 2: Runtime
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install wget for health checks
|
||||||
|
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set timezone
|
# Set timezone
|
||||||
ENV TZ=Europe/Warsaw
|
ENV TZ=Europe/Warsaw
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|||||||
@@ -11,13 +11,14 @@ builder.Services.AddRazorComponents()
|
|||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents();
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices();
|
||||||
|
|
||||||
builder.Services.AddSharedServices("http://localhost:7142");
|
var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"]
|
||||||
|
?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured");
|
||||||
|
builder.Services.AddSharedServices(apiBaseUrl);
|
||||||
|
|
||||||
builder.Services.AddSingleton<IScannerService, NoOpScannerService>();
|
builder.Services.AddSingleton<IScannerService, NoOpScannerService>();
|
||||||
builder.Services.AddScoped<AuthService>();
|
builder.Services.AddScoped<AuthService>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
|
|||||||
Binary file not shown.
@@ -1,16 +1,9 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"ApiSettings": {
|
|
||||||
"BaseUrl": "#{api-base-url}#"
|
|
||||||
},
|
|
||||||
"GoogleAuth": {
|
"GoogleAuth": {
|
||||||
"ClientId": "#{google-auth-client-id}#"
|
"ClientId": ""
|
||||||
|
},
|
||||||
|
"ApiSettings": {
|
||||||
|
"BaseUrl": ""
|
||||||
},
|
},
|
||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
@@ -19,4 +12,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
BimAI.UI.Web/appsettings.json
Normal file
9
BimAI.UI.Web/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
114
BimAI.sln
114
BimAI.sln
@@ -1,58 +1,56 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.0.31903.59
|
VisualStudioVersion = 17.0.31903.59
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Domain", "BimAI.Domain\BimAI.Domain.csproj", "{190E3B1F-C91F-430F-BE32-4E7221574D36}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Domain", "BimAI.Domain\BimAI.Domain.csproj", "{190E3B1F-C91F-430F-BE32-4E7221574D36}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Application", "BimAI.Application\BimAI.Application.csproj", "{2E61A11C-851F-47D6-A8B6-329078CF1AFC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Application", "BimAI.Application\BimAI.Application.csproj", "{2E61A11C-851F-47D6-A8B6-329078CF1AFC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Infrastructure", "BimAI.Infrastructure\BimAI.Infrastructure.csproj", "{1049E8B5-6965-4CCD-A989-88E44D40BF48}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Infrastructure", "BimAI.Infrastructure\BimAI.Infrastructure.csproj", "{1049E8B5-6965-4CCD-A989-88E44D40BF48}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.API", "BimAI.API\BimAI.API.csproj", "{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.API", "BimAI.API\BimAI.API.csproj", "{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Shared", "BimAI.UI.Shared\BimAI.UI.Shared.csproj", "{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Shared", "BimAI.UI.Shared\BimAI.UI.Shared.csproj", "{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Web", "BimAI.UI.Web\BimAI.UI.Web.csproj", "{7ACBFE74-E72C-4033-9172-30512233A518}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Web", "BimAI.UI.Web\BimAI.UI.Web.csproj", "{7ACBFE74-E72C-4033-9172-30512233A518}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Mobile", "BimAI.UI.Mobile\BimAI.UI.Mobile.csproj", "{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Mobile", "BimAI.UI.Mobile\BimAI.UI.Mobile.csproj", "{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.Build.0 = Release|Any CPU
|
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
EndGlobalSection
|
||||||
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Release|Any CPU.Build.0 = Release|Any CPU
|
EndGlobal
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
services:
|
|
||||||
mssql:
|
|
||||||
image: mcr.microsoft.com/mssql/server:2022-latest
|
|
||||||
container_name: bimai-mssql
|
|
||||||
hostname: bimai-mssql
|
|
||||||
environment:
|
|
||||||
- ACCEPT_EULA=Y
|
|
||||||
- SA_PASSWORD=BimAI_Dev_Pass_2024!
|
|
||||||
- MSSQL_PID=Developer
|
|
||||||
ports:
|
|
||||||
- "1433:1433"
|
|
||||||
volumes:
|
|
||||||
- mssql-data:/var/opt/mssql
|
|
||||||
- ./docker/mssql/init:/docker-entrypoint-initdb.d
|
|
||||||
networks:
|
|
||||||
- bimai-network
|
|
||||||
healthcheck:
|
|
||||||
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "BimAI_Dev_Pass_2024!" -Q "SELECT 1" || exit 1
|
|
||||||
interval: 10s
|
|
||||||
timeout: 3s
|
|
||||||
retries: 10
|
|
||||||
start_period: 10s
|
|
||||||
|
|
||||||
mongodb:
|
|
||||||
image: mongo:7.0
|
|
||||||
container_name: bimai-mongodb
|
|
||||||
hostname: bimai-mongodb
|
|
||||||
environment:
|
|
||||||
- MONGO_INITDB_ROOT_USERNAME=admin
|
|
||||||
- MONGO_INITDB_ROOT_PASSWORD=BimAI_Mongo_2024!
|
|
||||||
- MONGO_INITDB_DATABASE=bimai
|
|
||||||
ports:
|
|
||||||
- "27017:27017"
|
|
||||||
volumes:
|
|
||||||
- mongodb-data:/data/db
|
|
||||||
- mongodb-config:/data/configdb
|
|
||||||
- ./docker/mongodb/init:/docker-entrypoint-initdb.d
|
|
||||||
networks:
|
|
||||||
- bimai-network
|
|
||||||
healthcheck:
|
|
||||||
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
start_period: 10s
|
|
||||||
|
|
||||||
networks:
|
|
||||||
bimai-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mssql-data:
|
|
||||||
name: bimai-mssql-data
|
|
||||||
mongodb-data:
|
|
||||||
name: bimai-mongodb-data
|
|
||||||
mongodb-config:
|
|
||||||
name: bimai-mongodb-config
|
|
||||||
Reference in New Issue
Block a user