12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777 |
- using Flyinsono.DBCopy.Tool.Entities;
- using Flyinsono.DBCopy.Tool.RpcService;
- using Flyinsono.DBCopy.Tool.Service.Repositories;
- using MongoDB.Driver;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Security;
- using System.Reflection;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- using System.Xml.Linq;
- using WingInterfaceLibrary.DTO.Common;
- using WingInterfaceLibrary.DTO.DataCenter;
- using WingInterfaceLibrary.DTO.Management;
- using WingInterfaceLibrary.DTO.Record;
- using WingInterfaceLibrary.Enum;
- using WingInterfaceLibrary.Enum.CourseEnum;
- using WingInterfaceLibrary.Internal.Request;
- using WingInterfaceLibrary.Request;
- using WingInterfaceLibrary.Request.DBCopy;
- using WingServerCommon.Mapper;
- using MongoDB.Bson.IO;
- using JsonConvert = Newtonsoft.Json.JsonConvert;
- using WingInterfaceLibrary.Request.AIDiagnosis;
- using DnsClient.Protocol;
- using System.Text.RegularExpressions;
- using WingInterfaceLibrary.Result.AppletAPI;
- using WingInterfaceLibrary.DTO.Comment;
- using WingInterfaceLibrary.Request.Report;
- using WingInterfaceLibrary.DTO.Report;
- using WingInterfaceLibrary.LiveConsultation.Consultation;
- using WingInterfaceLibrary.DTO.Consultation;
- using System.Net.Http;
- using System.Net;
- using WingInterfaceLibrary.Request.Storage;
- using SharpCompress.Common;
- using System.Security.Policy;
- using System.Net.Http.Headers;
- using WingServerCommon.Interfaces.FileTransfer;
- using WingInterfaceLibrary.LiveConsultation;
- using WingInterfaceLibrary.Request.Report;
- using WingInterfaceLibrary.DTO.Report;
- using WingInterfaceLibrary.LiveConsultation.Consultation;
- using WingInterfaceLibrary.DTO.Consultation;
- using WingInterfaceLibrary.Request.User;
- using MongoDB.Driver.Core.Operations;
- using Flyinsono.DBCopy.Tool.Utilities;
- using Flyinsono.DBCopy.Tool.Entities.Config;
- using System.Diagnostics;
- using Newtonsoft.Json.Linq;
- namespace Flyinsono.DBCopy.Tool.Service
- {
- internal partial class MigrateService
- {
- private JsonRpcProxy _jsonRpcProxy;
- public static HttpClient _httpClient = new HttpClient();
- private readonly string _tempFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DownloadTemp");
- private TerminalRecordDBRepository _terminalRecordDBRepository;
- private TerminalDatasDBRepository _terminalDatasDBRepository;
- private TerminalAIDatasDBRepository _terminalAIDatasDBRepository;
- private Carotid3dModelDatasDBRepository _carotid3dModelDatasDBRepository;
- private TerminalRecordReportStatesDBRepository _terminalRecordReportStatesDBRepository;
- private OrganizationsDBRepository _organizationsDBRepository;
- private TerminalsDBRepository _terminalsDBRepository;
- private PosterConfigsDBRepository _posterConfigsDBRepository;
- private MigrateRecordDTO _migrateRecord;
- private readonly string DefaultToken = "637f02a065ad47fbbe01b956919419c2";
- private ConsultationRecordDBRepository _consultationRecordDBRepository;
- private UsersDBRepository _usersDBRepository;
- private VideoDBRepository _videoDBRepository;
- private UserGroupDBRepository _userGroupDBRepository;
- private UltrasonicClassDBRepository _ultrasonicClassDBRepository;
- private CoursesDBRepository _coursesDBRepository;
- private AdminDBRepository _adminDBRepository;
- private ExaminationPaperDBPepository _examinationPaperDBPepository;
- private ExamScoreDBRepository _examScoreDBRepository;
- private ReportTemplateDBRepository _reportTemplateDBRepository;
- private ReportInfoResultDBRepository _reportInfoResultDBRepository;
- private CustomLabelDBRepository _customLabelDBRepository;
- protected readonly object locker = new object();
- protected ProbeAppHepler _probeAppHepler;
- public MigrateService(string dcServiceUrl)
- {
- _jsonRpcProxy = new JsonRpcProxy(dcServiceUrl);
- _httpClient.Timeout = TimeSpan.FromMinutes(15);
- _terminalRecordDBRepository = new TerminalRecordDBRepository();
- _terminalDatasDBRepository = new TerminalDatasDBRepository();
- _carotid3dModelDatasDBRepository = new Carotid3dModelDatasDBRepository();
- _terminalRecordReportStatesDBRepository = new TerminalRecordReportStatesDBRepository();
- _organizationsDBRepository = new OrganizationsDBRepository();
- _terminalsDBRepository = new TerminalsDBRepository();
- _posterConfigsDBRepository = new PosterConfigsDBRepository();
- _migrateRecord = GetQueryMigrateTimeRange();
- _terminalAIDatasDBRepository = new TerminalAIDatasDBRepository();
- _consultationRecordDBRepository = new ConsultationRecordDBRepository();
- _usersDBRepository = new UsersDBRepository();
- _videoDBRepository = new VideoDBRepository();
- _userGroupDBRepository = new UserGroupDBRepository();
- _ultrasonicClassDBRepository = new UltrasonicClassDBRepository();
- _coursesDBRepository = new CoursesDBRepository();
- _adminDBRepository = new AdminDBRepository();
- _examinationPaperDBPepository = new ExaminationPaperDBPepository();
- _examScoreDBRepository = new ExamScoreDBRepository();
- _reportTemplateDBRepository = new ReportTemplateDBRepository();
- _adminDBRepository = new AdminDBRepository();
- _reportInfoResultDBRepository = new ReportInfoResultDBRepository();
- _customLabelDBRepository = new CustomLabelDBRepository();
- _probeAppHepler = new ProbeAppHepler();
- }
- public async Task WriteMigrateStaticAsync()
- {
- Logger.WriteLineInfo($"Migrate Static Starting");
- Logger.WriteLineInfo($"terminal record totalCount:{_terminalRecordDBRepository.GetTerminalRecords(Builders<TerminalRecords>.Filter.Where(x => x.IsDelete == false)).Count()}");
- Logger.WriteLineInfo($"consultation record totalCount:{_consultationRecordDBRepository.GetTerminalRecords(Builders<ConsultationRecords>.Filter.Where(x => x.IsDeleted == false)).Count()}");
- Logger.WriteLineInfo($"video totalCount:{_videoDBRepository.GetVideos(Builders<Video>.Filter.Where(x => x.IsDeleted == false)).Count()}");
- Logger.WriteLineInfo($"course totalCount:{_coursesDBRepository.GetCourses(Builders<Courses>.Filter.Where(x => x.IsDeleted == false)).Count()}");
- Logger.WriteLineInfo($"exam paper totalCount:{_examinationPaperDBPepository.GetExaminationPapers(Builders<ExaminationPaper>.Filter.Where(x => x.IsDeleted == false)).Count()}");
- Logger.WriteLineInfo($"report totalCount:{_reportInfoResultDBRepository.GetReports(Builders<ReportInfoResults>.Filter.Where(x => true)).Count()}");
- Logger.WriteLineInfo($"terminal ai data totalCount:{_terminalAIDatasDBRepository.GetTerminalAIDatas(Builders<TerminalAIDatas>.Filter.Where(x => true)).Count()}");
- Logger.WriteLineInfo($"Migrate Static Successfully");
- }
- /// <summary>
- /// 查询同步数据的时间范围
- /// </summary>
- /// <returns></returns>
- private MigrateRecordDTO GetQueryMigrateTimeRange()
- {
- lock (locker)
- {
- if (_migrateRecord != null && _migrateRecord.EndTime > DateTime.MinValue)
- {
- return _migrateRecord;
- }
- var request = new QueryMigrateTimeRequest
- {
- Token = DefaultToken,
- IsInitMigreate = true
- };
- var result = _jsonRpcProxy.User.QueryMigrateTimeAsync(request).Result;
- return result;
- }
- }
- /// <summary>
- /// 备份库迁移分时诊断数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateRemoteDiagnosisInfosAsync()
- {
- Logger.WriteLineInfo($"Remote Diagnosis Infos Migrate Starting");
- var source = _terminalRecordDBRepository.GetTerminalRecords(Builders<TerminalRecords>.Filter.Where(x => x.IsDelete == false))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("terminal record", source, SendRemoteDiagnosisInfos);
- source.Clear();
- Logger.WriteLineInfo($"Remote Diagnosis Infos Migrate Successfully");
- }
- /// <summary>
- /// 备份库迁移实时会诊数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateLiveConsultationInfosAsync()
- {
- Logger.WriteLineInfo($"Live Consultation Infos Migrate Starting");
- var source = _consultationRecordDBRepository.GetTerminalRecords(Builders<ConsultationRecords>.Filter.Where(x => x.IsDeleted == false))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("consultation record", source, SendLiveConsultationInfos);
- source.Clear();
- Logger.WriteLineInfo($"Live Consultation Infos Migrate Successfully");
- }
- /// <summary>
- /// 备份库迁移在线视频数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateOnlineVideoInfosAsync()
- {
- Logger.WriteLineInfo($"Online Video Infos Migrate Starting");
- var videos = _videoDBRepository.GetVideos(Builders<Video>.Filter.Where(x => x.IsDeleted == false))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("video", videos, SendVideoInfos);
- videos.Clear();
- Logger.WriteLineInfo($"Online Video Infos Migrate Successfully");
- }
- /// <summary>
- /// 备份库迁移在线培训数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateOnlineTrainingInfosAsync()
- {
- Logger.WriteLineInfo($"Online Training Infos Migrate Starting");
- var videos = _coursesDBRepository.GetCourses(Builders<Courses>.Filter.Where(x => x.IsDeleted == false))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("course", videos, SendCourseInfos);
- videos.Clear();
- Logger.WriteLineInfo($"Online Training Infos Migrate Successfully");
- }
- /// <summary>
- /// 备份库迁移教培试卷数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateExamPaperInfosAsync()
- {
- Logger.WriteLineInfo($"Exam Paper Infos Migrate Starting");
- var examPapers = _examinationPaperDBPepository.GetExaminationPapers(Builders<ExaminationPaper>.Filter.Where(x => x.IsDeleted == false))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("exam paper", examPapers, SendExaminationPaperInfos);
- examPapers.Clear();
- Logger.WriteLineInfo($"Exam Paper Infos Migrate Successfully");
- }
- /// <summary>
- /// 备份库迁移报告数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateReportInfosAsync()
- {
- Logger.WriteLineInfo($"Report Infos Migrate Starting");
- var reports = _reportInfoResultDBRepository.GetReports(Builders<ReportInfoResults>.Filter.Where(x => true))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("report", reports, SendReportInfos);
- reports.Clear();
- Logger.WriteLineInfo($"Report Infos Migrate Successfully");
- }
- /// <summary>
- /// 备份库迁移图像诊断结果数据
- /// </summary>
- /// <returns></returns>
- public async Task MigrateTerminalAIDataInfosAsync()
- {
- Logger.WriteLineInfo($"Terminal AI Data Infos Migrate Starting");
- var terminalAIDatas = _terminalAIDatasDBRepository.GetTerminalAIDatas(Builders<TerminalAIDatas>.Filter.Where(x => true))
- .OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
- OnMigrate("terminal ai data", terminalAIDatas, SendTerminalAIDataInfos);
- terminalAIDatas.Clear();
- Logger.WriteLineInfo($"Terminal AI Data Infos Migrate Successfully");
- }
- private void OnMigrate<IEntity>(string name, IList<IEntity> source, Action<IList<IEntity>, SyncDBEnum> migrateAction, SyncDBEnum syncType = SyncDBEnum.Migrate, int processNumber = 100)
- {
- Logger.WriteLineInfo($"{name} totalCount:{source.Count}");
- var totalCount = source.Count;
- var processedCount = 0;
- var minute = DateTime.Now.Minute;
- while (true)
- {
- var pendingRecords = source.Skip(processedCount).Take(processNumber)?.ToList() ?? new List<IEntity>();
- var pendingCount = pendingRecords.Count;
- if (pendingCount > 0)
- {
- migrateAction.Invoke(pendingRecords, syncType);
- processedCount += pendingCount;
- }
- if (DateTime.Now.Minute != minute)
- {
- minute = DateTime.Now.Minute;
- Logger.WriteLineInfo($"{name} processing: {processedCount * 100 / totalCount}%");
- }
- if (pendingCount < processNumber)
- {
- Logger.WriteLineInfo($"{name} processing: 100%");
- break;
- }
- }
- }
- private void SendRemoteDiagnosisInfos(IList<TerminalRecords> terminalRecords, SyncDBEnum syncType)
- {
- try
- {
- var terminalRecordCodes = terminalRecords.Select(x => x.Id).ToList();
- var terminalDatas = _terminalDatasDBRepository.GetTerminalDatasByCodes(terminalRecordCodes)?.ToList() ?? new List<TerminalDatas>();
- var terminalRecordStates = _terminalRecordReportStatesDBRepository.GetTerminalRecordReportStatesByCodes(terminalRecordCodes)?.ToList() ?? new List<TerminalRecordReportStates>();
- var deviceCodes = terminalRecords.Select(x => x.Terminal?.Id ?? string.Empty).ToList();
- var terminals = _terminalsDBRepository.GetTerminalByCodes(deviceCodes)?.ToList() ?? new List<Terminals>();
- var orgCodes = terminalRecords.Select(x => x.Organization?.Id ?? string.Empty).ToList();
- if (terminals.Any())
- {
- var terminalOrgs = terminals.Select(x => x.Organization?.Id ?? string.Empty);
- orgCodes = orgCodes.Union(terminalOrgs).ToList();
- }
- var organizations = _organizationsDBRepository.GetOrganizationByCodes(orgCodes)?.ToList() ?? new List<Organizations>();
- var remoteDiagnosisInfos = new List<RemoteDiagnosisDTO>();
- foreach (var terminalRecord in terminalRecords)
- {
- var terminalRecordId = terminalRecord.Id;
- var patientInfo = terminalRecord.PatientInfo;
- var terminalDataInfos = terminalDatas.Where(x => x.TerminalRecordId == terminalRecordId)?.ToList() ?? new List<TerminalDatas>();
- var terminalRecordStateInfos = terminalRecordStates.Where(x => x.TerminalRecordId == terminalRecordId)?.ToList() ?? new List<TerminalRecordReportStates>();
- var remoteDiagnosisInfo = new RemoteDiagnosisDTO
- {
- Code = terminalRecordId,
- CreateTime = terminalRecord.CreateTime,
- UpdateTime = terminalRecord.UpdateTime,
- ExamId = terminalRecord.ExamId,
- OrganizationInfo = MapToOrganizationView(organizations, terminalRecord.Organization?.Id),
- DeviceInfo = MapToDeviceView(terminals, terminalRecord.Terminal?.Id),
- QualifiedInfo = new QualifiedView
- {
- QualifiedState = (WingInterfaceLibrary.Enum.QualifiedState)terminalRecord.QualifiedState,
- QualityType = (WingInterfaceLibrary.Enum.QualityType)terminalRecord.QualityType,
- },
- DiagnosisInfos = new List<DiagnosisView>(),
- ShareUserCodes = terminalRecord.SharerIds?.ToList() ?? new List<string>(),
- CustomDoctor = terminalRecord.CustomDoctor,
- CustomOrganzation = terminalRecord.CustomOrganzation,
- EquipmentSN = terminalRecord.EquipmentSN,
- FileInfos = terminalDataInfos.Select(x =>
- {
- var fileInfo = x.Files.FirstOrDefault(f => f.ImageQuality == ImageQuality.High);
- var fileUrl = GetFileUrl(fileInfo?.FileName);
- var terminalData = new RemoteDiagnosisFileView
- {
- DataType = (WingInterfaceLibrary.Enum.RemedicalFileDataTypeEnum)x.DataType,
- OriginalUrl = GetSourceUrl(fileUrl),
- CdnUrl = fileUrl,
- PreviewUrl = GetFileUrl(x.PreviewImageFileToken),
- ConverUrl = "",
- Application = x.Application,
- };
- if (x.ImageLocation != null)
- {
- if (x.ImageLocation is BreastImageLocation bi)
- {
- terminalData.ImageLocationInfo = new ImageLocationView
- {
- Group = "BreastImageLocation",
- Position = bi.Position.ToString(),
- Quadrant = bi.Quadrant.ToString(),
- };
- }
- if (x.ImageLocation is LiverImageLocation li)
- {
- terminalData.ImageLocationInfo = new ImageLocationView
- {
- Group = "LiverImageLocation",
- Position = li.Position.ToString(),
- };
- }
- if (x.ImageLocation is PositionImageLocation pi)
- {
- terminalData.ImageLocationInfo = new ImageLocationView
- {
- Group = pi.Position,
- Position = pi.Position.ToString(),
- };
- }
- }
- return terminalData;
- }).ToList(),
- CompletedUsers = terminalRecordStateInfos.Select(x => x.UserId).ToList(),
- };
- if (patientInfo != null)
- {
- remoteDiagnosisInfo.PatientInfo = new PatientView
- {
- IdentityCardId = patientInfo.IdentityCardId,
- Name = patientInfo.LastName,
- Gender = patientInfo.GenderType.ToString(),
- Age = patientInfo.Age,
- };
- }
- if (terminalRecord.TerminalRecordSource == TerminalRecordSource.Screenshot)
- {
- remoteDiagnosisInfo.ScreenshotInfo = new ScreenshotView
- {
- CreateUserCode = terminalRecord.CreatorUserId,
- CreateUserName = "",
- PrelDiagnosis = terminalRecord.PrelDiagnosis,
- ExamDoctor = terminalRecord.ExamDoctor,
- };
- }
- if (terminalRecord.AIDiagnosisInfos != null && terminalRecord.AIDiagnosisInfos.Any())
- {
- remoteDiagnosisInfo.DiagnosisInfos = terminalRecord.AIDiagnosisInfos.Select(x => new DiagnosisView
- {
- Organ = (WingInterfaceLibrary.Enum.DiagnosisOrganEnum)x.Organ,
- DiagnosisStatus = (WingInterfaceLibrary.Enum.DiagnosisConclusionEnum)x.Status,
- }).ToList();
- }
- remoteDiagnosisInfos.Add(remoteDiagnosisInfo);
- }
- var request = new ReceiveRemoteDiagnosisRequest
- {
- RemoteDiagnosisInfos = remoteDiagnosisInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveRemoteDiagnosisAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemoteDiagnosisInfos err, ex:{ex}");
- }
- }
- private void SendLiveConsultationInfos(IList<ConsultationRecords> consultationRecords, SyncDBEnum syncType)
- {
- try
- {
- var userIds = consultationRecords.Select(x => x.DoctorInfo?.ID ?? string.Empty)
- .Union(consultationRecords.Select(x => x.ExpertInfo?.ID ?? string.Empty))
- .Distinct().ToList();
- var users = _usersDBRepository.GetUserByCodes(userIds);
- var orgIds = consultationRecords.Select(x => x.PrimaryHosptial?.Id ?? string.Empty)
- .Union(consultationRecords.Select(x => x.CentralHospital?.Id ?? string.Empty))
- .Union(users.Select(x => x.HospitalId))
- .Distinct().ToList();
- var organizations = _organizationsDBRepository.GetOrganizationByCodes(orgIds);
- var terminalIds = consultationRecords.Select(x => x.TerminalInfo?.Id ?? string.Empty).Distinct().ToList();
- var terminals = _terminalsDBRepository.GetTerminalByCodes(terminalIds);
- var liveConsultationInfos = new List<LiveConsultationDTO>();
- foreach (var consultationRecord in consultationRecords)
- {
- var patient = consultationRecord.PatientInfo;
- var liveConsultationInfo = new LiveConsultationDTO
- {
- Code = consultationRecord.Id,
- CreateTime = consultationRecord.CreateTime,
- UpdateTime = consultationRecord.UpdateTime,
- ScanUserName = consultationRecord.ScanDoctor,
- ConsultationTime = consultationRecord.AppointmentTime,
- DoctorInfo = MapToUserView(organizations, users, consultationRecord.DoctorInfo?.ID),
- ExpertInfo = MapToUserView(organizations, users, consultationRecord.ExpertInfo?.ID),
- PrimaryHosptial = MapToOrganizationView(organizations, consultationRecord.PrimaryHosptial?.Id),
- CentralHospital = MapToOrganizationView(organizations, consultationRecord.CentralHospital?.Id),
- DeviceInfo = MapToDeviceView(terminals, consultationRecord.TerminalInfo?.Id),
- CheckPoint = consultationRecord.CheckPoint,
- ConsultationNumber = consultationRecord.ConsultationNumber,
- QueuingNumber = consultationRecord.QueuingNumber,
- IsNeedFollowUpVisit = consultationRecord.IsNeedFollowUpVisit,
- State = (WingInterfaceLibrary.Enum.ConsultationState)consultationRecord.State,
- QualityType = (WingInterfaceLibrary.Enum.QualityType)consultationRecord.QualityType,
- FollowUpVisitStatus = (FollowUpVisitStatusEnum)consultationRecord.FollowUpVisitStatus,
- EvaluateGrade = (EvaluateGradeEnum)consultationRecord.EvaluateGrade,
- FileInfos = new List<LiveConsultationFileView>(),
- ReportConclusionInfos = new List<ReportConclusionView>(),
- };
- if (patient != null)
- {
- liveConsultationInfo.PatientInfo = new PatientView
- {
- IdentityCardId = patient.ID,
- Name = patient.Name,
- Mobile = patient.ContactInfo,
- Gender = patient.GenderType.ToString(),
- Age = patient.Age,
- //PastHistory = patient.PastHistory,
- //Diagnosis = patient.Diagnosis,
- };
- }
- if (consultationRecord.ImageTokens != null && consultationRecord.ImageTokens.Any())
- {
- foreach (var item in consultationRecord.ImageTokens)
- {
- liveConsultationInfo.FileInfos.Add(new LiveConsultationFileView
- {
- Type = "FileTokens",
- DataType = RemedicalFileDataTypeEnum.VinnoVidSingle,
- OriginalUrl = GetSourceUrl(item),
- CdnUrl = GetFileUrl(item),
- PreviewUrl = "",
- ConverUrl = "",
- });
- }
- }
- if (consultationRecord.VideoTokens != null && consultationRecord.VideoTokens.Any())
- {
- foreach (var item in consultationRecord.VideoTokens)
- {
- liveConsultationInfo.FileInfos.Add(new LiveConsultationFileView
- {
- Type = "FileTokens",
- DataType = RemedicalFileDataTypeEnum.VinnoVidMovie,
- OriginalUrl = GetSourceUrl(item.VideoToken),
- CdnUrl = GetFileUrl(item.VideoToken),
- PreviewUrl = GetFileUrl(item.PreviewImageToken),
- ConverUrl = "",
- });
- }
- }
- if (consultationRecord.GraphicData != null && consultationRecord.GraphicData.Any())
- {
- foreach (var item in consultationRecord.GraphicData)
- {
- liveConsultationInfo.FileInfos.Add(new LiveConsultationFileView
- {
- Type = "GraphicData",
- DataType = item.GraphicType == 0 ? RemedicalFileDataTypeEnum.ThirdVidSingle : RemedicalFileDataTypeEnum.ThirdVidMovie,
- OriginalUrl = GetSourceUrl(item.GraphicToken),
- CdnUrl = GetFileUrl(item.GraphicToken),
- PreviewUrl = GetFileUrl(item.PreviewGraphicToken),
- ConverUrl = "",
- UserCode = item.UserId,
- });
- }
- }
- if (consultationRecord.PreFileItems != null && consultationRecord.PreFileItems.Any())
- {
- foreach (var item in consultationRecord.PreFileItems)
- {
- liveConsultationInfo.FileInfos.Add(new LiveConsultationFileView
- {
- Type = "PreFileItems",
- DataType = item.FileType == 0 ? RemedicalFileDataTypeEnum.ThirdVidSingle : RemedicalFileDataTypeEnum.ThirdVidMovie,
- OriginalUrl = GetSourceUrl(item.OriginalFileUrl),
- CdnUrl = GetFileUrl(item.OriginalFileUrl),
- PreviewUrl = GetFileUrl(item.ThumbnailUrl),
- ConverUrl = "",
- UserCode = item.Uploader,
- FileName = item.FileName,
- });
- }
- }
- if (consultationRecord.ReportConclusionInfos != null && consultationRecord.ReportConclusionInfos.Any())
- {
- foreach (var item in consultationRecord.ReportConclusionInfos)
- {
- liveConsultationInfo.ReportConclusionInfos.Add(new ReportConclusionView
- {
- ReportId = item.ReportId,
- DiseaseName = item.DiseaseName,
- DiseaseConclusion = (WingInterfaceLibrary.Enum.DiseaseConclusion)item.DiseaseConclusion,
- });
- }
- }
- liveConsultationInfos.Add(liveConsultationInfo);
- }
- var request = new ReceiveLiveConsultationRequest
- {
- LiveConsultationInfos = liveConsultationInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveLiveConsultationAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendLiveConsultationInfos err, ex:{ex}");
- }
- }
- private void SendVideoInfos(IList<Video> videos, SyncDBEnum syncType)
- {
- try
- {
- var userIds = videos.Select(x => x.CreatorId)
- .Union(videos.SelectMany(x => x.UserIds ?? new List<string>()))
- .Union(videos.SelectMany(x => x.FinishedUserIds ?? new List<string>()))
- .Distinct().ToList();
- var users = _usersDBRepository.GetUserByCodes(userIds);
- var orgIds = users.Select(x => x.HospitalId).Distinct().ToList();
- var organizations = _organizationsDBRepository.GetOrganizationByCodes(orgIds);
- var userGroupIds = videos.SelectMany(x => x.UserGroupIds ?? new List<string>()).Distinct().ToList();
- var userGroups = _userGroupDBRepository.GetUserGroupByCodes(userGroupIds);
- var classIds = videos.SelectMany(x => x.ClassIds ?? new List<string>()).Distinct().ToList();
- var classes = _ultrasonicClassDBRepository.GetUltrasonicClassByCodes(classIds);
- //var courseIds = videos.SelectMany(x => x.Courses ?? new List<VideoLinkCourseInfo>()).Select(x => x.Id).Distinct().ToList();
- //var courses = _coursesDBRepository.GetCourseByCodes(courseIds);
- var onlineVideoInfos = new List<OnlineVideoDTO>();
- foreach (var video in videos)
- {
- var creator = MapToUserView(organizations, users, video.CreatorId);
- var videoInfo = new OnlineVideoDTO
- {
- Code = video.Id,
- CreateTime = video.CreateTime,
- UpdateTime = video.UpdateTime,
- Name = video.Title,
- Poster = GetFileUrl(video.PosterToken),
- Duration = video.Duration,
- VideoSize = video.Size,
- Description = video.Description,
- VideoToken = video.Url,
- Importance = (VideoImportanceEnum)video.Importance,
- CreatorCode = video.CreatorId,
- CreatorName = creator?.Name,
- Permissions = (VideoPermissionsEnum)video.Permissions,
- Users = new List<UserView>(),
- UserGroups = new List<GroupView>(),
- Courses = new List<OnlineTrainingDTO>(),
- ClassInfos = new List<ClassView>(),
- Labels = new List<VideoLabelEnum>(),
- TeachingDocumentName = video.TeachingDocumentName,
- TeachingDocument = GetFileUrl(video.TeachingDocument),
- RealBrowsedCount = video.RealBrowsedCount,
- BaseBrowsedCount = video.BaseBrowsedCount,
- FinishedUsers = new List<UserView>(),
- };
- if (video.UserIds != null && video.UserIds.Any())
- {
- foreach (var item in video.UserIds)
- {
- var user = MapToUserView(organizations, users, item);
- if (user != null)
- {
- videoInfo.Users.Add(user);
- }
- }
- }
- if (video.FinishedUserIds != null && video.FinishedUserIds.Any())
- {
- foreach (var item in video.FinishedUserIds)
- {
- var user = MapToUserView(organizations, users, item);
- if (user != null)
- {
- videoInfo.FinishedUsers.Add(user);
- }
- }
- }
- if (video.Labels != null && video.Labels.Any())
- {
- foreach (var item in video.Labels)
- {
- videoInfo.Labels.Add((VideoLabelEnum)item);
- }
- }
- if (video.Courses != null && video.Courses.Any())
- {
- foreach (var item in video.Courses)
- {
- videoInfo.Courses.Add(new OnlineTrainingDTO
- {
- Code = item.Id,
- Name = item.Name,
- });
- }
- }
- if (video.UserGroupIds != null && video.UserGroupIds.Any())
- {
- foreach (var item in video.UserGroupIds)
- {
- var userGroup = MapToUserGroupView(userGroups, item);
- if (userGroup != null)
- {
- videoInfo.UserGroups.Add(userGroup);
- }
- }
- }
- if (video.ClassIds != null && video.ClassIds.Any())
- {
- foreach (var item in video.ClassIds)
- {
- var classInfo = MapToClassView(classes, item);
- if (classInfo != null)
- {
- videoInfo.ClassInfos.Add(classInfo);
- }
- }
- }
- onlineVideoInfos.Add(videoInfo);
- }
- var request = new ReceiveOnlineVideoRequest
- {
- OnlineVideoInfos = onlineVideoInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveOnlineVideoAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendVideoInfos err, ex:{ex}");
- }
- }
- private void SendCourseInfos(IList<Courses> courses, SyncDBEnum syncType)
- {
- try
- {
- var userIds = courses.SelectMany(x => x.AssistantIds ?? new List<string>())
- .Union(courses.SelectMany(x => x.GuestIds ?? new List<string>()))
- .Union(courses.SelectMany(x => x.MeetingMemberIds ?? new List<string>()))
- .Distinct().ToList();
- var users = _usersDBRepository.GetUserByCodes(userIds);
- var orgIds = users.Select(x => x.HospitalId).Distinct().ToList();
- var organizations = _organizationsDBRepository.GetOrganizationByCodes(orgIds);
- var onlineTrainingInfos = new List<OnlineTrainingDTO>();
- foreach (var course in courses)
- {
- var teacher = course.Teacher;
- var createAdmin = course.CreateAdmin;
- var courseInfo = new OnlineTrainingDTO
- {
- Code = course.Id,
- CreateTime = course.CreateTime,
- UpdateTime = course.UpdateTime,
- Name = course.Name,
- CourseIntro = course.Information,
- Price = (decimal)course.Price,
- Status = (CourseStatusEnum)course.State,//TODO
- StartTime = course.StarTime,
- Duration = course.Duration,
- Deadline = course.Deadline,
- ApplyState = (ApplyStateEnum)course.ApplyState,//TODO
- Poster = GetFileUrl(course.Poster),
- Students = new List<SignStudentView>(),
- ConversationId = course.ConversationId,//TODO
- ChannelDatas = new List<ChannelDataView>(),
- Owners = new List<AdminView>(),
- TeacherOnlineState = course.TeacherState == TeacherState.OnLine,
- StartCourseInAdvance = course.StartCourseInAdvance,
- ActualStartTime = course.ActualStartTime ?? DateTime.MinValue,
- ActualEndTime = course.ActualEndTime ?? DateTime.MinValue,
- AssistantInfos = new List<UserView>(),
- GuestInfos = new List<UserView>(),
- CredentialCode = course.CredentialCode,
- CourseNotice = course.CourseNotice,
- MeetingMemberInfos = new List<UserView>(),
- };
- if (teacher != null)
- {
- var name = !string.IsNullOrWhiteSpace(teacher.FullName) ? teacher.FullName
- : !string.IsNullOrWhiteSpace(teacher.LastName) ? teacher.LastName
- : !string.IsNullOrWhiteSpace(teacher.FirstName) ? teacher.FirstName
- : !string.IsNullOrWhiteSpace(teacher.NickName) ? teacher.NickName
- : teacher.Name;
- courseInfo.TeacherCode = teacher.Id;
- courseInfo.TeacherName = name;
- }
- if (course.ChannelDatas != null && course.ChannelDatas.Any())
- {
- foreach (var item in course.ChannelDatas)
- {
- courseInfo.ChannelDatas.Add(new ChannelDataView
- {
- ChannelId = item.ChannelId,
- DownLoadUrl = item.DownLoadUrl,
- UpLoadUrl = item.UpLoadUrl,
- Description = (ChannelDescriptionEnum)item.Description,
- HttpUrl = item.HttpUrl,
- HlsUrl = item.HlsUrl,
- });
- }
- }
- if (course.Students != null && course.Students.Any())
- {
- foreach (var item in course.Students)
- {
- courseInfo.Students.Add(new SignStudentView
- {
- StudentCode = item.Id,
- StudentName = item.Name,
- SmallHeadImage = item.SmallHeadImage,
- IsNoSpeaking = item.IsNoSpeaking,
- IsAssistant = item.IsAssistant,
- });
- }
- }
- if (createAdmin != null)
- {
- courseInfo.CreateAdmin = new AdminView
- {
- Code = createAdmin._id,
- Name = createAdmin.Name,
- };
- }
- if (course.Owners != null && course.Owners.Any())
- {
- foreach (var item in course.Owners)
- {
- courseInfo.Owners.Add(new AdminView
- {
- Code = item._id,
- Name = item.Name,
- });
- }
- }
- if (course.AssistantIds != null && course.AssistantIds.Any())
- {
- foreach (var item in course.AssistantIds)
- {
- var user = MapToUserView(organizations, users, item);
- if (user != null)
- {
- courseInfo.AssistantInfos.Add(user);
- }
- }
- }
- if (course.GuestIds != null && course.GuestIds.Any())
- {
- foreach (var item in course.GuestIds)
- {
- var user = MapToUserView(organizations, users, item);
- if (user != null)
- {
- courseInfo.GuestInfos.Add(user);
- }
- }
- }
- if (course.MeetingMemberIds != null && course.MeetingMemberIds.Any())
- {
- foreach (var item in course.MeetingMemberIds)
- {
- var user = MapToUserView(organizations, users, item);
- if (user != null)
- {
- courseInfo.MeetingMemberInfos.Add(user);
- }
- }
- }
- onlineTrainingInfos.Add(courseInfo);
- }
- var request = new ReceiveOnlineTrainingRequest
- {
- OnlineTrainingInfos = onlineTrainingInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveOnlineTrainingAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendCourseInfos err, ex:{ex}");
- }
- }
- private void SendExaminationPaperInfos(IList<ExaminationPaper> examPapers, SyncDBEnum syncType)
- {
- try
- {
- var userIds = examPapers.Select(x => x.CreatorId)
- .Union(examPapers.SelectMany(x => x.ExaminerIds ?? new List<string>()))
- .Distinct().ToList();
- var users = _usersDBRepository.GetUserByCodes(userIds);
- var admins = _adminDBRepository.GetAdminByCodes(userIds);
- var orgIds = users.Select(x => x.HospitalId).Distinct().ToList();
- var organizations = _organizationsDBRepository.GetOrganizationByCodes(orgIds);
- var userGroupIds = examPapers.SelectMany(x => x.ExaminerUserGroupIds ?? new List<string>()).Distinct().ToList();
- var userGroups = _userGroupDBRepository.GetUserGroupByCodes(userGroupIds);
- var classIds = examPapers.SelectMany(x => x.ClassIds ?? new List<string>()).Distinct().ToList();
- var classes = _ultrasonicClassDBRepository.GetUltrasonicClassByCodes(classIds);
- var examIds = examPapers.Select(x => x.Id).ToList();
- var examScores = _examScoreDBRepository.GetExamScoresByCodes(examIds);
- var examPaperInfos = new List<ExamPaperDTO>();
- foreach (var examPaper in examPapers)
- {
- var creatorName = MapToUserView(organizations, users, examPaper.CreatorId)?.Name;
- if (string.IsNullOrWhiteSpace(creatorName))
- {
- var admin = admins.FirstOrDefault(x => x.Id == examPaper.CreatorId);
- if (admin != null)
- {
- var adminName = !string.IsNullOrWhiteSpace(admin.FullName) ? admin.FullName
- : !string.IsNullOrWhiteSpace(admin.LastName) ? admin.LastName
- : !string.IsNullOrWhiteSpace(admin.FirstName) ? admin.FirstName
- : admin.Name;
- creatorName = adminName;
- }
- }
- var examPaperInfo = new ExamPaperDTO
- {
- Code = examPaper.Id,
- CreateTime = examPaper.CreateTime,
- UpdateTime = examPaper.UpdateTime,
- Name = examPaper.Title,
- Description = examPaper.Description,
- StarTime = examPaper.StarTime,
- EndTime = examPaper.EndTime,
- TotalScore = examPaper.TotalScore,
- LimitCount = examPaper.LimitCount,
- Result = examPaper.Result,
- Examiners = new List<UserView>(),
- ExaminerUserGroups = new List<GroupView>(),
- ExaminationAvailability = (ExaminationAvailabilityEnum)examPaper.ExaminationAvailability,
- Classes = new List<ClassView>(),
- CreatorId = examPaper.CreatorId,
- CreatorName = creatorName,
- ExamType = (ExamTypeEnum)examPaper.ExamType,
- HasPassScore = examPaper.HasPassScore,
- PassScore = examPaper.PassScore,
- IsDisplayAnswer = examPaper.IsDisplayAnswer,
- ExamVideoInfos = new List<ExamVideoView>(),
- ExamScoreInfos = new List<ExamScoreView>(),
- };
- if (examPaper.ExaminerIds != null && examPaper.ExaminerIds.Any())
- {
- foreach (var item in examPaper.ExaminerIds)
- {
- var user = MapToUserView(organizations, users, item);
- if (user != null)
- {
- examPaperInfo.Examiners.Add(user);
- }
- }
- }
- if (examPaper.ExaminerUserGroupIds != null && examPaper.ExaminerUserGroupIds.Any())
- {
- foreach (var item in examPaper.ExaminerUserGroupIds)
- {
- var userGroup = MapToUserGroupView(userGroups, item);
- if (userGroup != null)
- {
- examPaperInfo.ExaminerUserGroups.Add(userGroup);
- }
- }
- }
- if (examPaper.ClassIds != null && examPaper.ClassIds.Any())
- {
- foreach (var item in examPaper.ClassIds)
- {
- var classInfo = MapToClassView(classes, item);
- if (classInfo != null)
- {
- examPaperInfo.Classes.Add(classInfo);
- }
- }
- }
- if (examPaper.ExamVideoInfos != null && examPaper.ExamVideoInfos.Any())
- {
- foreach (var item in examPaper.ExamVideoInfos)
- {
- examPaperInfo.ExamVideoInfos.Add(new ExamVideoView
- {
- Id = item.Id,
- VideoName = item.VideoName,
- CreateTime = item.CreateTime,
- PosterToken = GetFileUrl(item.PosterToken),
- Duration = item.Duration,
- Size = item.Size,
- Description = item.Description,
- Url = GetFileUrl(item.Url),
- });
- }
- }
- if (examPaper.ExamTemplate != null)
- {
- var examTemplate = examPaper.ExamTemplate.MappingTo<ExamTemplateView>();
- if (examTemplate != null && examTemplate.Subjects != null && examTemplate.Subjects.Any())
- {
- foreach (var item in examTemplate.Subjects)
- {
- item.Images = item.Images?.Select(x => GetFileUrl(x))?.ToList() ?? new List<string>();
- if (item.Videos != null && item.Videos.Any())
- {
- item.Videos?.ForEach(x =>
- {
- x.VideoImageToken = GetFileUrl(x.VideoImageToken);
- x.VideoToken = GetFileUrl(x.VideoToken);
- });
- }
- }
- }
- examPaperInfo.ExamTemplate = examTemplate;
- }
- var examScoreInfos = examScores.Where(x => x.ExamId == examPaper.Id)?.ToList() ?? new List<ExamScores>();
- if (examScoreInfos.Any())
- {
- examPaperInfo.ExamScoreInfos = examScoreInfos.MappingTo<List<ExamScoreView>>();
- }
- examPaperInfos.Add(examPaperInfo);
- }
- var request = new ReceiveExamPaperInfosRequest
- {
- ExamPaperInfos = examPaperInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveExamPaperAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendCourseInfos err, ex:{ex}");
- }
- }
- private void SendReportInfos(IList<ReportInfoResults> reports, SyncDBEnum syncType)
- {
- try
- {
- var customLabelIds = reports.SelectMany(x => x.CustomLabels ?? new List<string>()).Distinct().ToList();
- var customerLabels = _customLabelDBRepository.GetCustomLabelByCodes(customLabelIds);
- var reportInfos = new List<ReportInfoResultDTO>();
- foreach (var report in reports)
- {
- var reportInfo = new ReportInfoResultDTO
- {
- Code = report.Id,
- CreateTime = report.CreateTime,
- UpdateTime = report.UpdateTime,
- ReportTemplateJson = report.Template,
- ElementCollectionJson = Newtonsoft.Json.JsonConvert.SerializeObject(report.ElementCollection),
- MeasureElementCollectionJson = Newtonsoft.Json.JsonConvert.SerializeObject(report.MeasureElementCollection),
- ReportUserCode = report.User?._id,
- ReportUserName = report.User?.Name,
- RecordCode = report.RecordId,
- PatientPerfPhysician = report.PatientPerfPhysician,
- PatientRefPhysician = report.PatientRefPhysician,
- PatientName = report.PatientName,
- PreviewImages = report.PreviewImages.MappingTo<List<WingInterfaceLibrary.DTO.DataCenter.ReportImageInfo>>(),
- CustomLabels = new List<CustomLabelView>(),
- ReportOrgan = (DiagnosisOrganEnum)report.Organ,
- QualifiedState = (WingInterfaceLibrary.Enum.QualifiedState)report.QualifiedState,
- QualityType = (WingInterfaceLibrary.Enum.QualityType)report.QualityType,
- ReportPreviewPdf = GetFileUrl(report.ReportPreviewPdf),
- QualityControlDatas = new List<QualityControlDataView>(),
- };
- if (report.CustomLabels != null && report.CustomLabels.Any())
- {
- foreach (var item in report.CustomLabels)
- {
- var customLabel = customerLabels.FirstOrDefault(x => x.Code == item);
- if (customLabel != null)
- {
- reportInfo.CustomLabels.Add(customLabel.MappingTo<CustomLabelView>());
- }
- }
- }
- if (report.QualityControlDatas != null && report.QualityControlDatas.Any())
- {
- reportInfo.QualityControlDatas = report.QualityControlDatas.MappingTo<List<QualityControlDataView>>();
- }
- reportInfos.Add(reportInfo);
- }
- var request = new ReceiveReportInfosRequest
- {
- ReportInfos = reportInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveReportAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendReportInfos err, ex:{ex}");
- }
- }
- private void SendTerminalAIDataInfos(IList<TerminalAIDatas> terminalAIDatas, SyncDBEnum syncType)
- {
- try
- {
- var fileDiagnosisInfos = new List<FileDiagnosisResultDTO>();
- foreach (var terminalAIData in terminalAIDatas)
- {
- var fileDiagnosisResult = new FileDiagnosisResultDTO
- {
- Code = terminalAIData.Id,
- CreateTime = terminalAIData.CreateTime,
- UpdateTime = terminalAIData.UpdateTime,
- RemedicalCode = terminalAIData.TerminalDataId,
- };
- var diagnosisDatas = new List<AIDiagnosisPerImg>();
- foreach (var item in terminalAIData.DiagResults)
- {
- diagnosisDatas.Add(new AIDiagnosisPerImg
- {
- Index = item.Index,
- PriorityScore = item.ImageDiagResult.PriorityScore,
- DiagResultsForEachOrgan = item.ImageDiagResult.DiagResultsForEachOrgan,
- });
- }
- fileDiagnosisResult.DiagnosisOrgans = GetDiagnosisOrgans(diagnosisDatas);
- fileDiagnosisResult.DiagnosisConclusion = GetDiagnosisConclusion(diagnosisDatas);
- fileDiagnosisResult.DiagnosisResult = Newtonsoft.Json.JsonConvert.SerializeObject(diagnosisDatas);
- fileDiagnosisInfos.Add(fileDiagnosisResult);
- }
- var request = new ReceiveFileDiagnosisResultInfosRequest
- {
- FileDiagnosisResultInfos = fileDiagnosisInfos,
- };
- var result = _jsonRpcProxy.DataCenter.ReceiveFileDiagnosisResultAsync(request).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendTerminalAIDataInfos err, ex:{ex}");
- }
- }
- /// <summary>
- /// 同步热数据到2.0
- /// </summary>
- /// <returns></returns>
- public async Task MigrateRemedicalAndConsultationToWingServerAsync(int batchExcuteRemedicalDataCount)
- {
- Logger.WriteLineInfo($"Remote diagnosis infos migrate to wingServer starting");
- //远程
- await MigrateRemedicalRecords(SyncDBEnum.Synchronize);
- //远程图像
- MigrateRemedicalDatas(SyncDBEnum.Synchronize, batchExcuteRemedicalDataCount);
- //AI
- MigrateRemedicalAIDatas(SyncDBEnum.Synchronize);
- //颈动脉
- MigrateRemedicalCarotidDatas(SyncDBEnum.Synchronize);
- //会诊
- MigrateConsultationResults(SyncDBEnum.Synchronize);
- //报告
- MigrateReportInfoResults(SyncDBEnum.Synchronize);
- Logger.WriteLineInfo($"Remote diagnosis infos migrate to wingServer successfully");
- }
- public async Task MigrateRemedicalRecords(SyncDBEnum syncType)
- {
- Logger.WriteLineInfo($"Remote diagnosis records migrate to wingServer starting");
- //获取上次同步到的时间
- var builder = Builders<TerminalRecords>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- var terminalRecords = new List<TerminalRecords>();
- try
- {
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- var tempTerminalRecords = _terminalRecordDBRepository.GetTerminalRecords(filter).OrderByDescending(x => x.CreateTime).ToList();
-
- terminalRecords = await FilterData<TerminalRecords>(tempTerminalRecords, "TerminalRecordsData");
- OnMigrate("Remote diagnosis records", terminalRecords, SendRemedicalRecordInfos, syncType, 100);
- terminalRecords.Clear();
- Logger.WriteLineInfo($"Remote diagnosis records migrate to wingServer successfully");
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"Remote diagnosis records migrate migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"Remote diagnosis records migrate migrate to wingServer successfully, result:{terminalRecords?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (terminalRecords != null)
- {
- terminalRecords.Clear();
- }
- }
- }
- private void SendRemedicalRecordInfos(IList<TerminalRecords> terminalRecords, SyncDBEnum syncType)
- {
- try
- {
- var terminalRecordCodes = terminalRecords.Select(x => x.Id).ToList();
- var terminalRecordStates = _terminalRecordReportStatesDBRepository.GetTerminalRecordReportStatesByCodes(terminalRecordCodes)?.ToList() ?? new List<TerminalRecordReportStates>();
- var terminalIds = terminalRecords.Select(x => x.Terminal?.Id ?? string.Empty).Distinct().ToList();
- var terminals = _terminalsDBRepository.GetTerminalByCodes(terminalIds);
- var syncBatchRemedicalRecordRequest = new SyncBatchRemedicalRecordRequest();
- syncBatchRemedicalRecordRequest.SyncType = syncType;
- syncBatchRemedicalRecordRequest.RemedicalRecordList = new List<SyncRemedicalRecordRequest>();
- foreach (var terminalRecord in terminalRecords)
- {
- try
- {
- var terminalRecordId = terminalRecord.Id;
- var terminalRecordStateInfos = terminalRecordStates.Where(x => x.TerminalRecordId == terminalRecordId)?.ToList() ?? new List<TerminalRecordReportStates>();
- var terminal = terminals.FirstOrDefault(x => x.Id == terminalRecord.Terminal?.Id);
- var patientInfo = terminalRecord.PatientInfo;
- var remoteDiagnosisInfo = new SyncRemedicalRecordRequest
- {
- Code = terminalRecordId,
- OrganizationCode = terminalRecord.Organization?.Id,
- DeviceCode = terminalRecord.Terminal?.Id,
- CreateTime = terminalRecord.CreateTime,
- Creator = terminalRecord.CreatorUserId,
- UpdateTime = terminalRecord.UpdateTime < new DateTime(2000, 1, 1) ? terminalRecord.CreateTime : terminalRecord.UpdateTime,
- IsUploadReport = terminalRecordStateInfos.Count > 0,
- IsDelete = terminalRecord.IsDelete,
- CustomDoctor = terminalRecord.CustomDoctor,
- CustomOrganzation = terminalRecord.CustomOrganzation,
- EquipmentSN = terminalRecord.EquipmentSN,
- PatientInfo = new List<DataItemDTO>
- {
- new DataItemDTO{Key="Name",Value=$"{patientInfo.LastName} {patientInfo.FirstName}".Trim()},
- new DataItemDTO{Key="Phone",Value=patientInfo.Mobile},
- new DataItemDTO{Key="ID",Value=patientInfo.IdentityCardId},//设备病人ID
- new DataItemDTO{Key="Sex",Value = patientInfo.GenderType.ToString()=="Unassigned"?"NotFilled":patientInfo.GenderType.ToString()},
- }
- };
- if (CommonConfigManager.SpecialOrgCodes.Contains(remoteDiagnosisInfo.OrganizationCode))
- {
- remoteDiagnosisInfo.OrganizationCode = "VINNO_FIS";
- }
- if (patientInfo.Birthday != null && patientInfo.Birthday > new DateTime(1900, 1, 1))
- {
- remoteDiagnosisInfo.PatientInfo.Add(new DataItemDTO { Key = "Birthday", Value = ((DateTime)patientInfo.Birthday).ToString("yyyy-MM-dd") });
- }
- if (!string.IsNullOrWhiteSpace(patientInfo.Age))
- {
- remoteDiagnosisInfo.PatientInfo.Add(new DataItemDTO { Key = "AgeUnits", Value = "Year" });
- remoteDiagnosisInfo.PatientInfo.Add(new DataItemDTO { Key = "AgeYear", Value = patientInfo.Age });
- }
- if (terminal != null && terminal.IsAIDiagnosis)
- {
- remoteDiagnosisInfo.DiagnosisStatus = DiagnosisStatusEnum.Under;
- }
- if (terminalRecord.AIDiagnosisInfos != null && terminalRecord.AIDiagnosisInfos.Any())
- {
- remoteDiagnosisInfo.AIDiagnosisInfos = terminalRecord.AIDiagnosisInfos.Select(x =>
- {
- var status = DiagnosisConclusionEnum.InProcess;
- switch (x.Status)
- {
- case EnumAiDiagnosisStatus.NoObviousLesion:
- status = DiagnosisConclusionEnum.NoObviousLesion;
- break;
- case EnumAiDiagnosisStatus.Benign:
- status = DiagnosisConclusionEnum.Benign;
- break;
- case EnumAiDiagnosisStatus.Malignant:
- status = DiagnosisConclusionEnum.Malignant;
- break;
- case EnumAiDiagnosisStatus.BenignAndMalignant:
- status = DiagnosisConclusionEnum.BenignAndMalignant;
- break;
- }
- return new DiagnosisInfoDTO
- {
- DiagnosisOrgan = (DiagnosisOrganEnum)x.Organ,
- Conclusion = status,
- };
- }).ToList();
- remoteDiagnosisInfo.DiagnosisStatus = DiagnosisStatusEnum.Completed;
- }
- syncBatchRemedicalRecordRequest.RemedicalRecordList.Add(remoteDiagnosisInfo);
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalRecordInfos err, ex:{ex}");
- }
- }
- var result = _jsonRpcProxy.RemedicalService.SyncBatchRemedicalRecordsAsync(syncBatchRemedicalRecordRequest).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalRecordInfos err, ex:{ex}");
- }
- }
- public async Task MigrateRemedicalDatas(SyncDBEnum syncType, int batchExcuteRemedicalDataCount)
- {
- Logger.WriteLineInfo($"Remote diagnosis datas migrate to wingServer starting");
- //获取上次同步到的时间
- var builder = Builders<TerminalDatas>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- //startTime = Convert.ToDateTime("2023-06-26");
- //_migrateRecord.EndTime = DateTime.Now;
- var terminalDatas = new List<TerminalDatas>();
- try
- {
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- var tempTerminalDatas = _terminalDatasDBRepository.GetTerminalDatas(filter).OrderByDescending(x => x.CreateTime).ToList();
-
- terminalDatas = await FilterData<TerminalDatas>(tempTerminalDatas, "TerminalDatasData");
- //只保留有预览图的数据,如果生成中会在生成后修改update时间,会再次同步
- //terminalDatas = terminalDatas.Where(x => !string.IsNullOrWhiteSpace(x.PreviewImageFileToken)).ToList();
- OnMigrate("Remote diagnosis datas", terminalDatas, SendRemedicalDatas, syncType, batchExcuteRemedicalDataCount);
- terminalDatas.Clear();
- Logger.WriteLineInfo($"Remote diagnosis datas migrate to wingServer successfully");
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"Remote diagnosis datas migrate migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"Remote diagnosis datas migrate migrate to wingServer successfully, result:{terminalDatas?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (terminalDatas != null)
- {
- terminalDatas.Clear();
- }
- }
- }
- private void SendRemedicalDatas(IList<TerminalDatas> terminalDatas, SyncDBEnum syncType)
- {
- try
- {
- var builder = Builders<TerminalRecords>.Filter;
- var recordCodes = terminalDatas.Select(x => x.TerminalRecordId);
- var filter = builder.Where(x => x.IsDelete == false && recordCodes.Contains(x.Id));
- var records = _terminalRecordDBRepository.GetTerminalRecords(filter);
- var syncBatchRemedicalRecordRequest = new SyncBatchUploadRemedicalDatasRequest();
- syncBatchRemedicalRecordRequest.SyncType = syncType;
- syncBatchRemedicalRecordRequest.SyncUploadRemedicalDataList = new List<SyncUploadRemedicalDataRequest>();
- //根据结果查询recordId和对应检查所属超声机的短码code
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (terminalDatas?.Count > 0)
- {
- var recordIds = terminalDatas.Select(c => c.TerminalRecordId).Distinct().ToList();
- var terRecords = _terminalRecordDBRepository.GetTerminalRecordByCodes(recordIds);
- if (terRecords?.Count > 0)
- {
- foreach (var item in terRecords)
- {
- if (!string.IsNullOrEmpty(item?.Terminal?.Id))
- {
- var deviceInfo = _terminalsDBRepository.GetTerminalByCode(item.Terminal.Id);
- if (!string.IsNullOrEmpty(deviceInfo.UniquedId))
- {
- dic.Add(item.Id, deviceInfo.UniquedId);
- }
- }
- }
- }
- }
- foreach (var terminalData in terminalDatas)
- {
- try
- {
- var record = records.FirstOrDefault(x => x.Id == terminalData.TerminalRecordId);
- var fileInfo = terminalData.Files.FirstOrDefault(f => f.ImageQuality == ImageQuality.High);
- var fileUrl = GetFileUrl(fileInfo?.FileName);
- var imageLocation = new ImageLocationDTO();
- if (terminalData.ImageLocation != null)
- {
- if (terminalData.ImageLocation is BreastImageLocation bi)
- {
- imageLocation = new ImageLocationDTO
- {
- Group = "BreastImageLocation",
- Position = bi.Position.ToString(),
- Quadrant = bi.Quadrant.ToString(),
- };
- }
- if (terminalData.ImageLocation is LiverImageLocation li)
- {
- imageLocation = new ImageLocationDTO
- {
- Group = "LiverImageLocation",
- Position = li.Position.ToString(),
- };
- }
- if (terminalData.ImageLocation is PositionImageLocation pi)
- {
- imageLocation = new ImageLocationDTO
- {
- Group = pi.Position,
- Position = pi.Position.ToString(),
- };
- }
- }
- //验证超声机code是否在配置中,如果在,则需要优先处理
- bool oldPlatformNeedAI = false;
- if (dic?.Count > 0)
- {
- if (dic.Keys.Contains(terminalData.TerminalRecordId))
- {
- var shortCode = dic[terminalData.TerminalRecordId];
- if (CommonConfigManager.DeviceShortCodes.Contains(shortCode))
- {
- oldPlatformNeedAI = true;
- }
- }
- }
- var applicationValue = _probeAppHepler.GetApplication(terminalData.Application, terminalData.Id);
- var organDiagnosisResult = terminalData.OrganDiagnosisResult?.ToList() ?? new List<EnumOrgans>();
- var syncUploadRemedicalDataRequest = new SyncUploadRemedicalDataRequest
- {
- Code = terminalData.Id,
- CreateTime = terminalData.CreateTime,
- UpdateTime = terminalData.UpdateTime < new DateTime(2000, 1, 1) ? terminalData.CreateTime : terminalData.UpdateTime,
- ExamCode = terminalData.TerminalRecordId,
- FileDataType = (WingInterfaceLibrary.Enum.RemedicalFileDataTypeEnum)terminalData.DataType,
- ImageUrl = GetCDNUrl(fileUrl),
- FileToken = GetSourceUrl(fileUrl),
- PreviewFileToken = GetFileUrl(terminalData.PreviewImageFileToken),
- ApplicationCategory = applicationValue.Item1,
- Application = applicationValue.Item2,
- ImageLocation = imageLocation,
- DeviceCode = record?.Terminal?.Id,
- OrganDiagnosisInfos = organDiagnosisResult.Select(x => x.ToString()).ToList(),
- OldPlatformNeedAI = oldPlatformNeedAI
- };
- syncBatchRemedicalRecordRequest.SyncUploadRemedicalDataList.Add(syncUploadRemedicalDataRequest);
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalDatas err, ex:{ex}");
- }
- }
- var result = _jsonRpcProxy.RemedicalService.SyncBatchUploadRemedicalDatasAsync(syncBatchRemedicalRecordRequest).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalDatas err, ex:{ex}");
- }
- }
- ///// <summary>
- ///// 数据转换
- ///// </summary>
- ///// <typeparam name="T"></typeparam>
- ///// <param name="tempRecords"></param>
- ///// <param name="key"></param>
- ///// <returns></returns>
- //private async Task<List<TerminalAIDatas>> AIFilterData(List<TerminalAIDatas> list)
- //{
- // var records = new List<TerminalAIDatas>();
- // var key = "TerminalAIDatasData";
- // if (list?.Count() > 0)
- // {
- // var tempReportTemplateData = new List<CacheBasicInfo>();
- // foreach (var t in list)
- // {
- // if (t != null)
- // {
- // var createTime = t.CreateTime;
- // var updateTime = t.UpdateTime;
- // var item = new CacheBasicInfo()
- // {
- // Id = t.Id,
- // CacheTime = createTime > updateTime ? createTime : updateTime,
- // };
- // tempReportTemplateData.Add(item);
- // }
- // }
- // if (CommonConfigManager.CacheSynDataInfo.CacheDic.Keys.Contains(key) && CommonConfigManager.CacheSynDataInfo.CacheDic[key]?.Count > 0)
- // {
- // foreach (var templateInfo in tempReportTemplateData)
- // {
- // if (CommonConfigManager.CacheSynDataInfo.CacheDic[key].Exists(c => c.Id == templateInfo.Id && c.CacheTime == templateInfo.CacheTime))
- // {
- // //存在,表示已经处理过
- // }
- // else
- // {
- // //不存在,表示没处理过
- // CommonConfigManager.CacheSynDataInfo.CacheDic[key].Add(templateInfo);
- // var findEntity = list.FirstOrDefault(c => c.Id.ToString() == templateInfo.Id);
- // if (!string.IsNullOrEmpty(findEntity?.Id))
- // {
- // records.Add(findEntity);
- // }
- // }
- // }
- // }
- // else
- // {
- // CommonConfigManager.CacheSynDataInfo.CacheDic.Add(key, tempReportTemplateData);
- // records = list;
- // }
- // }
- // return records;
- //}
- public async Task MigrateRemedicalAIDatas(SyncDBEnum syncType)
- {
- Logger.WriteLineInfo($"Remote diagnosis ai datas migrate to wingServer starting");
- //获取上次同步到的时间
- //判断热数据
- var builder = Builders<TerminalAIDatas>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- var terminalDatas = new List<TerminalAIDatas>();
- try
- {
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- var tempTerminalDatas = _terminalAIDatasDBRepository.GetTerminalAIDatas(filter).OrderByDescending(x => x.CreateTime).ToList();
- terminalDatas = await FilterData<TerminalAIDatas>(tempTerminalDatas, "TerminalAIDatasData");
- OnMigrate("Remote diagnosis ai datas", terminalDatas, SendRemedicalAIDatas, syncType, 1);
- terminalDatas.Clear();
- Logger.WriteLineInfo($"Remote diagnosis datas migrate to wingServer successfully");
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"Remote diagnosis datas migrate migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"Remote diagnosis datas migrate migrate to wingServer successfully, result:{terminalDatas?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (terminalDatas != null)
- {
- terminalDatas.Clear();
- }
- }
- }
- private void SendRemedicalAIDatas(IList<TerminalAIDatas> terminalAIDatas, SyncDBEnum syncType)
- {
- try
- {
- var syncBatchAIResultRequest = new SyncBatchAIResultRequest();
- syncBatchAIResultRequest.SyncType = syncType;
- syncBatchAIResultRequest.SyncAIResultList = new List<SyncAIResultRequest>();
- foreach (var terminalAIData in terminalAIDatas)
- {
- try
- {
- var syncAIResultRequest = new SyncAIResultRequest
- {
- RemedicalCode = terminalAIData.TerminalDataId,
- CreateTime = terminalAIData.CreateTime,
- UpdateTime = terminalAIData.UpdateTime < new DateTime(2000, 1, 1) ? terminalAIData.CreateTime : terminalAIData.UpdateTime,
- DiagnosisResult = JsonConvert.SerializeObject(terminalAIData.DiagResults),
- };
- syncBatchAIResultRequest.SyncAIResultList.Add(syncAIResultRequest);
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalAIDatas err, ex:{ex}");
- }
- }
- var result = _jsonRpcProxy.RemedicalService.SyncBatchAIResultAsync(syncBatchAIResultRequest).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalAIDatas err, ex:{ex}");
- }
- }
- public async Task MigrateRemedicalCarotidDatas(SyncDBEnum syncType)
- {
- Logger.WriteLineInfo($"Remote diagnosis carotid datas migrate to wingServer starting");
- //获取上次同步到的时间
- //判断热数据
- var builder = Builders<Carotid3dModelData>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- var carotid3dModelDatas = new List<Carotid3dModelData>();
- try
- {
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- var tempCarotid3dModelDatas = _carotid3dModelDatasDBRepository.GetCarotid3dModelDatas(filter).OrderByDescending(x => x.CreateTime).ToList();
-
- carotid3dModelDatas = await FilterData<Carotid3dModelData>(tempCarotid3dModelDatas, "Carotid3dModelDataData");
- OnMigrate("Remote diagnosis carotid datas", carotid3dModelDatas, SendRemedicalCarotidDatas, syncType, 1);
- carotid3dModelDatas.Clear();
- Logger.WriteLineInfo($"Remote diagnosis carotid datas migrate to wingServer successfully");
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"Remote diagnosis carotid datas migrate migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"Remote diagnosis carotid datas migrate migrate to wingServer successfully, result:{carotid3dModelDatas?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (carotid3dModelDatas != null)
- {
- carotid3dModelDatas.Clear();
- }
- }
- }
- private void SendRemedicalCarotidDatas(IList<Carotid3dModelData> carotid3dModelDatas, SyncDBEnum syncType)
- {
- try
- {
- var syncBatchCarotidResultRequest = new SyncBatchCarotidResultRequest();
- syncBatchCarotidResultRequest.SyncType = syncType;
- syncBatchCarotidResultRequest.SyncCarotidResultRequest = new List<GetCarotidResultRequest>();
- foreach (var carotid3dModelData in carotid3dModelDatas)
- {
- try
- {
- var getCarotidResultRequest = new GetCarotidResultRequest
- {
- RemedicalCode = carotid3dModelData.ExamDataId,
- SurfaceToken = GetFileUrl(carotid3dModelData.SurfaceToken),
- MdlToken = GetFileUrl(carotid3dModelData.MdlToken),
- CarotidScanDirection = (CarotidScanDirectionEnum)carotid3dModelData.CarotidScanDirection,
- CarotidScanType = (CarotidScanTypeEnum)carotid3dModelData.CarotidScanType,
- MeasureImageFiles = new List<MeasureImageFileDTO>()
- };
- if (!string.IsNullOrWhiteSpace(carotid3dModelData.CarotidAIMeasureImageToken))
- {
- string[] keyValuePairs = carotid3dModelData.CarotidAIMeasureImageToken.Split(';');
- foreach (string keyValuePair in keyValuePairs)
- {
- string[] parts = keyValuePair.Split('=');
- if (parts.Length != 2) continue;
- if (Enum.TryParse(parts[0], out CarotidAIImageTypeEnum imageType))
- {
- string url = GetFileUrl(parts[1]);
- getCarotidResultRequest.MeasureImageFiles.Add(new MeasureImageFileDTO { ImageType = imageType, ImageFile = url });
- }
- }
- }
- getCarotidResultRequest.MeasureResult = carotid3dModelData.CarotidAIMeasureResult;
- syncBatchCarotidResultRequest.SyncCarotidResultRequest.Add(getCarotidResultRequest);
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalCarotidDatas err, ex:{ex}");
- }
- }
- var result = _jsonRpcProxy.RemedicalService.SyncBatchCarotidResultAsync(syncBatchCarotidResultRequest).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalCarotidDatas err, ex:{ex}");
- }
- }
- public async Task MigrateConsultationResults(SyncDBEnum syncType)
- {
- Logger.WriteLineInfo($"consultations migrate to wingServer starting");
- //获取上次同步到的时间
- var builder = Builders<ConsultationRecords>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- var consultations = new List<ConsultationRecords>();
- try
- {
- var filter = builder.Where(x => x.IsDeleted == false && ((x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime)));
- var tempConsultations = _consultationRecordDBRepository.GetTerminalRecords(filter).OrderByDescending(x => x.CreateTime).ToList();
-
- consultations = await FilterData<ConsultationRecords>(tempConsultations, "ConsultationRecordsData");
- OnMigrate("consultations", consultations, SendConsultations, syncType, 10);
- consultations.Clear();
- Logger.WriteLineInfo($"consultations migrate to wingServer successfully");
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"consultations migrate migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"consultations migrate to wingServer successfully, result:{consultations?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (consultations != null)
- {
- consultations.Clear();
- }
- }
- }
- private void SendConsultations(IList<ConsultationRecords> consultations, SyncDBEnum syncType)
- {
- try
- {
- var builder = Builders<FollowUpVisitInfos>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- var followVistorList = _consultationRecordDBRepository.GetAllFollowUpVisitInfosRecords(filter).OrderByDescending(x => x.CreateTime).ToList();
- var evaluatesBuilder = Builders<ConsultationEvaluates>.Filter;
- var evaluatesFilter = evaluatesBuilder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- var valuatesList = _consultationRecordDBRepository.GetAllConsultationEvaluatesRecords(evaluatesFilter).OrderByDescending(x => x.CreateTime).ToList();
- var syncBatchConsultationRequest = new SyncBatchConsultationRequest();
- syncBatchConsultationRequest.SyncType = syncType;
- syncBatchConsultationRequest.SyncConsultations = new List<SyncConsultationRequest>();
- foreach (var consultation in consultations)
- {
- try
- {
- if (consultation.TerminalInfo == null)
- {
- continue;
- }
- var patientInfo = consultation.PatientInfo;
- var syncReportInfoRequest = new SyncConsultationRequest
- {
- ConsultationCode = consultation.Id,
- CreateTime = consultation.CreateTime,
- UpdateTime = consultation.UpdateTime,
- ApplyOrganizationCode = consultation.PrimaryHosptial.Id,
- ApplyUserCode = consultation.DoctorInfo.ID,
- ExpertOrganizationCode = consultation.CentralHospital.Id,
- ExpertUserCode = consultation.ExpertInfo.ID,
- DeviceCode = consultation.TerminalInfo.Id,
- ScanUser = consultation.ScanDoctor,
- PatientInfo = new List<DataItemDTO>
- {
- new DataItemDTO { Key = "Name", Value = patientInfo.Name },
- new DataItemDTO { Key = "Phone", Value = patientInfo.ContactInfo },
- new DataItemDTO { Key = "ID", Value = patientInfo.ID },//设备病人ID
- new DataItemDTO { Key = "Sex", Value = patientInfo.GenderType.ToString() == "Unassigned" ? "NotFilled" : patientInfo.GenderType.ToString() },
- new DataItemDTO { Key = "Anamnesis", Value = patientInfo.PastHistory },
- new DataItemDTO { Key = "Anamnesis", Value = patientInfo.PastHistory },
- new DataItemDTO { Key = "AgeUnits", Value = "Year" },
- new DataItemDTO { Key = "AgeYear", Value = patientInfo.Age },
- },
- ScanPositions = new List<string>(),
- ConsultationTime = consultation.AppointmentTime,
- ConsultationTimeEnd = consultation.AppointmentTime.AddHours(2),
- PrimaryDiagnosis = consultation.PatientInfo.Diagnosis,
- ConsultationStatus = GetStatusEnum(consultation.State),
- FollowUpVisitStatus = (FollowUpVisitStatusEnum)consultation.FollowUpVisitStatus,
- //EvaluateGradeEnum = (EvaluateGradeEnum)consultation.EvaluateGrade,
- Evaluates = null,
- ConsultationFileList = new List<ConsultationFileDTO>()
- };
- if (CommonConfigManager.SpecialOrgCodes.Contains(syncReportInfoRequest.ApplyOrganizationCode))
- {
- syncReportInfoRequest.ApplyOrganizationCode = "VINNO_FIS";
- }
- if (CommonConfigManager.SpecialOrgCodes.Contains(syncReportInfoRequest.ExpertOrganizationCode))
- {
- syncReportInfoRequest.ExpertOrganizationCode = "VINNO_FIS";
- }
- syncReportInfoRequest.ScanPositions.Add(GetScanPosition(consultation.CheckPoint));
- if (valuatesList?.Count > 0)
- {
- var findEntity = valuatesList.OrderByDescending(c => c.CreateTime).FirstOrDefault(c => c.ConsultationRecordId == consultation.Id) ?? new ConsultationEvaluates();
- if (!string.IsNullOrEmpty(findEntity.Id))
- {
- syncReportInfoRequest.Evaluates = new SyncEvaluatesRequest()
- {
- ConsultationRecordCode = findEntity.ConsultationRecordId,
- EvaluateGrade = (EvaluateGradeEnum)findEntity.EvaluateGrade,
- Feedback = findEntity.Feedback,
- IsDelete = findEntity.IsDeleted,
- CreateTime = findEntity.CreateTime,
- UpdateTime = findEntity.UpdateTime,
- Code = findEntity.Id
- };
- if (findEntity.EvaluateGrade == EvaluateGrade.Satisfaction)
- {
- syncReportInfoRequest.Evaluates.EvaluateScore = 5;
- }
- else if (findEntity.EvaluateGrade == EvaluateGrade.General)
- {
- syncReportInfoRequest.Evaluates.EvaluateScore = 3;
- }
- else if (findEntity.EvaluateGrade == EvaluateGrade.Dissatisfaction)
- {
- syncReportInfoRequest.Evaluates.EvaluateScore = 1;
- }
- else
- {
- syncReportInfoRequest.Evaluates.EvaluateScore = 0;
- }
- }
- }
- //查询随访记录
- if (followVistorList?.Count > 0)
- {
- var findList = followVistorList.Where(c => c.ConsultationRecordId == consultation.Id)?.ToList();
- if (findList?.Count > 0)
- {
- var followUpVistorList = findList.Select(c => new SyncFollowUpVisitRequest()
- {
- IsDelete = c.IsDeleted,
- CreateTime = c.CreateTime,
- UpdateTime = c.UpdateTime,
- FollowUpVisitCode = c.Id,
- ConsultationRecordCode = c.ConsultationRecordId,
- PatientName = c.PatientName,
- PatientPhone = c.PatientPhone,
- GeneralCase = c.GeneralCase,
- ClinicalSituation = c.ClinicalSituation,
- DoctorCode = c.Doctor,
- OccurredTime = c.OccurredTime
- }).ToList();
- syncReportInfoRequest.SyncFollowUpVisitList = followUpVistorList;
- }
- }
- if (consultation.ImageTokens != null && consultation.ImageTokens.Any())
- {
- foreach (var item in consultation.ImageTokens)
- {
- var consultationFileDTO = new ConsultationFileDTO();
- consultationFileDTO.FileDataType = RemedicalFileDataTypeEnum.VinnoVidSingle;
- consultationFileDTO.SourceUrl = ConvertToJpg(item);
- consultationFileDTO.PreviewImageUrl = ConvertToJpg(item);
- consultationFileDTO.CreatorCode = syncReportInfoRequest.ApplyUserCode;
- syncReportInfoRequest.ConsultationFileList.Add(consultationFileDTO);
- }
- }
- if (consultation.VideoTokens != null && consultation.VideoTokens.Any())
- {
- foreach (var item in consultation.VideoTokens)
- {
- var consultationFileDTO = new ConsultationFileDTO();
- consultationFileDTO.FileDataType = RemedicalFileDataTypeEnum.VinnoVidMovie;
- string previewImg = "";
- string file = "";
- var tuple = ConvertToVid(item.VideoToken, UploadFileTypeEnum.FVID);
- if (tuple != null)
- {
- file = tuple.Item1;
- if (string.IsNullOrEmpty(previewImg))
- {
- previewImg = tuple.Item2;
- }
- }
- consultationFileDTO.SourceUrl = file;
- consultationFileDTO.PreviewImageUrl = previewImg;
- consultationFileDTO.CreatorCode = syncReportInfoRequest.ApplyUserCode;
- syncReportInfoRequest.ConsultationFileList.Add(consultationFileDTO);
- }
- }
- if (consultation.GraphicData != null && consultation.GraphicData.Any())
- {
- foreach (var item in consultation.GraphicData)
- {
- var consultationFileDTO = new ConsultationFileDTO();
- string previewImg = "";
- string file = "";
- if (item.GraphicType == 0)
- {
- if (!string.IsNullOrEmpty(item.PreviewGraphicToken))
- {
- previewImg = ConvertToJpg(item.PreviewGraphicToken);
- }
- if (!string.IsNullOrEmpty(item.GraphicToken))
- {
- var tuple = ConvertToVid(item.GraphicToken, UploadFileTypeEnum.IMG);
- if (tuple != null)
- {
- file = tuple.Item1;
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(item.PreviewGraphicToken))
- {
- previewImg = ConvertToJpg(item.PreviewGraphicToken);
- }
- if (!string.IsNullOrEmpty(item.GraphicToken))
- {
- var tuple = ConvertToVid(item.GraphicToken, UploadFileTypeEnum.FVID);
- if (tuple != null)
- {
- file = tuple.Item1;
- if (string.IsNullOrEmpty(previewImg))
- {
- previewImg = tuple.Item2;
- }
- }
- }
- }
- consultationFileDTO.CoverImageUrl = previewImg;
- consultationFileDTO.FileDataType = item.GraphicType == 0 ? RemedicalFileDataTypeEnum.ThirdVidSingle : RemedicalFileDataTypeEnum.ThirdVidMovie;
- consultationFileDTO.SourceUrl = file;
- consultationFileDTO.PreviewImageUrl = previewImg;
- consultationFileDTO.CreatorCode = item.UserId;
- consultationFileDTO.CreateTime = (consultation.UpdateTime <= DateTime.MinValue ? consultation.CreateTime : consultation.UpdateTime);
- syncReportInfoRequest.ConsultationFileList.Add(consultationFileDTO);
- }
- }
- if (consultation.PreFileItems != null && consultation.PreFileItems.Any())
- {
- foreach (var item in consultation.PreFileItems)
- {
- string previewImg = "";
- string file = "";
- if (item.FileType == 0)
- {
- if (!string.IsNullOrEmpty(item.ThumbnailUrl))
- {
- previewImg = ConvertToJpg(item.ThumbnailUrl);
- }
- if (!string.IsNullOrEmpty(item.OriginalFileUrl))
- {
- var tuple = ConvertToVid(item.OriginalFileUrl, UploadFileTypeEnum.IMG);
- if (tuple != null)
- {
- file = tuple.Item1;
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(item.ThumbnailUrl))
- {
- previewImg = ConvertToJpg(item.ThumbnailUrl);
- }
- if (!string.IsNullOrEmpty(item.OriginalFileUrl))
- {
- //file = ConvertToVid(item.GraphicToken, UploadFileTypeEnum.FVID);
- //pdf文件
- }
- }
- var consultationFileDTO = new ConsultationFileDTO();
- consultationFileDTO.FileDataType = item.FileType == 0 ? RemedicalFileDataTypeEnum.ThirdVidSingle : RemedicalFileDataTypeEnum.ThirdVidMovie;
- consultationFileDTO.SourceUrl = file;
- consultationFileDTO.PreviewImageUrl = previewImg;
- consultationFileDTO.CreatorCode = item.Uploader;
- syncReportInfoRequest.ConsultationFileList.Add(consultationFileDTO);
- }
- }
- syncBatchConsultationRequest.SyncConsultations.Add(syncReportInfoRequest);
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendConsultations err, ex:{ex}");
- }
- }
- var result = _jsonRpcProxy.LiveConsultationService.SyncBatchConsultationAsync(syncBatchConsultationRequest).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendConsultations err, ex:{ex}");
- }
- }
- private string GetScanPosition(string checkPoint)
- {
- if (checkPoint == "Fetu")
- {
- return "Fetus";
- }
- else if (checkPoint == "Appendages")
- {
- return "Adnexa";
- }
- else if (checkPoint == "PelvicCavity")
- {
- return "Pelvic";
- }
- else if (checkPoint == "GB")
- {
- return "Cholecyst";
- }
- else if (checkPoint == "DoubleKidney")
- {
- return "Kidneys";
- }
- return checkPoint;
- }
- private TransactionStatusEnum GetStatusEnum(Entities.ConsultationState state)
- {
- TransactionStatusEnum transactionStatusEnum = TransactionStatusEnum.Applied;
- switch (state)
- {
- case Entities.ConsultationState.Unhandled:
- transactionStatusEnum = TransactionStatusEnum.Applied;
- break;
- case Entities.ConsultationState.Withdrawn:
- transactionStatusEnum = TransactionStatusEnum.Withdrawn;
- break;
- case Entities.ConsultationState.Handled:
- transactionStatusEnum = TransactionStatusEnum.ToStart;
- break;
- case Entities.ConsultationState.Started:
- transactionStatusEnum = TransactionStatusEnum.InProgress;
- break;
- case Entities.ConsultationState.WaitForReportUpload:
- transactionStatusEnum = TransactionStatusEnum.PendingReport;
- break;
- case Entities.ConsultationState.ReportUploading:
- transactionStatusEnum = TransactionStatusEnum.PendingReport;
- break;
- case Entities.ConsultationState.ReportUploaded:
- transactionStatusEnum = TransactionStatusEnum.End;
- break;
- case Entities.ConsultationState.ReportUploadFailed:
- transactionStatusEnum = TransactionStatusEnum.PendingReport;
- break;
- case Entities.ConsultationState.Expired:
- transactionStatusEnum = TransactionStatusEnum.Expired;
- break;
- case Entities.ConsultationState.Qualified:
- transactionStatusEnum = TransactionStatusEnum.End;
- break;
- case Entities.ConsultationState.UnQualified:
- transactionStatusEnum = TransactionStatusEnum.End;
- break;
- default:
- break;
- }
- return transactionStatusEnum;
- }
- ///// <summary>
- ///// 数据转换
- ///// </summary>
- ///// <typeparam name="T"></typeparam>
- ///// <param name="tempRecords"></param>
- ///// <param name="key"></param>
- ///// <returns></returns>
- //private async Task<List<ReportInfoResults>> ReportInfoFilterData(List<ReportInfoResults> list)
- //{
- // var records = new List<ReportInfoResults>();
- // var key = "ReportInfoResultsData";
- // if (list?.Count() > 0)
- // {
- // var tempReportTemplateData = new List<CacheBasicInfo>();
- // foreach (var t in list)
- // {
- // if (t != null)
- // {
- // var createTime = t.CreateTime;
- // var updateTime = t.UpdateTime;
- // var item = new CacheBasicInfo()
- // {
- // Id = t.Id,
- // CacheTime = createTime > updateTime ? createTime : updateTime,
- // };
- // tempReportTemplateData.Add(item);
- // }
- // }
- // if (CommonConfigManager.CacheSynDataInfo.CacheDic.Keys.Contains(key) && CommonConfigManager.CacheSynDataInfo.CacheDic[key]?.Count > 0)
- // {
- // foreach (var templateInfo in tempReportTemplateData)
- // {
- // if (CommonConfigManager.CacheSynDataInfo.CacheDic[key].Exists(c => c.Id == templateInfo.Id && c.CacheTime == templateInfo.CacheTime))
- // {
- // //存在,表示已经处理过
- // }
- // else
- // {
- // //不存在,表示没处理过
- // CommonConfigManager.CacheSynDataInfo.CacheDic[key].Add(templateInfo);
- // var findEntity = list.FirstOrDefault(c => c.Id.ToString() == templateInfo.Id);
- // if (!string.IsNullOrEmpty(findEntity?.Id))
- // {
- // records.Add(findEntity);
- // }
- // }
- // }
- // }
- // else
- // {
- // CommonConfigManager.CacheSynDataInfo.CacheDic.Add(key, tempReportTemplateData);
- // records = list;
- // }
- // }
- // return records;
- //}
- public async Task MigrateReportInfoResults(SyncDBEnum syncType)
- {
- Logger.WriteLineInfo($"ReportInfoResults migrate to wingServer starting");
- //获取上次同步到的时间
- var builder = Builders<ReportInfoResults>.Filter;
- var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
- var reportInfoResults = new List<ReportInfoResults>();
- try
- {
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= _migrateRecord.EndTime) || (x.UpdateTime > startTime && x.UpdateTime <= _migrateRecord.EndTime));
- //var filter = builder.Where(x => x.Id == "DE2642FAFCA64AEAAB285BD38E6DEEC0");
- var tempReportInfoResults = _reportInfoResultDBRepository.GetReports(filter).OrderByDescending(x => x.CreateTime).ToList();
- reportInfoResults = await FilterData(tempReportInfoResults, "ReportInfoResultsData");
- OnMigrate("reportInfoResults", reportInfoResults, SendRemedicalreportInfoResults, syncType, 1);
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"ReportInfoResults migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"reportInfoResults migrate to wingServer successfully, result:{reportInfoResults?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (reportInfoResults != null)
- {
- reportInfoResults.Clear();
- }
- }
- }
- public async Task MigrateSpeicalReportInfoResults(DateTime startTime, DateTime endTime)
- {
- Logger.WriteLineInfo($"MigrateSpeicalReportInfoResults migrate to wingServer starting");
- //获取上次同步到的时间
- var builder = Builders<ReportInfoResults>.Filter;
- var reportInfoResults = new List<ReportInfoResults>();
- try
- {
- var filter = builder.Where(x => (x.CreateTime > startTime && x.CreateTime <= endTime) || (x.UpdateTime > startTime && x.UpdateTime <= endTime));
- //var filter = builder.Where(x => x.Id == "DE2642FAFCA64AEAAB285BD38E6DEEC0");
- reportInfoResults = _reportInfoResultDBRepository.GetReports(filter).OrderByDescending(x => x.CreateTime).ToList();
- OnMigrate("reportInfoResults", reportInfoResults, SendRemedicalreportInfoResults, SyncDBEnum.Synchronize, 1);
- }
- catch (Exception ex)
- {
- Logger.WriteLineInfo($"MigrateSpeicalReportInfoResults migrate to wingServer Error: {ex}");
- }
- finally
- {
- Logger.WriteLineInfo($"MigrateSpeicalReportInfoResults migrate to wingServer successfully, result:{reportInfoResults?.Count}, startTime: {startTime.ToString("yyyy-MM-dd HH:mm:ss")}--endTime: {_migrateRecord.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
- if (reportInfoResults != null)
- {
- reportInfoResults.Clear();
- }
- }
- }
- private void SendRemedicalreportInfoResults(IList<ReportInfoResults> reportInfoResults, SyncDBEnum syncType)
- {
- try
- {
- var syncBatchReportInfoRequest = new SyncBatchReportInfoRequest();
- syncBatchReportInfoRequest.SyncType = syncType;
- syncBatchReportInfoRequest.SyncReportInfos = new List<SyncReportInfoRequest>();
- foreach (var reportInfoResult in reportInfoResults)
- {
- try
- {
- var terminalRecord = _terminalRecordDBRepository.GetTerminalRecordByCodes(new List<string> { reportInfoResult.RecordId })?.FirstOrDefault();
- var diagnosisLabels = new List<string>();
- var reportUserCode = "";
- var isAI = false;
- if (reportInfoResult?.User?.Name == "AI")
- {
- diagnosisLabels = new List<string> { "VAid" };
- isAI = true;
- if (terminalRecord != null && terminalRecord.AIDiagnosisInfos != null && terminalRecord.AIDiagnosisInfos.Any())
- {
- foreach (var ai in terminalRecord.AIDiagnosisInfos)
- {
- if (ai.Organ == reportInfoResult.Organ && ai.Status != EnumAiDiagnosisStatus.Null)
- {
- diagnosisLabels.Add(ai.Status.ToString());
- }
- }
- }
- }
- else
- {
- reportUserCode = reportInfoResult.User._id;
- }
- Logger.WriteLineInfo($"reportInfoResults migrate to wingServer successfully, reportInfoResult.Id: {reportInfoResult.Id}");
- var syncReportInfoRequest = new SyncReportInfoRequest
- {
- ReportCode = reportInfoResult.Id,
- CreateTime = reportInfoResult.CreateTime,
- UpdateTime = reportInfoResult.UpdateTime,
- RecordCode = reportInfoResult.RecordId,
- ReportTemplateJson = reportInfoResult.Template,
- ReportDatasJson = ReportElementsSerializer.ConvertReportElementsToJson(isAI, reportInfoResult.Template, reportInfoResult.ElementCollection),
- ReportPreviewList = new List<ReportPreviewDTO>(),
- ReportOrgan = (DiagnosisOrganEnum)reportInfoResult.Organ,
- DiagnosisLabels = diagnosisLabels,
- ReportUserCode = reportUserCode
- };
- if (reportInfoResult.PreviewImages != null && reportInfoResult.PreviewImages.Count > 0)
- {
- foreach (var item in reportInfoResult.PreviewImages)
- {
- var reportPreviewDTO = new ReportPreviewDTO();
- reportPreviewDTO.FileToken = GetFileUrl(item.Name);
- reportPreviewDTO.FileType = UploadFileTypeEnum.JPG;
- syncReportInfoRequest.ReportPreviewList.Add(reportPreviewDTO);
- }
- }
- syncBatchReportInfoRequest.SyncReportInfos.Add(syncReportInfoRequest);
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalreportInfoResults err, ex:{ex}");
- }
- }
- var result = _jsonRpcProxy.ReportService.SyncBatchReportInfoAsync(syncBatchReportInfoRequest).Result;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"SendRemedicalreportInfoResults err, ex:{ex}");
- }
- }
- private string GetFileUrl(string fileUrl)
- {
- var prefix = "1!U$";
- if (!string.IsNullOrWhiteSpace(fileUrl) && fileUrl.StartsWith(prefix))
- {
- return fileUrl.Replace(prefix, "");
- }
- return fileUrl ?? string.Empty;
- }
- internal string GetSourceUrl(string cdnUrl)
- {
- cdnUrl = GetFileUrl(cdnUrl);
- var sourceUrl = cdnUrl.Replace("http://cdn-bj.fis.plus", "https://flyinsono-bj-1300984704.cos.ap-beijing.myqcloud.com")
- .Replace("http://cdn-hk.fis.plus", "https://flyinsono-hk-1300984704.cos.ap-hongkong.myqcloud.com")
- .Replace("http://cdn-fra.fis.plus", "https://flyinsono-fra-1300984704.cos.eu-frankfurt.myqcloud.com")
- .Replace("http://cdn-bom.fis.plus", "https://flyinsono-bom-1300984704.cos.ap-mumbai.myqcloud.com")
- .Replace("http://static.fis.plus", "https://static-1300984704.cos.ap-shanghai.myqcloud.com");
- return sourceUrl;
- }
- internal string GetCDNUrl(string sourceUrl)
- {
- if (sourceUrl.Contains("cdn-"))
- {
- return sourceUrl;
- }
- var cndUrl = sourceUrl.Replace("https://flyinsono-bj-1300984704.cos.ap-beijing.myqcloud.com", "http://cdn-bj.fis.plus")
- .Replace("https://flyinsono-hk-1300984704.cos.ap-hongkong.myqcloud.com", "http://cdn-hk.fis.plus")
- .Replace("https://flyinsono-fra-1300984704.cos.eu-frankfurt.myqcloud.com", "http://cdn-fra.fis.plus")
- .Replace("https://flyinsono-bom-1300984704.cos.ap-mumbai.myqcloud.com", "http://cdn-bom.fis.plus")
- .Replace("https://static-1300984704.cos.ap-shanghai.myqcloud.com", "http://static.fis.plus")
- .Replace("http://flyinsono-bj-1300984704.cos.ap-beijing.myqcloud.com", "http://cdn-bj.fis.plus")
- .Replace("http://flyinsono-hk-1300984704.cos.ap-hongkong.myqcloud.com", "http://cdn-hk.fis.plus")
- .Replace("http://flyinsono-fra-1300984704.cos.eu-frankfurt.myqcloud.com", "http://cdn-fra.fis.plus")
- .Replace("http://flyinsono-bom-1300984704.cos.ap-mumbai.myqcloud.com", "http://cdn-bom.fis.plus")
- .Replace("http://static-1300984704.cos.ap-shanghai.myqcloud.com", "http://static.fis.plus");
- return cndUrl;
- }
- private string ConvertToJpg(string oldFileToken)
- {
- try
- {
- var prefix = "1!U$";
- if (!string.IsNullOrWhiteSpace(oldFileToken) && oldFileToken.StartsWith(prefix))
- {
- var fileUrl = oldFileToken.Replace(prefix, "");
- var fileName = Path.GetFileNameWithoutExtension(fileUrl);
- var jpgFileName = fileName + ".jpg";
- //验证头
- var storageUrl = "";
- var validateResult = ValidateHeadFile(jpgFileName, ref storageUrl);
- if (validateResult)
- {
- return storageUrl;
- }
- var localPath = DownloadAsync(fileUrl, jpgFileName).Result;
- if (!string.IsNullOrWhiteSpace(localPath))
- {
- var newUrl = UploadAsync(localPath).Result;
- if (!string.IsNullOrWhiteSpace(newUrl))
- {
- return newUrl;
- }
- }
- }
- return oldFileToken;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"ConvertToJpg err, ex:{ex}");
- return oldFileToken;
- }
- }
- private bool ValidateHeadFile(string fileName, ref string storageUrl)
- {
- bool result = true;
- var authorizationResult = _jsonRpcProxy.Storage.GetAuthorizationAsync(new FileServiceRequest
- {
- Token = DefaultToken,
- FileName = fileName,
- IsRechristen = false,
- IsUpgradePackage = false,
- RequestMethod = "head"
- }).Result;
- if (authorizationResult == null)
- {
- Logger.WriteLineInfo("Head Create Signature Fail");
- return false;
- }
- var newRequestHeads = new Dictionary<string, string>();
- newRequestHeads.Add("Authorization", authorizationResult.Authorization);
- storageUrl = authorizationResult.StorageUrl;
- using (var newRequest = new HttpRequestMessage())
- {
- newRequest.RequestUri = new Uri(storageUrl);
- newRequest.Method = HttpMethod.Head;
- foreach (var newHead in newRequestHeads)
- {
- newRequest.Headers.TryAddWithoutValidation(newHead.Key, newHead.Value);
- }
- var newResponse = _httpClient.SendAsync(newRequest).Result;
- if (newResponse != null && newResponse.StatusCode == HttpStatusCode.OK)
- {
- //read response content
- if (storageUrl.Contains("/SystemUpgradePackage/"))//表示vinno
- {
- var resultContent = newResponse.Content.Headers.ContentLength > 0;
- if (resultContent)
- {
- result = result & true;
- }
- else
- {
- result = result & false;
- }
- }
- else
- {
- var newETag = newResponse.Headers?.ETag?.Tag ?? string.Empty;
- if (!string.IsNullOrEmpty(newETag))
- {
- result = result & true;
- }
- else
- {
- result = result & false;
- }
- }
- }
- else
- {
- result = result & false;
- }
- }
- return result;
- }
- private Tuple<string, string> ConvertToVid(string oldFileToken, UploadFileTypeEnum fileType)
- {
- try
- {
- var prefix = "1!U$";
- if (!string.IsNullOrWhiteSpace(oldFileToken) && oldFileToken.StartsWith(prefix))
- {
- var fileUrl = oldFileToken.Replace(prefix, "");
- var fileName = Path.GetFileNameWithoutExtension(fileUrl);
- var vidFileName = fileName + ".vid";
- //验证头
- var storageUrl = "";
- var host = "";
- var validateResult = ValidateHeadFile(vidFileName, ref storageUrl);
- if (validateResult)
- {
- host = storageUrl.Replace(vidFileName, "");
- var previewUrl = host + fileName + ".jpg";
- return Tuple.Create<string, string>(storageUrl, previewUrl);
- }
- var vidResult = _jsonRpcProxy.RemedicalService.DoConvertToVid(new WingInterfaceLibrary.Request.Lab.LabFileInfoRequest
- {
- Token = DefaultToken,
- FileName = fileName,
- FilePath = fileUrl,
- FileType = fileType
- }).Result;
- if (!string.IsNullOrWhiteSpace(vidResult))
- {
- host = vidResult.Replace(vidFileName, "");
- var previewUrl = host + fileName + ".jpg";
- return Tuple.Create<string, string>(vidResult, previewUrl);
- }
- }
- return Tuple.Create<string, string>("", "");
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"ConvertToVid err, ex:{ex}");
- return Tuple.Create<string, string>("", "");
- }
- }
- private OrganizationView MapToOrganizationView(IList<Organizations> organizations, string? hospitalId)
- {
- var hospital = organizations.FirstOrDefault(x => x.Id == hospitalId);
- if (hospital != null)
- {
- return new OrganizationView
- {
- Code = hospital.Id,
- Name = hospital.Name,
- Description = hospital.Description,
- CountryCode = hospital.Country?.Id,
- CountryName = hospital.Country?.Name,
- ProvinceCode = hospital.Province?.Id,
- ProvinceName = hospital.Province?.Name,
- CityCode = hospital.City?.Id,
- CityName = hospital.City?.Name,
- };
- }
- return null;
- }
- private UserView MapToUserView(IList<Organizations> organizations, IList<Users> users, string? userId)
- {
- var user = users.FirstOrDefault(x => x.Id == userId);
- if (user != null)
- {
- var hospital = organizations.FirstOrDefault(x => x.Id == user.HospitalId);
- var name = !string.IsNullOrWhiteSpace(user.FullName) ? user.FullName
- : !string.IsNullOrWhiteSpace(user.LastName) ? user.LastName
- : !string.IsNullOrWhiteSpace(user.FirstName) ? user.FirstName
- : !string.IsNullOrWhiteSpace(user.NickName) ? user.NickName
- : user.Name;
- return new UserView
- {
- Code = user.Id,
- Name = name,
- OrganizationCode = user.HospitalId,
- OrganizationName = hospital?.Name,
- };
- }
- return null;
- }
- private DeviceView MapToDeviceView(IList<Terminals> terminals, string? terminalId)
- {
- var terminal = terminals.FirstOrDefault(x => x.Id == terminalId);
- if (terminal != null)
- {
- return new DeviceView
- {
- Code = terminal.Id,
- Name = terminal.Name,
- Description = terminal.Description,
- UniqueCode = terminal.UniquedId,
- DeviceType = terminal.IsSonopost ? "sonopost" : "US",
- DeviceModel = terminal.Model,
- OrganizationCode = terminal.Organization?.Id,
- OrganizationName = terminal.Organization?.Name,
- };
- }
- return null;
- }
- private GroupView MapToUserGroupView(IList<UserGroup> userGroups, string? userGroupId)
- {
- var userGroup = userGroups.FirstOrDefault(x => x.Id == userGroupId);
- if (userGroup != null)
- {
- return new GroupView
- {
- Code = userGroup.Id,
- Name = userGroup.Name,
- };
- }
- return null;
- }
- private ClassView MapToClassView(IList<UltrasonicClass> classes, string? classId)
- {
- var classInfo = classes.FirstOrDefault(x => x.Id == classId);
- if (classInfo != null)
- {
- return new ClassView
- {
- Code = classInfo.Id,
- Name = classInfo.Name,
- };
- }
- return null;
- }
- private List<DiagnosisOrganEnum> GetDiagnosisOrgans(List<AIDiagnosisPerImg> results)
- {
- var diagnosisOrgans = new List<DiagnosisOrganEnum>();
- foreach (var imageResult in results)
- {
- foreach (var diagnosisResult in imageResult.DiagResultsForEachOrgan)
- {
- var organName = Enum.GetName(typeof(DiagnosisOrganEnum), (int)diagnosisResult.Organ);
- if (!string.IsNullOrWhiteSpace(organName) && diagnosisResult.Organ != EnumOrgans.Null && diagnosisResult.DetectedObjects?.Any() == true)
- {
- diagnosisOrgans.Add((DiagnosisOrganEnum)diagnosisResult.Organ);
- }
- }
- }
- return diagnosisOrgans.Distinct().ToList();
- }
- private DiagnosisConclusionEnum GetDiagnosisConclusion(List<AIDiagnosisPerImg> results)
- {
- var diagnosisConclusions = new List<DiagnosisConclusionEnum>();
- foreach (var imageResult in results)
- {
- foreach (var diagnosisResult in imageResult.DiagResultsForEachOrgan)
- {
- var benignLabels = new List<int>();
- var malignantLabels = new List<int>();
- if (diagnosisResult.Organ == EnumOrgans.Breast)
- {
- benignLabels = new List<int> { 1, 2, 3 };
- malignantLabels = new List<int> { 4, 5, 6, 7 };
- }
- else if (diagnosisResult.Organ == EnumOrgans.Liver)
- {
- benignLabels = new List<int> { 1, 2, 3, 5, 6, 7, 8 };
- malignantLabels = new List<int> { 4 };
- }
- else if (diagnosisResult.Organ == EnumOrgans.Thyroid)
- {
- benignLabels = new List<int> { 1, 2, 7 };
- malignantLabels = new List<int> { 3, 4, 5, 6 };
- }
- var labels = diagnosisResult.DetectedObjects.Select(x => x.Label);
- if (labels.Contains(0))
- {
- diagnosisConclusions.Add(DiagnosisConclusionEnum.NoObviousLesion);
- }
- if (labels.Intersect(benignLabels).Any())
- {
- diagnosisConclusions.Add(DiagnosisConclusionEnum.Benign);
- }
- if (labels.Intersect(malignantLabels).Any())
- {
- diagnosisConclusions.Add(DiagnosisConclusionEnum.Malignant);
- }
- }
- }
- var containsBenign = diagnosisConclusions.Contains(DiagnosisConclusionEnum.Benign);
- var containsMalignant = diagnosisConclusions.Contains(DiagnosisConclusionEnum.Malignant);
- var containsNoObviousLesion = diagnosisConclusions.Contains(DiagnosisConclusionEnum.NoObviousLesion);
- if (containsBenign && containsMalignant)
- {
- return DiagnosisConclusionEnum.BenignAndMalignant;
- }
- else if (containsBenign)
- {
- return DiagnosisConclusionEnum.Benign;
- }
- else if (containsMalignant)
- {
- return DiagnosisConclusionEnum.Malignant;
- }
- else if (containsNoObviousLesion)
- {
- return DiagnosisConclusionEnum.NoObviousLesion;
- }
- else
- {
- return DiagnosisConclusionEnum.Unrecognized;
- }
- }
- /// <summary>下载文件</summary>
- /// <param name="fileUrl"></param>
- /// <returns></returns>
- private async Task<string> DownloadAsync(string fileUrl, string fileNameAndExtension = "")
- {
- try
- {
- if (string.IsNullOrEmpty(fileUrl))
- {
- return string.Empty;
- }
- if (!Directory.Exists(_tempFolder))
- {
- Directory.CreateDirectory(_tempFolder);
- }
- var fileName = Path.GetFileName(fileUrl);
- if (!string.IsNullOrWhiteSpace(fileNameAndExtension))
- {
- fileName = fileNameAndExtension;
- }
- var tempFile = Path.Combine(_tempFolder, fileName);
- if (File.Exists(tempFile))
- {
- return tempFile;
- }
- long fileSize = 0;
- using (var request = new HttpRequestMessage())
- {
- request.RequestUri = new Uri(fileUrl);
- request.Method = HttpMethod.Get;
- var response = await _httpClient.SendAsync(request);
- if (response != null && response.StatusCode == HttpStatusCode.OK)
- {
- var contentLength = response.Content.Headers.ContentLength;
- fileSize = contentLength == null ? 0 : contentLength.Value;
- }
- }
- if (fileSize <= 0)
- {
- throw new NotSupportedException($"fileSize is {fileSize}");
- }
- byte[] bytes = await _httpClient.GetByteArrayAsync(fileUrl);
- File.WriteAllBytes(tempFile, bytes);
- return tempFile;
- }
- catch (Exception ex)
- {
- Logger.WriteLineWarn($"MigrateService download file err, url: {fileUrl}, {ex}");
- }
- finally
- {
- //Logger.WriteLineInfo($"download file:{fileUrl}");
- }
- return string.Empty;
- }
- private async Task<string> UploadAsync(string localPath)
- {
- var authorizationResult = await _jsonRpcProxy.Storage.GetAuthorizationAsync(new FileServiceRequest
- {
- Token = DefaultToken,
- FileName = Path.GetFileName(localPath),
- IsRechristen = false,
- });
- var fileUrl = authorizationResult.StorageUrl;
- using (var fileStream = new FileStream(localPath, FileMode.Open))
- {
- var size = fileStream.Length;
- byte[] buffer = new byte[fileStream.Length];
- fileStream.Read(buffer, 0, buffer.Length);
- var requestHeads = new Dictionary<string, string>();
- requestHeads.Add("Authorization", authorizationResult.Authorization);
- using (var request = new HttpRequestMessage())
- {
- var fileExtension = Path.GetExtension(localPath);
- var mimeType = FileHelper.GetMimeType(fileExtension);
- var contentType = MediaTypeHeaderValue.Parse(mimeType);
- using (UploadContent content = new UploadContent(buffer, contentType))
- {
- request.RequestUri = new Uri(fileUrl);
- request.Method = HttpMethod.Put;
- request.Content = content;
- foreach (var head in requestHeads)
- {
- request.Headers.TryAddWithoutValidation(head.Key, head.Value);
- }
- var result = await ExecuteRequest(request);
- if (result)
- {
- return fileUrl;
- }
- }
- }
- }
- return null;
- }
- /// <summary>
- /// 执行请求
- /// </summary>
- /// <param name="httpRequestMessage"></param>
- /// <typeparam name="T"></typeparam>
- /// <returns></returns>
- private async Task<bool> ExecuteRequest(HttpRequestMessage httpRequestMessage)
- {
- try
- {
- var response = await _httpClient.SendAsync(httpRequestMessage);
- if (response != null && response.StatusCode == HttpStatusCode.OK)
- {
- return true;
- }
- return false;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取实际时间
- /// </summary>
- /// <param name="beginTime"></param>
- /// <param name="endTime"></param>
- /// <returns></returns>
- private DateTime GetFactBeginTime(DateTime beginTime, DateTime endTime)
- {
- if (beginTime > endTime)
- {
- var dateDiff = endTime - beginTime;
- if (dateDiff.TotalDays > 365)
- {
- beginTime = endTime.AddYears(-1);
- }
- }
- else
- {
- var diffMintues = CommonConfigManager.MigrateRuleInfo.StartTimeDiffMintues;
- if (diffMintues > 0)
- {
- beginTime = beginTime.AddMinutes(-diffMintues);
- }
- }
- return beginTime;
- }
- }
- public class AIDiagnosisPerImg
- {
- /// <summary>
- /// Index
- /// </summary>
- public int Index { get; set; }
- /// <summary>
- /// Priority Score
- /// </summary>
- public float PriorityScore { get; set; }
- /// <summary>
- /// DiagResults of each Organ
- /// </summary>
- public IList<AIDiagResultPerOrganForDB> DiagResultsForEachOrgan { get; set; }
- }
- public class UploadContent : HttpContent
- {
- private const int ChunkSize = 2097152;//2M;
- private readonly Stream _uploadStream;
- private readonly long _fileSize;
- public event EventHandler<double> ProgressChanged;
- public UploadContent(string filePath)
- {
- if (string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath))
- {
- throw new Exception("UploadFile not find");
- }
- var fileName = Path.GetFileName(filePath);
- _uploadStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
- var mimeType = FileHelper.GetMimeType(fileName.Substring(fileName.LastIndexOf(".")));
- Headers.ContentType = MediaTypeHeaderValue.Parse(mimeType);
- Headers.ContentLength = _uploadStream.Length;
- _fileSize = _uploadStream.Length;
- }
- public UploadContent(byte[] fileData, MediaTypeHeaderValue mediaTypeHeaderValue)
- {
- if (fileData == null || fileData.Length == 0)
- {
- throw new Exception("FileData is empty");
- }
- _uploadStream = new MemoryStream(fileData);
- Headers.ContentType = mediaTypeHeaderValue;
- Headers.ContentLength = _uploadStream.Length;
- _fileSize = _uploadStream.Length;
- }
- /// <summary>
- /// 将内容写入流
- /// </summary>
- /// <param name="stream"></param>
- /// <param name="context"></param>
- /// <returns></returns>
- protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context)
- {
- for (long i = 0; i < _uploadStream.Length; i += ChunkSize)
- {
- var dataToWrite = new byte[Math.Min(ChunkSize, _uploadStream.Length - i)];
- await _uploadStream.ReadAsync(dataToWrite, 0, dataToWrite.Length);
- await stream.WriteAsync(dataToWrite, 0, dataToWrite.Length);
- OnProgressChanged((double)(i * 100 / _uploadStream.Length));
- }
- OnProgressChanged(100);
- }
- /// <summary>
- /// 比较文件大小
- /// </summary>
- /// <returns></returns>
- public bool CompareFileSizes(long webFileSize)
- {
- return _fileSize == webFileSize;
- }
- protected override bool TryComputeLength(out long length)
- {
- length = _uploadStream.Length;
- return true;
- }
- private void OnProgressChanged(double e)
- {
- ProgressChanged?.Invoke(this, e);
- }
- public new void Dispose()
- {
- base.Dispose();
- _uploadStream.Close();
- ProgressChanged = null;
- }
- }
- }
|