예제 #1
0
        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 ) );
            }
        }
예제 #2
0
        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 ) );
            }
        }
예제 #3
0
 /// <inheritdoc/>
 public override void AddIssue( Issue issue )
 {
 }
예제 #4
0
 /// <inheritdoc/>
 public override void CloseIssue( Issue issue )
 {
 }
예제 #5
0
 /// <inheritdoc/>
 public virtual void CloseIssue( Issue issue )
 {
     _contained.CloseIssue( issue );
 }
예제 #6
0
 /// <inheritdoc/>
 public void Execute( Issue issue )
 {
     SendRequest( "/issues/{0}", issue.ID );
 }
예제 #7
0
        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;
        }
예제 #8
0
 /// <inheritdoc/>
 public virtual void AddIssue( Issue issue )
 {
     _contained.AddIssue( issue );
 }
예제 #9
0
 /// <inheritdoc/>
 public override void UpdateIssue( Issue         issue,
                                   IssueFieldId  fieldsToUpdate )
 {
     base.UpdateIssue( Denormalize( issue ),
                       Denormalize( fieldsToUpdate ) );
 }
예제 #10
0
 /// <inheritdoc/>
 public override void CloseIssue( Issue issue )
 {
     base.CloseIssue( Denormalize( issue ) );
 }
예제 #11
0
 /// <inheritdoc/>
 public override void AddIssue( Issue issue )
 {
     base.AddIssue( Denormalize( issue ) );
 }
예제 #12
0
        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;
        }
예제 #13
0
        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 ) );
        }
예제 #14
0
        /// <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() );
        }
예제 #15
0
        /// <inheritdoc/>
        public override void AddIssue( Issue issue )
        {
            if( _config.IsOutputLogged )
            {
                LogIssue( "ADD", issue );
            }

            Contained.AddIssue( issue );
        }
예제 #16
0
        /// <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() );
            }
        }
예제 #17
0
        /// <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 );
        }
예제 #18
0
 /// <inheritdoc/>
 public virtual void UpdateIssue( Issue          issue,
                                  IssueFieldId   fieldsToUpdate )
 {
     _contained.UpdateIssue( issue, fieldsToUpdate );
 }
예제 #19
0
        /// <inheritdoc/>
        public override void CloseIssue( Issue issue )
        {
            if( _config.IsOutputLogged )
            {
                LogIssue( "CLOSE", issue );
            }

            Contained.CloseIssue( issue );
        }
예제 #20
0
        /// <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 };
        }
예제 #21
0
 private void LogIssue( string action, Issue issue )
 {
     LogIssue( action, issue, null );
 }
예제 #22
0
        /// <inheritdoc/>
        public void Execute( Issue issue )
        {
            _issue = issue;

            SendRequest( "/issues" );
        }
예제 #23
0
        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();
        }
예제 #24
0
 /// <inheritdoc/>
 public override void UpdateIssue( Issue          issue,
                                  IssueFieldId   fieldsToUpdate )
 {
 }
예제 #25
0
        /// <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 ) );
            }
        }
예제 #26
0
 /// <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 );
 }
예제 #27
0
 /// <inheritdoc/>
 public void Execute( Issue issue )
 {
     SendRequest( "/cards/{0}/idList?value={1}",
                  issue.ID, SourceSettings.ClosedCardListIds[0] );
 }
예제 #28
0
 private void OnCloseIssue( ResolverSourceType sourceType, Issue issue )
 {
     _actions.Add( new CloseIssueSyncAction( _sourceFromType( sourceType ), issue ) );
 }
예제 #29
0
 /// <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;
 }