/// <summary> /// 添加会议记录 /// </summary> /// <param name="key"></param> /// <param name="model"></param> public void MeetingDataAdd(Guid key, MeetingSyncModel model) { if (!syncMeeting.ContainsKey(key)) { syncMeeting.Add(key, new ConcurrentQueue <MeetingSyncModel>()); } var items = syncMeeting[key] as ConcurrentQueue <MeetingSyncModel>; if (items.IsNull()) { return; } items.Enqueue(model); Console.WriteLine($"items:{items.Count}"); }
/// <summary> /// 获取会议记录(本地+线上) /// </summary> /// <returns></returns> public MeetingSyncModel MeetingDataGet(Guid key) { if (!syncMeeting.ContainsKey(key)) { syncMeeting.Add(key, new ConcurrentQueue <MeetingSyncModel>()); } var queue = syncMeeting[key] as ConcurrentQueue <MeetingSyncModel>; if (queue.IsNull()) { return(null); } MeetingSyncModel model = null; queue.TryDequeue(out model); return(model); }
private void SyncData(MeetingSyncModel model) { if (model == null || (model != null && model.Content.IsEmpty())) { return; } if (model.SyncType <= 0) { var last = Records.Where(x => !x.IsComplete).LastOrDefault(); if (last.IsNull()) { last = new RecordObservable(); last.Id = Guid.Empty; last.LocalId = Guid.Empty; last.IsComplete = false; last.Translations = new ObservableCollection <TranslationObservable>(); Records.Add(last); } last.MeetingId = Meeting.Id; last.Langue = Setting.SourceLang; last.LangueTrs = Setting.TargetLangs; last.Content = last.Content + model.Content; last.RefreshDt = DateTime.Now; last.IsComplete = model.SyncType == 0; if (last.LocalId == Guid.Empty) { last.LocalId = Guid.NewGuid(); last.Content = last.Content.TrimStartPunctuation(); } } if (model.SyncType == 1) { var record = Records.Where(x => x.LocalId == model.LocalId).FirstOrDefault(); if (record.IsNull() && !model.RecordId.IsEmpty()) { record = new RecordObservable(); record.IsComplete = true; Records.Add(record); } if (record.IsNull()) { return; } record.Id = model.RecordId; record.LocalId = model.LocalId; record.MeetingId = model.MeetingId; record.Langue = model.Langue; record.LangueTrs = model.LangueTrs; record.Content = model.Content; record.Des = $" -B-"; record.RefreshDt = model.RefreshDt; record.Sort = model.Sort; record.SyncType = model.SyncType; } if (model.SyncType == 2) { RecordObservable record = Records.Where(x => x.Id == model.RecordId).FirstOrDefault(); if (record.IsNull()) { return; } var translation = record.Translations.FirstOrDefault(x => x.Langue == model.Langue); var isAdd = translation.IsNull(); if (isAdd) { translation = new TranslationObservable(); } translation.Id = model.TranslationId; translation.MeetingId = model.MeetingId; translation.RecordId = model.RecordId; translation.Langue = model.Langue; translation.Content = model.Content; translation.Sort = model.Sort; if (isAdd) { record.Translations.Add(translation); } } }