|
@@ -10,58 +10,41 @@ using WingInterfaceLibrary.Enum;
|
|
|
using WingInterfaceLibrary.Request.Notification;
|
|
|
using WingInterfaceLibrary.Enum.NotificationEnum;
|
|
|
using WingServerCommon.Service;
|
|
|
+using WingInterfaceLibrary.LiveConsultation;
|
|
|
+using WingInterfaceLibrary.DTO.Organization;
|
|
|
+using WingInterfaceLibrary.Request.Consultation;
|
|
|
+using WingInterfaceLibrary.DTO;
|
|
|
+using WingInterfaceLibrary.Result;
|
|
|
+using WingInterfaceLibrary.DTO.Consultation;
|
|
|
+using WingInterfaceLibrary.Interface.DBInterface;
|
|
|
+using WingServerCommon.Interfaces.Cache;
|
|
|
+using WingInterfaceLibrary.DB.Request;
|
|
|
|
|
|
namespace WingLiveConsultationService
|
|
|
{
|
|
|
- public interface ILiveConsultationService
|
|
|
- {
|
|
|
- /// <summary>
|
|
|
- /// Initiate a diagnosis meeting
|
|
|
- /// </summary>
|
|
|
- /// <param name="request">The request</param>
|
|
|
- /// <returns></returns>
|
|
|
- Task<InitiateLiveConsultationResult> InitiateLiveConsultationAsync(InitiateLiveConsultationRequest request);
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Accept a diagnosis request
|
|
|
- /// </summary>
|
|
|
- /// <param name="request">The request</param>
|
|
|
- /// <returns></returns>
|
|
|
- Task<AcceptLiveConsultationResult> AcceptLiveConsultationAsync(AcceptLiveConsultationRequest request);
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Reject a diagnosis request
|
|
|
- /// </summary>
|
|
|
- /// <param name="request">The request</param>
|
|
|
- /// <returns></returns>
|
|
|
- Task<RejectLiveConsultationResult> RejectLiveConsultationAsync(RejectLiveConsultationRequest request);
|
|
|
- /// <summary>
|
|
|
- /// Join a diagnosis request
|
|
|
- /// </summary>
|
|
|
- /// <param name="request">The request</param>
|
|
|
- /// <returns></returns>
|
|
|
- Task<JoinLiveConsultationResult> JoinLiveConsultationAsync(JoinLiveConsultationRequest request);
|
|
|
- /// <summary>
|
|
|
- /// Leave a diagnosis request
|
|
|
- /// </summary>
|
|
|
- /// <param name="request">The request</param>
|
|
|
- /// <returns></returns>
|
|
|
- Task<LeaveLiveConsultationResult> LeaveLiveConsultationAsync(LeaveLiveConsultationRequest request);
|
|
|
- /// <summary>
|
|
|
- /// Send HeartRate request in a diagnosis metting
|
|
|
- /// </summary>
|
|
|
- /// <param name="request">The request</param>
|
|
|
- /// <returns></returns>
|
|
|
- Task<LiveConsultationHeartRateResult> HeartRateAsync(LiveConsultationHeartRateRequest request);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
public class LiveConsultationService : JsonRpcService, ILiveConsultationService
|
|
|
{
|
|
|
private readonly VideoProtocol _videoProtocol; //Todo from config
|
|
|
private ILiveConsultationRoomManager _realtimeDiagosisRoomManager;
|
|
|
private IAuthenticationService _authenticationService;
|
|
|
private INotificationService _notificationService;
|
|
|
-
|
|
|
+ private IUserDBService _userDBService;
|
|
|
+ private IOrganizationDBService _organizationDBService;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Init service
|
|
|
+ /// </summary>
|
|
|
+ public override void Load(JsonRpcClientPool jsonRpcClientPool)
|
|
|
+ {
|
|
|
+ base.Load(jsonRpcClientPool);
|
|
|
+ _authenticationService = GetProxy<IAuthenticationService>();
|
|
|
+ _notificationService = GetProxy<INotificationService>();
|
|
|
+ _userDBService = GetProxy<IUserDBService>();
|
|
|
+ _organizationDBService = GetProxy<IOrganizationDBService>();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Dispatch message function
|
|
|
/// </summary>
|
|
@@ -81,17 +64,18 @@ namespace WingLiveConsultationService
|
|
|
{
|
|
|
var token = request.Token;
|
|
|
var otherIds = request.OtherIds;
|
|
|
- var tokenRequest = new TokenRequest(){ Token= token};
|
|
|
- var tokensRequest = new GetTokenWithClientIdsRequest(){
|
|
|
- ClientIds = otherIds as List<string>
|
|
|
+ var tokenRequest = new TokenRequest() { Token = token };
|
|
|
+ var tokensRequest = new GetTokenWithClientIdsRequest()
|
|
|
+ {
|
|
|
+ ClientIds = otherIds as List<string>
|
|
|
};
|
|
|
var initiateToken = await _authenticationService.GetTokenAsync(tokenRequest);
|
|
|
var othersTokens = await _authenticationService.GetTokenWithClientIdsAsync(tokensRequest);
|
|
|
-
|
|
|
+
|
|
|
LiveConsultationMemeber initiator = null;
|
|
|
if (_videoProtocol == VideoProtocol.Rtc)
|
|
|
- {
|
|
|
- initiator = new LiveConsultationMemeber() {Id = initiateToken.Code, Name = initiateToken.AccountName};
|
|
|
+ {
|
|
|
+ initiator = new LiveConsultationMemeber() { Id = initiateToken.Code, Name = initiateToken.AccountName };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -100,20 +84,20 @@ namespace WingLiveConsultationService
|
|
|
{
|
|
|
//RtmpPushUrl = TODO
|
|
|
};
|
|
|
-
|
|
|
- initiator = new LiveConsultationMemeber()
|
|
|
+
|
|
|
+ initiator = new LiveConsultationMemeber()
|
|
|
{
|
|
|
- Id = initiateToken.Code,
|
|
|
+ Id = initiateToken.Code,
|
|
|
Name = initiateToken.AccountName,
|
|
|
LiveData = liveData
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
}
|
|
|
|
|
|
var others = new List<LiveConsultationMemeber>();
|
|
|
var devices = new List<LiveConsultationMemeber>();
|
|
|
|
|
|
- foreach(var tokenInfo in othersTokens)
|
|
|
+ foreach (var tokenInfo in othersTokens)
|
|
|
{
|
|
|
var type = tokenInfo.AccountType;
|
|
|
|
|
@@ -121,43 +105,43 @@ namespace WingLiveConsultationService
|
|
|
{
|
|
|
//RtmpPushUrl = TODO
|
|
|
};
|
|
|
-
|
|
|
- var member = new LiveConsultationMemeber()
|
|
|
+
|
|
|
+ var member = new LiveConsultationMemeber()
|
|
|
{
|
|
|
- Id = tokenInfo.Code,
|
|
|
+ Id = tokenInfo.Code,
|
|
|
Name = tokenInfo.AccountName,
|
|
|
LiveData = liveData
|
|
|
- };
|
|
|
- if(type == AccountType.User)
|
|
|
- {
|
|
|
+ };
|
|
|
+ if (type == AccountType.User)
|
|
|
+ {
|
|
|
others.Add(member);
|
|
|
- }
|
|
|
- else if(type == AccountType.US || type == AccountType.USBox)
|
|
|
- {
|
|
|
+ }
|
|
|
+ else if (type == AccountType.US || type == AccountType.USBox)
|
|
|
+ {
|
|
|
devices.Add(member);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- var room = _realtimeDiagosisRoomManager.CreateRoom(initiator, others, devices);
|
|
|
-
|
|
|
+ var room = _realtimeDiagosisRoomManager.CreateRoom(initiator, others, devices);
|
|
|
+
|
|
|
BroadcastNotificationRequest notificationRequest = new BroadcastNotificationRequest();
|
|
|
- var ids = others.Select(x=>x.Id).ToList();
|
|
|
+ var ids = others.Select(x => x.Id).ToList();
|
|
|
notificationRequest.ClientIds = ids; //TODO set message content
|
|
|
//notificationRequest.Message = new NotifyMessage
|
|
|
var notification = new InviteLiveConsultationNotification();
|
|
|
//notify other guys
|
|
|
- await _notificationService.PostBroadcastMessageAsync(notificationRequest);
|
|
|
+ await _notificationService.BroadcastMessageAsync(notificationRequest);
|
|
|
|
|
|
var result = new InitiateLiveConsultationResult();
|
|
|
|
|
|
//Start a timer for timeout process
|
|
|
room.StartCheckConnectionTimeout(60000);//TOOD get the timeout from config
|
|
|
-
|
|
|
- return result;
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Accept a diagnosis request
|
|
|
/// </summary>
|
|
@@ -166,8 +150,9 @@ namespace WingLiveConsultationService
|
|
|
public async Task<AcceptLiveConsultationResult> AcceptLiveConsultationAsync(AcceptLiveConsultationRequest request)
|
|
|
{
|
|
|
var token = request.Token;
|
|
|
- var roomId = request.RoomNo;
|
|
|
- var tokenRequest = new TokenRequest(){ Token= token};
|
|
|
+ //todo roomCode change to roomId ??
|
|
|
+ var roomId = Convert.ToInt32(request.RoomCode);
|
|
|
+ var tokenRequest = new TokenRequest() { Token = token };
|
|
|
var accepterToken = await _authenticationService.GetTokenAsync(tokenRequest);
|
|
|
|
|
|
var result = new AcceptLiveConsultationResult();
|
|
@@ -181,19 +166,19 @@ namespace WingLiveConsultationService
|
|
|
else
|
|
|
{
|
|
|
//Notify other guys
|
|
|
- var others = room.Members.Where(x=>x.Id != accepterToken.Code);
|
|
|
+ var others = room.Members.Where(x => x.Id != accepterToken.Code);
|
|
|
BroadcastNotificationRequest notificationRequest = new BroadcastNotificationRequest();
|
|
|
- var otherIds = others.Select(x=>x.Id).ToList();
|
|
|
+ var otherIds = others.Select(x => x.Id).ToList();
|
|
|
notificationRequest.ClientIds = otherIds; //TODO set message content
|
|
|
//notificationRequest.Message = new NotifyMessage
|
|
|
//notify other guys
|
|
|
- await _notificationService.PostBroadcastMessageAsync(notificationRequest);
|
|
|
+ await _notificationService.BroadcastMessageAsync(notificationRequest);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
+ /// <summary>
|
|
|
/// Reject a diagnosis request
|
|
|
/// </summary>
|
|
|
/// <param name="request">The request</param>
|
|
@@ -229,10 +214,99 @@ namespace WingLiveConsultationService
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
-
|
|
|
- private void ThrowRpcException(CustomerRpcCode code, string message, string internalMessage=null)
|
|
|
+
|
|
|
+ private void ThrowRpcException(CustomerRpcCode code, string message, string internalMessage = null)
|
|
|
+ {
|
|
|
+ base.ThrowRpcException((int)code, message, internalMessage ?? message);
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<List<OrganizationBaseDTO>> FindParentOrganizationsAsync(FindHigherOrganizationsRequest request)
|
|
|
+ {
|
|
|
+ var userCode = await GetClientIdByTokenAsync(request.Token);
|
|
|
+ var userInfoDO = await _userDBService.FindUserByCodeAsync(userCode);
|
|
|
+ var result = new List<OrganizationBaseDTO>
|
|
|
+ {
|
|
|
+
|
|
|
+ };
|
|
|
+ if (userInfoDO != null)
|
|
|
+ {
|
|
|
+ var organization = CacheMaintenance.Instance.Get<IOrganizationsManager>().Get(userInfoDO.RootOrganizationCode);
|
|
|
+ var organizationList = await _organizationDBService.GetOrganizationListAsync(new GetOrganizationListDBRequest
|
|
|
+ {
|
|
|
+ OrganizationType = OrganizationTypeEnum.Corporation,
|
|
|
+ Isinvented = false,
|
|
|
+ });
|
|
|
+ organizationList = organizationList.Where(x => x.OrganizationCode != userInfoDO.RootOrganizationCode)?.ToList() ?? new List<OrganizationDTO>();
|
|
|
+ result = organizationList.Select(c => new OrganizationBaseDTO()
|
|
|
+ {
|
|
|
+ OrganizationCode = c.OrganizationCode,
|
|
|
+ OrganizationName = c.OrganizationName,
|
|
|
+ }).ToList();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<List<OrganizationBaseDTO>> FindGrassRootsOrganizationsAsync(FindGrassRootsOrganizationsRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<List<BaseDTO>> FindOrganizationExpertsAsync(FindOrganizationExpertsRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<string> ApplyConsultationAsync(ApplyConsultationRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<PageResult<ConsultationDetailDTO>> FindConsultationByPageAsync(FindConsultationByPageRequest request)
|
|
|
{
|
|
|
- base.ThrowRpcException((int)code, message, internalMessage?? message);
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<ConsultationDetailDTO> FindConsultationDetailAsync(FindConsultationDetailRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
+
|
|
|
+ public Task<bool> ApprovalConsultationAsync(ApprovalConsultationRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<bool> RevokeConsultationAsync(RevokeConsultationRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<bool> DeleteConsultationAsync(DeleteConsultationRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<bool> UploadConsultationFilesAsync(UploadConsultationFilesRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<List<ConsultationFileDTO>> FindConsultationFilesAsync(FindConsultationFilesRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Task<CancelLiveConsultationResult> InitiateLiveConsultationAsync(CancelLiveConsultationRequest request)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task<string> GetClientIdByTokenAsync(string token)
|
|
|
+ {
|
|
|
+ var request = new TokenRequest() { Token = token };
|
|
|
+ var result = await _authenticationService.GetTokenAsync(request);
|
|
|
+ return result.ClientId; //return User code
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|