private void Watcher_Changed(object sender, CmisChangeLogEventArgs e) { var doc = GetMakuraDocument(e.UpdatedDocument); var eventArgs = new MakuraDocumentEventArgs(); eventArgs.UpdatedDocument = doc; //マルチファイリング負対応 var path = e.UpdatedDocument.Paths.FirstOrDefault(); eventArgs.Path = path ?? String.Empty; Changed?.Invoke(sender, eventArgs); }
public async void PollingStartAsync() { pollingOn = true; await Task.Run(() => { while (pollingOn) { var session = connector.CreateSession(); var latestChangeLogToken = LatestChangeLogTokenProvider.GetChangeLogToken(); var changeLogs = session.GetContentChanges(latestChangeLogToken, false, 10); if (changeLogs.TotalNumItems > 0) { foreach (var cle in changeLogs.ChangeEventList) { try { var doc = session.GetObject(cle.ObjectId) as Document; if (doc == null) continue; //とりあえずドキュメントのみ var evChangeType = WatcherChangeTypes.Changed; if (cle.ChangeType == ChangeType.Created) { evChangeType = WatcherChangeTypes.Created; } else if (cle.ChangeType == ChangeType.Deleted) { evChangeType = WatcherChangeTypes.Deleted; } else if (cle.ChangeType == ChangeType.Updated) { evChangeType = WatcherChangeTypes.Changed; } var evArg = new CmisChangeLogEventArgs(evChangeType, doc); this.Changed(this, evArg); } catch { } } LatestChangeLogTokenProvider.SetChangeLogToken(session.RepositoryInfo.LatestChangeLogToken); } } }); }