Compare commits
No commits in common. "9c298c6e76545b171215f9ab2fd3ad56ad22cb31" and "d3c0737bfe7f125ee43a947d67844e149c6fb8e0" have entirely different histories.
9c298c6e76
...
d3c0737bfe
|
@ -1,48 +0,0 @@
|
||||||
using DataAccess.DbAccess;
|
|
||||||
using DataAccess.Models;
|
|
||||||
|
|
||||||
namespace DataAccess.Data;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ermöglicht den Zugriff auf die BildInfo Datenbank.
|
|
||||||
/// </summary>
|
|
||||||
public class BildInfoData
|
|
||||||
{
|
|
||||||
private readonly ISqlDataAccess _db;
|
|
||||||
|
|
||||||
public BildInfoData(ISqlDataAccess db)
|
|
||||||
{
|
|
||||||
_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fügt die gegebene BildInfo zur Datenbank hinzu und aktualisiert das <see cref="BildInfoModel.Id"/>-Feld mit dem entsprechenden Wert.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="bildInfo">Die BildInfo, die zur Datenbank hinzugefügt werden soll.</param>
|
|
||||||
public async Task AddBildInfoAsync(BildInfoModel bildInfo)
|
|
||||||
{
|
|
||||||
var id = await _db.LoadData<int, BildInfoModel>("dbo.spBildInfo_Insert", bildInfo);
|
|
||||||
bildInfo.Id = id.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Aktualisiert das Dateiname-Feld der übergebenen BildInfo in der Datenbank.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="bildInfo">Die BildInfo deren Dateiname aktualisiert werden soll.</param>
|
|
||||||
public Task UpdateBildInfoDateinameAsync(BildInfoModel bildInfo)
|
|
||||||
{
|
|
||||||
return _db.SaveData("dbo.spBildInfo_UpdateFileName",
|
|
||||||
new {
|
|
||||||
Id = bildInfo.Id,
|
|
||||||
Dateiname = bildInfo.Dateiname,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gibt alle Bild Infos der Datenbank zurück.
|
|
||||||
/// </summary>
|
|
||||||
public Task<IEnumerable<BildInfoModel>> GetAllBildInfosAsync()
|
|
||||||
{
|
|
||||||
return _db.LoadData<BildInfoModel, dynamic>("dbo.spBildInfo_GetAll", new { });
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using DataAccess.DbAccess;
|
|
||||||
using DataAccess.Models;
|
|
||||||
|
|
||||||
namespace DataAccess.Data;
|
|
||||||
|
|
||||||
public class WunschInfoData
|
|
||||||
{
|
|
||||||
private readonly ISqlDataAccess _db;
|
|
||||||
|
|
||||||
public WunschInfoData(ISqlDataAccess db)
|
|
||||||
{
|
|
||||||
_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task AddWunschInfoAsync(WunschInfoModel wunschInfo)
|
|
||||||
{
|
|
||||||
var id = await _db.LoadData<int, WunschInfoModel>("dbo.spWunschInfo_Insert", wunschInfo);
|
|
||||||
wunschInfo.Id = id.Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gibt die WunschInfo mit der gegebenen Id zurück.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="wunschId">Die Id der zu ladenen WunschInfo</param>
|
|
||||||
/// <returns>Die WunschInfo mit der gegebenen Id</returns>
|
|
||||||
public async Task<WunschInfoModel> GetWunschInfoAsync(int wunschId)
|
|
||||||
{
|
|
||||||
var wunschInfo = await _db.LoadData<WunschInfoModel, dynamic>("dbo.spWunschInfo_Get", new { Id = wunschId });
|
|
||||||
return wunschInfo.Single();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Dapper" Version="2.1.4" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,26 +0,0 @@
|
||||||
namespace DataAccess.DbAccess;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bietet lesenden und schreibenden Zugriff auf eine Datenbank.
|
|
||||||
/// </summary>
|
|
||||||
public interface ISqlDataAccess
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Führt die angegebene Stored Procedure aus. Diese Prozedur nimmt Parameter des Typs <see cref="TParameter"/> engegen und gibt ein Enumerable des Typs <see cref="TResult"/> zurück.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TResult">Der Typ der Parameter</typeparam>
|
|
||||||
/// <typeparam name="TParameter">Der Typ der Rückgabewerte</typeparam>
|
|
||||||
/// <param name="storedProcedure">Der Name der Prozedur</param>
|
|
||||||
/// <param name="parameters">Die Parameter für die Prozedur.</param>
|
|
||||||
/// <param name="connectionId">Die optionale Id des zu verwendenen Connection Strings.</param>
|
|
||||||
Task<IEnumerable<TResult>> LoadData<TResult, TParameter>(string storedProcedure, TParameter parameters, string connectionId = "Default");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Führt die angegebene Stored Procedure aus. Diese Prozedur nimmt Parameter des Typs <see cref="TParameter"/> engegen und gibt nichts zurück.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TParameter">Der Typ der Parameter</typeparam>
|
|
||||||
/// <param name="storedProcedure">Der Name der Prozedur</param>
|
|
||||||
/// <param name="parameters">Die Parameter für die Prozedur.</param>
|
|
||||||
/// <param name="connectionId">Die optionale Id des zu verwendenen Connection Strings.</param>
|
|
||||||
Task SaveData<TParameter>(string storedProcedure, TParameter parameters, string connectionId = "Default");
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Data;
|
|
||||||
using Dapper;
|
|
||||||
|
|
||||||
namespace DataAccess.DbAccess;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bietet lesenden und schreibenden Zugriff auf eine Datenbank.
|
|
||||||
/// </summary>
|
|
||||||
public class SqlDataAccess : ISqlDataAccess
|
|
||||||
{
|
|
||||||
private readonly IConfiguration _config;
|
|
||||||
|
|
||||||
public SqlDataAccess(IConfiguration config)
|
|
||||||
{
|
|
||||||
_config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<TResult>> LoadData<TResult, TParameter>(string storedProcedure, TParameter parameters, string connectionId = "Default")
|
|
||||||
{
|
|
||||||
using IDbConnection connection = new SqlConnection(_config.GetConnectionString(connectionId));
|
|
||||||
|
|
||||||
return await connection.QueryAsync<TResult>(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SaveData<TParameter>(string storedProcedure, TParameter parameters, string connectionId = "Default")
|
|
||||||
{
|
|
||||||
using IDbConnection connection = new SqlConnection(_config.GetConnectionString(connectionId));
|
|
||||||
|
|
||||||
await connection.ExecuteAsync(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
namespace DataAccess.Models;
|
|
||||||
|
|
||||||
public class BildInfoModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public DateTime Datum { get; set; }
|
|
||||||
public string Dateiname { get; set; }
|
|
||||||
public string ImageModel { get; set; }
|
|
||||||
public int WunschId { get; set; }
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
namespace DataAccess.Models;
|
|
||||||
|
|
||||||
public class WunschInfoModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string BildPrompt { get; set; }
|
|
||||||
public string Wunsch { get; set; }
|
|
||||||
public string BildBeschreibung { get; set; }
|
|
||||||
public DateTime Datum { get; set; }
|
|
||||||
public string GPTModel { get; set; }
|
|
||||||
}
|
|
|
@ -5,10 +5,6 @@ VisualStudioVersion = 17.6.33829.357
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KIKunstKirstenKlöckner", "KIKunstKirstenKlöckner\KIKunstKirstenKlöckner.csproj", "{0085541E-50D4-42A5-9BFD-6CE402FB8B26}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KIKunstKirstenKlöckner", "KIKunstKirstenKlöckner\KIKunstKirstenKlöckner.csproj", "{0085541E-50D4-42A5-9BFD-6CE402FB8B26}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "KiKunstDatenbank", "KiKunstDatenbank\KiKunstDatenbank.sqlproj", "{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "DataAccess\DataAccess.csproj", "{0880FD07-236B-42C1-9CA3-2A6F695A623C}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -19,16 +15,6 @@ Global
|
||||||
{0085541E-50D4-42A5-9BFD-6CE402FB8B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0085541E-50D4-42A5-9BFD-6CE402FB8B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0085541E-50D4-42A5-9BFD-6CE402FB8B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0085541E-50D4-42A5-9BFD-6CE402FB8B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0085541E-50D4-42A5-9BFD-6CE402FB8B26}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0085541E-50D4-42A5-9BFD-6CE402FB8B26}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
|
||||||
{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{A19CD19A-FE5B-4D4E-896B-DCC43B45F734}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
|
||||||
{0880FD07-236B-42C1-9CA3-2A6F695A623C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0880FD07-236B-42C1-9CA3-2A6F695A623C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0880FD07-236B-42C1-9CA3-2A6F695A623C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0880FD07-236B-42C1-9CA3-2A6F695A623C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"version": 1,
|
|
||||||
"isRoot": true,
|
|
||||||
"tools": {
|
|
||||||
"dotnet-ef": {
|
|
||||||
"version": "7.0.9",
|
|
||||||
"commands": [
|
|
||||||
"dotnet-ef"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,8 +20,4 @@
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\DataAccess\DataAccess.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -4,16 +4,11 @@
|
||||||
@using OpenAI_API.Chat
|
@using OpenAI_API.Chat
|
||||||
@using OpenAI_API.Models
|
@using OpenAI_API.Models
|
||||||
@using System.Diagnostics
|
@using System.Diagnostics
|
||||||
@using DataAccess.Data
|
|
||||||
@using DataAccess.Models
|
|
||||||
|
|
||||||
@inject IConfiguration Config
|
@inject IConfiguration Config
|
||||||
@inject TooltipService TooltipService
|
@inject TooltipService TooltipService
|
||||||
@inject DialogService DialogService
|
@inject DialogService DialogService
|
||||||
|
|
||||||
@inject BildInfoData BildInfoData;
|
|
||||||
@inject WunschInfoData WunschInfoData;
|
|
||||||
|
|
||||||
<PageTitle>AiArt</PageTitle>
|
<PageTitle>AiArt</PageTitle>
|
||||||
|
|
||||||
<section class="about_section layout_padding" style="background-image: url('images/5KeineAngstvorFehlern2014.jpeg'); background-size: cover; background-repeat: no-repeat; background-blend-mode:lighten">
|
<section class="about_section layout_padding" style="background-image: url('images/5KeineAngstvorFehlern2014.jpeg'); background-size: cover; background-repeat: no-repeat; background-blend-mode:lighten">
|
||||||
|
@ -249,7 +244,7 @@
|
||||||
private string _inferenceApiKey = "";
|
private string _inferenceApiKey = "";
|
||||||
private string _openAiApiKey = "";
|
private string _openAiApiKey = "";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_inferenceApiKey = Config.GetValue<string>("API:HF_Inference");
|
_inferenceApiKey = Config.GetValue<string>("API:HF_Inference");
|
||||||
_openAiApiKey = Config.GetValue<string>("API:OpenAI");
|
_openAiApiKey = Config.GetValue<string>("API:OpenAI");
|
||||||
|
@ -263,37 +258,74 @@
|
||||||
_client.DefaultRequestHeaders.Clear();
|
_client.DefaultRequestHeaders.Clear();
|
||||||
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_inferenceApiKey}");
|
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_inferenceApiKey}");
|
||||||
|
|
||||||
|
return base.OnInitializedAsync();
|
||||||
// BildInfoModel bildInfo = new()
|
|
||||||
// {
|
|
||||||
// BildBeschreibung = "Test",
|
|
||||||
// BildPrompt = "Tost",
|
|
||||||
// Dateiname = "Task",
|
|
||||||
// Datum = DateTime.Now,
|
|
||||||
// GPTModel = "Geht dich nichts an",
|
|
||||||
// ImageModel = "Jup",
|
|
||||||
// Wunsch = request
|
|
||||||
// };
|
|
||||||
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
|
|
||||||
// //await BildInfoData.AddBildInfo(bildInfo);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// catch (Exception e)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine(e);
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Geneiert das Bild für den aktuellen <see cref="_imagePrompt"/>
|
/// Geneiert das Bild für den aktuellen <see cref="_imagePrompt"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string?> GenerateImageAsync(string prompt, WunschInfoModel wunschInfo, bool isRetry = false)
|
public async Task GenerateImageAsync()
|
||||||
|
{
|
||||||
|
var postData = new
|
||||||
|
{
|
||||||
|
inputs = _imagePrompt
|
||||||
|
};
|
||||||
|
|
||||||
|
JsonContent content = JsonContent.Create(postData);
|
||||||
|
|
||||||
|
async Task FailedToDrawImage()
|
||||||
|
{
|
||||||
|
bool? retry = await DialogService.Confirm("Leider konnte das Bild nicht gemalt werden. Möchtest du es noch eimal versuchen?", "Ups, ein Fehler ist aufgetreten...",
|
||||||
|
new ConfirmOptions { OkButtonText = "Ja", CancelButtonText = "Nein" });
|
||||||
|
|
||||||
|
if (retry == true)
|
||||||
|
await GenerateImageAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var inferenceModelUrl = "https://api-inference.huggingface.co/models/Nacken/kkkk-sdxl-5000";
|
||||||
|
|
||||||
|
var response = await _client.PostAsync(inferenceModelUrl, content);
|
||||||
|
|
||||||
|
if (response?.IsSuccessStatusCode == true)
|
||||||
|
{
|
||||||
|
await using Stream imageStream = await response.Content.ReadAsStreamAsync();
|
||||||
|
|
||||||
|
using Image image = await Image.LoadAsync(imageStream);
|
||||||
|
|
||||||
|
string imgUrl = $"generated_images/{DateTime.Now:dd_MM_yyyy_hh_mm_s}.jpg";
|
||||||
|
|
||||||
|
string mapPath = $"./wwwroot/{imgUrl}";
|
||||||
|
await image.SaveAsJpegAsync(mapPath);
|
||||||
|
|
||||||
|
_imageUrl = imgUrl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Image conversion failed: {response}");
|
||||||
|
|
||||||
|
if (Debugger.IsAttached)
|
||||||
|
Debugger.Break();
|
||||||
|
|
||||||
|
await FailedToDrawImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Image request failed: {exception}");
|
||||||
|
|
||||||
|
if (Debugger.IsAttached)
|
||||||
|
Debugger.Break();
|
||||||
|
|
||||||
|
await FailedToDrawImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Geneiert das Bild für den aktuellen <see cref="_imagePrompt"/>
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string?> GenerateImageAsync(string prompt, bool isRetry = false)
|
||||||
{
|
{
|
||||||
var postData = new
|
var postData = new
|
||||||
{
|
{
|
||||||
|
@ -322,7 +354,7 @@
|
||||||
|
|
||||||
if (retry == true)
|
if (retry == true)
|
||||||
{
|
{
|
||||||
return await GenerateImageAsync(prompt, wunschInfo, true);
|
return await GenerateImageAsync(prompt, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -330,9 +362,7 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const string modelName = "Nacken/kkkk-sdxl-5000";
|
var inferenceModelUrl = "https://api-inference.huggingface.co/models/Nacken/kkkk-sdxl-5000";
|
||||||
|
|
||||||
var inferenceModelUrl = $"https://api-inference.huggingface.co/models/{modelName}";
|
|
||||||
|
|
||||||
var response = await _client.PostAsync(inferenceModelUrl, content);
|
var response = await _client.PostAsync(inferenceModelUrl, content);
|
||||||
|
|
||||||
|
@ -342,25 +372,16 @@
|
||||||
|
|
||||||
using Image image = await Image.LoadAsync(imageStream);
|
using Image image = await Image.LoadAsync(imageStream);
|
||||||
|
|
||||||
DateTime imageDate = DateTime.Now;
|
string imgUrl = $"generated_images/{DateTime.Now:dd_MM_yyyy_hh_mm_s_fffffff}.jpg";
|
||||||
|
|
||||||
BildInfoModel bildInfo = new()
|
|
||||||
{
|
|
||||||
Dateiname = "PlaceHolder",
|
|
||||||
Datum = imageDate,
|
|
||||||
ImageModel = modelName,
|
|
||||||
WunschId = wunschInfo.Id
|
|
||||||
};
|
|
||||||
|
|
||||||
await BildInfoData.AddBildInfoAsync(bildInfo);
|
|
||||||
|
|
||||||
string imgUrl = $"generated_images/Image_{bildInfo.Id}.jpg";
|
|
||||||
|
|
||||||
string mapPath = $"./wwwroot/{imgUrl}";
|
string mapPath = $"./wwwroot/{imgUrl}";
|
||||||
await image.SaveAsJpegAsync(mapPath);
|
await image.SaveAsJpegAsync(mapPath);
|
||||||
|
|
||||||
bildInfo.Dateiname = imgUrl;
|
// Hier speichern wir die Daten in die 'info_texts.txt'-Datei
|
||||||
await BildInfoData.UpdateBildInfoDateinameAsync(bildInfo);
|
string infoTextsPath = Path.Combine(_environment.WebRootPath, "generated_images", "info_texts.txt");
|
||||||
|
string desc = _imageDescription.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
|
||||||
|
string newLine = $"{imgUrl}: {request}, {desc}\n";
|
||||||
|
await File.AppendAllTextAsync(infoTextsPath, newLine);
|
||||||
|
|
||||||
return imgUrl;
|
return imgUrl;
|
||||||
}
|
}
|
||||||
|
@ -443,22 +464,10 @@
|
||||||
|
|
||||||
await UpdateBusyMessage("Kirstens Assistent hat eine Idee! Er wird sie nun malen...");
|
await UpdateBusyMessage("Kirstens Assistent hat eine Idee! Er wird sie nun malen...");
|
||||||
|
|
||||||
WunschInfoModel wunschInfo = new()
|
|
||||||
{
|
|
||||||
BildBeschreibung = _imageDescription,
|
|
||||||
BildPrompt = _imagePrompt,
|
|
||||||
Datum = DateTime.Now,
|
|
||||||
GPTModel = converse.Model,
|
|
||||||
Wunsch = request
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: Try
|
|
||||||
await WunschInfoData.AddWunschInfoAsync(wunschInfo);
|
|
||||||
|
|
||||||
// Vier Bilder generieren
|
// Vier Bilder generieren
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
_imageUrls[i] = await GenerateImageAsync(_imagePrompt, wunschInfo);
|
_imageUrls[i] = await GenerateImageAsync(_imagePrompt);
|
||||||
_imageStates[i] = ImageState.FadeIn;
|
_imageStates[i] = ImageState.FadeIn;
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,70 +1,150 @@
|
||||||
@page "/gallery"
|
@page "/gallery"
|
||||||
|
|
||||||
@using DataAccess.Data
|
|
||||||
@using DataAccess.Models
|
|
||||||
|
|
||||||
@inject DialogService DialogService;
|
|
||||||
@inject BildInfoData BildInfoData;
|
|
||||||
@inject WunschInfoData WunschInfoData;
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.small-image {
|
.image-grid {
|
||||||
width: 10em;
|
background-color: white; /* Hintergrund der RadzenDataList weiß machen */
|
||||||
height: 10em;
|
|
||||||
z-index: auto;
|
|
||||||
margin: 0.5em;
|
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
||||||
border-radius: 1em;
|
|
||||||
/* Gibt an, dass Änderungen an der transform-Eigenschaft innerhalb von 0.2s angewandt werden.*/
|
|
||||||
transition: transform 0.2s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Style, der angewendet wird, wenn über small-image gehovert wird. */
|
.rz-data-list {
|
||||||
.small-image:hover {
|
display: flex;
|
||||||
transform: scale(1.1, 1.1);
|
flex-wrap: wrap;
|
||||||
z-index: 100;
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-grid-item {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-popup {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(255, 255, 255, 0.9); /* Weißer Hintergrund mit Transparenz */
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-popup-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
max-width: 800px;
|
||||||
|
max-height: 400px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: white; /* Weißer Hintergrund für den Inhalt */
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-button {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<RadzenDataList WrapItems="@true" AllowPaging="true" PageSize="40" Data="@_bildInfos" PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true">
|
<div>
|
||||||
<Template Context="bildInfo">
|
<RadzenDataList WrapItems="@true" AllowPaging="true" Data="@imagePaths" PageSize="20" PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true" class="image-grid">
|
||||||
<RadzenImage class="small-image" Src="@bildInfo.Dateiname" Click="@(args => ShowImageDialog(bildInfo))" />
|
<Template Context="imagePath">
|
||||||
</Template>
|
<div class="image-grid-item">
|
||||||
</RadzenDataList>
|
<RadzenCard Style="width: 200px; height: 200px; padding: 0; border: none;">
|
||||||
|
<RadzenButton Click="@(args => ShowImageInfo(imagePath))">
|
||||||
|
<RadzenImage Src="@imagePath" Style="width: 100%; height: 100%; object-fit: cover;" />
|
||||||
|
</RadzenButton>
|
||||||
|
</RadzenCard>
|
||||||
|
</div>
|
||||||
|
</Template>
|
||||||
|
</RadzenDataList>
|
||||||
|
|
||||||
|
<div class="image-popup" style="@popupStyle">
|
||||||
|
<div class="image-popup-content">
|
||||||
|
<div class="image-info">
|
||||||
|
<RadzenImage Src="@selectedImage" Style="max-width: 100%; max-height: 300px; object-fit: contain;" />
|
||||||
|
<p>@infoText</p>
|
||||||
|
</div>
|
||||||
|
<div class="close-button">
|
||||||
|
<RadzenButton Text="Close" Click="CloseImageInfo" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
IEnumerable<BildInfoModel>? _bildInfos;
|
List<string> imagePaths = new List<string>();
|
||||||
|
string selectedImage;
|
||||||
|
string infoText = "Info Text";
|
||||||
|
string popupStyle = "display: none;";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_bildInfos = await BildInfoData.GetAllBildInfosAsync();
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
|
// Get the physical path to the folder
|
||||||
|
string folderPath = Path.Combine(_environment.WebRootPath, "generated_images");
|
||||||
|
|
||||||
|
if (Directory.Exists(folderPath))
|
||||||
|
{
|
||||||
|
// Load the image file names from the folder
|
||||||
|
var imageFiles = Directory.GetFiles(folderPath, "*.jpg");
|
||||||
|
|
||||||
|
// Get the relative paths to the images
|
||||||
|
imagePaths = imageFiles.Select(file => file.Replace(_environment.WebRootPath, "").Replace("\\", "/")).ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task ShowImageDialog(BildInfoModel bildInfo)
|
private async void ShowImageInfo(string imagePath)
|
||||||
{
|
{
|
||||||
WunschInfoModel wunschInfo = await WunschInfoData.GetWunschInfoAsync(bildInfo.WunschId);
|
selectedImage = imagePath;
|
||||||
|
popupStyle = "display: block;";
|
||||||
|
infoText = await GetInfoTextForImageAsync(imagePath);
|
||||||
|
}
|
||||||
|
|
||||||
List<BildInfoModel> bilderVomWunsch = _bildInfos!.Where(info => info.WunschId == wunschInfo.Id).ToList();
|
|
||||||
|
|
||||||
var result = await DialogService.OpenAsync(wunschInfo.Wunsch, ds =>
|
private async Task<string> GetInfoTextForImageAsync(string imagePath)
|
||||||
@<div>
|
{
|
||||||
<RadzenStack Orientation="Orientation.Horizontal" Wrap="FlexWrap.Wrap">
|
// Bestimme den Ordnerpfad, in dem sich die Bilder und die info_texts.txt Datei befinden
|
||||||
<RadzenStack Orientation="Orientation.Horizontal">
|
string folderPath = Path.Combine(_environment.WebRootPath, "generated_images");
|
||||||
<RadzenStack Orientation="Orientation.Vertical">
|
|
||||||
<RadzenImage Style="width: 400px; height: 400px;" Path="@bildInfo.Dateiname" />
|
// Bestimme den Pfad zur info_texts.txt Datei
|
||||||
</RadzenStack>
|
string infoTextsFilePath = Path.Combine(folderPath, "info_texts.txt");
|
||||||
<RadzenText Text="@wunschInfo.BildBeschreibung"/>
|
|
||||||
</RadzenStack>
|
// Überprüfe, ob die Datei existiert
|
||||||
@foreach (var bild in bilderVomWunsch)
|
if (!File.Exists(infoTextsFilePath))
|
||||||
{
|
return $"Kein Infotext für {imagePath} gefunden.";
|
||||||
<RadzenImage class="small-image" Path="@bild.Dateiname"
|
|
||||||
Click="async () => { bildInfo = bild; DialogService.Close(); await ShowImageDialog(bild); }" />
|
// Lies alle Zeilen der Datei
|
||||||
}
|
var lines = await File.ReadAllLinesAsync(infoTextsFilePath);
|
||||||
</RadzenStack>
|
string adaptedImagePath = imagePath.Substring(1) + ":";
|
||||||
</div>,
|
|
||||||
new DialogOptions() { CloseDialogOnOverlayClick = true, Width = "50%" });
|
// Durchsuche jede Zeile nach dem gegebenen imagePath
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
if (line.StartsWith(adaptedImagePath)) // Überprüft, ob die Zeile mit dem Dateinamen des Bildes beginnt
|
||||||
|
{
|
||||||
|
// Trenne den Dateinamen und den Infotext und gib den Infotext zurück
|
||||||
|
return line.Split(new[] { ':' }, 2).LastOrDefault()?.Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"Kein Infotext für {imagePath} gefunden.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseImageInfo()
|
||||||
|
{
|
||||||
|
popupStyle = "display: none;";
|
||||||
}
|
}
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
using DataAccess.Data;
|
|
||||||
using DataAccess.DbAccess;
|
|
||||||
using Radzen;
|
using Radzen;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
@ -10,9 +8,6 @@ builder.Services.AddServerSideBlazor();
|
||||||
builder.Services.AddScoped<TooltipService>();
|
builder.Services.AddScoped<TooltipService>();
|
||||||
builder.Services.AddScoped<DialogService>();
|
builder.Services.AddScoped<DialogService>();
|
||||||
builder.Services.AddScoped<NotificationService>();
|
builder.Services.AddScoped<NotificationService>();
|
||||||
builder.Services.AddSingleton<ISqlDataAccess, SqlDataAccess>();
|
|
||||||
builder.Services.AddSingleton<BildInfoData>();
|
|
||||||
builder.Services.AddSingleton<WunschInfoData>();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<span class="nav-link">Über Kirsten Klöckner</span>
|
<span class="nav-link">Über Kirsten Klöckner</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
<NavLink class="nav-item" href="gallery" Match="NavLinkMatch.All">
|
<NavLink class="nav-item" href="gallery" Match="NavLinkMatch.All">
|
||||||
<span class="nav-link">Galerie</span>
|
<span class="nav-link">Galerier</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
{
|
{
|
||||||
"DetailedErrors": true,
|
"DetailedErrors": true,
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
|
||||||
},
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"Default": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=KiKunstDatenbank;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,5 @@
|
||||||
"API": {
|
"API": {
|
||||||
"OpenAI": "<put OpenAI Key here>",
|
"OpenAI": "<put OpenAI Key here>",
|
||||||
"HF_Inference": "<put Hugging Face inference API Key here>"
|
"HF_Inference": "<put Hugging Face inference API Key here>"
|
||||||
},
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"Default": "<put Connection String here>"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Operations Version="1.0" xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02">
|
|
||||||
<Operation Name="Rename Refactor" Key="c957123b-8f1b-4753-96eb-c2ea2811027a" ChangeDateTime="10/10/2023 12:47:37">
|
|
||||||
<Property Name="ElementName" Value="[dbo].[BildInfo].[Prompt]" />
|
|
||||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
|
||||||
<Property Name="ParentElementName" Value="[dbo].[BildInfo]" />
|
|
||||||
<Property Name="ParentElementType" Value="SqlTable" />
|
|
||||||
<Property Name="NewName" Value="BildPrompt" />
|
|
||||||
</Operation>
|
|
||||||
<Operation Name="Rename Refactor" Key="9e69babc-e66c-496f-960a-0c9ad936d763" ChangeDateTime="10/10/2023 12:47:42">
|
|
||||||
<Property Name="ElementName" Value="[dbo].[BildInfo].[Beschreibung]" />
|
|
||||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
|
||||||
<Property Name="ParentElementName" Value="[dbo].[BildInfo]" />
|
|
||||||
<Property Name="ParentElementType" Value="SqlTable" />
|
|
||||||
<Property Name="NewName" Value="BildBeschreibung" />
|
|
||||||
</Operation>
|
|
||||||
<Operation Name="Rename Refactor" Key="1dc11132-1619-4a0d-b261-0d56392a3d51" ChangeDateTime="10/10/2023 13:39:00">
|
|
||||||
<Property Name="ElementName" Value="[dbo].[BildInfo].[Index]" />
|
|
||||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
|
||||||
<Property Name="ParentElementName" Value="[dbo].[BildInfo]" />
|
|
||||||
<Property Name="ParentElementType" Value="SqlTable" />
|
|
||||||
<Property Name="NewName" Value="GroupIndex" />
|
|
||||||
</Operation>
|
|
||||||
</Operations>
|
|
|
@ -1,81 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<Name>KiKunstDatenbank</Name>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
<ProjectVersion>4.1</ProjectVersion>
|
|
||||||
<ProjectGuid>{a19cd19a-fe5b-4d4e-896b-dcc43b45f734}</ProjectGuid>
|
|
||||||
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider</DSP>
|
|
||||||
<OutputType>Database</OutputType>
|
|
||||||
<RootPath>
|
|
||||||
</RootPath>
|
|
||||||
<RootNamespace>KiKunstDatenbank</RootNamespace>
|
|
||||||
<AssemblyName>KiKunstDatenbank</AssemblyName>
|
|
||||||
<ModelCollation>1033, CI</ModelCollation>
|
|
||||||
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
|
|
||||||
<DeployToDatabase>True</DeployToDatabase>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<TargetLanguage>CS</TargetLanguage>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<SqlServerVerification>False</SqlServerVerification>
|
|
||||||
<IncludeCompositeObjects>True</IncludeCompositeObjects>
|
|
||||||
<TargetDatabaseSet>True</TargetDatabaseSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
|
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<DefineDebug>false</DefineDebug>
|
|
||||||
<DefineTrace>true</DefineTrace>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
|
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<DefineDebug>true</DefineDebug>
|
|
||||||
<DefineTrace>true</DefineTrace>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
|
|
||||||
<!-- Default to the v11.0 targets path if the targets file for the current VS version is not found -->
|
|
||||||
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
|
|
||||||
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">11.0</VisualStudioVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
|
|
||||||
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties" />
|
|
||||||
<Folder Include="dpo" />
|
|
||||||
<Folder Include="dpo\Tables" />
|
|
||||||
<Folder Include="dpo\StoredProcedures" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Build Include="dpo\Tables\BildInfo.sql" />
|
|
||||||
<Build Include="dpo\StoredProcedures\spBildInfo_Insert.sql" />
|
|
||||||
<Build Include="dpo\Tables\WunschInfo.sql" />
|
|
||||||
<Build Include="dpo\StoredProcedures\spWunschInfo_Insert.sql" />
|
|
||||||
<Build Include="dpo\StoredProcedures\spBildInfo_UpdateFileName.sql" />
|
|
||||||
<Build Include="dpo\StoredProcedures\spBildInfo_GetAll.sql" />
|
|
||||||
<Build Include="dpo\StoredProcedures\spWunschInfo_Get.sql" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<RefactorLog Include="KiKunstDatenbank.refactorlog" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<PostDeploy Include="Script.PostDeployment.sql" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="KiKunstDatenbank.publish.xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
Vorlage für ein Skript nach der Bereitstellung
|
|
||||||
--------------------------------------------------------------------------------------
|
|
||||||
Diese Datei enthält SQL-Anweisungen, die an das Buildskript angefügt werden.
|
|
||||||
Schließen Sie mit der SQLCMD-Syntax eine Datei in das Skript nach der Bereitstellung ein.
|
|
||||||
Beispiel: :r .\myfile.sql
|
|
||||||
Verwenden Sie die SQLCMD-Syntax, um auf eine Variable im Skript nach der Bereitstellung zu verweisen.
|
|
||||||
Beispiel: :setvar TableName MyTable
|
|
||||||
SELECT * FROM [$(TableName)]
|
|
||||||
--------------------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
--IF NOT EXISTS (SELECT 1 FROM [dbo].[User])
|
|
||||||
--BEGIN
|
|
||||||
-- INSERT INTO [dbo].[User] (FirstName, LastName)
|
|
||||||
-- VALUES ('Simon', 'Lübeß'),
|
|
||||||
-- ('Peter', 'Enis'),
|
|
||||||
-- ('John', 'Smith'),
|
|
||||||
-- ('Mary', 'Jones')
|
|
||||||
--END
|
|
|
@ -1,6 +0,0 @@
|
||||||
CREATE PROCEDURE [dbo].[spBildInfo_GetAll]
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
SELECT Id, Datum, Dateiname, ImageModel, WunschId
|
|
||||||
FROM [dbo].[BildInfo];
|
|
||||||
END
|
|
|
@ -1,16 +0,0 @@
|
||||||
CREATE PROCEDURE [dbo].[spBildInfo_Insert]
|
|
||||||
@Id INT,
|
|
||||||
@Datum DATETIME2 ,
|
|
||||||
@Dateiname NCHAR(256) ,
|
|
||||||
@ImageModel NCHAR(32) ,
|
|
||||||
@WunschId INT
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO [dbo].[BildInfo] (Datum, Dateiname, ImageModel, WunschId)
|
|
||||||
VALUES (@Datum,
|
|
||||||
@Dateiname,
|
|
||||||
@ImageModel,
|
|
||||||
@WunschId);
|
|
||||||
|
|
||||||
SELECT Id FROM [dbo].[BildInfo] WHERE Id = CAST(SCOPE_IDENTITY() AS INT);
|
|
||||||
END
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE PROCEDURE [dbo].[spBildInfo_UpdateFileName]
|
|
||||||
@Id INT,
|
|
||||||
@Dateiname NCHAR(256)
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
UPDATE [dbo].[BildInfo]
|
|
||||||
SET Dateiname = @Dateiname
|
|
||||||
WHERE Id = @Id;
|
|
||||||
END
|
|
|
@ -1,8 +0,0 @@
|
||||||
CREATE PROCEDURE [dbo].[spWunschInfo_Get]
|
|
||||||
@Id INT
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
SELECT Id, Wunsch, BildPrompt, BildBeschreibung, Datum, GPTModel
|
|
||||||
FROM [dbo].[WunschInfo]
|
|
||||||
WHERE Id = @Id;
|
|
||||||
END
|
|
|
@ -1,18 +0,0 @@
|
||||||
CREATE PROCEDURE [dbo].[spWunschInfo_Insert]
|
|
||||||
@Id INT,
|
|
||||||
@Wunsch NVARCHAR(1024),
|
|
||||||
@BildPrompt NVARCHAR(MAX),
|
|
||||||
@BildBeschreibung NVARCHAR(MAX),
|
|
||||||
@Datum DATETIME2,
|
|
||||||
@GPTModel NCHAR(32)
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO [dbo].[WunschInfo] (Wunsch, BildPrompt, BildBeschreibung, Datum, GPTModel)
|
|
||||||
VALUES (@Wunsch,
|
|
||||||
@BildPrompt,
|
|
||||||
@BildBeschreibung,
|
|
||||||
@Datum,
|
|
||||||
@GPTModel);
|
|
||||||
|
|
||||||
SELECT Id FROM [dbo].[WunschInfo] WHERE Id = CAST(SCOPE_IDENTITY() AS INT);
|
|
||||||
END
|
|
|
@ -1,8 +0,0 @@
|
||||||
CREATE TABLE [dbo].[BildInfo]
|
|
||||||
(
|
|
||||||
[Id] INT NOT NULL PRIMARY KEY IDENTITY,
|
|
||||||
[Datum] DATETIME2 NOT NULL,
|
|
||||||
[Dateiname] NCHAR(256) NOT NULL,
|
|
||||||
[ImageModel] NCHAR(32) NOT NULL,
|
|
||||||
[WunschId] INT NOT NULL
|
|
||||||
)
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE TABLE [dbo].[WunschInfo]
|
|
||||||
(
|
|
||||||
[Id] INT NOT NULL PRIMARY KEY IDENTITY,
|
|
||||||
[Wunsch] NVARCHAR (1024) NOT NULL,
|
|
||||||
[BildPrompt] NVARCHAR (MAX) NOT NULL,
|
|
||||||
[BildBeschreibung] NVARCHAR (MAX) NOT NULL,
|
|
||||||
[Datum] DATETIME2 (7) NOT NULL,
|
|
||||||
[GPTModel] NCHAR (32) NOT NULL
|
|
||||||
)
|
|
Loading…
Reference in New Issue