temp
This commit is contained in:
@@ -1208,6 +1208,7 @@
|
||||
<Compile Include="ViewModel\BaseVM.cs" />
|
||||
<Compile Include="ViewModel\CustomerVermittlungArbeitVM.cs" />
|
||||
<Compile Include="ViewModel\ListViewModel\AbstractListVM.cs" />
|
||||
<Compile Include="ViewModel\ListViewModel\AiConversationMessageListVM.cs" />
|
||||
<Compile Include="ViewModel\ListViewModel\AiConversationListVM.cs" />
|
||||
<Compile Include="ViewModel\ListViewModel\CustomerVermittlungArbeitListVM.cs" />
|
||||
<Compile Include="ViewModel\Wohnhilfe\CustomerWohnhilfeBereichBundVM.cs" />
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace BeWo.ServiceProxy
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiModelDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiConversationMessageDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))]
|
||||
object Method1(object input, object input2);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/Method2", ReplyAction="http://tempuri.org/IOperationsEnhancedService/Method2Response")]
|
||||
@@ -29,6 +33,10 @@ namespace BeWo.ServiceProxy
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiModelDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiConversationMessageDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))]
|
||||
object Method2(object input, object input2);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/Method3", ReplyAction="http://tempuri.org/IOperationsEnhancedService/Method3Response")]
|
||||
@@ -37,6 +45,10 @@ namespace BeWo.ServiceProxy
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiModelDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiConversationMessageDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))]
|
||||
object Method3(object input, object input2);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/Method4", ReplyAction="http://tempuri.org/IOperationsEnhancedService/Method4Response")]
|
||||
@@ -45,11 +57,19 @@ namespace BeWo.ServiceProxy
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiModelDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List<BS.Shared.DataContracts.AiConversationMessageDC>))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))]
|
||||
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))]
|
||||
object Method4(object input, object input2);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/GetAiModels", ReplyAction="http://tempuri.org/IOperationsEnhancedService/GetAiModelsResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/GetAiModelsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.AiModelDC> GetAiModels();
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessage", ReplyAction="http://tempuri.org/IOperationsEnhancedService/SendNewMessageResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessageBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.Shared.DataContracts.AiConversationMessageDC SendNewMessage(BS.Shared.DataContracts.AiConversationDC conversation, string context, string input);
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
@@ -110,5 +130,10 @@ namespace BeWo.ServiceProxy
|
||||
{
|
||||
return base.Channel.GetAiModels();
|
||||
}
|
||||
|
||||
public BS.Shared.DataContracts.AiConversationMessageDC SendNewMessage(BS.Shared.DataContracts.AiConversationDC conversation, string context, string input)
|
||||
{
|
||||
return base.Channel.SendNewMessage(conversation, context, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,23 +49,23 @@ namespace BeWo.ServiceProxy
|
||||
_ServerName += "/";
|
||||
|
||||
_EndpointAddresses = new Dictionary<Type, EndpointAddress>
|
||||
{
|
||||
{ typeof(IQueryService), new EndpointAddress(_ServerName + "QueryService.svc") },
|
||||
{ typeof(IStreamingService), new EndpointAddress(_ServerName + "StreamingService.svc") },
|
||||
{ typeof(IEmployeeService), new EndpointAddress(_ServerName + "EmployeeService.svc") },
|
||||
{ typeof(ICustomerService), new EndpointAddress(_ServerName + "CustomerService.svc") },
|
||||
{ typeof(IUserService), new EndpointAddress(_ServerName + "UserService.svc") },
|
||||
{ typeof(IValueListService), new EndpointAddress(_ServerName + "ValueListService.svc") },
|
||||
{ typeof(IDownloadService), new EndpointAddress(_ServerName + "DownloadService.svc") },
|
||||
{ typeof(IResourceService), new EndpointAddress(_ServerName + "ResourceService.svc") },
|
||||
{ typeof(IOperationsService), new EndpointAddress(_ServerName + "OperationsService.svc") },
|
||||
{ typeof(IOperationsEnhancedService), new EndpointAddress(_ServerName + "OperationsEnhancedService.svc") },
|
||||
{ typeof(IAnalysisService), new EndpointAddress(_ServerName + "AnalysisService.svc") },
|
||||
{ typeof(IMailService), new EndpointAddress(_ServerName + "MailService.svc") },
|
||||
{ typeof(IAccountingService), new EndpointAddress(_ServerName + "AccountingService.svc") },
|
||||
{ typeof(IGkvAccountingService), new EndpointAddress(_ServerName + "GkvAccountingService.svc") },
|
||||
{
|
||||
{ typeof(IQueryService), new EndpointAddress(_ServerName + "QueryService.svc") },
|
||||
{ typeof(IStreamingService), new EndpointAddress(_ServerName + "StreamingService.svc") },
|
||||
{ typeof(IEmployeeService), new EndpointAddress(_ServerName + "EmployeeService.svc") },
|
||||
{ typeof(ICustomerService), new EndpointAddress(_ServerName + "CustomerService.svc") },
|
||||
{ typeof(IUserService), new EndpointAddress(_ServerName + "UserService.svc") },
|
||||
{ typeof(IValueListService), new EndpointAddress(_ServerName + "ValueListService.svc") },
|
||||
{ typeof(IDownloadService), new EndpointAddress(_ServerName + "DownloadService.svc") },
|
||||
{ typeof(IResourceService), new EndpointAddress(_ServerName + "ResourceService.svc") },
|
||||
{ typeof(IOperationsService), new EndpointAddress(_ServerName + "OperationsService.svc") },
|
||||
{ typeof(IOperationsEnhancedService), new EndpointAddress(_ServerName + "OperationsEnhancedService.svc") },
|
||||
{ typeof(IAnalysisService), new EndpointAddress(_ServerName + "AnalysisService.svc") },
|
||||
{ typeof(IMailService), new EndpointAddress(_ServerName + "MailService.svc") },
|
||||
{ typeof(IAccountingService), new EndpointAddress(_ServerName + "AccountingService.svc") },
|
||||
{ typeof(IGkvAccountingService), new EndpointAddress(_ServerName + "GkvAccountingService.svc") },
|
||||
{ typeof(IReportService), new EndpointAddress(_ServerName + "ReportService.svc") }
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ namespace BeWo.ServiceProxy
|
||||
|
||||
public static void DoOperationsEnhancedServiceSnyc(Action<IOperationsEnhancedService> pAction)
|
||||
=> DoSync<OperationsEnhancedServiceClient, IOperationsEnhancedService>(pAction);
|
||||
public static void DoOperationsEnhancedServiceSnyc<T>(Func<IOperationsEnhancedService, T> pFunc)
|
||||
public static T DoOperationsEnhancedServiceSnyc<T>(Func<IOperationsEnhancedService, T> pFunc)
|
||||
=> DoSync<OperationsEnhancedServiceClient, IOperationsEnhancedService, T>(pFunc);
|
||||
public static void DoOperationsEnhancedServiceAsnyc(Action<IOperationsEnhancedService> pAction, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null)
|
||||
=> DoAsync<OperationsEnhancedServiceClient, IOperationsEnhancedService>(pAction, pCallback, showWaitDialog, caller?.Dispatcher);
|
||||
public static void DoOperationsEnhancedServiceAsnyc<T>(Func < IOperationsEnhancedService, T> pFunc, Action<T> pCallback = null, bool showWaitDialog = true, UserControl caller = null)
|
||||
public static void DoOperationsEnhancedServiceAsnyc<T>(Func<IOperationsEnhancedService, T> pFunc, Action<T> pCallback = null, bool showWaitDialog = true, UserControl caller = null)
|
||||
=> DoAsync<OperationsEnhancedServiceClient, IOperationsEnhancedService, T>(pFunc, pCallback, showWaitDialog, caller?.Dispatcher);
|
||||
|
||||
public static void DoAccountingServiceAsync<T>(Func<IAccountingService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
@@ -115,17 +115,17 @@ namespace BeWo.ServiceProxy
|
||||
public static void DoAnalysisServiceAsync<T>(Func<IAnalysisService, T> pFunc, Action<T> pCallBack)
|
||||
{
|
||||
DoAsync<AnalysisServiceClient, IAnalysisService, T>(pFunc, pCallBack, true);
|
||||
|
||||
}
|
||||
public static void DoAnalysisServiceAsync<T>(Func<IAnalysisService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<AnalysisServiceClient, IAnalysisService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
|
||||
}
|
||||
public static void DoAccountingServiceSync(Action<IAccountingService> pAction)
|
||||
{
|
||||
pAction.Invoke(GetInstance<AccountingServiceClient, IAccountingService>());
|
||||
}
|
||||
}
|
||||
public static void DoAnalysisServiceAsync<T>(Func<IAnalysisService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<AnalysisServiceClient, IAnalysisService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
|
||||
}
|
||||
public static void DoAccountingServiceSync(Action<IAccountingService> pAction)
|
||||
{
|
||||
pAction.Invoke(GetInstance<AccountingServiceClient, IAccountingService>());
|
||||
}
|
||||
|
||||
//
|
||||
public static void DoAnalysisServiceAsync(Action<IAnalysisService> pAction)
|
||||
@@ -191,21 +191,21 @@ namespace BeWo.ServiceProxy
|
||||
}
|
||||
}
|
||||
|
||||
public static T DoDownloadServiceSync<T>(Func<IDownloadService, T> pFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<DownloadServiceClient, IDownloadService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
public static T DoDownloadServiceSync<T>(Func<IDownloadService, T> pFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<DownloadServiceClient, IDownloadService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public static void DoEmployeeServiceAsync<T>(Func<IEmployeeService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
public static void DoEmployeeServiceAsync<T>(Func<IEmployeeService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<EmployeeServiceClient, IEmployeeService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
}
|
||||
@@ -232,57 +232,57 @@ namespace BeWo.ServiceProxy
|
||||
}
|
||||
}
|
||||
|
||||
public static T DoEmployeeServiceSync<T>(Func<IEmployeeService, T> pFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<EmployeeServiceClient, IEmployeeService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
public static T DoEmployeeServiceSync<T>(Func<IEmployeeService, T> pFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<EmployeeServiceClient, IEmployeeService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
#region Wohnheim
|
||||
public static void DoWohnheimServiceAsync<T>(Func<ICustomerService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<CustomerServiceClient, ICustomerService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
}
|
||||
public static void DoWohnheimServiceAsync<T>(Func<ICustomerService, T> pFunc, Action<T> pCallBack)
|
||||
{
|
||||
DoAsync<CustomerServiceClient, ICustomerService, T>(pFunc, pCallBack, true);
|
||||
}
|
||||
public static void DoWohnheimServiceAsync(Action<ICustomerService> pAction)
|
||||
{
|
||||
DoAsync<CustomerServiceClient,ICustomerService>(pAction, true);
|
||||
}
|
||||
public static void DoWohnheimServiceSync(Action<ICustomerService> pAction)
|
||||
{
|
||||
try
|
||||
{
|
||||
pAction.Invoke(GetInstance<CustomerServiceClient, ICustomerService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
}
|
||||
public static T DoWohnheimServiceSync<T>(Func<ICustomerService, T> pFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<CustomerServiceClient, ICustomerService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
{
|
||||
DoAsync<CustomerServiceClient, ICustomerService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
}
|
||||
public static void DoWohnheimServiceAsync<T>(Func<ICustomerService, T> pFunc, Action<T> pCallBack)
|
||||
{
|
||||
DoAsync<CustomerServiceClient, ICustomerService, T>(pFunc, pCallBack, true);
|
||||
}
|
||||
public static void DoWohnheimServiceAsync(Action<ICustomerService> pAction)
|
||||
{
|
||||
DoAsync<CustomerServiceClient, ICustomerService>(pAction, true);
|
||||
}
|
||||
public static void DoWohnheimServiceSync(Action<ICustomerService> pAction)
|
||||
{
|
||||
try
|
||||
{
|
||||
pAction.Invoke(GetInstance<CustomerServiceClient, ICustomerService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
}
|
||||
public static T DoWohnheimServiceSync<T>(Func<ICustomerService, T> pFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<CustomerServiceClient, ICustomerService>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage(e);
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GkvAccounting
|
||||
@@ -353,7 +353,7 @@ namespace BeWo.ServiceProxy
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
|
||||
public static void DoMultipleAccountingServicesAsync(List<Action<IAccountingService>> pActions, Action pAllDoneCallBack)
|
||||
{
|
||||
DoMulitpleAsync<AccountingServiceClient, IAccountingService>(pActions, pAllDoneCallBack, true);
|
||||
@@ -501,11 +501,11 @@ namespace BeWo.ServiceProxy
|
||||
DoAsync<ResourceServiceClient, IResourceService>(pAction, true);
|
||||
}
|
||||
|
||||
public static void DoResourceServiceAsync(Action<IResourceService> pAction, Action pCallback)
|
||||
{
|
||||
DoAsync<ResourceServiceClient, IResourceService>(pAction, pCallback, true);
|
||||
}
|
||||
|
||||
public static void DoResourceServiceAsync(Action<IResourceService> pAction, Action pCallback)
|
||||
{
|
||||
DoAsync<ResourceServiceClient, IResourceService>(pAction, pCallback, true);
|
||||
}
|
||||
|
||||
public static void DoStreamingServiceAsync<T>(Func<IStreamingService, T> pFunc, Action<T> pCallBack, Action pErrorCallBack)
|
||||
{
|
||||
DoAsync<StreamingServiceClient, IStreamingService, T>(pFunc, pCallBack, pErrorCallBack, true);
|
||||
@@ -521,20 +521,20 @@ namespace BeWo.ServiceProxy
|
||||
DoAsync<UserServiceClient, IUserService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
}
|
||||
|
||||
public static T DoUserServiceSync<T>(Func<IUserService, T> pFunc)
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<UserServiceClient, IUserService>());
|
||||
}
|
||||
public static T DoUserServiceSync<T>(Func<IUserService, T> pFunc)
|
||||
{
|
||||
return pFunc.Invoke(GetInstance<UserServiceClient, IUserService>());
|
||||
}
|
||||
|
||||
public static void DoUserServiceAsync(Action<IUserService> pAction, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<UserServiceClient, IUserService>(pAction, showWaitDialog);
|
||||
}
|
||||
|
||||
public static void DoUserServiceAsync(Action<IUserService> pAction, Action pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<UserServiceClient, IUserService>(pAction, pCallBack, showWaitDialog);
|
||||
}
|
||||
public static void DoUserServiceAsync(Action<IUserService> pAction, Action pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<UserServiceClient, IUserService>(pAction, pCallBack, showWaitDialog);
|
||||
}
|
||||
|
||||
public static void DoValueListServiceAsync<T>(Func<IValueListService, T> pFunc, Action<T> pCallBack)
|
||||
{
|
||||
@@ -570,12 +570,12 @@ namespace BeWo.ServiceProxy
|
||||
DoAsync<ReportServiceClient, IReportService, T>(pFunc, pCallBack, true);
|
||||
}
|
||||
|
||||
public static void DoReportServiceAsync<T>(Func<IReportService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<ReportServiceClient, IReportService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
}
|
||||
public static void DoReportServiceAsync<T>(Func<IReportService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
|
||||
{
|
||||
DoAsync<ReportServiceClient, IReportService, T>(pFunc, pCallBack, showWaitDialog);
|
||||
}
|
||||
|
||||
public static void DoReportServiceSync(Action<IReportService> pAction)
|
||||
public static void DoReportServiceSync(Action<IReportService> pAction)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -656,14 +656,14 @@ namespace BeWo.ServiceProxy
|
||||
{
|
||||
DoUserServiceAsync(s => s.GetAllUsersCompact().Cast<T>().ToList(), r => pCallBack(r), true);
|
||||
}
|
||||
else if (typeof (T) == typeof (ResourceDC))
|
||||
else if (typeof(T) == typeof(ResourceDC))
|
||||
{
|
||||
DoResourceServiceAsync(s => s.GetAllResources().Cast<T>().ToList(), pCallBack, true);
|
||||
}
|
||||
else if (typeof (T) == typeof (TextModuleDC))
|
||||
{
|
||||
DoOperationsServiceAsync(s => s.GetAllTextModules().Cast<T>().ToList(), pCallBack);
|
||||
}
|
||||
else if (typeof(T) == typeof(TextModuleDC))
|
||||
{
|
||||
DoOperationsServiceAsync(s => s.GetAllTextModules().Cast<T>().ToList(), pCallBack);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -683,18 +683,19 @@ namespace BeWo.ServiceProxy
|
||||
where TClient : ClientBase<TInterface>, TInterface, new()
|
||||
where TInterface : class
|
||||
{
|
||||
Action<T> action = pCallback;
|
||||
|
||||
if (dispatcher != null)
|
||||
|
||||
if(dispatcher is null)
|
||||
{
|
||||
action = (t) => dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Normal,
|
||||
(Action)delegate
|
||||
{
|
||||
pCallback(t);
|
||||
});
|
||||
dispatcher = BeWoApp.Current.Dispatcher;
|
||||
}
|
||||
|
||||
Action<T> action = (t) => dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Normal,
|
||||
(Action)delegate
|
||||
{
|
||||
pCallback(t);
|
||||
});
|
||||
|
||||
DoAsync<TClient, TInterface, T>(pFunc, action, showWaitDialog);
|
||||
}
|
||||
|
||||
@@ -775,7 +776,7 @@ namespace BeWo.ServiceProxy
|
||||
{
|
||||
Action action = pCallback;
|
||||
|
||||
if(dispatcher != null)
|
||||
if (dispatcher != null)
|
||||
{
|
||||
action = () => dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Normal,
|
||||
@@ -898,7 +899,7 @@ namespace BeWo.ServiceProxy
|
||||
}
|
||||
|
||||
private static void DoSync<TClient, TInterface>(Action<TInterface> pAction)
|
||||
where TClient : ClientBase<TInterface>, TInterface, new ()
|
||||
where TClient : ClientBase<TInterface>, TInterface, new()
|
||||
where TInterface : class
|
||||
{
|
||||
try
|
||||
@@ -965,17 +966,17 @@ namespace BeWo.ServiceProxy
|
||||
{
|
||||
lClient = new TClient();
|
||||
|
||||
if(!_ProxyCache.ContainsKey(lClient.GetType()))
|
||||
{
|
||||
_ProxyCache.Add(typeof(TClient), lClient);
|
||||
}
|
||||
if (!_ProxyCache.ContainsKey(lClient.GetType()))
|
||||
{
|
||||
_ProxyCache.Add(typeof(TClient), lClient);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
if (DebugConfig.CurrentConfig is DebugConfig current && current.EnableAutoRemoteDebugging)
|
||||
{
|
||||
if (lClient.Endpoint.Binding is BasicHttpBinding binding)
|
||||
{
|
||||
if(_ServerName?.StartsWith("https") ?? true)
|
||||
if (_ServerName?.StartsWith("https") ?? true)
|
||||
{
|
||||
binding.Security.Mode = BasicHttpSecurityMode.Transport;
|
||||
}
|
||||
@@ -992,7 +993,7 @@ namespace BeWo.ServiceProxy
|
||||
|
||||
lClient.Endpoint.Address = EndpointAddresses[typeof(TInterface)];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
d:DataContext="{d:DesignInstance Type=listviewmodel:AiConversationListVM}"
|
||||
d:DesignHeight="300"
|
||||
d:DesignHeight="600"
|
||||
d:DesignWidth="600"
|
||||
Focusable="True"
|
||||
Loaded="BeWoView_Loaded"
|
||||
@@ -135,21 +135,69 @@
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel>
|
||||
<Grid>
|
||||
<ListView
|
||||
x:Name="listbox_conversations"
|
||||
Background="Transparent"
|
||||
ItemsSource="{Binding VMList}">
|
||||
ItemsSource="{Binding VMList}"
|
||||
SelectedItem="{Binding SelectedVM}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:Name="conversation_datatemplate" DataType="viewmodel:AiConversationVM">
|
||||
<TextBlock Text="{Binding Json}" />
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</DockPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox
|
||||
Height="100"
|
||||
MaxHeight="200"
|
||||
x:Name="txt_input_context"
|
||||
Margin="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Text="{Binding Context_Input}"
|
||||
AcceptsReturn="True"/>
|
||||
<TextBox
|
||||
Height="100"
|
||||
MaxHeight="200"
|
||||
Grid.Column="1"
|
||||
x:Name="txt_input_message"
|
||||
Margin="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Text="{Binding MessageInput}"
|
||||
AcceptsReturn="True"/>
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Margin="5"
|
||||
VerticalAlignment="Stretch"
|
||||
Command="{Binding SendNewMessageCommand}"
|
||||
Content="Senden" />
|
||||
</Grid>
|
||||
<ListView
|
||||
x:Name="listbox_messages"
|
||||
Grid.Row="1"
|
||||
Background="Transparent"
|
||||
ItemsSource="{Binding SelectedVM.Messages.VMList, Converter={StaticResource TestDebugConverter}}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:Name="messages_datatemplate" DataType="viewmodel:AiConversationMessageVM">
|
||||
<TextBlock Text="{Binding Json}" />
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
@@ -175,7 +223,7 @@
|
||||
x:Name="btnNew"
|
||||
Height="25"
|
||||
Margin="0,0,0,0"
|
||||
Command=""
|
||||
Command="{Binding RequestNewConversationCommand}"
|
||||
Content="Neuer Chat"
|
||||
FontWeight="Medium"
|
||||
Style="{StaticResource NavigationToolbarButtonStyle}"
|
||||
@@ -189,6 +237,15 @@
|
||||
FontWeight="Medium"
|
||||
Style="{StaticResource NavigationToolbarButtonStyle}"
|
||||
Visibility="Visible" />
|
||||
<Button
|
||||
x:Name="btnTest"
|
||||
Height="25"
|
||||
Margin="0,0,0,0"
|
||||
Command="{Binding TestCommand}"
|
||||
Content="Test Szenario"
|
||||
FontWeight="Medium"
|
||||
Style="{StaticResource NavigationToolbarButtonStyle}"
|
||||
Visibility="Visible" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Height="Auto"
|
||||
@@ -217,7 +274,7 @@
|
||||
Width="200"
|
||||
Height="200"
|
||||
StaysOpen="True">
|
||||
<Grid Margin="5">
|
||||
<Grid Margin="5" Background="Orange">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
|
||||
@@ -26,13 +26,10 @@ namespace BeWo.View.Master
|
||||
/// </summary>
|
||||
public partial class AiConversationView : BeWoView
|
||||
{
|
||||
private bool models_loaded = false;
|
||||
|
||||
public AiConversationView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
RequestNewConversationCommand = new DelegateCommand(RequestNewConversation);
|
||||
OpenAiSettingCommand = new DelegateCommand(OpenAiSetting);
|
||||
}
|
||||
|
||||
@@ -42,16 +39,11 @@ namespace BeWo.View.Master
|
||||
set => DataContext = value;
|
||||
}
|
||||
|
||||
public DelegateCommand RequestNewConversationCommand { get; set; }
|
||||
public DelegateCommand OpenAiSettingCommand { get; set; }
|
||||
|
||||
private void BeWoView_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (models_loaded) return;
|
||||
|
||||
models_loaded = true;
|
||||
|
||||
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); }, true, this);
|
||||
}
|
||||
|
||||
private void ReloadButton_OnClick(object sender, RoutedEventArgs e)
|
||||
@@ -59,12 +51,6 @@ namespace BeWo.View.Master
|
||||
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); }, true, this);
|
||||
}
|
||||
|
||||
|
||||
public void RequestNewConversation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OpenAiSetting()
|
||||
{
|
||||
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) =>
|
||||
|
||||
@@ -2,36 +2,47 @@
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BeWo.ViewModel
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class AiConversationMessageVM : AbstractDCMapperVM<AiConversationMessageDC>
|
||||
{
|
||||
private long? _Oid;
|
||||
private string _ApiMethods;
|
||||
private string _Context;
|
||||
private string _Context2;
|
||||
private string _Prompt;
|
||||
private string _Model;
|
||||
private string _Result;
|
||||
private DateTime _TimeStamp;
|
||||
|
||||
public AiConversationMessageVM(AiConversationMessageDC dc) : base(dc, dc.Oid is null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public long? Oid
|
||||
public string Json
|
||||
{
|
||||
get { return _Oid; }
|
||||
get => JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 4)]
|
||||
public string ApiMethods
|
||||
{
|
||||
get { return _ApiMethods; }
|
||||
set
|
||||
{
|
||||
if (!AreDifferent(_Oid, value))
|
||||
if (!AreDifferent(ApiMethods, value))
|
||||
return;
|
||||
|
||||
_Oid = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Oid, value), nameof(Oid));
|
||||
FirePropertyChanged(nameof(Oid));
|
||||
_ApiMethods = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.ApiMethods, value), nameof(ApiMethods));
|
||||
FirePropertyChanged(nameof(ApiMethods));
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 3)]
|
||||
public string Context
|
||||
{
|
||||
get { return _Context; }
|
||||
@@ -46,6 +57,22 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 5)]
|
||||
public string Context2
|
||||
{
|
||||
get { return _Context2; }
|
||||
set
|
||||
{
|
||||
if (!AreDifferent(_Context2, value))
|
||||
return;
|
||||
|
||||
_Context2 = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Context2, value), nameof(Context2));
|
||||
FirePropertyChanged(nameof(Context2));
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 2)]
|
||||
public string Prompt
|
||||
{
|
||||
get { return _Prompt; }
|
||||
@@ -60,6 +87,7 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 1)]
|
||||
public string Model
|
||||
{
|
||||
get { return _Model; }
|
||||
@@ -74,6 +102,7 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 6)]
|
||||
public string Result
|
||||
{
|
||||
get { return _Result; }
|
||||
@@ -88,22 +117,39 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(Order = 7)]
|
||||
public DateTime TimeStamp
|
||||
{
|
||||
get { return _TimeStamp; }
|
||||
set
|
||||
{
|
||||
if (!AreDifferent(_TimeStamp, value))
|
||||
return;
|
||||
|
||||
_TimeStamp = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.TimeStamp, value), nameof(TimeStamp));
|
||||
FirePropertyChanged(nameof(TimeStamp));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitByDataContract(AiConversationMessageDC pDataContract)
|
||||
{
|
||||
_Oid = pDataContract.Oid;
|
||||
_Context = pDataContract.Context;
|
||||
_Prompt = pDataContract.Prompt;
|
||||
_Model = pDataContract.Model;
|
||||
_Result = pDataContract.Result;
|
||||
_TimeStamp = pDataContract.TimeStamp;
|
||||
_Context2 = pDataContract.Context2;
|
||||
_ApiMethods = pDataContract.ApiMethods;
|
||||
}
|
||||
|
||||
protected override AiConversationMessageDC MapToDataContract(AiConversationMessageDC pDataContract, bool doCommit)
|
||||
{
|
||||
pDataContract.Oid = _Oid;
|
||||
pDataContract.Context = _Context;
|
||||
pDataContract.Prompt = _Prompt;
|
||||
pDataContract.Model = _Model;
|
||||
pDataContract.Result = _Result;
|
||||
pDataContract.TimeStamp = _TimeStamp;
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BeWo.ViewModel
|
||||
private string _Modell;
|
||||
private string _View;
|
||||
private AiSettingDC _Setting;
|
||||
private ObservableCollection<AiConversationMessageDC> _Messages;
|
||||
private AiConversationMessageListVM _Messages;
|
||||
|
||||
public AiConversationVM() : this(new AiConversationDC()) { }
|
||||
public AiConversationVM(AiConversationDC dc) : base(dc, dc.Oid is null)
|
||||
@@ -104,9 +104,9 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<AiConversationMessageDC> Messages
|
||||
public AiConversationMessageListVM Messages
|
||||
{
|
||||
get { return _Messages; }
|
||||
get { return _Messages ?? (_Messages = new AiConversationMessageListVM()); }
|
||||
set
|
||||
{
|
||||
if (!AreDifferent(_Messages, value))
|
||||
@@ -127,9 +127,7 @@ namespace BeWo.ViewModel
|
||||
_Setting = pDataContract.Setting;
|
||||
|
||||
if (pDataContract.Messages is object)
|
||||
_Messages = new ObservableCollection<AiConversationMessageDC>(pDataContract.Messages);
|
||||
else
|
||||
_Messages = new ObservableCollection<AiConversationMessageDC>();
|
||||
_Messages = new AiConversationMessageListVM(pDataContract.Messages);
|
||||
}
|
||||
|
||||
protected override AiConversationDC MapToDataContract(AiConversationDC pDataContract, bool doCommit)
|
||||
@@ -139,7 +137,7 @@ namespace BeWo.ViewModel
|
||||
pDataContract.Modell = _Modell;
|
||||
pDataContract.View = _View;
|
||||
pDataContract.Setting = _Setting;
|
||||
pDataContract.Messages = _Messages.ToList();
|
||||
pDataContract.Messages = _Messages?.CopyToDCList(doCommit);
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
@@ -16,21 +17,41 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
public class AiConversationListVM : AbstractDCListMapperVM<AiConversationDC, AiConversationVM>
|
||||
{
|
||||
private string _MessageInput;
|
||||
private string _ContextInput;
|
||||
|
||||
private AiModelDC _SelectedModel;
|
||||
|
||||
public AiConversationListVM() : this(null)
|
||||
{
|
||||
VMList.Add(new AiConversationVM()
|
||||
{
|
||||
Created = DateTime.Now,
|
||||
Displayname = "Chat1"
|
||||
});
|
||||
//VMList.Add(new AiConversationVM()
|
||||
//{
|
||||
// Created = DateTime.Now,
|
||||
// Displayname = "Chat1",
|
||||
// Messages = new AiConversationMessageListVM(new List<AiConversationMessageDC>()
|
||||
// {
|
||||
// new AiConversationMessageDC() {
|
||||
// Context = "context",
|
||||
// Model = "model",
|
||||
// Oid = 1,
|
||||
// Prompt = "prompt",
|
||||
// Result = "result" }
|
||||
// })
|
||||
//});
|
||||
}
|
||||
public AiConversationListVM(List<AiConversationDC> pDCs) : base(pDCs)
|
||||
{
|
||||
Models = new ObservableSortCollection<AiModelDC>();
|
||||
|
||||
SendNewMessageCommand = new DelegateCommand(SendNewMessage, CanSendNewMessage);
|
||||
RequestNewConversationCommand = new DelegateCommand(RequestNewConversation);
|
||||
TestCommand = new DelegateCommand(Test);
|
||||
}
|
||||
|
||||
public DelegateCommand SendNewMessageCommand { get; set; }
|
||||
public DelegateCommand RequestNewConversationCommand { get; set; }
|
||||
public DelegateCommand TestCommand { get; set; }
|
||||
|
||||
public ObservableCollection<AiModelDC> Models { get; set; }
|
||||
public AiModelDC SelectedModel {
|
||||
get { return _SelectedModel; }
|
||||
@@ -43,5 +64,97 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
FirePropertyChanged(nameof(SelectedModel));
|
||||
}
|
||||
}
|
||||
public string MessageInput
|
||||
{
|
||||
get { return _MessageInput; }
|
||||
set
|
||||
{
|
||||
if (MessageInput == value)
|
||||
return;
|
||||
|
||||
_MessageInput = value;
|
||||
FirePropertyChanged(nameof(MessageInput));
|
||||
}
|
||||
}
|
||||
|
||||
public string ContextInput
|
||||
{
|
||||
get { return _ContextInput; }
|
||||
set
|
||||
{
|
||||
if (ContextInput == value)
|
||||
return;
|
||||
|
||||
_ContextInput = value;
|
||||
FirePropertyChanged(nameof(ContextInput));
|
||||
}
|
||||
}
|
||||
|
||||
public void SendNewMessage()
|
||||
{
|
||||
var msg = MessageInput;
|
||||
|
||||
var context = ContextInput;
|
||||
|
||||
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.SendNewMessage(SelectedVM.CommitToDataContract(), context, msg), (message) =>
|
||||
{
|
||||
SelectedVM.Messages.VMList.Add(new AiConversationMessageVM(message));
|
||||
});
|
||||
}
|
||||
|
||||
public void RequestNewConversation()
|
||||
{
|
||||
var dc = new AiConversationDC();
|
||||
|
||||
dc.Created = DateTime.Now;
|
||||
dc.Displayname = "Example";
|
||||
dc.Modell = SelectedModel?.ToString();
|
||||
|
||||
var vm = new AiConversationVM(dc);
|
||||
|
||||
VMList.Add(vm);
|
||||
}
|
||||
|
||||
public void Test()
|
||||
{
|
||||
var limit = 5;
|
||||
|
||||
var models = ServiceFacade.DoOperationsEnhancedServiceSnyc(x => x.GetAiModels());
|
||||
Models.MakeEqualTo(models);
|
||||
|
||||
VMList.Clear();
|
||||
|
||||
foreach (var vm in Models)
|
||||
{
|
||||
var dc = new AiConversationDC();
|
||||
|
||||
dc.Created = DateTime.Now;
|
||||
dc.Displayname = "Example";
|
||||
dc.Modell = vm.ToString();
|
||||
|
||||
var pvm = new AiConversationVM(dc);
|
||||
|
||||
VMList.Add(pvm);
|
||||
}
|
||||
|
||||
var msg = "Wie alt ist Frau Müller?";
|
||||
var context = "Frau Müller wurde am 1.1.1950 geboren. Aktuelle haben wir folgende Universalzeit: " + DateTime.Now.ToUniversalTime();
|
||||
|
||||
for (var i = 0; i < limit; i++)
|
||||
{
|
||||
foreach (var vm in VMList)
|
||||
{
|
||||
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.SendNewMessage(vm.CommitToDataContract(), context, msg), (message) =>
|
||||
{
|
||||
vm.Messages.VMList.Add(new AiConversationMessageVM(message));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanSendNewMessage()
|
||||
{
|
||||
return SelectedVM is object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
BeWo/ViewModel/ListViewModel/AiConversationMessageListVM.cs
Normal file
25
BeWo/ViewModel/ListViewModel/AiConversationMessageListVM.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using BeWo.ServiceProxy;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
using ChatController.Utilities.Extensions;
|
||||
using DevExpress.Mvvm;
|
||||
using DevExpress.XtraPrinting.Native;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
public class AiConversationMessageListVM : AbstractDCListMapperVM<AiConversationMessageDC, AiConversationMessageVM>
|
||||
{
|
||||
public AiConversationMessageListVM() : this(null) { }
|
||||
public AiConversationMessageListVM(List<AiConversationMessageDC> pDCs) : base(pDCs)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -587,7 +587,6 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="AI\" />
|
||||
<Folder Include="ServiceUtils\API\" />
|
||||
<Folder Include="ServiceUtils\Generell\" />
|
||||
<Folder Include="Utils\" />
|
||||
@@ -601,6 +600,12 @@
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="AI\system_prompt.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="AI\system_prompt2.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace BeWo.Service.ServiceContracts
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
List<AiModelDC> GetAiModels();
|
||||
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
AiConversationMessageDC SendNewMessage(AiConversationDC conversation, string context, string input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
using BeWo.Service.ServiceContracts;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.ServiceContracts;
|
||||
using BeWo.Service.ServiceProxy;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.MikePHPContracts;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -15,13 +19,13 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
public object Method1(object input, object input2)
|
||||
{
|
||||
if(input is int i)
|
||||
if (input is int i)
|
||||
{
|
||||
if(i == 1)
|
||||
if (i == 1)
|
||||
{
|
||||
return new AiSettingDC();
|
||||
}
|
||||
if(i == 2)
|
||||
if (i == 2)
|
||||
{
|
||||
return new List<AiConversationDC>();
|
||||
}
|
||||
@@ -53,5 +57,66 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
return ServiceFacade.MikePHPScriptFacade.GetAiModelle();
|
||||
}
|
||||
|
||||
public AiConversationMessageDC SendNewMessage(AiConversationDC conversation, string context, string input)
|
||||
{
|
||||
var model = conversation.Modell;
|
||||
|
||||
var dc = new AiConversationMessageDC();
|
||||
|
||||
dc.Prompt = input;
|
||||
dc.Model = model;
|
||||
dc.TimeStamp = DateTime.Now;
|
||||
|
||||
var result = ServiceFacade.MikePHPScriptFacade.SendAiRequestComplex(dc);
|
||||
|
||||
var test = result.GetResponseData();
|
||||
|
||||
var req = new AiMessageRequest2();
|
||||
|
||||
req.ApiData = new List<AiMessageRequestData>();
|
||||
|
||||
foreach (var endpoint in test.Endpoints) {
|
||||
if (string.IsNullOrEmpty(endpoint))
|
||||
continue;
|
||||
|
||||
List<string> data = new List<string>();
|
||||
if(endpoint == "get_klienten")
|
||||
{
|
||||
var dat = new CustomerServiceImp().GetAllCompactCustomers();
|
||||
data = dat.Select(JsonConvert.SerializeObject).ToList();
|
||||
}
|
||||
else if (endpoint == "get_mitarbeiter")
|
||||
{
|
||||
var dat = new EmployeeServiceImp().GetAllCompactEmployees();
|
||||
data = dat.Select(JsonConvert.SerializeObject).ToList();
|
||||
}
|
||||
else if (endpoint == "get_personen")
|
||||
{
|
||||
var dat = new CustomerServiceImp().GetAllActivePersonsCompact();
|
||||
data = dat.Select(JsonConvert.SerializeObject).ToList();
|
||||
}
|
||||
else if (endpoint == "get_arbeitsverträge")
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
req.ApiData.Add(new AiMessageRequestData() { Data = data, Name = endpoint });
|
||||
}
|
||||
}
|
||||
|
||||
dc.ApiMethods = string.Join(",", req.ApiData.Select(x => x.Name));
|
||||
|
||||
var input2 = JsonConvert.SerializeObject(req);
|
||||
|
||||
var result1 = ServiceFacade.MikePHPScriptFacade.SendAiRequest(dc, input2);
|
||||
|
||||
|
||||
dc.Result = result1.Response;
|
||||
|
||||
return dc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.MikePHPContracts;
|
||||
using DevExpress.DataAccess.Native.EntityFramework;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -30,5 +33,73 @@ namespace BeWo.Service.ServiceProxy
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public AiMessageResponse SendAiRequest(AiConversationMessageDC msg, string api_data)
|
||||
{
|
||||
var url = "https://ai1.ownsoft.de/osaiquery.php";
|
||||
|
||||
msg.Context2 = getSystemPrompt2() + api_data;
|
||||
|
||||
var request = new AiMessageRequest()
|
||||
{
|
||||
Context = msg.Context2,
|
||||
Model = msg.Model,
|
||||
Option = "json",
|
||||
Prompt = msg.Prompt
|
||||
};
|
||||
|
||||
var result = SendPost<AiMessageRequest, AiMessageResponse>(url, request);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public AiMessageResponse2 SendAiRequestComplex(AiConversationMessageDC msg)
|
||||
{
|
||||
var url = "https://ai1.ownsoft.de/osaiquery.php";
|
||||
|
||||
msg.Context = getSystemPrompt();
|
||||
|
||||
var request = new AiMessageRequest()
|
||||
{
|
||||
Context = msg.Context,
|
||||
Model = msg.Model,
|
||||
Option = "json",
|
||||
Prompt = msg.Prompt
|
||||
};
|
||||
|
||||
var result = SendPost<AiMessageRequest, AiMessageResponse2>(url, request);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string getSystemPrompt()
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName = "BeWo.Service.AI.system_prompt.txt";
|
||||
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
string result = reader.ReadToEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string getSystemPrompt2()
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName = "BeWo.Service.AI.system_prompt2.txt";
|
||||
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
string result = reader.ReadToEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
Service/ai/system_prompt.txt
Normal file
19
Service/ai/system_prompt.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Du bist ein intelligenter API-Assistent. Deine einzige Aufgabe ist es, Benutzeranfragen zu analysieren und die benötigten API-Endpunkte zu bestimmen.
|
||||
|
||||
### Regeln:
|
||||
- Deine Antwort MUSS IMMER ein gültiges JSON-Objekt sein, nichts anderes.
|
||||
- KEINE Erklärungen, KEIN Fließtext, KEINE zusätzlichen Notizen!
|
||||
- Falls keine passenden API-Endpunkte existieren, antworte mit `{}`.
|
||||
|
||||
### Verfügbare API-Endpunkte:
|
||||
- get_klienten: Gibt eine Liste aller Klienten mit Verweis auf Person zurück.
|
||||
- get_mitarbeiter: Gibt eine Liste aller Mitarbeiter mit Verweis auf Person zurück.
|
||||
- get_personen: Gibt eine Liste aller Personen zurück. Hier werden Daten wie Geburtstag, Geschlecht und Anschrift gespeichert.
|
||||
- get_arbeitsverträge: Gibt eine Liste aller Arbeitsvertrage zurück.
|
||||
|
||||
### Beispielantworten:
|
||||
|
||||
**Benutzeranfrage:**
|
||||
"Wie ist die Telefonnummer von Klientin Frau Müller?"
|
||||
**Erwartete JSON-Antwort:**
|
||||
{"endpoints": ["get_klienten"]}
|
||||
12
Service/ai/system_prompt2.txt
Normal file
12
Service/ai/system_prompt2.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Du bist ein intelligenter Assistent. Deine Aufgabe ist es, basierend auf einer Nutzeranfrage und den bereitgestellten API-Daten eine klare und präzise Antwort zu generieren.
|
||||
|
||||
WICHTIG:
|
||||
- Verwende ausschließlich die bereitgestellten API-Daten für deine Antwort.
|
||||
- Falls die API-Daten nicht die benötigte Information enthalten, gib an, dass die Daten fehlen, anstatt zu raten.
|
||||
- KEINE Erklärungen, KEIN Fließtext, KEINE zusätzlichen Notizen!
|
||||
- Deine Antwort soll eine direkte und verständliche Antwort für den Nutzer sein.
|
||||
|
||||
---
|
||||
|
||||
### **API-Daten**
|
||||
Du erhälst folgendes:
|
||||
@@ -1,7 +1,11 @@
|
||||
using DevExpress.DataAccess.Native.EntityFramework;
|
||||
using BS.Shared.Extensions;
|
||||
using DevExpress.DataAccess.Native.EntityFramework;
|
||||
using DevExpress.DataAccess.Native.Web;
|
||||
using DevExpress.XtraRichEdit.Import.Html;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Policy;
|
||||
@@ -15,49 +19,48 @@ namespace BS.Shared.Core
|
||||
//
|
||||
// GET
|
||||
//
|
||||
protected TRes SendGet<TRes>(string url)
|
||||
=> Get<TRes>(url);
|
||||
protected Task<TRes> SendGetAsync<TRes>(string url)
|
||||
=> GetAsync<TRes>(url);
|
||||
protected TRes SendGet<TRes>(string url, string token = null)
|
||||
=> Get<TRes>(url, token);
|
||||
protected Task<TRes> SendGetAsync<TRes>(string url, string token = null)
|
||||
=> GetAsync<TRes>(url, token);
|
||||
|
||||
//
|
||||
// POST
|
||||
//
|
||||
protected TRes SendPost<TReq, TRes>(string url, TReq req)
|
||||
=> Send<TReq, TRes>(url, "POST", req);
|
||||
public Task<TRes> SendPostAsync<TReq, TRes>(string url, TReq req)
|
||||
=> SendAsync<TReq, TRes>(url, "POST", req);
|
||||
|
||||
protected TRes SendPost<TReq, TRes>(string url, TReq req, string token = null)
|
||||
=> Send<TReq, TRes>(url, "POST", req, token);
|
||||
protected Task<TRes> SendPostAsync<TReq, TRes>(string url, TReq req, string token = null)
|
||||
=> SendAsync<TReq, TRes>(url, "POST", req, token);
|
||||
|
||||
#region private
|
||||
//
|
||||
// Requests
|
||||
//
|
||||
private TRes Get<TRes>(string url)
|
||||
private TRes Get<TRes>(string url, string token = null)
|
||||
{
|
||||
string response = Get(url);
|
||||
string response = Get(url, token);
|
||||
|
||||
return deserialize<TRes>(response);
|
||||
}
|
||||
private TRes Send<TReq, TRes>(string url, string method, TReq req)
|
||||
private TRes Send<TReq, TRes>(string url, string method, TReq req, string token = null)
|
||||
{
|
||||
string dataString = serialize(req);
|
||||
var data = serialize(req);
|
||||
|
||||
string response = Send(url, method, dataString);
|
||||
string response = Send(url, method, data, token);
|
||||
|
||||
return deserialize<TRes>(response);
|
||||
}
|
||||
private async Task<TRes> GetAsync<TRes>(string url)
|
||||
private async Task<TRes> GetAsync<TRes>(string url, string token = null)
|
||||
{
|
||||
string response = await GetAsync(url);
|
||||
string response = await GetAsync(url, token);
|
||||
|
||||
return deserialize<TRes>(response);
|
||||
}
|
||||
private async Task<TRes> SendAsync<TReq, TRes>(string url, string method, TReq req)
|
||||
private async Task<TRes> SendAsync<TReq, TRes>(string url, string method, TReq req, string token = null)
|
||||
{
|
||||
string dataString = serialize(req);
|
||||
var data = serialize(req);
|
||||
|
||||
string response = await SendAsync(url, method, method);
|
||||
string response = await SendAsync(url, method, method, token);
|
||||
|
||||
return deserialize<TRes>(response);
|
||||
}
|
||||
@@ -65,19 +68,19 @@ namespace BS.Shared.Core
|
||||
//
|
||||
// String
|
||||
//
|
||||
private string Get(string url)
|
||||
=> exec(client => client.DownloadString(url));
|
||||
private string Send(string url, string method, string dataString)
|
||||
=> exec(client => client.UploadString(url, method, dataString));
|
||||
private async Task<string> GetAsync(string url)
|
||||
=> await execasync(client => client.DownloadStringTaskAsync(url));
|
||||
private async Task<string> SendAsync(string url, string method, string dataString)
|
||||
=> await execasync(client => client.UploadStringTaskAsync(url, method, dataString));
|
||||
private string Get(string url, string token = null)
|
||||
=> exec(true, client => client.DownloadString(url), token);
|
||||
private string Send<T>(string url, string method, T request, string token = null)
|
||||
=> exec(false, client => Encoding.UTF8.GetString(client.UploadValues(url, method, request?.ToNameValueCollection())), token);
|
||||
private async Task<string> GetAsync(string url, string token = null)
|
||||
=> await execasync(true, client => client.DownloadStringTaskAsync(url), token);
|
||||
private async Task<string> SendAsync<T>(string url, string method, T request, string token = null)
|
||||
=> await execasync(false, async client => Encoding.UTF8.GetString(await client.UploadValuesTaskAsync(url, method, request?.ToNameValueCollection())), token);
|
||||
|
||||
//
|
||||
// Base
|
||||
//
|
||||
private string exec(Func<WebClient, string> action)
|
||||
private string exec(bool override_header, Func<WebClient, string> action, string token = null)
|
||||
{
|
||||
string response;
|
||||
|
||||
@@ -85,14 +88,18 @@ namespace BS.Shared.Core
|
||||
{
|
||||
client.Encoding = Encoding.UTF8;
|
||||
|
||||
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
|
||||
if (override_header)
|
||||
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
|
||||
|
||||
if(token != null)
|
||||
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + token);
|
||||
|
||||
response = action(client);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
private async Task<string> execasync(Func<WebClient, Task<string>> action)
|
||||
private async Task<string> execasync(bool override_header, Func<WebClient, Task<string>> action, string token = null)
|
||||
{
|
||||
string response;
|
||||
|
||||
@@ -100,7 +107,11 @@ namespace BS.Shared.Core
|
||||
{
|
||||
client.Encoding = Encoding.UTF8;
|
||||
|
||||
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
|
||||
if(override_header)
|
||||
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
|
||||
|
||||
if (token != null)
|
||||
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + token);
|
||||
|
||||
response = await action(client);
|
||||
}
|
||||
@@ -110,16 +121,19 @@ namespace BS.Shared.Core
|
||||
|
||||
private T deserialize<T>(string input)
|
||||
{
|
||||
if(string.IsNullOrEmpty(input))
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return default(T);
|
||||
|
||||
return JsonConvert.DeserializeObject<T>(input);
|
||||
if (typeof(T) == typeof(String))
|
||||
return (T)(object)input;
|
||||
|
||||
var t = JsonConvert.DeserializeObject<T>(input);
|
||||
|
||||
return t;
|
||||
}
|
||||
private string serialize<T>(T input)
|
||||
private IDictionary<string, string> serialize<T>(T input)
|
||||
{
|
||||
if(input is T)
|
||||
return JsonConvert.SerializeObject(input);
|
||||
return string.Empty;
|
||||
return input?.ToKeyValue();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -10,10 +10,14 @@ namespace BS.Shared.DataContracts
|
||||
[DataContract]
|
||||
public class AiConversationMessageDC : IDataContract
|
||||
{
|
||||
public long? Oid { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string Context { get; set; }
|
||||
public string Prompt { get; set; }
|
||||
public string Result { get; set; }
|
||||
[DataMember] public long? Oid { get; set; }
|
||||
[DataMember] public long? Version { get; set; }
|
||||
[DataMember] public string Model { get; set; }
|
||||
[DataMember] public string Context { get; set; }
|
||||
[DataMember] public string Prompt { get; set; }
|
||||
[DataMember] public string ApiMethods { get; set; }
|
||||
[DataMember] public string Context2 { get; set; }
|
||||
[DataMember] public string Result { get; set; }
|
||||
[DataMember] public DateTime TimeStamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
25
Shared/DataContracts/MikePHPContracts/AiMessageRequest.cs
Normal file
25
Shared/DataContracts/MikePHPContracts/AiMessageRequest.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts.MikePHPContracts
|
||||
{
|
||||
public class AiMessageRequest
|
||||
{
|
||||
[JsonProperty("mel")]
|
||||
public string Model { get; set; }
|
||||
|
||||
[JsonProperty("stm")]
|
||||
public string Context { get; set; }
|
||||
|
||||
[JsonProperty("pmt")]
|
||||
public string Prompt { get; set; }
|
||||
|
||||
[JsonProperty("opt")]
|
||||
public string Option { get; set; }
|
||||
}
|
||||
}
|
||||
22
Shared/DataContracts/MikePHPContracts/AiMessageRequest2.cs
Normal file
22
Shared/DataContracts/MikePHPContracts/AiMessageRequest2.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts.MikePHPContracts
|
||||
{
|
||||
public class AiMessageRequest2
|
||||
{
|
||||
[JsonProperty("api_data")]
|
||||
public List<AiMessageRequestData> ApiData { get; set; }
|
||||
}
|
||||
|
||||
public class AiMessageRequestData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<string> Data { get; set; }
|
||||
}
|
||||
}
|
||||
18
Shared/DataContracts/MikePHPContracts/AiMessageResponse.cs
Normal file
18
Shared/DataContracts/MikePHPContracts/AiMessageResponse.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts.MikePHPContracts
|
||||
{
|
||||
public class AiMessageResponse
|
||||
{
|
||||
[JsonProperty("model")]
|
||||
public string Model { get; set; }
|
||||
|
||||
[JsonProperty("response")]
|
||||
public string Response { get; set; }
|
||||
}
|
||||
}
|
||||
29
Shared/DataContracts/MikePHPContracts/AiMessageResponse2.cs
Normal file
29
Shared/DataContracts/MikePHPContracts/AiMessageResponse2.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts.MikePHPContracts
|
||||
{
|
||||
public class AiMessageResponse2
|
||||
{
|
||||
[JsonProperty("model")]
|
||||
public string Model { get; set; }
|
||||
|
||||
[JsonProperty("response")]
|
||||
public string Response { get; set; }
|
||||
|
||||
public AiMessageResponseData GetResponseData()
|
||||
{
|
||||
return JsonConvert.DeserializeObject<AiMessageResponseData>(Response);
|
||||
}
|
||||
}
|
||||
|
||||
public class AiMessageResponseData
|
||||
{
|
||||
[JsonProperty("endpoints")]
|
||||
public List<string> Endpoints { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BS.Shared.Extensions
|
||||
{
|
||||
@@ -25,5 +30,61 @@ namespace BS.Shared.Extensions
|
||||
{
|
||||
return pObject == null ? string.Empty : pObject.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static IDictionary<string, string> ToKeyValue(this object metaToken)
|
||||
{
|
||||
if (metaToken == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
JToken token = metaToken as JToken;
|
||||
if (token == null)
|
||||
{
|
||||
return ToKeyValue(JObject.FromObject(metaToken));
|
||||
}
|
||||
|
||||
if (token.HasValues)
|
||||
{
|
||||
var contentData = new Dictionary<string, string>();
|
||||
foreach (var child in token.Children().ToList())
|
||||
{
|
||||
var childContent = child.ToKeyValue();
|
||||
if (childContent != null)
|
||||
{
|
||||
contentData = contentData.Concat(childContent)
|
||||
.ToDictionary(k => k.Key, v => v.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return contentData;
|
||||
}
|
||||
|
||||
var jValue = token as JValue;
|
||||
if (jValue?.Value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var value = jValue?.Type == JTokenType.Date ?
|
||||
jValue?.ToString("o", CultureInfo.InvariantCulture) :
|
||||
jValue?.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
return new Dictionary<string, string> { { token.Path, value } };
|
||||
}
|
||||
|
||||
public static NameValueCollection ToNameValueCollection(this object obj)
|
||||
{
|
||||
var coll = new NameValueCollection();
|
||||
|
||||
var keyvalues = obj.ToKeyValue();
|
||||
|
||||
foreach (var kv in keyvalues)
|
||||
{
|
||||
coll.Add(kv.Key, kv.Value);
|
||||
}
|
||||
|
||||
return coll;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,7 @@
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Runtime.Serialization">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
@@ -203,6 +204,10 @@
|
||||
<Compile Include="DataContracts\GkvAbrechnung\GkvServerGetStatusResponseDC.cs" />
|
||||
<Compile Include="DataContracts\GkvAbrechnung\GkvClientResultRequestDC.cs" />
|
||||
<Compile Include="DataContracts\Invoicing\BankAccountDC.cs" />
|
||||
<Compile Include="DataContracts\MikePHPContracts\AiMessageRequest2.cs" />
|
||||
<Compile Include="DataContracts\MikePHPContracts\AiMessageRequest.cs" />
|
||||
<Compile Include="DataContracts\MikePHPContracts\AiMessageResponse2.cs" />
|
||||
<Compile Include="DataContracts\MikePHPContracts\AiMessageResponse.cs" />
|
||||
<Compile Include="DataContracts\Wohnhilfe\CustomerWohnhilfeDC.cs" />
|
||||
<Compile Include="DataContracts\ImageDC.cs" />
|
||||
<Compile Include="DataContracts\Wohnhilfe\CustomerWohnhilfeBereichBundDC.cs" />
|
||||
|
||||
Reference in New Issue
Block a user