async public Task <Discussion> GetDiscussion() { using (DiscussionOperator discussionOperator = new DiscussionOperator( _mrk.ProjectKey.HostName, _settings, _networkOperationStatusListener)) { try { return(await discussionOperator.GetDiscussionAsync(_mrk, _discussionId)); } catch (OperatorException ex) { if (ex.InnerException is GitLabSharp.Accessors.GitLabRequestException rx) { if (rx.InnerException is System.Net.WebException wx) { if (wx.Response is System.Net.HttpWebResponse response && response.StatusCode == System.Net.HttpStatusCode.NotFound) { // it is not an error here, we treat it as 'last discussion item has been deleted' return(null); } } } throw new DiscussionEditorException("Cannot obtain discussion", ex); } } }
internal DiscussionCreator(MergeRequestKey mrk, IHostProperties hostProperties, User currentUser, IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener) { _discussionOperator = new DiscussionOperator( mrk.ProjectKey.HostName, hostProperties, networkOperationStatusListener); _mergeRequestKey = mrk; _currentUser = currentUser; _modificationListener = modificationListener; }
async public Task ResolveNoteAsync(int noteId, bool resolve) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties)) { try { await discussionOperator.ResolveNoteAsync(_mergeRequestKey, _discussionId, noteId, resolve); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot change discussion note resolve state", ex); } } }
async public Task DeleteNoteAsync(int noteId) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties)) { try { await discussionOperator.DeleteNoteAsync(_mergeRequestKey, noteId); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot delete discussion note", ex); } } }
async public Task <DiscussionNote> ModifyNoteBodyAsync(int noteId, string body) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties)) { try { return(await discussionOperator.ModifyNoteBodyAsync(_mergeRequestKey, _discussionId, noteId, body)); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot modify discussion body", ex); } } }
async public Task ReplyAndResolveDiscussionAsync(string body, bool resolve) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties)) { try { await discussionOperator.ReplyAndResolveDiscussionAsync(_mergeRequestKey, _discussionId, body, resolve); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot send reply", ex); } } }
async public Task ResolveNoteAsync(int noteId, bool resolve) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties, _networkOperationStatusListener)) { try { await discussionOperator.ResolveNoteAsync(_mergeRequestKey, _discussionId, noteId, resolve); _modificationListener.OnDiscussionModified(_mergeRequestKey); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot change discussion note resolve state", ex); } } }
async public Task DeleteNoteAsync(int noteId) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties, _networkOperationStatusListener)) { try { await discussionOperator.DeleteNoteAsync(_mergeRequestKey, noteId); _modificationListener.OnDiscussionModified(_mergeRequestKey); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot delete discussion note", ex); } } }
async public Task ReplyAndResolveDiscussionAsync(string body, bool resolve) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties, _networkOperationStatusListener)) { try { await discussionOperator.ReplyAndResolveDiscussionAsync(_mergeRequestKey, _discussionId, body, resolve); _modificationListener.OnDiscussionModified(_mergeRequestKey); } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot send reply", ex); } } }
async public Task<DiscussionNote> ModifyNoteBodyAsync(int noteId, string body) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties, _networkOperationStatusListener)) { try { var result = await discussionOperator.ModifyNoteBodyAsync(_mergeRequestKey, _discussionId, noteId, body); _modificationListener.OnDiscussionModified(_mergeRequestKey); return result; } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot modify discussion body", ex); } } }
async public Task<Discussion> ResolveDiscussionAsync(bool resolve) { using (DiscussionOperator discussionOperator = new DiscussionOperator(_mergeRequestKey.ProjectKey.HostName, _hostProperties, _networkOperationStatusListener)) { try { var result = await discussionOperator.ResolveDiscussionAsync(_mergeRequestKey, _discussionId, resolve); _modificationListener.OnDiscussionResolved(_mergeRequestKey); return result; } catch (OperatorException ex) { throw new DiscussionEditorException("Cannot change discussion resolve state", ex); } } }
internal DiscussionManager( DataCacheContext dataCacheContext, string hostname, IHostProperties hostProperties, User user, IMergeRequestCache mergeRequestCache, IModificationNotifier modificationNotifier, INetworkOperationStatusListener networkOperationStatusListener) { _operator = new DiscussionOperator(hostname, hostProperties, networkOperationStatusListener); _parser = new DiscussionParser(this, dataCacheContext.DiscussionKeywords, user); _parser.DiscussionEvent += onDiscussionParserEvent; _mergeRequestFilterChecker = dataCacheContext.MergeRequestFilterChecker; _tagForLogging = dataCacheContext.TagForLogging; _mergeRequestCache = mergeRequestCache; _mergeRequestCache.MergeRequestEvent += OnMergeRequestEvent; _modificationNotifier = modificationNotifier; _modificationNotifier.DiscussionResolved += onDiscussionResolved; _modificationNotifier.DiscussionModified += onDiscussionModified; if (dataCacheContext.UpdateRules.UpdateDiscussionsPeriod.HasValue) { _timer = new System.Timers.Timer { Interval = dataCacheContext.UpdateRules.UpdateDiscussionsPeriod.Value }; _timer.Elapsed += onTimer; _timer.SynchronizingObject = dataCacheContext.SynchronizeInvoke; _timer.Start(); scheduleUpdate(null /* update all merge requests cached at the moment of update processing */, DiscussionUpdateType.InitialSnapshot); } }
internal DiscussionCreator(MergeRequestKey mrk, IHostProperties hostProperties, User currentUser) { _discussionOperator = new DiscussionOperator(mrk.ProjectKey.HostName, hostProperties); _mergeRequestKey = mrk; _currentUser = currentUser; }