Neuer Chat direkt beim Start
This commit is contained in:
@@ -147,9 +147,9 @@ namespace BeWo
|
||||
AutoLogin = true,
|
||||
//SelectView = UIContext.AiConversation,
|
||||
//SelectIndex = 8,
|
||||
DefaultLoginUsername = "m1",
|
||||
DefaultLoginPassword = "bewobewo",
|
||||
DefaultProfilename = "5000000000",
|
||||
//DefaultLoginUsername = "m1",
|
||||
//DefaultLoginPassword = "bewobewo",
|
||||
//DefaultProfilename = "5000000000",
|
||||
EnableAutoRemoteDebugging = true
|
||||
});
|
||||
|
||||
|
||||
@@ -28,12 +28,17 @@ namespace BeWo.ServiceProxy
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/GetAiConversations", ReplyAction="http://tempuri.org/IAiEnhancedService/GetAiConversationsResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/GetAiConversationsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(int uicontext, long? oid);
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(int uicontext, System.Nullable<long> oid);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CreateAiConversation", ReplyAction="http://tempuri.org/IAiEnhancedService/CreateAiConversationResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CreateAiConversationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CreateAiConversationWithMessage", ReplyAction="http://tempuri.org/IAiEnhancedService/CreateAiConversationWithMessageResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CreateAiConversationWithMessageBeWoFaultFau" +
|
||||
"lt", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversationWithMessage(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid, string message);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CloneAiConversation", ReplyAction="http://tempuri.org/IAiEnhancedService/CloneAiConversationResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CloneAiConversationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.Shared.DataContracts.Feature.AI.AiConversationDC CloneAiConversation(long conversation_oid, System.Nullable<long> message_oid);
|
||||
@@ -96,7 +101,7 @@ namespace BeWo.ServiceProxy
|
||||
return base.Channel.GetAiModels();
|
||||
}
|
||||
|
||||
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(int uicontext, long? oid)
|
||||
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(int uicontext, System.Nullable<long> oid)
|
||||
{
|
||||
return base.Channel.GetAiConversations(uicontext, oid);
|
||||
}
|
||||
@@ -106,6 +111,11 @@ namespace BeWo.ServiceProxy
|
||||
return base.Channel.CreateAiConversation(conversation, modell_oid);
|
||||
}
|
||||
|
||||
public BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversationWithMessage(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid, string message)
|
||||
{
|
||||
return base.Channel.CreateAiConversationWithMessage(conversation, modell_oid, message);
|
||||
}
|
||||
|
||||
public BS.Shared.DataContracts.Feature.AI.AiConversationDC CloneAiConversation(long conversation_oid, System.Nullable<long> message_oid)
|
||||
{
|
||||
return base.Channel.CloneAiConversation(conversation_oid, message_oid);
|
||||
|
||||
@@ -131,11 +131,11 @@
|
||||
<Color x:Key="ModuleAiControlEmployeeNavigationHeaderColor">#FF205C19</Color>
|
||||
<Color x:Key="ModuleAiControlEmployeeNavigationContentColor">#FF45993B</Color>
|
||||
<Color x:Key="ModuleAiControlEmployeeNavigationContentColor2">#FF205C19</Color>
|
||||
|
||||
|
||||
<Color x:Key="ModuleAiControlOrganisationNavigationHeaderColor">#FFC8C000</Color>
|
||||
<Color x:Key="ModuleAiControlOrganisationNavigationContentColor">#FFC8C000</Color>
|
||||
<Color x:Key="ModuleAiControlOrganisationNavigationContentColor2">#FF706000</Color>
|
||||
|
||||
|
||||
<Color x:Key="BrightTextPrimary">#FFFFFFFF</Color>
|
||||
<Color x:Key="BrightTextSecondary">#FFD2D2D2</Color>
|
||||
|
||||
|
||||
@@ -147,12 +147,14 @@
|
||||
x:Name="listbox_messages"
|
||||
Grid.Column="1"
|
||||
Padding="3"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
ItemTemplateSelector="{StaticResource AiConversationMessageTemplateSelector}"
|
||||
ItemsSource="{Binding SelectedVM.Messages.VMList, Converter={StaticResource AiConversationMessageSystemConverter}, UpdateSourceTrigger=PropertyChanged}"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
Visibility="{Binding IsNewConversationVisible, Converter={StaticResource BoolVisibilityConverter}, ConverterParameter=Reverse}">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
@@ -179,7 +181,7 @@
|
||||
Margin="4">
|
||||
<Grid.Visibility>
|
||||
<MultiBinding Converter="{StaticResource BooleanAndVisibilityMultiConverter}">
|
||||
<Binding Converter="{StaticResource ObjectBoolConverter}" Path="SelectedVM" />
|
||||
<Binding Converter="{StaticResource BoolReverseConverter}" Path="IsNewConversationVisible" />
|
||||
<Binding Converter="{StaticResource UserPermission2BoolConverter}" ConverterParameter="{x:Static shared:UserRightType.AiModuleChatAdd}" />
|
||||
</MultiBinding>
|
||||
</Grid.Visibility>
|
||||
@@ -205,7 +207,6 @@
|
||||
MaxHeight="200"
|
||||
Margin="0,0,4,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="{Binding IsSending}"
|
||||
Text="{Binding MessageInput, UpdateSourceTrigger=PropertyChanged}" />
|
||||
@@ -220,6 +221,45 @@
|
||||
Content="Senden"
|
||||
Visibility="Visible" />
|
||||
</Grid>
|
||||
<Grid Grid.Column="1" Grid.RowSpan="2" Margin="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.Visibility>
|
||||
<MultiBinding Converter="{StaticResource BooleanAndVisibilityMultiConverter}">
|
||||
<Binding Path="IsNewConversationVisible" />
|
||||
<Binding Converter="{StaticResource UserPermission2BoolConverter}" ConverterParameter="{x:Static shared:UserRightType.AiModuleChatAdd}" />
|
||||
</MultiBinding>
|
||||
</Grid.Visibility>
|
||||
<TextBox
|
||||
x:Name="txt_input_message2"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Height="auto"
|
||||
MaxHeight="200"
|
||||
Margin="0,0,4,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="{Binding IsSending}"
|
||||
Text="{Binding MessageInput, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Height="auto"
|
||||
MinHeight="25"
|
||||
MaxHeight="100"
|
||||
Margin="0"
|
||||
VerticalAlignment="Stretch"
|
||||
Command="{Binding StartConversationWithMessageCommand}"
|
||||
Content="Senden"
|
||||
Visibility="Visible" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Border
|
||||
@@ -250,7 +290,7 @@
|
||||
<Button
|
||||
x:Name="btnNew"
|
||||
Margin="0,0,0,0"
|
||||
Command="{Binding RequestNewConversationCommand}"
|
||||
Command="{Binding OpenNewConversationCommand}"
|
||||
Content="Neuer Chat" />
|
||||
<Button
|
||||
x:Name="btnSettings"
|
||||
|
||||
@@ -87,8 +87,10 @@ namespace BeWo.View.Detail.AI
|
||||
// Console.WriteLine("Enter erkannt");
|
||||
|
||||
object p = null;
|
||||
if(ViewModel.SendNewMessageCommand.CanExecute(p))
|
||||
if(ViewModel.SelectedVM is object && ViewModel.SendNewMessageCommand.CanExecute(p))
|
||||
ViewModel.SendNewMessageCommand.Execute(p);
|
||||
else if (ViewModel.SelectedVM is null && ViewModel.StartConversationWithMessageCommand.CanExecute(p))
|
||||
ViewModel.StartConversationWithMessageCommand.Execute(p);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,11 @@ namespace BeWo.ViewModel
|
||||
|
||||
protected abstract DCType MapToDataContract(DCType pDataContract, bool doCommit);
|
||||
|
||||
internal virtual void UpdateByDataContract(DCType pDataContract)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected void StoreDirtyInformation(bool pDirty, string pPropName)
|
||||
{
|
||||
if (_DirtyProps.Contains(pPropName) && !pDirty)
|
||||
|
||||
@@ -98,5 +98,16 @@ namespace BeWo.ViewModel
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
internal override void UpdateByDataContract(AiConversationDC pDataContract)
|
||||
{
|
||||
DataContract = pDataContract;
|
||||
|
||||
Displayname = pDataContract.Displayname;
|
||||
Updated = pDataContract.Updated;
|
||||
|
||||
if (pDataContract.Messages is object)
|
||||
Messages = new AiConversationMessageListVM(pDataContract.Messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,8 +48,8 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
Models = new ObservableSortCollection<AiModelDC>();
|
||||
|
||||
SendNewMessageCommand = new DelegateCommand(SendNewMessage, () => SelectedVM is object && !string.IsNullOrWhiteSpace(MessageInput) && !IsSending);
|
||||
RequestNewConversationCommand = new DelegateCommand(RequestNewConversation, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleChatAdd));
|
||||
//TestCommand = new DelegateCommand(Test);
|
||||
OpenNewConversationCommand = new DelegateCommand(OpenNewConversation, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleChatAdd));
|
||||
StartConversationWithMessageCommand = new DelegateCommand(StartConversationWithMessage, () => !string.IsNullOrWhiteSpace(MessageInput) && !IsSending);
|
||||
|
||||
ReloadConfigCommand = new DelegateCommand(ReloadConfig);
|
||||
ReloadConversationsCommand = new DelegateCommand(ReloadConversations);
|
||||
@@ -60,11 +60,15 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
CloneCommand = new DelegateCommand(Clone);
|
||||
|
||||
AskDeleteCommand = new DelegateCommand(AskDelete, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleChatDelete) && SelectedVM is object);
|
||||
|
||||
SelectedVMChanged += (s, e) => FirePropertyChanged(nameof(IsNewConversationVisible));
|
||||
}
|
||||
|
||||
public event EventHandler SendNewMessageSuccess;
|
||||
|
||||
public DelegateCommand SendNewMessageCommand { get; set; }
|
||||
public DelegateCommand OpenNewConversationCommand { get; set; }
|
||||
public DelegateCommand StartConversationWithMessageCommand { get; set; }
|
||||
public DelegateCommand RequestNewConversationCommand { get; set; }
|
||||
public DelegateCommand TestCommand { get; set; }
|
||||
public DelegateCommand AskDeleteCommand { get; set; }
|
||||
@@ -154,26 +158,55 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
FirePropertyChanged(nameof(IsSending));
|
||||
}
|
||||
}
|
||||
public bool IsNewConversationVisible => SelectedVM is null;
|
||||
|
||||
public int UIContext { get; set; }
|
||||
public long? ReferenceObjectOid { get; set; }
|
||||
public Dictionary<TableID, long[]> ContextBeWoObjects { get; set; }
|
||||
|
||||
private void RequestNewConversation()
|
||||
private void StartConversationWithMessage()
|
||||
{
|
||||
var conv = new AiConversationDC();
|
||||
StartSending();
|
||||
|
||||
conv.UIContext = UIContext;
|
||||
conv.ContextBeWoObjects = ContextBeWoObjects;
|
||||
try
|
||||
{
|
||||
var message = MessageInput;
|
||||
|
||||
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.CreateAiConversation(conv, Config.SelectedModel.Oid.Value), InsertConverstion);
|
||||
var conv = new AiConversationDC();
|
||||
|
||||
conv.Created = DateTime.Now;
|
||||
conv.Updated = DateTime.Now;
|
||||
conv.UIContext = UIContext;
|
||||
conv.ContextBeWoObjects = ContextBeWoObjects;
|
||||
conv.Messages = new List<AiConversationMessageDC>()
|
||||
{
|
||||
new AiConversationMessageDC()
|
||||
{
|
||||
Message = message,
|
||||
Role = AiConversationMessageRole.User
|
||||
}
|
||||
};
|
||||
|
||||
var vm = InsertConverstion(conv);
|
||||
|
||||
ServiceFacade.DoAiEnhancedServiceAsnyc(
|
||||
x => x.CreateAiConversationWithMessage(conv, Config.SelectedModel.Oid.Value, message),
|
||||
dc => UpdateConverstion(vm, dc),
|
||||
e => EndSending());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
EndSending();
|
||||
}
|
||||
}
|
||||
private void OpenNewConversation()
|
||||
{
|
||||
SelectedVM = null;
|
||||
}
|
||||
private void SendNewMessage()
|
||||
{
|
||||
if (IsSending)
|
||||
throw new InvalidOperationException("Sendet bereits");
|
||||
StartSending();
|
||||
|
||||
IsSending = true;
|
||||
try
|
||||
{
|
||||
var conv = SelectedVM;
|
||||
@@ -201,7 +234,7 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
|
||||
MessageInput = string.Empty;
|
||||
|
||||
IsSending = false;
|
||||
EndSending();
|
||||
|
||||
SendNewMessageSuccess?.Invoke(this, EventArgs.Empty);
|
||||
},
|
||||
@@ -209,15 +242,27 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
conv.Messages.VMList.Remove(msg_vm);
|
||||
|
||||
IsSending = false;
|
||||
EndSending();
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
IsSending = false;
|
||||
EndSending();
|
||||
}
|
||||
}
|
||||
private void StartSending()
|
||||
{
|
||||
if (IsSending)
|
||||
throw new InvalidOperationException("Sendet bereits");
|
||||
|
||||
|
||||
IsSending = true;
|
||||
}
|
||||
private void EndSending()
|
||||
{
|
||||
if (!IsSending)
|
||||
throw new InvalidOperationException("Sendet nicht");
|
||||
|
||||
IsSending = false;
|
||||
}
|
||||
private void Test()
|
||||
{
|
||||
@@ -258,11 +303,24 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
//}
|
||||
}
|
||||
|
||||
private void InsertConverstion(AiConversationDC dc)
|
||||
private AiConversationVM InsertConverstion(AiConversationDC dc)
|
||||
{
|
||||
var vm = new AiConversationVM(dc);
|
||||
VMList.Insert(0, vm);
|
||||
SelectedVM = vm;
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
private void UpdateConverstion(AiConversationVM vm, AiConversationDC dc)
|
||||
{
|
||||
vm.UpdateByDataContract(dc);
|
||||
|
||||
MessageInput = string.Empty;
|
||||
|
||||
EndSending();
|
||||
|
||||
SendNewMessageSuccess?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void ReloadConfig()
|
||||
@@ -431,7 +489,7 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
|
||||
InitDummyConversations(10);
|
||||
|
||||
SelectedVM = conversation_vm;
|
||||
//SelectedVM = conversation_vm;
|
||||
}
|
||||
private void InitDummyConversations(int count)
|
||||
{
|
||||
|
||||
@@ -1,319 +1,319 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeWo.Service.Invoicing
|
||||
{
|
||||
[IDSpecificClass(Identifier = "Soziotherapie")]
|
||||
public class SoziotherapieInvoiceCreation : InvoiceCreation
|
||||
{
|
||||
public SoziotherapieInvoiceCreation() : base()
|
||||
{
|
||||
//Wichtig für Finanzauswertung. Hier sollen entweder nur die normalen Therapieeinheiten oder nur die Hausbesuchspauschale berechnet werden
|
||||
ErstelleTherapieeinheiten = true;
|
||||
ErstelleHausbesuchspauschale = true;
|
||||
}
|
||||
|
||||
public bool ErstelleTherapieeinheiten { get; set; }
|
||||
public bool ErstelleHausbesuchspauschale { get; set; }
|
||||
|
||||
public override void SetInvoiceId(ServiceInvoice invoice)
|
||||
{
|
||||
invoice.InvoiceBase.InvoiceId = "RechnungSoziotherapie";
|
||||
invoice.InvoiceBase.InvoiceTypeText = "Soziotherapie";
|
||||
}
|
||||
|
||||
public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List<ServiceRecordDC> serviceRecords)
|
||||
{
|
||||
var invoice = base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords);
|
||||
|
||||
if (invoicePeriod != null)
|
||||
{
|
||||
SetAmountEquityContribution(invoice);
|
||||
}
|
||||
|
||||
return invoice;
|
||||
}
|
||||
|
||||
public override void SetAmountEquityContribution(ServiceInvoice invoice)
|
||||
{
|
||||
decimal equity = 0;
|
||||
|
||||
IList<InvoiceBase> EquityInvoiceList = DAOFactory.SearchDAO.GetInvoiceBaseByTypeAndSupportConceptOid(InvoiceType.CustomerEquity, invoice.InvoiceBase.SupportConceptOid.Value);
|
||||
|
||||
EquityInvoiceList = EquityInvoiceList.Where(i =>
|
||||
{
|
||||
if (i.AccountingPeriodEnd >= invoice.InvoiceBase.AccountingPeriodStart && i.AccountingPeriodStart <= invoice.InvoiceBase.AccountingPeriodEnd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}).ToList();
|
||||
|
||||
foreach (InvoiceBase iEquityInvoice in EquityInvoiceList)
|
||||
{
|
||||
foreach (InvoiceItem item in iEquityInvoice.InvoiceItems)
|
||||
{
|
||||
if (item.AmountTotal != null)
|
||||
{
|
||||
equity += item.AmountTotal.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
invoice.AmountEquityContribution = equity;
|
||||
}
|
||||
|
||||
public override InvoiceItem CreateInvoiceItem(ServiceRecordDC serviceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var ii = base.CreateInvoiceItem(serviceRecord, scap, calc);
|
||||
ii.ItemDescription = serviceRecord.ServiceDescription.Name;
|
||||
|
||||
var sozioLeistung = ii.ItemDescription.ToLower();
|
||||
|
||||
if (sozioLeistung.Contains("gruppe"))
|
||||
AktualisierePreis(ii, GetGruppenPreis(scap.CostBearer2SupportConcept, serviceRecord.Start.Value));
|
||||
else
|
||||
AktualisierePreis(ii, GetEinzelPreis(scap.CostBearer2SupportConcept, serviceRecord.Start.Value));
|
||||
|
||||
ii.UnitDescription = ErmittleGPosNummer(serviceRecord, sozioLeistung);
|
||||
|
||||
return ii;
|
||||
}
|
||||
|
||||
public virtual InvoiceItem CreateInvoiceItemFactor(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
return CreateInvoiceItem(iServiceRecord, scap, calc);
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateInvoiceItems(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap,
|
||||
BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var list = new List<InvoiceItem>();
|
||||
|
||||
if (ErstelleTherapieeinheiten)
|
||||
{
|
||||
list = (List<InvoiceItem>)base.CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, scap, calc);
|
||||
}
|
||||
|
||||
if (ErstelleHausbesuchspauschale)
|
||||
{
|
||||
var ii = CreateHausbesuchspauschale(serviceRecordsInPeriod, invoicePeriod, scap);
|
||||
list.AddRange(ii);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public virtual IList<InvoiceItem> CreateHausbesuchspauschale(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap)
|
||||
{
|
||||
IList<InvoiceItem> items = new List<InvoiceItem>();
|
||||
decimal hausbesuchspauschale = GetHausbesuchspauschale(scap.CostBearer2SupportConcept, invoicePeriod.StartDate);
|
||||
|
||||
var date2hausbesuch = new Dictionary<DateTime, int>();
|
||||
|
||||
foreach (var sr in serviceRecordsInPeriod)
|
||||
{
|
||||
if (sr.ServiceDescription.Name.ToLower().Contains("aufsuchend"))
|
||||
{
|
||||
var date = sr.Start.Value.Date;
|
||||
|
||||
if (date2hausbesuch.ContainsKey(date))
|
||||
{
|
||||
date2hausbesuch[date]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
date2hausbesuch.Add(date, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!date2hausbesuch.Any())
|
||||
return items;
|
||||
|
||||
foreach (var kvp in date2hausbesuch)
|
||||
{
|
||||
var date = kvp.Key;
|
||||
var count = kvp.Value;
|
||||
|
||||
var invoiceItem = new InvoiceItem();
|
||||
|
||||
decimal anzahlHausbesuche = count;
|
||||
|
||||
invoiceItem.AmountPerUnit = hausbesuchspauschale;
|
||||
invoiceItem.UnitCount = anzahlHausbesuche;
|
||||
invoiceItem.AmountTotal = anzahlHausbesuche * hausbesuchspauschale;
|
||||
invoiceItem.ItemPeriodStart = date;
|
||||
invoiceItem.ItemPeriodEnd = date;
|
||||
invoiceItem.RateFactor = null;
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal;
|
||||
invoiceItem.ItemDescription = "Hausbesuchspauschale";
|
||||
invoiceItem.UnitDescription = "GPos: 2009690";
|
||||
if (scap != null)
|
||||
invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid;
|
||||
|
||||
items.Add(invoiceItem);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BeWo.Service.Invoicing
|
||||
{
|
||||
[IDSpecificClass(Identifier = "Soziotherapie")]
|
||||
public class SoziotherapieInvoiceCreation : InvoiceCreation
|
||||
{
|
||||
public SoziotherapieInvoiceCreation() : base()
|
||||
{
|
||||
//Wichtig für Finanzauswertung. Hier sollen entweder nur die normalen Therapieeinheiten oder nur die Hausbesuchspauschale berechnet werden
|
||||
ErstelleTherapieeinheiten = true;
|
||||
ErstelleHausbesuchspauschale = true;
|
||||
}
|
||||
|
||||
public bool ErstelleTherapieeinheiten { get; set; }
|
||||
public bool ErstelleHausbesuchspauschale { get; set; }
|
||||
|
||||
public override void SetInvoiceId(ServiceInvoice invoice)
|
||||
{
|
||||
invoice.InvoiceBase.InvoiceId = "RechnungSoziotherapie";
|
||||
invoice.InvoiceBase.InvoiceTypeText = "Soziotherapie";
|
||||
}
|
||||
|
||||
public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List<ServiceRecordDC> serviceRecords)
|
||||
{
|
||||
var invoice = base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords);
|
||||
|
||||
if (invoicePeriod != null)
|
||||
{
|
||||
SetAmountEquityContribution(invoice);
|
||||
}
|
||||
|
||||
return invoice;
|
||||
}
|
||||
|
||||
public override void SetAmountEquityContribution(ServiceInvoice invoice)
|
||||
{
|
||||
decimal equity = 0;
|
||||
|
||||
IList<InvoiceBase> EquityInvoiceList = DAOFactory.SearchDAO.GetInvoiceBaseByTypeAndSupportConceptOid(InvoiceType.CustomerEquity, invoice.InvoiceBase.SupportConceptOid.Value);
|
||||
|
||||
EquityInvoiceList = EquityInvoiceList.Where(i =>
|
||||
{
|
||||
if (i.AccountingPeriodEnd >= invoice.InvoiceBase.AccountingPeriodStart && i.AccountingPeriodStart <= invoice.InvoiceBase.AccountingPeriodEnd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}).ToList();
|
||||
|
||||
foreach (InvoiceBase iEquityInvoice in EquityInvoiceList)
|
||||
{
|
||||
foreach (InvoiceItem item in iEquityInvoice.InvoiceItems)
|
||||
{
|
||||
if (item.AmountTotal != null)
|
||||
{
|
||||
equity += item.AmountTotal.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
invoice.AmountEquityContribution = equity;
|
||||
}
|
||||
|
||||
public override InvoiceItem CreateInvoiceItem(ServiceRecordDC serviceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var ii = base.CreateInvoiceItem(serviceRecord, scap, calc);
|
||||
ii.ItemDescription = serviceRecord.ServiceDescription.Name;
|
||||
|
||||
var sozioLeistung = ii.ItemDescription.ToLower();
|
||||
|
||||
if (sozioLeistung.Contains("gruppe"))
|
||||
AktualisierePreis(ii, GetGruppenPreis(scap.CostBearer2SupportConcept, serviceRecord.Start.Value));
|
||||
else
|
||||
AktualisierePreis(ii, GetEinzelPreis(scap.CostBearer2SupportConcept, serviceRecord.Start.Value));
|
||||
|
||||
ii.UnitDescription = ErmittleGPosNummer(serviceRecord, sozioLeistung);
|
||||
|
||||
return ii;
|
||||
}
|
||||
|
||||
public virtual InvoiceItem CreateInvoiceItemFactor(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
return CreateInvoiceItem(iServiceRecord, scap, calc);
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateInvoiceItems(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap,
|
||||
BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var list = new List<InvoiceItem>();
|
||||
|
||||
if (ErstelleTherapieeinheiten)
|
||||
{
|
||||
list = (List<InvoiceItem>)base.CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, scap, calc);
|
||||
}
|
||||
|
||||
if (ErstelleHausbesuchspauschale)
|
||||
{
|
||||
var ii = CreateHausbesuchspauschale(serviceRecordsInPeriod, invoicePeriod, scap);
|
||||
list.AddRange(ii);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public virtual IList<InvoiceItem> CreateHausbesuchspauschale(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap)
|
||||
{
|
||||
IList<InvoiceItem> items = new List<InvoiceItem>();
|
||||
decimal hausbesuchspauschale = GetHausbesuchspauschale(scap.CostBearer2SupportConcept, invoicePeriod.StartDate);
|
||||
|
||||
var date2hausbesuch = new Dictionary<DateTime, int>();
|
||||
|
||||
foreach (var sr in serviceRecordsInPeriod)
|
||||
{
|
||||
if (sr.ServiceDescription.Name.ToLower().Contains("aufsuchend"))
|
||||
{
|
||||
var date = sr.Start.Value.Date;
|
||||
|
||||
if (date2hausbesuch.ContainsKey(date))
|
||||
{
|
||||
date2hausbesuch[date]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
date2hausbesuch.Add(date, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!date2hausbesuch.Any())
|
||||
return items;
|
||||
|
||||
foreach (var kvp in date2hausbesuch)
|
||||
{
|
||||
var date = kvp.Key;
|
||||
var count = kvp.Value;
|
||||
|
||||
var invoiceItem = new InvoiceItem();
|
||||
|
||||
decimal anzahlHausbesuche = count;
|
||||
|
||||
invoiceItem.AmountPerUnit = hausbesuchspauschale;
|
||||
invoiceItem.UnitCount = anzahlHausbesuche;
|
||||
invoiceItem.AmountTotal = anzahlHausbesuche * hausbesuchspauschale;
|
||||
invoiceItem.ItemPeriodStart = date;
|
||||
invoiceItem.ItemPeriodEnd = date;
|
||||
invoiceItem.RateFactor = null;
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal;
|
||||
invoiceItem.ItemDescription = "Hausbesuchspauschale";
|
||||
invoiceItem.UnitDescription = "GPos: 2009690";
|
||||
if (scap != null)
|
||||
invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid;
|
||||
|
||||
items.Add(invoiceItem);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
protected void AktualisierePreis(InvoiceItem invoiceItem, decimal preis)
|
||||
{
|
||||
{
|
||||
if (preis > 0)
|
||||
{
|
||||
invoiceItem.AmountPerUnit = preis;
|
||||
invoiceItem.AmountTotal = invoiceItem.AmountPerUnit * invoiceItem.UnitCount;
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
invoiceItem.AmountPerUnit = preis;
|
||||
invoiceItem.AmountTotal = invoiceItem.AmountPerUnit * invoiceItem.UnitCount;
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string ErmittleGPosNummer(ServiceRecordDC serviceRecord, string sozioLeistung)
|
||||
{
|
||||
string unitDescription = "";
|
||||
var duration = serviceRecord.RoundedDuration;
|
||||
|
||||
if (sozioLeistung.Contains("gruppe"))
|
||||
{
|
||||
if (duration <= 45)
|
||||
unitDescription = "GPos: 2002678";
|
||||
else if (duration <= 60)
|
||||
unitDescription = "GPos: 2002677";
|
||||
else
|
||||
if (sozioLeistung.Contains("gruppe"))
|
||||
{
|
||||
if (duration <= 45)
|
||||
unitDescription = "GPos: 2002678";
|
||||
else if (duration <= 60)
|
||||
unitDescription = "GPos: 2002677";
|
||||
else
|
||||
unitDescription = "GPos: 2002672"; // 90 min, 2-5 Personen
|
||||
}
|
||||
else if (sozioLeistung.Contains("video"))
|
||||
{
|
||||
if (duration <= 30)
|
||||
unitDescription = "GPos: 2001616";
|
||||
else
|
||||
unitDescription = "GPos: 2001615";
|
||||
}
|
||||
else if (sozioLeistung.Contains("telefon"))
|
||||
{
|
||||
if (duration <= 30)
|
||||
unitDescription = "GPos: 2001618";
|
||||
else
|
||||
unitDescription = "GPos: 2001617";
|
||||
}
|
||||
else if (sozioLeistung.Contains("aufsuchende probatorik") || sozioLeistung.Contains("büroprobatorik"))
|
||||
{
|
||||
unitDescription = "GPos: 2001607";
|
||||
}
|
||||
else if (sozioLeistung.Contains("aufsuchende einheit") || sozioLeistung.Contains("büroeinheit"))
|
||||
{
|
||||
if (duration <= 10)
|
||||
unitDescription = "GPos: 2001613";
|
||||
else if (duration <= 30)
|
||||
unitDescription = "GPos: 2001612";
|
||||
else if (duration <= 45)
|
||||
unitDescription = "GPos: 2001611";
|
||||
else
|
||||
unitDescription = "GPos: 2001610";
|
||||
}
|
||||
}
|
||||
else if (sozioLeistung.Contains("video"))
|
||||
{
|
||||
if (duration <= 30)
|
||||
unitDescription = "GPos: 2001616";
|
||||
else
|
||||
unitDescription = "GPos: 2001615";
|
||||
}
|
||||
else if (sozioLeistung.Contains("telefon"))
|
||||
{
|
||||
if (duration <= 30)
|
||||
unitDescription = "GPos: 2001618";
|
||||
else
|
||||
unitDescription = "GPos: 2001617";
|
||||
}
|
||||
else if (sozioLeistung.Contains("aufsuchende probatorik") || sozioLeistung.Contains("büroprobatorik"))
|
||||
{
|
||||
unitDescription = "GPos: 2001607";
|
||||
}
|
||||
else if (sozioLeistung.Contains("aufsuchende einheit") || sozioLeistung.Contains("büroeinheit"))
|
||||
{
|
||||
if (duration <= 10)
|
||||
unitDescription = "GPos: 2001613";
|
||||
else if (duration <= 30)
|
||||
unitDescription = "GPos: 2001612";
|
||||
else if (duration <= 45)
|
||||
unitDescription = "GPos: 2001611";
|
||||
else
|
||||
unitDescription = "GPos: 2001610";
|
||||
}
|
||||
|
||||
return unitDescription;
|
||||
}
|
||||
|
||||
private decimal GetHausbesuchspauschale(CostBearer2SupportConcept c2s, DateTime dt)
|
||||
{
|
||||
String preisName = "Hausbesuchspauschale Primärkasse";
|
||||
|
||||
if (c2s.CostBearer.Organisation.Function != null)
|
||||
{
|
||||
if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse"))
|
||||
{
|
||||
preisName = "Hausbesuchspauschale Ersatzkasse";
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetPreis(preisName, dt);
|
||||
}
|
||||
|
||||
protected decimal GetGruppenPreis(CostBearer2SupportConcept c2s, DateTime dt)
|
||||
{
|
||||
String preisName = "Gruppentherapie Primärkasse";
|
||||
|
||||
if (c2s.CostBearer.Organisation.Function != null)
|
||||
{
|
||||
if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse"))
|
||||
{
|
||||
preisName = "Gruppentherapie Ersatzkasse";
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetPreis(preisName, dt);
|
||||
}
|
||||
|
||||
protected decimal GetEinzelPreis(CostBearer2SupportConcept c2s, DateTime dt)
|
||||
{
|
||||
String preisName = "Einzelstunde Primärkasse";
|
||||
|
||||
if (c2s.CostBearer.Organisation.Function != null)
|
||||
{
|
||||
if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse"))
|
||||
{
|
||||
preisName = "Einzelstunde Ersatzkasse";
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetPreis(preisName, dt);
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateSummaryInvoiceItems(IList<InvoiceItem> itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount)
|
||||
{
|
||||
var newlist = new List<InvoiceItem>();
|
||||
|
||||
var rateToItem = new Dictionary<String, InvoiceItem>();
|
||||
foreach (InvoiceItem iitem in itemList)
|
||||
{
|
||||
InvoiceItem item;
|
||||
|
||||
var key = String.Format("{0}_{1}_{2:yyyyMMdd}_{3}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemPeriodStart, iitem.UnitDescription);
|
||||
|
||||
if (rateToItem.ContainsKey(key))
|
||||
{
|
||||
item = rateToItem[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
item = new InvoiceItem();
|
||||
newlist.Add(item);
|
||||
|
||||
item.AmountPerUnit = iitem.AmountPerUnit;
|
||||
item.ItemPeriodStart = iitem.ItemPeriodStart.Value.Date;
|
||||
item.ItemPeriodEnd = iitem.ItemPeriodEnd.Value.Date;
|
||||
|
||||
item.RateFactor = iitem.RateFactor;
|
||||
|
||||
item.AccountingInterval = iitem.AccountingInterval;
|
||||
item.ItemDescription = iitem.ItemDescription;
|
||||
item.UnitDescription = iitem.UnitDescription;
|
||||
item.SupportConceptApprovalPeriodOid = scap.Oid;
|
||||
item.ServiceRecord = iitem.ServiceRecord;
|
||||
|
||||
rateToItem[key] = item;
|
||||
}
|
||||
|
||||
|
||||
if (!item.UnitCount.HasValue)
|
||||
{
|
||||
item.UnitCount = 0;
|
||||
}
|
||||
item.UnitCount += iitem.UnitCount ?? 0;
|
||||
}
|
||||
|
||||
BerechneSummaryItemsSummen(newlist, addRateFactorToUnitCount);
|
||||
|
||||
return newlist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private decimal GetHausbesuchspauschale(CostBearer2SupportConcept c2s, DateTime dt)
|
||||
{
|
||||
String preisName = "Hausbesuchspauschale Primärkasse";
|
||||
|
||||
if (c2s.CostBearer.Organisation.Function != null)
|
||||
{
|
||||
if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse"))
|
||||
{
|
||||
preisName = "Hausbesuchspauschale Ersatzkasse";
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetPreis(preisName, dt);
|
||||
}
|
||||
|
||||
protected decimal GetGruppenPreis(CostBearer2SupportConcept c2s, DateTime dt)
|
||||
{
|
||||
String preisName = "Gruppentherapie Primärkasse";
|
||||
|
||||
if (c2s.CostBearer.Organisation.Function != null)
|
||||
{
|
||||
if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse"))
|
||||
{
|
||||
preisName = "Gruppentherapie Ersatzkasse";
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetPreis(preisName, dt);
|
||||
}
|
||||
|
||||
protected decimal GetEinzelPreis(CostBearer2SupportConcept c2s, DateTime dt)
|
||||
{
|
||||
String preisName = "Einzelstunde Primärkasse";
|
||||
|
||||
if (c2s.CostBearer.Organisation.Function != null)
|
||||
{
|
||||
if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse"))
|
||||
{
|
||||
preisName = "Einzelstunde Ersatzkasse";
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetPreis(preisName, dt);
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateSummaryInvoiceItems(IList<InvoiceItem> itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount)
|
||||
{
|
||||
var newlist = new List<InvoiceItem>();
|
||||
|
||||
var rateToItem = new Dictionary<String, InvoiceItem>();
|
||||
foreach (InvoiceItem iitem in itemList)
|
||||
{
|
||||
InvoiceItem item;
|
||||
|
||||
var key = String.Format("{0}_{1}_{2:yyyyMMdd}_{3}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemPeriodStart, iitem.UnitDescription);
|
||||
|
||||
if (rateToItem.ContainsKey(key))
|
||||
{
|
||||
item = rateToItem[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
item = new InvoiceItem();
|
||||
newlist.Add(item);
|
||||
|
||||
item.AmountPerUnit = iitem.AmountPerUnit;
|
||||
item.ItemPeriodStart = iitem.ItemPeriodStart.Value.Date;
|
||||
item.ItemPeriodEnd = iitem.ItemPeriodEnd.Value.Date;
|
||||
|
||||
item.RateFactor = iitem.RateFactor;
|
||||
|
||||
item.AccountingInterval = iitem.AccountingInterval;
|
||||
item.ItemDescription = iitem.ItemDescription;
|
||||
item.UnitDescription = iitem.UnitDescription;
|
||||
item.SupportConceptApprovalPeriodOid = scap.Oid;
|
||||
item.ServiceRecord = iitem.ServiceRecord;
|
||||
|
||||
rateToItem[key] = item;
|
||||
}
|
||||
|
||||
|
||||
if (!item.UnitCount.HasValue)
|
||||
{
|
||||
item.UnitCount = 0;
|
||||
}
|
||||
item.UnitCount += iitem.UnitCount ?? 0;
|
||||
}
|
||||
|
||||
BerechneSummaryItemsSummen(newlist, addRateFactorToUnitCount);
|
||||
|
||||
return newlist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ namespace BeWo.Service.ServiceContracts
|
||||
[RequirePermission(UserRightType.AiModuleChatAdd)]
|
||||
AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
[RequirePermission(UserRightType.AiModuleChatAdd)]
|
||||
AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, long modell_oid, string message);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
[RequirePermission(UserRightType.AiModuleChatClone)]
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Linq;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Description;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -106,34 +107,50 @@ namespace BeWo.Service.ServiceImplementations
|
||||
}
|
||||
public AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid)
|
||||
{
|
||||
var conv = CreateAiConversation(conversation.UIContext, conversation.ContextBeWoObjects, modell_oid);
|
||||
var conv_dc = MapperFactory.AiConversation.MapToNewDC(conv);
|
||||
return conv_dc;
|
||||
}
|
||||
|
||||
private AiConversation CreateAiConversation(int uicontext, Dictionary<TableID, long[]> context , long modell_oid) {
|
||||
var current_user = UserRightHelper.GetLoggedInUserWithOid();
|
||||
|
||||
var system_prompt = AiPromptFactory.CreateSystemInstructions(conversation.UIContext, conversation.ContextBeWoObjects);
|
||||
var system_prompt = AiPromptFactory.CreateSystemInstructions(uicontext, context);
|
||||
|
||||
var conv = new AiConversation();
|
||||
conv.Created = DateTime.Now;
|
||||
conv.ContextBeWoObjects = MapperFactory.AiConversation.Parse(conversation.ContextBeWoObjects);
|
||||
conv.ContextBeWoObjects = MapperFactory.AiConversation.Parse(context);
|
||||
conv.Displayname = "Displayname";
|
||||
conv.Messages = new List<AiConversationMessage>();
|
||||
conv.Modell = DAOFactory.GenericDAO.LoadByID<AiModel>(modell_oid);
|
||||
conv.UIContext = conversation.UIContext;
|
||||
conv.UIContext = uicontext;
|
||||
conv.Updated = DateTime.Now;
|
||||
conv.ApplicationUserOid = current_user.Oid;
|
||||
|
||||
var msg = new AiConversationMessage();
|
||||
msg.Message = system_prompt;
|
||||
msg.AiConversation = conv;
|
||||
msg.Role = BS.Shared.AiConversationMessageRole.System;
|
||||
msg.Role = AiConversationMessageRole.System;
|
||||
msg.Created = DateTime.Now;
|
||||
|
||||
conv.Messages.Add(msg);
|
||||
|
||||
DAOFactory.GenericDAO.Insert(conv);
|
||||
|
||||
var dc = MapperFactory.AiConversation.MapToNewDC(conv);
|
||||
|
||||
return dc;
|
||||
return conv;
|
||||
}
|
||||
|
||||
public AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, long modell_oid, string message)
|
||||
{
|
||||
var conv = CreateAiConversation(conversation.UIContext, conversation.ContextBeWoObjects, modell_oid);
|
||||
|
||||
var new_messages = SendNewMessage(conv, message);
|
||||
|
||||
var conv_dc = MapperFactory.AiConversation.MapToNewDC(conv);
|
||||
|
||||
return conv_dc;
|
||||
}
|
||||
|
||||
public AiConversationDC CloneAiConversation(long conversation_oid, long? last_message_oid)
|
||||
{
|
||||
var parent_conv = DAOFactory.GenericDAO.GetByID<AiConversation>(conversation_oid);
|
||||
@@ -186,6 +203,11 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
var conv = DAOFactory.GenericDAO.LoadByID<AiConversation>(conversation);
|
||||
|
||||
return SendNewMessage(conv, message);
|
||||
}
|
||||
|
||||
private AiConversationMessageDC[] SendNewMessage(AiConversation conv, string message)
|
||||
{
|
||||
// Updated
|
||||
conv.Updated = DateTime.Now;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user