private void OnAddIssue( ResolverSourceType sourceType, Issue issue ) { Sources.ISource destination = _sourceFromType( sourceType ); Sources.ISource source = _sourceFromType( sourceType.Other() ); _actions.Add( new AddIssueSyncAction( destination, issue ) ); if( destination.Settings.IsPrimary ) { _actions.Add( new UpdateIssueSyncAction( source, issue, IssueFieldId.ID ) ); } }
private void HandleOneSidedIssue( Issue primaryIssue, Issue secondaryIssue ) { Issue existingIssue; ResolverSourceType existingSource; ResolverSourceType missingSource; System.Diagnostics.Debug.Assert( ( primaryIssue == null ) != ( secondaryIssue == null ) ); if( primaryIssue == null ) { existingIssue = secondaryIssue; existingSource = ResolverSourceType.Secondary; missingSource = ResolverSourceType.Primary; } else { existingIssue = primaryIssue; existingSource = ResolverSourceType.Primary; missingSource = ResolverSourceType.Secondary; } if( existingIssue.State == IssueState.Closed ) return; var eventData = new ResolverNeedItemLookupEventArgs( existingIssue.ID, missingSource ); if( !string.IsNullOrEmpty( existingIssue.ID ) ) { this.NeedItemLookup( this, eventData ); } if( eventData.Issue == null ) { this.Action( this, new ResolverActionEventArgs( existingIssue, missingSource, ResolverActionType.Add ) ); } else if( eventData.Issue.State == IssueState.Closed ) { this.Action( this, new ResolverActionEventArgs( existingIssue, existingSource, ResolverActionType.Close ) ); } }
/// <inheritdoc/> public override void AddIssue( Issue issue ) { }
/// <inheritdoc/> public override void CloseIssue( Issue issue ) { }
/// <inheritdoc/> public virtual void CloseIssue( Issue issue ) { _contained.CloseIssue( issue ); }
/// <inheritdoc/> public void Execute( Issue issue ) { SendRequest( "/issues/{0}", issue.ID ); }
private Issue Normalize( Issue denormalizedIssue ) { Issue issue; Match match = _descSplitRegExp.Match( denormalizedIssue.Description ); issue = denormalizedIssue.Clone(); issue.ID = ( match.Groups.Count > 1 ? match.Groups[ 1 ].Value : "" ); issue.Description = denormalizedIssue.Description.Substring( match.Length ); issue.OriginalIssue = denormalizedIssue; return issue; }
/// <inheritdoc/> public virtual void AddIssue( Issue issue ) { _contained.AddIssue( issue ); }
/// <inheritdoc/> public override void UpdateIssue( Issue issue, IssueFieldId fieldsToUpdate ) { base.UpdateIssue( Denormalize( issue ), Denormalize( fieldsToUpdate ) ); }
/// <inheritdoc/> public override void CloseIssue( Issue issue ) { base.CloseIssue( Denormalize( issue ) ); }
/// <inheritdoc/> public override void AddIssue( Issue issue ) { base.AddIssue( Denormalize( issue ) ); }
private Issue Denormalize( Issue normalizedIssue ) { Issue issue = normalizedIssue.Clone(); issue.OriginalIssue = normalizedIssue; issue.Description = string.Format( "S{0}: {1}", normalizedIssue.ID, normalizedIssue.Description ); if( normalizedIssue.OriginalIssue != null ) { issue.ID = normalizedIssue.OriginalIssue.ID; } return issue; }
private void HandleIssueToClose( Issue primaryIssue, Issue secondaryIssue ) { Issue issueToClose; ResolverSourceType sourceToClose; if( primaryIssue.State == IssueState.Closed ) { issueToClose = secondaryIssue; sourceToClose = ResolverSourceType.Secondary; } else { issueToClose = primaryIssue; sourceToClose = ResolverSourceType.Primary; } this.Action( this, new ResolverActionEventArgs( issueToClose, sourceToClose, ResolverActionType.Close ) ); }
/// <inheritdoc/> public void Execute( Issue issue ) { StringBuilder sb = new StringBuilder(); _issue = issue; sb.Append( "/cards?" ). Append( "name=" ).Append( HttpUtility.UrlEncode( _issue.Description ) ). Append( "&idList=" ).Append( SourceSettings.NewCardListId ); if( !string.IsNullOrEmpty( _issue.Details ) ) { sb.Append( "&desc=" ).Append( HttpUtility.UrlEncode( _issue.Details ) ); } SendRequest( sb.ToString() ); }
/// <inheritdoc/> public override void AddIssue( Issue issue ) { if( _config.IsOutputLogged ) { LogIssue( "ADD", issue ); } Contained.AddIssue( issue ); }
/// <inheritdoc/> public void Execute( Issue issue, IssueFieldId fieldsToUpdate) { int fieldCount = 0; var sb = new StringBuilder(); sb.AppendFormat( "/cards/{0}", issue.ID ); foreach( var x in fieldsToUpdate.Flags().Cast<IssueFieldId>() ) { sb.Append( fieldCount == 0 ? '?' : '&' ); switch( x ) { case IssueFieldId.Desc: sb.AppendFormat( "name={0}", HttpUtility.UrlEncode( issue.Description ) ); break; case IssueFieldId.Details: sb.AppendFormat( "desc={1}", HttpUtility.UrlEncode( issue.Details ) ); break; default: throw new ApplicationException( string.Format( "Update of {0} field is not supported", Enum.GetName( typeof( IssueFieldId ), x ) ) ); } fieldCount++; } if( fieldCount > 0 ) { SendRequest( sb.ToString() ); } }
/// <inheritdoc/> public override void UpdateIssue( Issue issue, IssueFieldId fieldsToUpdate ) { if( _config.IsOutputLogged ) { string actionText = string.Format( "UPDATE( {0} )", fieldsToUpdate.ToString( "G" ) ); LogIssue( actionText, issue ); } Contained.UpdateIssue( issue, fieldsToUpdate ); }
/// <inheritdoc/> public virtual void UpdateIssue( Issue issue, IssueFieldId fieldsToUpdate ) { _contained.UpdateIssue( issue, fieldsToUpdate ); }
/// <inheritdoc/> public override void CloseIssue( Issue issue ) { if( _config.IsOutputLogged ) { LogIssue( "CLOSE", issue ); } Contained.CloseIssue( issue ); }
/// <inheritdoc/> protected override void HandleResponse( HttpWebResponse httpResponse, Stream responseStream ) { JObject jsonIssue = JObject.Load( new JsonTextReader( new StreamReader( responseStream ) ) ); _issue = new Issue() { ID = ( (int)jsonIssue[ "number" ] ).ToString(), Description = (string)jsonIssue[ "title" ], Details = (string)jsonIssue[ "body" ], State = (string)jsonIssue[ "state" ] == "open" ? IssueState.Open : IssueState.Closed }; }
private void LogIssue( string action, Issue issue ) { LogIssue( action, issue, null ); }
/// <inheritdoc/> public void Execute( Issue issue ) { _issue = issue; SendRequest( "/issues" ); }
private void LogIssue( string action, Issue issue, Action additionalText ) { _logWriter.WriteLine( "{0}--{1}", Name, action ); if( issue != null ) { _logWriter.WriteLine( " {0}: {1}", issue.ID, issue.Description ); _logWriter.WriteLine( " {0}", issue.Details ); } if( additionalText != null ) { additionalText(); } _logWriter.WriteLine( "--------------------------------------------------------------" ); _logWriter.WriteLine(); }
/// <inheritdoc/> public override void UpdateIssue( Issue issue, IssueFieldId fieldsToUpdate ) { }
/// <inheritdoc/> protected override void HandleResponse( HttpWebResponse httpResponse, Stream responseStream ) { JObject jsonCard = JObject.Load( new JsonTextReader( new StreamReader( responseStream ) ) ); _issue = new Issue() { ID = (string)jsonCard[ "id" ], Description = (string)jsonCard[ "name" ], Details = (string)jsonCard[ "desc" ] }; string listId = (string)jsonCard[ "idList" ]; if( SourceSettings.OpenCardListIds.Contains( listId ) ) { _issue.State = IssueState.Open; } else if( SourceSettings.ClosedCardListIds.Contains( listId ) ) { _issue.State = IssueState.Closed; } else { throw new ApplicationException( string.Format( "Unable to determine state for issue '{0}'", listId ) ); } }
/// <summary> /// Writes out a single issue /// </summary> /// <param name="issue">Issue to be written out</param> public void Write( Issue issue ) { _writer.WriteLine( "{0}[{2}]: {1}", issue.ID, issue.Description, issue.State == IssueState.Open ? "O" : "C" ); _writer.WriteLine( "{0}", issue.Details ); }
/// <inheritdoc/> public void Execute( Issue issue ) { SendRequest( "/cards/{0}/idList?value={1}", issue.ID, SourceSettings.ClosedCardListIds[0] ); }
private void OnCloseIssue( ResolverSourceType sourceType, Issue issue ) { _actions.Add( new CloseIssueSyncAction( _sourceFromType( sourceType ), issue ) ); }
/// <summary> /// Initializing constructor /// </summary> /// <param name="issue">Issue associated with the action</param> /// <param name="source">Identifies the source on which the action to take place</param> /// <param name="action">Identifies the action to perform</param> public ResolverActionEventArgs( Issue issue, ResolverSourceType source, ResolverActionType action ) { this.Issue = issue; this.Source = source; this.Action = action; }