public void Handle(NewRevisionDetectedLocalMessage localMessage) { string key; if (_revisionStorage.SaveRevisionInfo(localMessage.Revision, out key)) { _logger.InfoFormat("Importing revision. Revision ID: {0}", localMessage.Revision.Id.Value); var dto = new RevisionDTO { SourceControlID = localMessage.Revision.Id.Value, Description = localMessage.Revision.Comment, CommitDate = localMessage.Revision.Time, AuthorID = _userMapper.IsAuthorMapped(localMessage.Revision) ? (int?)_userMapper.GetAuthorBy(localMessage.Revision).Id : null }; Data.RevisionEntries = localMessage.Revision.Entries; Data.SourceControlID = localMessage.Revision.Id.Value; Data.RevisionKey = key; Send(new CreateEntityCommand <RevisionDTO>(dto)); } else { //_logger.InfoFormat("Revision has already been imported. Aborting revision import. Revision ID: {0}", localMessage.Revision.Id.Value); MarkAsComplete(); } }
public void Handle(BugUpdatedMessage message) { //TODO: take into account: when set the second developer in TP this developer assigned in Bugzilla if (!message.ChangedFields.Contains(BugField.EntityStateID)) { return; } var bugzillaBug = _bugzillaInfoStorageRepository.GetBugzillaBug(message.Dto.ID); if (bugzillaBug == null) { return; } var status = _entityStateConverter.GetMappedBugzillaStatus(message.Dto); if (status == null) { return; } try { _log.InfoFormat("Updating bug status in Bugzilla. TargetProcess Bug ID: {0}; Bugzilla Bug ID: {1}", message.Dto.ID, bugzillaBug.Id); _bugzillaService.Execute(_actionFactory.GetChangeStatusAction(message.Dto, bugzillaBug.Id, status)); _log.InfoFormat("Bug status in Bugzilla updated. TargetProcess Bug ID: {0}; Bugzilla Bug ID: {1}", message.Dto.ID, bugzillaBug.Id); } catch (Exception e) { _log.Error(e.Message, e); } }
protected void HandleInternal(WorkItemInfo itemInfo) { Data.WorkItem = itemInfo; TDto entityDto = CreateEntityDTO(itemInfo); if (itemInfo.Action == WorkItemAction.Create) { Logger.InfoFormat("Creating {0}: {1}", itemInfo.WorkItemType, itemInfo.ToString()); SendCreateCommand(entityDto); } else if (itemInfo.Action == WorkItemAction.Update) { Logger.InfoFormat("Updating {0}: {1}", itemInfo.WorkItemType, itemInfo.ToString()); if (itemInfo.TpEntityId == null) { var workItemField = itemInfo.FieldsValues.FirstOrDefault(x => x.Name == "Title"); Logger.WarnFormat( "Relation for Work Item '{0} {1}' not found in profile storage.", itemInfo.WorkItemId.Id, workItemField == null ? string.Empty : workItemField.Value); DoNotContinueDispatchingCurrentMessageToHandlers(); MarkAsComplete(); return; } entityDto.ID = int.Parse(itemInfo.TpEntityId.Id); SendUpdateCommand(entityDto, itemInfo); } }
public void Handle(ImportBugToTargetProcessCommand <BugzillaBug> message) { Data.ThirdPartyBug = message.ThirdPartyBug; var tpBug = ConvertToTpBug(message); var storedBug = _bugzillaInfoStorageRepository.GetTargetProcessBugId(message.ThirdPartyBug.bug_id); if (storedBug == null) { _logger.InfoFormat("Importing bug. {0}", message.ThirdPartyBug.ToString()); Send(new CreateBugCommand(tpBug.BugDto)); Data.CreatingBug = true; } else { _logger.InfoFormat("Updating bug. {0}", message.ThirdPartyBug.ToString()); tpBug.BugDto.ID = storedBug.Value; Send(new UpdateBugCommand(tpBug.BugDto) { ChangedFields = tpBug.ChangedFields.ToArray() }); // We will not receive BugUpdatedMessage if no fields were changed. So we should process related entities immediately. SendLocal(new ExistingBugImportedToTargetProcessMessage <BugzillaBug> { TpBugId = tpBug.BugDto.ID, ThirdPartyBug = Data.ThirdPartyBug }); _bugzillaInfoStorageRepository.SaveBugzillaBugInfo(tpBug.BugDto.ID, new BugzillaBugInfo(message.ThirdPartyBug) { TpId = tpBug.BugDto.ID }); } }
public bool RebuildIfNeeded(bool shouldRebuildIfNoProfile = false) { if (IsRebuildInProgress()) { return(false); } if (shouldRebuildIfNoProfile && _profileCollection.Empty()) { _logger.InfoFormat("Going to start rebuild becuase of no profile"); DoRebuild(); return(true); } var shouldRebuildIfNoActualVersionForAnyFile = _documentIndexProvider.DocumentIndexTypes.Any(type => { var versions = type.GetVersions(_pluginContext.AccountName, _documentIndexSetup); return(versions.Except(new[] { type.Version }).Any()); }); var shouldRebuildIfNoFile = _documentIndexProvider.DocumentIndexTypes.All(type => type.GetVersions(_pluginContext.AccountName, _documentIndexSetup).Empty()); if (shouldRebuildIfNoActualVersionForAnyFile || shouldRebuildIfNoFile) { _logger.InfoFormat("Going to start rebuild becuase of {0}", shouldRebuildIfNoActualVersionForAnyFile ? "no actual version of index file" : "no actual versions of index files"); DoRebuild(); return(true); } return(false); }
protected void SetFieldFromMapping(string value, ConvertedBug convertedBug) { var mappedValue = Map[value]; if (mappedValue.Id != 0) { SetValue(convertedBug, mappedValue.Id); convertedBug.ChangedFields.Add(BugField); _logger.InfoFormat("{0} mapped. Bug: {1}; Value: {2}", BugFieldName, convertedBug.BugDto.Name, value); } }
private void AssignUserToBug(int?tpBugId, int?tpUserId, MappingLookup role) { if (role != null && tpUserId.HasValue) { _logger.InfoFormat("Assigning user. TargetProcess Bug ID: {0}; User ID: {1}; Role: {2}", tpBugId, tpUserId, role.Name); Data.ActionsInProgress++; Send(new CreateTeamCommand(new TeamDTO { AssignableID = tpBugId.GetValueOrDefault(), UserID = tpUserId, RoleID = role.Id })); } }
public void Handle(AssignRevisionToEntityAction message) { Data.RevisionDto = message.Dto; var dto = new RevisionAssignableDTO { AssignableID = message.EntityId, RevisionID = message.Dto.ID }; Data.EntityId = message.EntityId; _logger.InfoFormat("Assigning revision to entity. Revision ID: {0}; Assignable ID: {1}", message.Dto.SourceControlID, message.EntityId); Send(new CreateEntityCommand <DataTransferObject>(dto)); }
private void ProcessNewlyChanges(DateTime?lastSyncDate) { var lastSyncronizationDate = LastSyncDates.FirstOrDefault(); if (lastSyncDate == null || lastSyncronizationDate == null || !lastSyncronizationDate.GetValue().HasValue || lastSyncronizationDate.GetValue().Value.AddMinutes(_storageRepository.GetProfile <BugzillaProfile>().SynchronizationInterval) < DateTime.Now) { var dateValue = GetSyncDate(lastSyncDate); var synchronizationTime = DateTime.Now; int[] changedIds; if (TryGetChangedIds(dateValue, out changedIds)) { if (changedIds.Length > 0) { _logger.InfoFormat("{0} changed bugs found", changedIds.Length); } LastSyncDates.ReplaceWith(new BugTracking.ImportToTp.LastSyncDate(synchronizationTime)); ProcessChangedBugIds(changedIds); } else { FailedSyncDates.ReplaceWith(new FailedSyncDate(dateValue)); } } }
private void PushAttachmentsToTp(int?tpBugId, BugzillaBug bug, List <LocalStoredAttachment> attachments) { _logger.InfoFormat("Processing attachments. Bug: {0}", bug.ToString()); _localBus.SendLocal(new PushAttachmentsToTpCommandInternal { LocalStoredAttachments = attachments.ToArray(), GeneralId = tpBugId }); }
public void Handle(NewRevisionRangeDetectedLocalMessage message) { _logger.Info("Retrieving new revisions"); var revisions = _versionControlSystem.GetRevisions(message.Range); _logger.Info("Filtering out non-assignable revisions"); revisions = revisions.Where(ContainsEntityId).ToArray(); _logger.InfoFormat("Revisions retrieved. Revision IDs: {0}", string.Join(", ", revisions.Select(x => x.Id.Value).ToArray())); SendLocal(revisions); }
private string OnExecute(string args) { var profile = _storageRepository.GetProfile <TestRunImportPluginProfile>(); _log.InfoFormat("Started synchronizing at {0}", DateTime.Now); if (!string.IsNullOrEmpty(args) && profile.FrameworkType == FrameworkTypes.FrameworkTypes.Selenium) { using (var reader = new StringReader(args)) { try { var result = _resultsReaderFactory.GetResolver(profile, reader).GetTestRunImportResults(); _log.InfoFormat("{0} items for import detected in resutls source", result.Count == 0 ? "No" : result.Count.ToString()); if (result.Count > 0) { _localBus.SendLocal(new TestRunImportResultDetectedLocalMessage { TestRunImportInfo = new TestRunImportInfo { TestRunImportResults = result.ToArray() } }); } } catch (ApplicationException) { throw; } catch (Exception ex) { throw new ApplicationException( string.Format("Could not read file \"{0}\": {1}", profile.ResultsFilePath, ex.Message), ex); } } } //return new PluginCommandResponseMessage { ResponseData = string.Empty, PluginCommandStatus = PluginCommandStatus.Succeed }; return(string.Empty); }
public void Handle(RevisionCreatedLocalMessage message) { _logger.InfoFormat("Parsing comment. Revision ID: {0}", message.Dto.SourceControlID); var commentParser = new CommentParser(); var actions = commentParser.ParseAssignToEntityAction(message.Dto); var actionParamFiller = new ActionParameterFillerVisitor(message.Dto); foreach (var action in actions) { action.Execute(actionParamFiller, x => _bus.SendLocal(action), _logger); } }
private void AssignUser(TeamDTO team, string userEmail, Action sucess) { if (!NeedToProcess(team) || AnotherRole(team)) { return; } var bugzillaBug = _bugzillaInfoStorageRepository.GetBugzillaBug(team.AssignableID); _logger.InfoFormat("Changing bug assignment in Bugzilla. TargetProcess Bug ID: {0}; Email: {1}", bugzillaBug.TpId, userEmail); try { _service.Execute(_actionFactory.GetAssigneeAction(bugzillaBug.Id, userEmail)); sucess(); } catch (Exception ex) { _logger.Error(ex.Message, ex); } _logger.InfoFormat("Bug assignment changed in Bugzilla. TargetProcess Bug ID: {0}; Email: {1}", bugzillaBug.TpId, userEmail); }
public void Handle(CommentCreatedMessage message) { if (!NeedToProcess(message.Dto)) { return; } _logger.InfoFormat("Importing comment to Bugzilla. TargetProcess Bug ID: {0}", message.Dto.GeneralID); try { var offset = _bugzillaService.GetTimeOffset(); _bugzillaService.Execute(_actionFactory.GetCommentAction(message.Dto, offset)); _storage.Get <CommentDTO>(message.Dto.GeneralID.ToString()).Add(message.Dto); } catch (Exception ex) { _logger.Error(ex.Message, ex); } _logger.InfoFormat("Comment imported to Bugzilla. TargetProcess Bug ID: {0}", message.Dto.GeneralID); }
public void Handle(EmailUidsRetrievedMessage message) { try { _log.InfoFormat("Downloading {0} messages from email server...", message.Uids.Count()); _client.Connect(); _client.Login(); var count = 0; while (ReadNextEmailMessage(message.Uids)) { count++; } _log.InfoFormat("Downloaded messages={0}", count); } catch (Exception ex) { _client.Disconnect(); _log.Error(String.Format("Error downloading messages."), ex); var skippedUids = message.Uids.Where(x => !_processedUids.Contains(x)); _messageUidRepository.Remove(skippedUids.ToArray()); } }
public void Handle(ImportBugsChunk message) { bugCollection bugs; _logger.Info("Retrieving changed bugs"); if (TryGetChangedBugsChunk(message.ThirdPartyBugsIds, out bugs)) { _logger.InfoFormat("Bugs retrieved. Bugzilla Bug IDs: {0}", string.Join(", ", message.ThirdPartyBugsIds.Select(x => x.ToString()).ToArray())); CreateBugsInTargetProcess(bugs); } else { FailedChunks.Add(new FailedChunk(message.ThirdPartyBugsIds)); } }
public void Handle(ExistingBugImportedToTargetProcessMessage <BugzillaBug> message) { var newComments = message.ThirdPartyBug.comments .Where(comment => !CommentExists(message, comment)) .Reverse() .ToList(); if (newComments.Any()) { _logger.InfoFormat("Importing {1} comment(s) for bug. {0}", message.ThirdPartyBug.ToString(), newComments.Count); } CreateComments(newComments, message.TpBugId); }
public static RevisionInfo[] ArrayOfSvnRevisionToArrayOfRevisionInfo(Collection <SvnLogEventArgs> svnRevisions, IVersionControlSystem versionControlSystem) { var tpRevisionInfo = new List <RevisionInfo>(svnRevisions.Count); _log.InfoFormat("Process svn revisions..."); foreach (var svnRevision in svnRevisions) { _log.InfoFormat("Do processing of revision {0}", svnRevision.Revision); if (svnRevision.Revision == 0 || svnRevision.ChangedPaths == null || svnRevision.ChangedPaths.Count == 0) { continue; } _log.Info("Adding revisions infos"); var info = SvnRevisionToRevisionInfo(svnRevision, versionControlSystem); tpRevisionInfo.Add(info); } return(tpRevisionInfo.ToArray()); }
protected override void Log(IActivityLogger logger) { logger.InfoFormat("Posting comment. Entity ID: {0}; Comment: {1}; Author: {2}", EntityId, Comment, UserId); }
protected override void Log(IActivityLogger logger) { logger.InfoFormat("Changing entity state. Entity ID: {0}; Entity State: {1}; Comment: {2}; Default comment: {3}", EntityId, Status, Comment, DefaultComment); }
protected override void Log(IActivityLogger logger) { logger.InfoFormat("Posting time. Entity ID: {0}; User ID: {3}; Time spent: {1:0.00}; Time left: {2:0.00}", EntityId, TimeSpent, TimeLeft, UserId); }
public void Handle(TickMessage message) { var profile = _storageRepository.GetProfile<TestRunImportPluginProfile>(); if (profile.FrameworkType == FrameworkTypes.FrameworkTypes.Selenium && profile.PostResultsToRemoteUrl) { return; } try { _log.InfoFormat("Started synchronizing at {0}", DateTime.Now); var lastModifyResults = _storageRepository.Get<LastModifyResult>(); var lastModifyResult = lastModifyResults.Empty() ? new LastModifyResult() : lastModifyResults.Single(); var jenkinsHudsonLastCompletedBuildNumber = profile.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson ? GetJenkinsHudsonLastCompletedBuildNumber(profile) : null; if (profile.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson && (jenkinsHudsonLastCompletedBuildNumber == null || string.CompareOrdinal(lastModifyResult.ETagHeader, jenkinsHudsonLastCompletedBuildNumber) == 0)) { _log.Info("No new modification of results source detected"); return; } var uri = profile.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson ? new Uri(string.Format("{0}/lastCompletedBuild/testReport/api/xml", profile.ResultsFilePath.TrimEnd(new[] { '/', '\\' }))) : new Uri(profile.ResultsFilePath); var factoryResult = _streamFactory.OpenStreamIfModified(uri, lastModifyResult, profile.PassiveMode); _log.InfoFormat("{0} modification of results source detected", factoryResult == null ? "No new" : "New"); if (factoryResult != null) { if (profile.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson) { factoryResult.LastModifyResult.ETagHeader = jenkinsHudsonLastCompletedBuildNumber; } lastModifyResults.Clear(); lastModifyResults.Add(factoryResult.LastModifyResult); using (factoryResult.Stream) { using (var reader = new StreamReader(factoryResult.Stream)) { try { var result = _resultsReaderFactory.GetResolver(profile, reader).GetTestRunImportResults(); _log.InfoFormat("{0} items for import detected in resutls source", result.Count == 0 ? "No" : result.Count.ToString(CultureInfo.InvariantCulture)); if (result.Count > 0) { _localBus.SendLocal(new TestRunImportResultDetectedLocalMessage { TestRunImportInfo = new TestRunImportInfo { TestRunImportResults = result.ToArray() } }); } } catch (ApplicationException) { throw; } catch (XmlException ex) { throw new ApplicationException("Error parsing results XML file", ex); } catch (Exception ex) { throw new ApplicationException("Error importing results XML file", ex); } } } } } catch (UriFormatException ex) { _log.Error(ex.Message); throw new ApplicationException(string.Format("Specified path has invalid format. {0}", ex.Message), ex); } catch (ApplicationException ex) { _log.Error(ex.Message); throw; } catch (Exception ex) { _log.ErrorFormat("Could not read file \"{0}\": {1}", profile.ResultsFilePath, ex.Message); throw new ApplicationException( string.Format("Could not read file \"{0}\": {1}", profile.ResultsFilePath, ex.Message), ex); } }