diff --git a/BeWo/AI/Controls/Icon_KI_Chat_Weiss_TEMP.png b/BeWo/AI/Controls/Icon_KI_Chat_Weiss_TEMP.png
new file mode 100644
index 000000000..5bdf51d2f
Binary files /dev/null and b/BeWo/AI/Controls/Icon_KI_Chat_Weiss_TEMP.png differ
diff --git a/BeWo/AI/Controls/VoiceToTextButtonControl.xaml b/BeWo/AI/Controls/VoiceToTextButtonControl.xaml
new file mode 100644
index 000000000..f27da309c
--- /dev/null
+++ b/BeWo/AI/Controls/VoiceToTextButtonControl.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BeWo/AI/Controls/VoiceToTextButtonControl.xaml.cs b/BeWo/AI/Controls/VoiceToTextButtonControl.xaml.cs
new file mode 100644
index 000000000..2d3968ee3
--- /dev/null
+++ b/BeWo/AI/Controls/VoiceToTextButtonControl.xaml.cs
@@ -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
+{
+ ///
+ /// Interaktionslogik für VoiceToTextButtonControl.xaml
+ ///
+ 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;
+ }
+
+ }
+}
diff --git a/BeWo/AI/View/AiTranskriptionView.xaml b/BeWo/AI/View/AiTranskriptionView.xaml
new file mode 100644
index 000000000..c78684b1f
--- /dev/null
+++ b/BeWo/AI/View/AiTranskriptionView.xaml
@@ -0,0 +1,222 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BeWo/AI/View/AiTranskriptionView.xaml.cs b/BeWo/AI/View/AiTranskriptionView.xaml.cs
new file mode 100644
index 000000000..24ed7fb15
--- /dev/null
+++ b/BeWo/AI/View/AiTranskriptionView.xaml.cs
@@ -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);
+ }
+
+
+ }
+}
diff --git a/BeWo/AI/View/Icon_KI_Chat_Weiss_TEMP.png b/BeWo/AI/View/Icon_KI_Chat_Weiss_TEMP.png
new file mode 100644
index 000000000..5bdf51d2f
Binary files /dev/null and b/BeWo/AI/View/Icon_KI_Chat_Weiss_TEMP.png differ
diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj
index 17a294bf5..5c60fb143 100644
--- a/BeWo/BeWo.csproj
+++ b/BeWo/BeWo.csproj
@@ -95,6 +95,12 @@
+
+ VoiceToTextButtonControl.xaml
+
+
+ AiTranskriptionView.xaml
+
@@ -133,6 +139,14 @@
AnimatedBeWoWindow.xaml
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
@@ -3575,6 +3589,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs
index 7cce2fc3e..98b80e28e 100644
--- a/BeWo/BeWoApp.xaml.cs
+++ b/BeWo/BeWoApp.xaml.cs
@@ -228,6 +228,9 @@ namespace BeWo
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowChat);
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);
AppSettings.ShowOwnChatSettings = val != null && val.Equals("1");
@@ -568,8 +571,12 @@ namespace BeWo
{
_AppSettings.ServiceRecordAllowChangeHours = Convert.ToInt32(val);
}
-
- val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth);
+ val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.AiVoiceRequestInterval);
+ if (val != null)
+ {
+ _AppSettings.AiVoiceRequestInterval = Convert.ToInt32(val);
+ }
+ val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth);
AppSettings.ShowServicesOverviewHalfOrWholeMonth = val?.Equals("1") ?? false;
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.AllowGkvAbrechnung);
diff --git a/BeWo/Core/Config/AppSettings.cs b/BeWo/Core/Config/AppSettings.cs
index a026c168e..574d0ad7b 100644
--- a/BeWo/Core/Config/AppSettings.cs
+++ b/BeWo/Core/Config/AppSettings.cs
@@ -52,6 +52,8 @@ namespace BeWo.Core.Config
private FLSAnalysisConfigDC _DefaultFlsAnalysisConfig = null;
+ private int mAiVoiceRequestInterval = 5;
+
public enum WindowStateType
{
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
{
get { return mServiceRecordAllowChangeHours; }
@@ -444,7 +460,7 @@ namespace BeWo.Core.Config
public bool IsWohnheimAllowed { get; set; }
public bool ShowOwnChat { get; set; }
-
+ public bool ShowAIVoice { get; set; }
public bool ShowOwnChatSettings { get; set; }
public bool IsMedicationAllowed { get; set; }
diff --git a/BeWo/Ressources/Icons/Icon_KI_Chat_Weiss_TEMP.png b/BeWo/Ressources/Icons/Icon_KI_Chat_Weiss_TEMP.png
new file mode 100644
index 000000000..5bdf51d2f
Binary files /dev/null and b/BeWo/Ressources/Icons/Icon_KI_Chat_Weiss_TEMP.png differ
diff --git a/BeWo/ServiceProxy/GeneratedOperationsService.cs b/BeWo/ServiceProxy/GeneratedOperationsService.cs
index 01a747a1a..eb381bd6b 100644
--- a/BeWo/ServiceProxy/GeneratedOperationsService.cs
+++ b/BeWo/ServiceProxy/GeneratedOperationsService.cs
@@ -99,6 +99,7 @@ namespace BeWo.ServiceProxy
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.CheckObjectDeletionResultDC))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))]
[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(System.Collections.Generic.List))]
[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")]
string CreateRtfDocumentFromTemplate(long vorlageOid, BS.Shared.TableID objectTid, System.Collections.Generic.List 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.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 alleDiensteintraege, System.Collections.Generic.List alleDienstvertretungen, int day, System.DateTime pflichtStart, System.DateTime pflichtEnde);
@@ -2068,6 +2077,16 @@ namespace BeWo.ServiceProxy
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 alleDiensteintraege, System.Collections.Generic.List alleDienstvertretungen, int day, System.DateTime pflichtStart, System.DateTime pflichtEnde)
{
return base.Channel.DeleteDienstvertretung2(empId, wohnId, zeile, date, dienstvertretung, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde);
diff --git a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml
index 5064ab239..9f18a1228 100644
--- a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml
+++ b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml
@@ -21,7 +21,8 @@
xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
xmlns:val="clr-namespace:BeWo.Validation"
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"
Height="Auto"
HorizontalAlignment="Stretch"
@@ -1718,6 +1719,8 @@
Content="A-"
IsTabStop="False"
TabIndex="999" />
+
+
+
+
diff --git a/Service/ServiceContracts/IOperationsService.cs b/Service/ServiceContracts/IOperationsService.cs
index 730195d86..826dfc40a 100644
--- a/Service/ServiceContracts/IOperationsService.cs
+++ b/Service/ServiceContracts/IOperationsService.cs
@@ -1415,5 +1415,13 @@ namespace BeWo.Service.ServiceContracts
[FaultContract(typeof(BeWoFault))]
[OperationContract]
String CreateRtfDocumentFromTemplate(long vorlageOid, TableID objectTid, List objectOids);
+
+ [FaultContract(typeof(BeWoFault))]
+ [OperationContract]
+ AiVoiceDataDC StartAIVoice();
+
+ [FaultContract(typeof(BeWoFault))]
+ [OperationContract]
+ AiVoiceDataDC GetAIVoiceTranscript(AiVoiceDataDC data);
}
}
\ No newline at end of file
diff --git a/Service/ServiceImplementations/OperationsServiceImp.cs b/Service/ServiceImplementations/OperationsServiceImp.cs
index 041260995..fac8b8854 100644
--- a/Service/ServiceImplementations/OperationsServiceImp.cs
+++ b/Service/ServiceImplementations/OperationsServiceImp.cs
@@ -42,6 +42,7 @@ using System.Collections.Specialized;
using BeWo.ServiceUtils.History;
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
+using BeWo.Service.AI;
namespace BeWo.Service.ServiceImplementations
{
@@ -9032,5 +9033,40 @@ namespace BeWo.Service.ServiceImplementations
throw Utils.CreateBeWoFaultException(e);
}
}
+
+ public AiVoiceDataDC StartAIVoice()
+ {
+ try
+ {
+ var s = PluginLoader.FindClass();
+
+ 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();
+
+ var avd = s.MapAiVoiceData(data);
+
+ var result = s.GetTranskription(avd);
+ return s.MapAiVoiceDataDC(result);
+
+ }
+ catch (Exception e)
+ {
+ throw Utils.CreateBeWoFaultException(e);
+ }
+ }
}
+
}
diff --git a/Service/ai/AiVoiceData.cs b/Service/ai/AiVoiceData.cs
new file mode 100644
index 000000000..23fe23c2f
--- /dev/null
+++ b/Service/ai/AiVoiceData.cs
@@ -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; }
+ }
+}
diff --git a/Service/ai/TranscriptionService.cs b/Service/ai/TranscriptionService.cs
new file mode 100644
index 000000000..7a322e89e
--- /dev/null
+++ b/Service/ai/TranscriptionService.cs
@@ -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
+ };
+ }
+ }
+}
diff --git a/Shared/Core/SettingsKeys.cs b/Shared/Core/SettingsKeys.cs
index 33d1df25d..350795b42 100644
--- a/Shared/Core/SettingsKeys.cs
+++ b/Shared/Core/SettingsKeys.cs
@@ -50,12 +50,14 @@ namespace BS.Shared.Core
public static string LastKassenSortOrder => "LastKassenSortOrder";
public static string LastBewilligungSortOrder => "LastBewilligungSortOrder";
public static string ServiceRecordAllowChangeHours => "ServiceRecordAllowChangeHours";
+ public static string AiVoiceRequestInterval => "AiVoiceRequestInterval";
public static string LetzteZeiterfassungsDauer => "LetzteZeiterfassungsDauer";
public static string StartupPanelOrder => "StartupPanelOrder";
public static string ShowMedication => "ShowMedication";
public static string ShowScheduler => "ShowScheduler";
public static string ShowWohnheime => "ShowWohnheime";
public static string ShowChat => "ShowChat";
+ public static string ShowAIVoice => "ShowAIVoice";
public static string ShowOwnChatSettings => "ShowOwnChatSettings";
public static string SetStartTimeToEndTimeAfterSave => "SetStartTimeToEndTimeAfterSave";
public static string IsPasswordSecurityActiv => "IsPasswordSecurityActiv";
diff --git a/Shared/DataContracts/AiVoiceDataDC.cs b/Shared/DataContracts/AiVoiceDataDC.cs
new file mode 100644
index 000000000..2de080c2d
--- /dev/null
+++ b/Shared/DataContracts/AiVoiceDataDC.cs
@@ -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; }
+ }
+}
\ No newline at end of file
diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj
index a10316e4f..941945bf7 100644
--- a/Shared/Shared.csproj
+++ b/Shared/Shared.csproj
@@ -188,6 +188,7 @@
+