181 lines
12 KiB
C#
181 lines
12 KiB
C#
|
|
using CloudBuilder.Core.DependencyInjection.Request;
|
|
using CloudBuilder.Core.Request;
|
|
using CloudBuilder.Core.Service;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using CloudBuilder.Master.Service;
|
|
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
|
using CloudBuilder.Master.Data;
|
|
using System;
|
|
using CloudBuilder.Master.SearchCriteria;
|
|
using Microsoft.AspNetCore.Http;
|
|
using CloudBuilder.Master.Entity;
|
|
|
|
namespace CloudBuilder.Request.Master
|
|
{
|
|
|
|
public class FamilyTreeRequest : IRequest
|
|
{
|
|
|
|
private readonly IServiceRequest serviceRequest;
|
|
public FamilyTreeRequest(IServiceRequest serviceRequest)
|
|
{
|
|
this.serviceRequest = serviceRequest;
|
|
}
|
|
|
|
public FamilyTreeData FindAllByTreeId(string treeId)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData>("/FamilyTree/FindAllByTreeId?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeData FindByKey(string key)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData>("/FamilyTree/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class FindByCurrentPersonCompositionData2 {
|
|
public string key { get; set; }
|
|
public string personId { get; set; }
|
|
|
|
}
|
|
public FamilyTreeData FindByCurrentPerson(string key, string personId)
|
|
{
|
|
var compositionData = new FindByCurrentPersonCompositionData2{
|
|
key = key,
|
|
personId = personId };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FindByCurrentPersonCompositionData2, FamilyTreeData>("/FamilyTree/FindByCurrentPerson", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeResultData FindBySearchCriteria(FamilyTreeSearchCriteria criteria)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeSearchCriteria,FamilyTreeResultData>("/FamilyTree/FindBySearchCriteria" , criteria)).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeData Insert(FamilyTreeData data)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData,FamilyTreeData>("/FamilyTree/Insert" , data)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class RequestFamilyTreePermissionCompositionData2 {
|
|
public string treeId { get; set; }
|
|
public string currentPersonId { get; set; }
|
|
|
|
}
|
|
public void RequestFamilyTreePermission(string treeId, string currentPersonId)
|
|
{
|
|
var compositionData = new RequestFamilyTreePermissionCompositionData2{
|
|
treeId = treeId,
|
|
currentPersonId = currentPersonId };
|
|
Task.Run(() => serviceRequest.PostAsJsonAsync<RequestFamilyTreePermissionCompositionData2, dynamic>("/FamilyTree/RequestFamilyTreePermission", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class ApproveFamilyTreePermissionCompositionData4 {
|
|
public string treeId { get; set; }
|
|
public string currentPersonId { get; set; }
|
|
public string userName { get; set; }
|
|
public string managerIndc { get; set; }
|
|
|
|
}
|
|
public void ApproveFamilyTreePermission(string treeId, string currentPersonId, string userName, string managerIndc)
|
|
{
|
|
var compositionData = new ApproveFamilyTreePermissionCompositionData4{
|
|
treeId = treeId,
|
|
currentPersonId = currentPersonId,
|
|
userName = userName,
|
|
managerIndc = managerIndc };
|
|
Task.Run(() => serviceRequest.PostAsJsonAsync<ApproveFamilyTreePermissionCompositionData4, dynamic>("/FamilyTree/ApproveFamilyTreePermission", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class RejectFamilyTreePermissionCompositionData3 {
|
|
public string treeId { get; set; }
|
|
public string currentPersonId { get; set; }
|
|
public string userName { get; set; }
|
|
|
|
}
|
|
public void RejectFamilyTreePermission(string treeId, string currentPersonId, string userName)
|
|
{
|
|
var compositionData = new RejectFamilyTreePermissionCompositionData3{
|
|
treeId = treeId,
|
|
currentPersonId = currentPersonId,
|
|
userName = userName };
|
|
Task.Run(() => serviceRequest.PostAsJsonAsync<RejectFamilyTreePermissionCompositionData3, dynamic>("/FamilyTree/RejectFamilyTreePermission", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class BindSelfPersonCompositionData2 {
|
|
public string treeId { get; set; }
|
|
public string personId { get; set; }
|
|
|
|
}
|
|
public FamilyTreeData BindSelfPerson(string treeId, string personId)
|
|
{
|
|
var compositionData = new BindSelfPersonCompositionData2{
|
|
treeId = treeId,
|
|
personId = personId };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<BindSelfPersonCompositionData2, FamilyTreeData>("/FamilyTree/BindSelfPerson", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeData UnbindSelfPerson(string treeId)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData>("/FamilyTree/UnbindSelfPerson?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeData Update(FamilyTreeData data)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData,FamilyTreeData>("/FamilyTree/Update" , data)).GetAwaiter().GetResult(); }
|
|
|
|
public void Delete(string key)
|
|
{
|
|
Task.Run(() => serviceRequest.PostAsync("/FamilyTree/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
public void Deletes(string[] keys)
|
|
{
|
|
Task.Run(() => serviceRequest.PostAsJsonAsync<string[],dynamic>("/FamilyTree/Deletes" , keys)).GetAwaiter().GetResult(); }
|
|
|
|
public string GetExchangeFactor()
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<string> ("/FamilyTree/GetExchangeFactor")).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class ExportFamilyTreeCompositionData3 {
|
|
public string treeId { get; set; }
|
|
public string scope { get; set; }
|
|
public string anchorPersonId { get; set; }
|
|
|
|
}
|
|
public FamilyTreeExchangeData ExportFamilyTree(string treeId, string scope, string anchorPersonId)
|
|
{
|
|
var compositionData = new ExportFamilyTreeCompositionData3{
|
|
treeId = treeId,
|
|
scope = scope,
|
|
anchorPersonId = anchorPersonId };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<ExportFamilyTreeCompositionData3, FamilyTreeExchangeData>("/FamilyTree/ExportFamilyTree", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class SaveExchangeFileCompositionData2 {
|
|
public string fileName { get; set; }
|
|
public string contentBase64 { get; set; }
|
|
|
|
}
|
|
public string SaveExchangeFile(string fileName, string contentBase64)
|
|
{
|
|
var compositionData = new SaveExchangeFileCompositionData2{
|
|
fileName = fileName,
|
|
contentBase64 = contentBase64 };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<SaveExchangeFileCompositionData2, string>("/FamilyTree/SaveExchangeFile", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeExchangeFileInfo[] ListExchangeFiles(string treeId)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeExchangeFileInfo[]>("/FamilyTree/ListExchangeFiles?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
public string ReadExchangeFile(string fileName)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<string>("/FamilyTree/ReadExchangeFile?fileName=" + fileName.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class ImportFamilyTreeCompositionData2 {
|
|
public string targetTreeId { get; set; }
|
|
public FamilyTreeExchangeData data { get; set; }
|
|
|
|
}
|
|
public Int32 ImportFamilyTree(string targetTreeId, FamilyTreeExchangeData data)
|
|
{
|
|
var compositionData = new ImportFamilyTreeCompositionData2{
|
|
targetTreeId = targetTreeId,
|
|
data = data };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<ImportFamilyTreeCompositionData2, Int32>("/FamilyTree/ImportFamilyTree", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class ImportSubTreeCompositionData3 {
|
|
public string targetTreeId { get; set; }
|
|
public string anchorPersonId { get; set; }
|
|
public FamilyTreeExchangeData data { get; set; }
|
|
|
|
}
|
|
public Int32 ImportSubTree(string targetTreeId, string anchorPersonId, FamilyTreeExchangeData data)
|
|
{
|
|
var compositionData = new ImportSubTreeCompositionData3{
|
|
targetTreeId = targetTreeId,
|
|
anchorPersonId = anchorPersonId,
|
|
data = data };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<ImportSubTreeCompositionData3, Int32>("/FamilyTree/ImportSubTree", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
public FamilyTreeExchangeFileInfo[] ListBackups(string treeId)
|
|
{
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeExchangeFileInfo[]>("/FamilyTree/ListBackups?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); }
|
|
|
|
|
|
public class RestoreBackupCompositionData2 {
|
|
public string targetTreeId { get; set; }
|
|
public string backupFileName { get; set; }
|
|
|
|
}
|
|
public Int32 RestoreBackup(string targetTreeId, string backupFileName)
|
|
{
|
|
var compositionData = new RestoreBackupCompositionData2{
|
|
targetTreeId = targetTreeId,
|
|
backupFileName = backupFileName };
|
|
return Task.Run(() => serviceRequest.PostAsJsonAsync<RestoreBackupCompositionData2, Int32>("/FamilyTree/RestoreBackup", compositionData)).GetAwaiter().GetResult(); }
|
|
|
|
|
|
}
|
|
} |