Konflike behoben

This commit is contained in:
2026-01-30 19:35:18 +01:00
parent 856e980296
commit a35eada8eb
23 changed files with 948 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -0,0 +1,21 @@
<UserControl x:Class="BeWo.AI.Controls.VoiceToTextButtonControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Button x:Name="ButtonOpenTranskriptionView" Click="ButtonOpenTranskriptionView_Click">
<Image Source="Icon_KI_Chat_Weiss_TEMP.png"
Width="22"
Height="22"
Margin="0,0,0,0"/>
</Button>
</Grid>
</UserControl>

View File

@@ -0,0 +1,102 @@
using BeWo.AI.View;
using BeWo.Services;
using BS.Shared.Translation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace BeWo.AI.Controls
{
/// <summary>
/// Interaktionslogik für VoiceToTextButtonControl.xaml
/// </summary>
public partial class VoiceToTextButtonControl : UserControl
{
public static readonly DependencyProperty TargetTextBoxProperty =
DependencyProperty.Register(
nameof(TargetTextBox),
typeof(TextBox),
typeof(VoiceToTextButtonControl));
public VoiceToTextButtonControl()
{
InitializeComponent();
}
public TextBox TargetTextBox
{
get => (TextBox)GetValue(TargetTextBoxProperty);
set => SetValue(TargetTextBoxProperty, value);
}
private void ButtonOpenTranskriptionView_Click(object sender, RoutedEventArgs e)
{
OpenTranskriptionView();
}
public void OpenTranskriptionView()
{
var view = new AiTranskriptionView();
view.InitView();
var factory = new BeWoWindowFactory();
var beWoWindow = factory.GetAnimatedBeWoWindow(Translator.Translate("BeWoPlaner"), view, 500, 600);
view.ApplyClicked += (s, e) =>
{
if (TargetTextBox != null)
{
InsertTextAtSelection(view.GetText());
}
beWoWindow.Close();
};
view.CancelClicked += (s, e) =>
{
if (!String.IsNullOrEmpty(view.GetText()))
{
if (MessageBox.Show("Sind Sie sicher, dass Sie abbrechnen und den Text verwerfen möchten?", "Abbrechen", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
beWoWindow.Close();
}
}
else
{
beWoWindow.Close();
}
};
beWoWindow.ShowDialog();
}
private void InsertTextAtSelection(string neuerText)
{
int start = TargetTextBox.SelectionStart;
int length = TargetTextBox.SelectionLength;
TargetTextBox.Text =
TargetTextBox.Text.Remove(start, length)
.Insert(start, neuerText);
TargetTextBox.CaretIndex = start + neuerText.Length;
}
}
}

View File

@@ -0,0 +1,222 @@
<view:BeWoView
x:Class="BeWo.AI.View.AiTranskriptionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
xmlns:core="clr-namespace:BS.Shared.Core;assembly=BS.Shared"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:t="clr-namespace:BeWo.MultiLanguage.Markup"
xmlns:validation="clr-namespace:BeWo.Validation"
xmlns:view="clr-namespace:BeWo.View"
Width="Auto"
Height="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
d:DesignHeight="400"
d:DesignWidth="500"
Focusable="True"
mc:Ignorable="d">
<Grid Margin="0" Background="{DynamicResource ObjectEditBackgroundBrush}" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Height="Auto"
VerticalAlignment="Center"
Orientation="Vertical">
<Button x:Name="ButtonStart"
Click="ButtonStartStop_Click"
Grid.Row="1"
HorizontalAlignment="Center"
Width="220"
Height="50"
Margin="0,10,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image Source="Icon_KI_Chat_Weiss_TEMP.png"
Width="32"
Height="32"
Margin="0,0,10,0"/>
<TextBlock Grid.Column="1" x:Name="ButtonText" VerticalAlignment="Center" Text="Aufnahme initiieren"/>
<Viewbox Grid.Column="2" x:Name="VBPlay" Width="40" Height="40" Visibility="Visible">
<Grid Width="100" Height="100">
<Ellipse
Width="80"
Height="80"
Stroke="White"
StrokeThickness="6"
Fill="Transparent"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<Path
Fill="White"
Data="M 40,30 L 40,70 L 70,50 Z"/>
</Grid>
</Viewbox>
<Viewbox Grid.Column="2" x:Name="VBStop" Width="40" Height="40" Visibility="Hidden">
<Grid Width="100" Height="100">
<Ellipse
Width="80"
Height="80"
StrokeThickness="6"
Fill="Transparent"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Ellipse.Stroke>
<LinearGradientBrush
x:Name="RingGradient"
StartPoint="0,0"
EndPoint="1,0">
<LinearGradientBrush.RelativeTransform>
<RotateTransform x:Name="GradientRotate"
CenterX="0.5"
CenterY="0.5"/>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="#00FF0000" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Stroke>
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetName="GradientRotate"
Storyboard.TargetProperty="Angle"
From="0"
To="360"
Duration="0:0:2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
<Rectangle
Width="33"
Height="33"
Fill="Red"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</Viewbox>
</Grid>
</Button>
<Label x:Name="lblStatus" Height="23" HorizontalAlignment="Center"></Label>
<StackPanel x:Name="PanelAnimation" Visibility="Hidden" Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<StackPanel.Resources>
<Storyboard x:Key="DotAnimation"
RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="0.3"
To="1"
Duration="0:0:0.6"
AutoReverse="True"/>
</Storyboard>
</StackPanel.Resources>
<!-- Punkt 1 -->
<Ellipse Width="8" Height="8" Fill="#007ACC" Margin="3">
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource DotAnimation}"/>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
<!-- Punkt 2 -->
<Ellipse Width="8" Height="8" Fill="#007ACC" Margin="3" Opacity="0.3">
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="0.3"
To="1"
Duration="0:0:0.6"
BeginTime="0:0:0.2"
AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
<!-- Punkt 3 -->
<Ellipse Width="8" Height="8" Fill="#007ACC" Margin="3" Opacity="0.3">
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="0.3"
To="1"
Duration="0:0:0.6"
BeginTime="0:0:0.4"
AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
</StackPanel>
</StackPanel>
<TextBox
Style="{x:Null}"
x:Name="TextBoxErgebnis"
Grid.Row="1"
AcceptsReturn="True"
AcceptsTab="True"
HorizontalScrollBarVisibility="Disabled"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
Margin="3"
/>
<StackPanel
Grid.Row="2"
Height="Auto"
Margin="5,10,10,10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">
<Button
x:Name="btnApply"
Height="25"
Margin="0,0,3,0"
Click="ButtonApply_Click"
Content="{t:Translate Text übernehmen}" />
<Button
x:Name="btnClose"
Height="25"
Margin="0,0,3,0"
Click="ButtonClose_Click"
Content=" Abbrechen " />
</StackPanel>
</Grid>
</view:BeWoView>

View File

@@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Threading;
using BeWo.Annotations;
using BeWo.Core;
using BeWo.ServiceProxy;
using BeWo.Validation;
using BeWo.View;
using BeWo.View.Controls;
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using BS.Shared.Translation;
using DevExpress.Utils;
using DevExpress.Xpf.Editors;
using DevExpress.Xpf.Grid;
using MessageBox = System.Windows.MessageBox;
namespace BeWo.AI.View
{
public partial class AiTranskriptionView : BeWoView
{
public event EventHandler ApplyClicked;
public event EventHandler CancelClicked;
bool cancel = false;
AiVoiceDataDC currentVoiceData = null;
public AiTranskriptionView()
{
InitializeComponent();
}
public void InitView()
{
}
public string GetText()
{
return TextBoxErgebnis.Text;
}
private void StartAufnahme()
{
cancel = false;
//lblStatus.Content = "Um die Aufnahme zu starten, klicken Sie auf den Link, den Sie in ownChat erhalten haben.";
StartTimer();
ButtonText.Text = "Aufnahme abbrechen";
currentVoiceData = ServiceFacade.DoOperationsServiceSync(s => s.StartAIVoice());
PanelAnimation.Visibility = Visibility.Visible;
VBPlay.Visibility = Visibility.Hidden;
VBStop.Visibility = Visibility.Visible;
}
private void StopAufnahme()
{
cancel = true;
VBPlay.Visibility = Visibility.Visible;
VBStop.Visibility = Visibility.Hidden;
}
private void StartTimer()
{
var sec = BeWoApp.AppSettings.AiVoiceRequestInterval;
new DispatcherTimer(
TimeSpan.FromMilliseconds(10000),
DispatcherPriority.Background,
(s1, e1) =>
{
CheckTranskriptionStatus();
if (cancel)
{
((DispatcherTimer)s1).Stop();
PanelAnimation.Visibility = Visibility.Hidden;
ButtonText.Text = "Neue Aufnahme starten";
}
},
this.Dispatcher).Start();
}
private void CheckTranskriptionStatus()
{
currentVoiceData = ServiceFacade.DoOperationsServiceSync(s => s.GetAIVoiceTranscript(currentVoiceData));
if (!String.IsNullOrEmpty(currentVoiceData.TranskriptionText))
{
InsertTextAtSelection(currentVoiceData.TranskriptionText);
lblStatus.Content = Translator.Translate("Transkription erfolgreich durchgeführt");
StopAufnahme();
}
else if (!String.IsNullOrEmpty(currentVoiceData.Error))
{
lblStatus.Content = currentVoiceData.Error;
StopAufnahme();
}
else if (!String.IsNullOrEmpty(currentVoiceData.StatusMessage))
{
lblStatus.Content = currentVoiceData.StatusMessage;
}
}
private void InsertTextAtSelection(string neuerText)
{
int start = TextBoxErgebnis.SelectionStart;
int length = TextBoxErgebnis.SelectionLength;
TextBoxErgebnis.Text =
TextBoxErgebnis.Text.Remove(start, length)
.Insert(start, neuerText);
TextBoxErgebnis.CaretIndex = start + neuerText.Length;
}
private void ButtonStartStop_Click(object sender, RoutedEventArgs e)
{
if (ButtonText.Text.Contains("Aufnahme"))
{
StartAufnahme();
}
else
{
ButtonText.Text = "Bitte warten...";
lblStatus.Content = "Aufnahme wird abgebrochen. Bitte warten...";
StopAufnahme();
}
}
private void ButtonApply_Click(object sender, RoutedEventArgs e)
{
ApplyClicked?.Invoke(this, EventArgs.Empty);
}
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
CancelClicked?.Invoke(this, EventArgs.Empty);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -95,6 +95,12 @@
</StartupObject> </StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AI\Controls\VoiceToTextButtonControl.xaml.cs">
<DependentUpon>VoiceToTextButtonControl.xaml</DependentUpon>
</Compile>
<Compile Include="AI\View\AiTranskriptionView.xaml.cs">
<DependentUpon>AiTranskriptionView.xaml</DependentUpon>
</Compile>
<Compile Include="Converter\AddressToStringConverter.cs" /> <Compile Include="Converter\AddressToStringConverter.cs" />
<Compile Include="Converter\NewlineConverter.cs" /> <Compile Include="Converter\NewlineConverter.cs" />
<Compile Include="Core\Commands\CommandFactory.cs" /> <Compile Include="Core\Commands\CommandFactory.cs" />
@@ -133,6 +139,14 @@
<Compile Include="View\Windows\AnimatedBeWoWindow.xaml.cs"> <Compile Include="View\Windows\AnimatedBeWoWindow.xaml.cs">
<DependentUpon>AnimatedBeWoWindow.xaml</DependentUpon> <DependentUpon>AnimatedBeWoWindow.xaml</DependentUpon>
</Compile> </Compile>
<Page Include="AI\Controls\VoiceToTextButtonControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="AI\View\AiTranskriptionView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\Detail\AI\AiConfigView.xaml"> <Page Include="View\Detail\AI\AiConfigView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -3575,6 +3589,18 @@
<ItemGroup> <ItemGroup>
<None Include="Scripts\src\SvcUtil.exe" /> <None Include="Scripts\src\SvcUtil.exe" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Ressources\Icons\micro.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="AI\Controls\micro.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="AI\Controls\Icon_KI_Chat_Weiss_TEMP.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="AI\View\Icon_KI_Chat_Weiss_TEMP.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent> <PostBuildEvent>

View File

@@ -228,6 +228,9 @@ namespace BeWo
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowChat); val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowChat);
AppSettings.ShowOwnChat = val != null && val.Equals("1"); AppSettings.ShowOwnChat = val != null && val.Equals("1");
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowAIVoice);
AppSettings.ShowAIVoice = val != null && val.Equals("1");
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowOwnChatSettings); val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowOwnChatSettings);
AppSettings.ShowOwnChatSettings = val != null && val.Equals("1"); AppSettings.ShowOwnChatSettings = val != null && val.Equals("1");
@@ -568,8 +571,12 @@ namespace BeWo
{ {
_AppSettings.ServiceRecordAllowChangeHours = Convert.ToInt32(val); _AppSettings.ServiceRecordAllowChangeHours = Convert.ToInt32(val);
} }
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.AiVoiceRequestInterval);
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth); if (val != null)
{
_AppSettings.AiVoiceRequestInterval = Convert.ToInt32(val);
}
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth);
AppSettings.ShowServicesOverviewHalfOrWholeMonth = val?.Equals("1") ?? false; AppSettings.ShowServicesOverviewHalfOrWholeMonth = val?.Equals("1") ?? false;
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.AllowGkvAbrechnung); val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.AllowGkvAbrechnung);

View File

@@ -52,6 +52,8 @@ namespace BeWo.Core.Config
private FLSAnalysisConfigDC _DefaultFlsAnalysisConfig = null; private FLSAnalysisConfigDC _DefaultFlsAnalysisConfig = null;
private int mAiVoiceRequestInterval = 5;
public enum WindowStateType public enum WindowStateType
{ {
Default, Default,
@@ -395,6 +397,20 @@ namespace BeWo.Core.Config
} }
public int AiVoiceRequestInterval
{
get { return mAiVoiceRequestInterval; }
set
{
if (mAiVoiceRequestInterval != value)
{
mAiVoiceRequestInterval = value;
IsDirty = true;
}
}
}
public int ServiceRecordAllowChangeHours public int ServiceRecordAllowChangeHours
{ {
get { return mServiceRecordAllowChangeHours; } get { return mServiceRecordAllowChangeHours; }
@@ -444,7 +460,7 @@ namespace BeWo.Core.Config
public bool IsWohnheimAllowed { get; set; } public bool IsWohnheimAllowed { get; set; }
public bool ShowOwnChat { get; set; } public bool ShowOwnChat { get; set; }
public bool ShowAIVoice { get; set; }
public bool ShowOwnChatSettings { get; set; } public bool ShowOwnChatSettings { get; set; }
public bool IsMedicationAllowed { get; set; } public bool IsMedicationAllowed { get; set; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -99,6 +99,7 @@ namespace BeWo.ServiceProxy
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CheckObjectDeletionResultDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CheckObjectDeletionResultDC))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.ConfirmationReceiptSignatureDC>))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.ConfirmationReceiptSignatureDC>))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.ConfirmationReceiptSignatureDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.ConfirmationReceiptSignatureDC))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiVoiceDataDC))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.DienstvertretungDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.DienstvertretungDC))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.DienstEintragDC>))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.DienstEintragDC>))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.DienstEintragDC))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.DienstEintragDC))]
@@ -478,6 +479,14 @@ namespace BeWo.ServiceProxy
"", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] "", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
string CreateRtfDocumentFromTemplate(long vorlageOid, BS.Shared.TableID objectTid, System.Collections.Generic.List<long> objectOids); string CreateRtfDocumentFromTemplate(long vorlageOid, BS.Shared.TableID objectTid, System.Collections.Generic.List<long> objectOids);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/StartAIVoice", ReplyAction="http://tempuri.org/IOperationsService/StartAIVoiceResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IOperationsService/StartAIVoiceBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
BS.Shared.DataContracts.AiVoiceDataDC StartAIVoice();
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/GetAIVoiceTranscript", ReplyAction="http://tempuri.org/IOperationsService/GetAIVoiceTranscriptResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IOperationsService/GetAIVoiceTranscriptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
BS.Shared.DataContracts.AiVoiceDataDC GetAIVoiceTranscript(BS.Shared.DataContracts.AiVoiceDataDC data);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/DeleteDienstvertretung2", ReplyAction="http://tempuri.org/IOperationsService/DeleteDienstvertretung2Response")] [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsService/DeleteDienstvertretung2", ReplyAction="http://tempuri.org/IOperationsService/DeleteDienstvertretung2Response")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IOperationsService/DeleteDienstvertretung2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IOperationsService/DeleteDienstvertretung2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
bool DeleteDienstvertretung2(long empId, long wohnId, int zeile, System.DateTime date, BS.Shared.DataContracts.DienstvertretungDC dienstvertretung, System.Collections.Generic.List<BS.Shared.DataContracts.DienstEintragDC> alleDiensteintraege, System.Collections.Generic.List<BS.Shared.DataContracts.DienstvertretungDC> alleDienstvertretungen, int day, System.DateTime pflichtStart, System.DateTime pflichtEnde); bool DeleteDienstvertretung2(long empId, long wohnId, int zeile, System.DateTime date, BS.Shared.DataContracts.DienstvertretungDC dienstvertretung, System.Collections.Generic.List<BS.Shared.DataContracts.DienstEintragDC> alleDiensteintraege, System.Collections.Generic.List<BS.Shared.DataContracts.DienstvertretungDC> alleDienstvertretungen, int day, System.DateTime pflichtStart, System.DateTime pflichtEnde);
@@ -2068,6 +2077,16 @@ namespace BeWo.ServiceProxy
return base.Channel.CreateRtfDocumentFromTemplate(vorlageOid, objectTid, objectOids); return base.Channel.CreateRtfDocumentFromTemplate(vorlageOid, objectTid, objectOids);
} }
public BS.Shared.DataContracts.AiVoiceDataDC StartAIVoice()
{
return base.Channel.StartAIVoice();
}
public BS.Shared.DataContracts.AiVoiceDataDC GetAIVoiceTranscript(BS.Shared.DataContracts.AiVoiceDataDC data)
{
return base.Channel.GetAIVoiceTranscript(data);
}
public bool DeleteDienstvertretung2(long empId, long wohnId, int zeile, System.DateTime date, BS.Shared.DataContracts.DienstvertretungDC dienstvertretung, System.Collections.Generic.List<BS.Shared.DataContracts.DienstEintragDC> alleDiensteintraege, System.Collections.Generic.List<BS.Shared.DataContracts.DienstvertretungDC> alleDienstvertretungen, int day, System.DateTime pflichtStart, System.DateTime pflichtEnde) public bool DeleteDienstvertretung2(long empId, long wohnId, int zeile, System.DateTime date, BS.Shared.DataContracts.DienstvertretungDC dienstvertretung, System.Collections.Generic.List<BS.Shared.DataContracts.DienstEintragDC> alleDiensteintraege, System.Collections.Generic.List<BS.Shared.DataContracts.DienstvertretungDC> alleDienstvertretungen, int day, System.DateTime pflichtStart, System.DateTime pflichtEnde)
{ {
return base.Channel.DeleteDienstvertretung2(empId, wohnId, zeile, date, dienstvertretung, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde); return base.Channel.DeleteDienstvertretung2(empId, wohnId, zeile, date, dienstvertretung, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde);

View File

@@ -21,7 +21,8 @@
xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls" xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
xmlns:val="clr-namespace:BeWo.Validation" xmlns:val="clr-namespace:BeWo.Validation"
xmlns:ve="http://schemas.devexpress.com/winfx/2008/xaml/docking/visualelements" xmlns:ve="http://schemas.devexpress.com/winfx/2008/xaml/docking/visualelements"
xmlns:zeit="clr-namespace:BeWo.View.Detail.Zeiterfassung" xmlns:zeit="clr-namespace:BeWo.View.Detail.Zeiterfassung"
xmlns:ai="clr-namespace:BeWo.AI.Controls"
Width="Auto" Width="Auto"
Height="Auto" Height="Auto"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
@@ -1718,6 +1719,8 @@
Content="A-" Content="A-"
IsTabStop="False" IsTabStop="False"
TabIndex="999" /> TabIndex="999" />
<ai:VoiceToTextButtonControl Margin="3" TargetTextBox="{Binding ElementName=dokumentationsTextBox}"/>
</DockPanel> </DockPanel>
<Button <Button

View File

@@ -1781,4 +1781,32 @@ ALTER TABLE `CustomerVermittlungArbeit` ADD COLUMN Fallnummer VARCHAR(256) NULL
ALTER TABLE `settings` ALTER TABLE `settings`
CHANGE COLUMN `Value` `Value` MEDIUMTEXT NULL DEFAULT NULL ; CHANGE COLUMN `Value` `Value` MEDIUMTEXT NULL DEFAULT NULL ;
CREATE TABLE IF NOT EXISTS `AiVoiceData` (
`Oid` bigint NOT NULL AUTO_INCREMENT,
`Tid` int NOT NULL,
`Notice` varchar(1024) DEFAULT NULL,
`InsTs` datetime DEFAULT NULL,
`InsUser` varchar(256) DEFAULT NULL,
`Version` bigint DEFAULT NULL,
`UdpUser` varchar(256) DEFAULT NULL,
`UpdTs` datetime DEFAULT NULL,
`IsActive` tinyint DEFAULT NULL,
`SystemEntryID` int DEFAULT NULL,
`ChangeType` tinyint NULL DEFAULT NULL,
`OvertimeOid` bigint NULL DEFAULT NULL,
`OvertimeEmployeeOid` bigint DEFAULT NULL,
`OvertimeDatum` datetime DEFAULT NULL,
`OvertimeBetrag` decimal(18,10) DEFAULT NULL,
`OvertimeAuszahlungsartOid` bigint DEFAULT NULL,
PRIMARY KEY (`Oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
UPDATE `query` SET `SQL` = 'SELECT \np.LastName as \'Nachname\',\np.Firstname as \'Vorname\',\nc2s.ApprovedStartDate as \'Bewilligt von\',\nc2s.ApprovedEndDate as \'Bewilligt bis\',\nscat.Name as \'Kategorie\',\nDate_Format(sr.StartDate, \'%d.%m.%Y\') as \'Datum\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(sr.StartDate, \'%H:%i\')) as \'von\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(Date_Add(sr.StartDate, INTERVAL sr.Roundedduration MINUTE), \'%H:%i\')) as \'bis\',\nRound(sr.Roundedduration, 0) as \'Minuten\',\nsr.InsUser as \'Angelegt von\',\nDATE_FORMAT(sr.InsTs, \'%d.%m.%Y %H:%i\') as \'Angelegt am\',\n(select CONCAT(emp1p.`FirstName`, \' \', emp1p.`LastName`) from employee emp1 join `person` emp1p on emp1p.`Oid` = emp1.`PersonOid` where emp1.`Oid` in (select employeeoid from `employee2customer` e2c1 join `valuelistentry2object` vl2o on e2c1.`Oid` = vl2o.`ObjectOid` join `valuelistentry` vle on vl2o.`ValueListEntryOid` = vle.`Oid` where e2c1.`CustomerOid` = c.`Oid` and vle.`SystemEntryID` = 3) LIMIT 1) as \'Hauptbetreuung\',\n(select t.`Name` from team t where t.`Oid` in (select teamoid from `team2customer` t2c where t2c.`CustomerOid` = c.`Oid`) LIMIT 1) as \'Team\' \nFROM servicerecord sr\njoin costbearer2supportconcept c2s on sr.costbearer2supportconceptoid = c2s.oid\njoin supportconcept sc on c2s.supportconceptoid = sc.oid\njoin customer c on sc.customeroid = c.oid\njoin person p on c.personoid = p.oid\njoin servicedescription sd on sd.oid = sr.servicedescriptionoid\njoin servicecategory scat on scat.oid = sd.servicecategoryoid\nwhere sr.SignatureOID is null and\nscat.billable = true and\nsr.startdate >= \':Von\' and sr.startdate < \':bis\'\norder by p.Lastname, sr.startdate' WHERE (`Oid` = '4711');
UPDATE `query` SET `SQL` = 'SELECT \np.LastName as \'Nachname\',\np.Firstname as \'Vorname\',\nc2s.ApprovedStartDate as \'Bewilligt von\',\nc2s.ApprovedEndDate as \'Bewilligt bis\',\nscat.Name as \'Kategorie\',\nDate_Format(sr.StartDate, \'%d.%m.%Y\') as \'Datum\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(sr.StartDate, \'%H:%i\')) as \'von\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(Date_Add(sr.StartDate, INTERVAL sr.Roundedduration MINUTE), \'%H:%i\')) as \'bis\',\nRound(sr.Roundedduration, 0) as \'Minuten\',\nsr.InsUser as \'Angelegt von\',\nDATE_FORMAT(sr.InsTs, \'%d.%m.%Y %H:%i\') as \'Angelegt am\',\n(select CONCAT(emp1p.`FirstName`, \' \', emp1p.`LastName`) from employee emp1 join `person` emp1p on emp1p.`Oid` = emp1.`PersonOid` where emp1.`Oid` in (select employeeoid from `employee2customer` e2c1 join `valuelistentry2object` vl2o on e2c1.`Oid` = vl2o.`ObjectOid` join `valuelistentry` vle on vl2o.`ValueListEntryOid` = vle.`Oid` where e2c1.`CustomerOid` = c.`Oid` and vle.`SystemEntryID` = 3) LIMIT 1) as \'Hauptbetreuung\',\n(select t.`Name` from team t where t.`Oid` in (select teamoid from `team2customer` t2c where t2c.`CustomerOid` = c.`Oid`) LIMIT 1) as \'Team\' \nFROM servicerecord sr\njoin costbearer2supportconcept c2s on sr.costbearer2supportconceptoid = c2s.oid\njoin supportconcept sc on c2s.supportconceptoid = sc.oid\njoin customer c on sc.customeroid = c.oid\njoin person p on c.personoid = p.oid\njoin servicedescription sd on sd.oid = sr.servicedescriptionoid\njoin servicecategory scat on scat.oid = sd.servicecategoryoid\nwhere sr.oid \nnot in (select servicerecordoid from confirmationreceiptsignature2servicerecord crs2s\njoin confirmationreceiptsignature crs on crs2s.confirmationreceiptsignatureoid = crs.oid where crs.employeeoid is null and crs.customeroid is not null) and\nscat.billable = true and\nsr.startdate >= \':Von\' and sr.startdate < \':bis\'\norder by p.Lastname, sr.startdate' WHERE (`Oid` = '4712');
UPDATE `query` SET `SQL` = 'SELECT \np.LastName as \'Nachname\',\np.Firstname as \'Vorname\',\nc2s.ApprovedStartDate as \'Bewilligt von\',\nc2s.ApprovedEndDate as \'Bewilligt bis\',\nscat.Name as \'Kategorie\',\nDate_Format(sr.StartDate, \'%d.%m.%Y\') as \'Datum\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(sr.StartDate, \'%H:%i\')) as \'von\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(Date_Add(sr.StartDate, INTERVAL sr.Roundedduration MINUTE), \'%H:%i\')) as \'bis\',\nRound(sr.Roundedduration, 0) as \'Minuten\',\nsr.InsUser as \'Angelegt von\',\nDATE_FORMAT(sr.InsTs, \'%d.%m.%Y %H:%i\') as \'Angelegt am\',\n(select CONCAT(emp1p.`FirstName`, \' \', emp1p.`LastName`) from employee emp1 join `person` emp1p on emp1p.`Oid` = emp1.`PersonOid` where emp1.`Oid` in (select employeeoid from `employee2customer` e2c1 join `valuelistentry2object` vl2o on e2c1.`Oid` = vl2o.`ObjectOid` join `valuelistentry` vle on vl2o.`ValueListEntryOid` = vle.`Oid` where e2c1.`CustomerOid` = c.`Oid` and vle.`SystemEntryID` = 3) LIMIT 1) as \'Hauptbetreuung\',\n(select t.`Name` from team t where t.`Oid` in (select teamoid from `team2customer` t2c where t2c.`CustomerOid` = c.`Oid`) LIMIT 1) as \'Team\' \nFROM servicerecord sr\njoin costbearer2supportconcept c2s on sr.costbearer2supportconceptoid = c2s.oid\njoin supportconcept sc on c2s.supportconceptoid = sc.oid\njoin customer c on sc.customeroid = c.oid\njoin person p on c.personoid = p.oid\njoin servicedescription sd on sd.oid = sr.servicedescriptionoid\njoin servicecategory scat on scat.oid = sd.servicecategoryoid\nwhere sr.oid \nnot in (select servicerecordoid from confirmationreceiptsignature2servicerecord crs2s\njoin confirmationreceiptsignature crs on crs2s.confirmationreceiptsignatureoid = crs.oid where crs.employeeoid is not null and crs.customeroid is null) and\nscat.billable = true and\nsr.startdate >= \':Von\' and sr.startdate < \':bis\'\norder by p.Lastname, sr.startdate' WHERE (`Oid` = '4713');

View File

@@ -4,6 +4,7 @@ using System.Configuration;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text.RegularExpressions;
using BeWo.Data.Access; using BeWo.Data.Access;
using BeWo.Data.Entities; using BeWo.Data.Entities;
using BeWo.Service.Configuration; using BeWo.Service.Configuration;
@@ -15,6 +16,7 @@ namespace BeWo.Service.OwnChat
{ {
public class OwnChatHelper public class OwnChatHelper
{ {
public static void StartOwnChatSync() public static void StartOwnChatSync()
{ {
//if (AppSettings.CreateSettings().ShowChat) //if (AppSettings.CreateSettings().ShowChat)
@@ -33,7 +35,7 @@ namespace BeWo.Service.OwnChat
{ {
try try
{ {
var serverUrl = ErmittleServerURL(tenant); var serverUrl = ErmittleServerURL("1", tenant);
if (!String.IsNullOrEmpty(serverUrl)) if (!String.IsNullOrEmpty(serverUrl))
{ {
@@ -63,30 +65,35 @@ namespace BeWo.Service.OwnChat
public static string ErmittleServerURL(string tenant) public static string ErmittleServerURL(string tenant)
{ {
//CB HACK solange App4 nicht geht: return ErmittleServerURL("1", tenant);
return GetUrlFromApp6(tenant); }
public static string ErmittleServerURL(string typ, string tenant)
{
//CB HACK solange App4 nicht geht:
#if !DEBUG
return GetUrlFromApp6(typ, tenant);
#endif
try try
{ {
string url = String.Format("https://dict.ownchat.de/api/server/resolve/{0}/{1}", typ, tenant);
string url = "https://dict.ownchat.de/api/server/resolve/1/" + tenant;
WebRequest request = WebRequest.Create(url); WebRequest request = WebRequest.Create(url);
request.Credentials = CredentialCache.DefaultCredentials; request.Credentials = CredentialCache.DefaultCredentials;
WebResponse response = request.GetResponse(); using (var response = request.GetResponse())
{
string responseFromServer = ReadStringFromResponse(response);
string responseFromServer = ReadStreamForChatCode(response); var definition = new { status = "", URL = "", SYNCTYPE = "" };
var definition = new { status = "", URL = "", SYNCTYPE = "" }; var jsondaten = JsonConvert.DeserializeAnonymousType(responseFromServer, definition);
var jsondaten = JsonConvert.DeserializeAnonymousType(responseFromServer, definition); string serverUrl = jsondaten.URL;
return serverUrl;
}
string serverUrl = jsondaten.URL;
response.Close();
return serverUrl;
} }
catch (Exception e) catch (Exception e)
{ {
@@ -142,7 +149,7 @@ LG
#if DEBUG #if DEBUG
tenant = "4368658435"; tenant = "4368658435";
var serverUrl = OwnChatHelper.ErmittleServerURL(tenant); var serverUrl = OwnChatHelper.ErmittleServerURL("1", tenant);
var apikey = "hNykpBwxE1Y6NmwZBTDQOpPXW6xCgnVHjJ5lh0QDQyCefgcnimC32aZ3CwB4qQl4"; var apikey = "hNykpBwxE1Y6NmwZBTDQOpPXW6xCgnVHjJ5lh0QDQyCefgcnimC32aZ3CwB4qQl4";
var userid = "1432790061"; var userid = "1432790061";
@@ -190,20 +197,20 @@ LG
} }
private static string GetUrlFromApp6(string tenant) private static string GetUrlFromApp6(string typ, string tenant)
{ {
try try
{ {
string url = "https://app6.bewoplaner.de/mobil/Chat/GetServerUrl?k=" + tenant; string url = String.Format("https://app6.bewoplaner.de/mobil/Chat/GetServerUrl?t={0}&k={1}", typ, tenant);
WebRequest request = WebRequest.Create(url); WebRequest request = WebRequest.Create(url);
request.Credentials = CredentialCache.DefaultCredentials; request.Credentials = CredentialCache.DefaultCredentials;
WebResponse response = request.GetResponse(); WebResponse response = request.GetResponse();
string responseFromServer = ReadStreamForChatCode(response); string responseFromServer = ReadStringFromResponse(response);
return responseFromServer; return responseFromServer;
@@ -215,23 +222,19 @@ LG
} }
private static string ReadStreamForChatCode(WebResponse response) private static string ReadStringFromResponse(WebResponse response)
{ {
try try
{ {
Stream dataStream = response.GetResponseStream(); using (Stream dataStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(dataStream))
{
string responseFromServer = reader.ReadToEnd();
StreamReader reader = new StreamReader(dataStream); return responseFromServer;
}
string responseFromServer = reader.ReadToEnd(); }
dataStream.Dispose();
reader.Dispose();
dataStream.Close();
reader.Close();
return responseFromServer;
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -85,7 +85,7 @@ namespace BeWo.Service.Plugins
//t = "4867997795"; // ADiK Kleve //t = "4867997795"; // ADiK Kleve
//t = "3184859776"; // Sergej Becker //t = "3184859776"; // Sergej Becker
//t = "7752610643"; // BWK Gbr //t = "7752610643"; // BWK Gbr
//t = "3785623125"; // Betreuwo t = "3785623125"; // Betreuwo
//t = "7130228334"; // LH Borken //t = "7130228334"; // LH Borken
//t = "4209820830"; // VKM Hamm //t = "4209820830"; // VKM Hamm
//t = "5700328131"; // Betreutes Wohnen St. Ludgerus Essen-Werden //t = "5700328131"; // Betreutes Wohnen St. Ludgerus Essen-Werden
@@ -226,7 +226,7 @@ namespace BeWo.Service.Plugins
//t = "7817461089"; // FAB e.V. (Familienarbeit und Beratung e.V.) //t = "7817461089"; // FAB e.V. (Familienarbeit und Beratung e.V.)
//t = "5207911843"; // Pro Balance //t = "5207911843"; // Pro Balance
//t = "8619663355"; // HSH Cologne //t = "8619663355"; // HSH Cologne
//t = "1652658918"; // LH Frankfurt Oder t = "1652658918"; // LH Frankfurt Oder
//t = "7696927868"; // Kuhring Betreuung //t = "7696927868"; // Kuhring Betreuung
//t = "6251348980"; // BeWo Gün //t = "6251348980"; // BeWo Gün
//t = "6782533512"; // LH Dorsten //t = "6782533512"; // LH Dorsten

View File

@@ -222,6 +222,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AI\AiVoiceData.cs" />
<Compile Include="AI\TranscriptionService.cs" />
<Compile Include="Attributes\RequireWcfAuthorizationAttribute.cs" /> <Compile Include="Attributes\RequireWcfAuthorizationAttribute.cs" />
<Compile Include="Attributes\RequireApiAuthorizationAttribute.cs" /> <Compile Include="Attributes\RequireApiAuthorizationAttribute.cs" />
<Compile Include="BeWoServiceEnums.cs" /> <Compile Include="BeWoServiceEnums.cs" />

View File

@@ -1415,5 +1415,13 @@ namespace BeWo.Service.ServiceContracts
[FaultContract(typeof(BeWoFault))] [FaultContract(typeof(BeWoFault))]
[OperationContract] [OperationContract]
String CreateRtfDocumentFromTemplate(long vorlageOid, TableID objectTid, List<long> objectOids); String CreateRtfDocumentFromTemplate(long vorlageOid, TableID objectTid, List<long> objectOids);
[FaultContract(typeof(BeWoFault))]
[OperationContract]
AiVoiceDataDC StartAIVoice();
[FaultContract(typeof(BeWoFault))]
[OperationContract]
AiVoiceDataDC GetAIVoiceTranscript(AiVoiceDataDC data);
} }
} }

View File

@@ -42,6 +42,7 @@ using System.Collections.Specialized;
using BeWo.ServiceUtils.History; using BeWo.ServiceUtils.History;
using SecurityUtils = BeWo.Service.Security.SecurityUtils; using SecurityUtils = BeWo.Service.Security.SecurityUtils;
using BeWo.Service.AI;
namespace BeWo.Service.ServiceImplementations namespace BeWo.Service.ServiceImplementations
{ {
@@ -9032,5 +9033,40 @@ namespace BeWo.Service.ServiceImplementations
throw Utils.CreateBeWoFaultException(e); throw Utils.CreateBeWoFaultException(e);
} }
} }
public AiVoiceDataDC StartAIVoice()
{
try
{
var s = PluginLoader.FindClass<TranscriptionService>();
var data = s.StartTranskription(PluginLoader.Tenant);
return s.MapAiVoiceDataDC(data);
}
catch (Exception e)
{
throw Utils.CreateBeWoFaultException(e);
}
}
public AiVoiceDataDC GetAIVoiceTranscript(AiVoiceDataDC data)
{
try
{
var s = PluginLoader.FindClass<TranscriptionService>();
var avd = s.MapAiVoiceData(data);
var result = s.GetTranskription(avd);
return s.MapAiVoiceDataDC(result);
}
catch (Exception e)
{
throw Utils.CreateBeWoFaultException(e);
}
}
} }
} }

20
Service/ai/AiVoiceData.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Service.AI
{
public class AiVoiceData
{
public String Result { get; set; }
public String Status { get; set; }
public String StatusMessage { get; set; }
public String Error { get; set; }
public String TranskriptionText { get; set; }
public String Token { get; set; }
public String UploadUrl { get; set; }
public String ResultUrl { get; set; }
}
}

View File

@@ -0,0 +1,206 @@
using BeWo.Data.Security;
using BeWo.Service.OwnChat;
using BS.Shared.DataContracts;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace BeWo.Service.AI
{
public class TranscriptionService
{
public AiVoiceData StartTranskription(String tenant, String sprache = "de")
{
AiVoiceData avd = null;
try
{
avd = GetTranskriptionToken(tenant, sprache);
if (!String.IsNullOrEmpty(avd.Token))
{
var url = String.Format("ownchat://voice/?token={0}", avd.Token);
var msg = String.Format("Bitte klicken Sie auf folgenden Link um die Aufnahme zu starten:\n\n{0}", url);
OwnChatHelper.SendOwnChatMessage(msg, UserRightHelper.GetLoggedInUser().Employee);
}
return avd;
}
catch (Exception e)
{
if (avd == null)
{
avd = new AiVoiceData();
}
avd.Error = e.Message;
return avd;
}
}
public AiVoiceData GetTranskription(AiVoiceData avd)
{
try
{
if (!String.IsNullOrEmpty(avd.ResultUrl))
{
if (CheckValidUrl(avd.ResultUrl))
{
WebRequest request = WebRequest.Create(avd.ResultUrl);
request.Credentials = CredentialCache.DefaultCredentials;
using (var response = request.GetResponse())
{
var responseString = ReadStringFromResponse(response);
var jsonDef = new { result = "", token = "", transcription = "", transcription_started_at = "", transcription_finished_at = "", state = "", callback_result = "" };
var json = JsonConvert.DeserializeAnonymousType(responseString, jsonDef);
avd.Result = json.result;
avd.Token = json.token;
avd.TranskriptionText = json.transcription;
avd.Status = json.state;
if (json.result == "20" && json.state == "0")
{
avd.StatusMessage = "Um die Aufnahme zu starten, klicken Sie auf den Link, den wir an Ihren ownChat Account gesendet haben.";
}
else if (json.result == "0" && json.state == "10")
{
avd.StatusMessage = "Die Aufnahme wurde erfolgreich hochgeladen und wird gerade transkribiert";
}
else if (json.result == "0" && json.state == "20")
{
avd.StatusMessage = "Die Transkription läuft gerade";
}
else if (json.result == "0" && json.state == "30")
{
avd.StatusMessage = "Transkription erfolgreich abgeschlossen";
}
else
{
avd.StatusMessage = String.Format("Es ist leider ein Fehler aufgetreten: Result = {0}, Status = {1}", json.result, json.state);
}
}
}
}
return avd;
}
catch (Exception e)
{
avd.Error = e.Message;
return avd;
}
}
private bool CheckValidUrl(String url)
{
string pattern = @"^https:\/\/.{1,3}\.ownsoft\.de\/.*$";
return Regex.IsMatch(url, pattern);
}
private AiVoiceData GetTranskriptionToken(String tenant, String sprache)
{
try
{
var serverUrl = OwnChatHelper.ErmittleServerURL("4", tenant);
if (!String.IsNullOrEmpty(serverUrl))
{
var endurl = String.Format("{0}/api/token/{1}/{2}", serverUrl, sprache, tenant);
WebRequest request = WebRequest.Create(endurl);
request.Credentials = CredentialCache.DefaultCredentials;
using (var response = request.GetResponse())
{
var responseString = ReadStringFromResponse(response);
var jsonDef = new { result = "", token = "", upload_url = "", result_url = "" };
var json = JsonConvert.DeserializeAnonymousType(responseString, jsonDef);
var avd = new AiVoiceData();
avd.Result = json.result;
avd.Token = json.token;
avd.UploadUrl = json.upload_url;
avd.ResultUrl = json.result_url;
return avd;
}
}
return null;
}
catch (Exception e)
{
return null;
}
}
private string ReadStringFromResponse(WebResponse response)
{
try
{
using (Stream dataStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(dataStream))
{
string responseFromServer = reader.ReadToEnd();
return responseFromServer;
}
}
}
catch (Exception e)
{
return null;
}
}
public AiVoiceDataDC MapAiVoiceDataDC(AiVoiceData data)
{
return new AiVoiceDataDC
{
Error = data.Error,
Result = data.Result,
ResultUrl = data.ResultUrl,
Status = data.Status,
StatusMessage = data.StatusMessage,
Token = data.Token,
TranskriptionText = data.TranskriptionText,
UploadUrl = data.UploadUrl
};
}
public AiVoiceData MapAiVoiceData(AiVoiceDataDC data)
{
return new AiVoiceData
{
Error = data.Error,
Result = data.Result,
ResultUrl = data.ResultUrl,
Status = data.Status,
StatusMessage = data.StatusMessage,
Token = data.Token,
TranskriptionText = data.TranskriptionText,
UploadUrl = data.UploadUrl
};
}
}
}

View File

@@ -50,12 +50,14 @@ namespace BS.Shared.Core
public static string LastKassenSortOrder => "LastKassenSortOrder"; public static string LastKassenSortOrder => "LastKassenSortOrder";
public static string LastBewilligungSortOrder => "LastBewilligungSortOrder"; public static string LastBewilligungSortOrder => "LastBewilligungSortOrder";
public static string ServiceRecordAllowChangeHours => "ServiceRecordAllowChangeHours"; public static string ServiceRecordAllowChangeHours => "ServiceRecordAllowChangeHours";
public static string AiVoiceRequestInterval => "AiVoiceRequestInterval";
public static string LetzteZeiterfassungsDauer => "LetzteZeiterfassungsDauer"; public static string LetzteZeiterfassungsDauer => "LetzteZeiterfassungsDauer";
public static string StartupPanelOrder => "StartupPanelOrder"; public static string StartupPanelOrder => "StartupPanelOrder";
public static string ShowMedication => "ShowMedication"; public static string ShowMedication => "ShowMedication";
public static string ShowScheduler => "ShowScheduler"; public static string ShowScheduler => "ShowScheduler";
public static string ShowWohnheime => "ShowWohnheime"; public static string ShowWohnheime => "ShowWohnheime";
public static string ShowChat => "ShowChat"; public static string ShowChat => "ShowChat";
public static string ShowAIVoice => "ShowAIVoice";
public static string ShowOwnChatSettings => "ShowOwnChatSettings"; public static string ShowOwnChatSettings => "ShowOwnChatSettings";
public static string SetStartTimeToEndTimeAfterSave => "SetStartTimeToEndTimeAfterSave"; public static string SetStartTimeToEndTimeAfterSave => "SetStartTimeToEndTimeAfterSave";
public static string IsPasswordSecurityActiv => "IsPasswordSecurityActiv"; public static string IsPasswordSecurityActiv => "IsPasswordSecurityActiv";

View File

@@ -0,0 +1,25 @@
using System.Runtime.Serialization;
namespace BS.Shared.DataContracts
{
[DataContract]
public partial class AiVoiceDataDC : IDataContract
{
[DataMember]
public string Result { get; set; }
[DataMember]
public string Status { get; set; }
[DataMember]
public string StatusMessage { get; set; }
[DataMember]
public string Error { get; set; }
[DataMember]
public string TranskriptionText { get; set; }
[DataMember]
public string Token { get; set; }
[DataMember]
public string UploadUrl { get; set; }
[DataMember]
public string ResultUrl { get; set; }
}
}

View File

@@ -188,6 +188,7 @@
<Compile Include="DataContracts\AdminService\IAdminServiceDC.cs" /> <Compile Include="DataContracts\AdminService\IAdminServiceDC.cs" />
<Compile Include="DataContracts\AdminService\AdminServiceSumReqDC.cs" /> <Compile Include="DataContracts\AdminService\AdminServiceSumReqDC.cs" />
<Compile Include="DataContracts\IAbsenceTime.cs" /> <Compile Include="DataContracts\IAbsenceTime.cs" />
<Compile Include="DataContracts\AiVoiceDataDC.cs" />
<Compile Include="DataContracts\Invoicing\GkvAbrechnung\GkvServerGetNumberRequestDC.cs" /> <Compile Include="DataContracts\Invoicing\GkvAbrechnung\GkvServerGetNumberRequestDC.cs" />
<Compile Include="DataContracts\Invoicing\GkvAbrechnung\GkvServerGetNumberResponseDC.cs" /> <Compile Include="DataContracts\Invoicing\GkvAbrechnung\GkvServerGetNumberResponseDC.cs" />
<Compile Include="DataContracts\Person2TeamDC.cs" /> <Compile Include="DataContracts\Person2TeamDC.cs" />