コード例 #1
0
        public void Handle(TickMessage message)
        {
            if (!ConfigHelper.GetWorkItemsState())
            {
                return;
            }

            if (!IsSourceControlEnabled())
            {
                var tpBus = ObjectFactory.GetInstance <TpBus>();
                tpBus.DoNotContinueDispatchingCurrentMessageToHandlers();
            }

            if (!IsSynchronizationEnabled())
            {
                _logger.Info("Work items synchronization disabled");
                return;
            }

            _logger.Info("Syncronize work items");

            var messages = GetTargetWorkItemsMessages(message.LastSyncDate);

            messages.ForEach(msg => _bus.SendLocal(msg));
        }
        protected override void OnStartInitialization()
        {
            try
            {
                foreach (var tpSagaEntity in ObjectFactory.GetInstance <IStorageRepository>().Get <ISagaEntity>())
                {
                    if (!(tpSagaEntity is SearcherPluginProfileInitializationSagaData ||
                          tpSagaEntity is SearcherPluginProfileUpdatedInitializationData))
                    {
                        continue;
                    }

                    if (tpSagaEntity.Id != Data.Id)
                    {
                        _sagaPersister.Complete(tpSagaEntity);
                    }
                }
            }
            catch (Exception e)
            {
                _log.ErrorFormat("Failed to complete Running Saga When start to rebuild indexed, error: ", e.Message);
            }

            Send(new GeneralQuery
            {
                Hql =
                    string.Format(
                        "select g from General g left join g.ParentProject p where g.EntityType IN ({0}) and (p is null or p.DeleteDate is null) order by g desc skip 0 take 1",
                        _entityTypeProvider.QueryableEntityTypesIdSqlString),
                IgnoreMessageSizeOverrunFailure = true,
                Params = new object[] { }
            });
            _log.Info("Started rebuilding indexes");
        }
コード例 #3
0
        public void Handle(TickMessage message)
        {
            _logger.Info("Checking changes in Bugzilla");

            ProcessFailedChunks();
            ProcessNewlyChanges(message.LastSyncDate);
        }
コード例 #4
0
 public void Run()
 {
     if (_isOnSite && _profileCollection.Empty())
     {
         var c = new BuildSearchIndexesCommand(_bus, _profileCollection, _pluginContext, _pluginMetadata);
         c.Execute(string.Empty);
     }
     _log.Info("Started Search Plugin");
 }
コード例 #5
0
        protected override void OnStartInitialization()
        {
            _log.Info("Started building indexes");
            var storage = _profileReadonly.Get <IndexProgress>();

            storage.Clear();
            storage.Add(new IndexProgress());
            SendLocal(new IndexExistingEntitiesLocalMessage {
                OuterSagaId = Data.Id
            });
        }
        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);
        }
 protected override void OnStartInitialization()
 {
     _log.Info("Started building indexes");
     Send(new GeneralQuery
     {
         Hql =
             string.Format(
                 "select g from General g left join g.ParentProject p where g.EntityType IN ({0}) and (p is null or p.DeleteDate is null) order by g desc skip 0 take 1",
                 _entityTypeProvider.QueryableEntityTypesIdSqlString),
         IgnoreMessageSizeOverrunFailure = true,
         Params = new object[] { }
     });
 }
        protected override void OnStartInitialization()
        {
            _sagaServices.TryCompleteInprogressSaga <SearcherPluginProfileInitializationSagaData>(Data.Id);
            _sagaServices.TryCompleteInprogressSaga <SearcherPluginProfileUpdatedInitializationData>(Data.Id);
            _log.Info("Started rebuilding indexes");
            var storage = _profile.Get <IndexProgress>();

            storage.Clear();
            storage.Add(new IndexProgress());
            SendLocal(new IndexExistingEntitiesLocalMessage {
                OuterSagaId = Data.Id
            });
        }
コード例 #9
0
        public void Handle(TickMessage tickMessage)
        {
            _log.Info("Downloading uids from email server...");
            using (var client = ObjectFactory.GetInstance <IEmailClient>())
            {
                client.Connect();
                client.Login();

                var uids = GetNewUids(client);
                _messageUidRepository.AddRange(uids.ToArray());

                Debug.Assert(uids != null, "uids != null");

                var lastIndex = 0;
                while (true)
                {
                    var uidsPack = uids.Skip(lastIndex).Take(_messagePackSize.Value).ToArray();
                    if (!uidsPack.Any())
                    {
                        break;
                    }
                    lastIndex += _messagePackSize.Value;
                    _localBus.SendLocal(new EmailUidsRetrievedMessage {
                        Uids = uidsPack
                    });
                }

                client.Disconnect();
            }
        }
コード例 #10
0
 public void Run()
 {
     if (_isOnSite)
     {
         _documentIndexRebuilder.RebuildIfNeeded(shouldRebuildIfNoProfile: true);
     }
     _log.Info("Started Search Plugin");
 }
コード例 #11
0
        public double?ApplyCalculation(Operation operation)
        {
            activityLogger.Info("start calculation by calculation engine...");
            if (!IsServerAvailable())
            {
                activityLogger.Error(new Exception("Error! Calculation engine service unavaliable"));
                throw new TimeoutException();
            }
            var calculationContext = new Context();

            switch (operation.OperationType)
            {
            case OperationType.Addition:
                activityLogger.Info("applying Addition...");
                calculationContext.SetCalculationStrategy(new AdditionStrategy());
                break;

            case OperationType.Division:
                activityLogger.Info("applying Division...");
                calculationContext.SetCalculationStrategy(new DivisionStrategy());

                break;

            case OperationType.Multiplication:
                activityLogger.Info("applying Multiplication...");
                calculationContext.SetCalculationStrategy(new MultiplicationStrategy());

                break;

            case OperationType.Subtraction:
                activityLogger.Info("applying Subtraction...");
                calculationContext.SetCalculationStrategy(new SubtractionStrategy());

                break;

            default:
                throw new ArgumentException("Invalid operation");
            }
            return(calculationContext.Execute(operation.FirstNumber.Value, operation.SecondNumber.Value));
        }
コード例 #12
0
        public BugzillaProperties GetBugzillaProperties(BugzillaProfile profile, PluginProfileErrorCollection errors)
        {
            profile.ValidateCredentials(errors);

            if (!errors.Any())
            {
                try
                {
                    _logger.Info("Checking connection");
                    var bugzillaProperties = new BugzillaService().CheckConnection(profile);
                    _logger.Info("Connection success");
                    return(new BugzillaProperties(bugzillaProperties));
                }
                catch (BugzillaPluginProfileException e)
                {
                    e.ErrorCollection.ForEach(errors.Add);
                    _logger.WarnFormat("Connection failed: {0}", e);
                }
            }

            return(null);
        }
コード例 #13
0
        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));
            }
        }
コード例 #14
0
        public double?ApplyCalculation(Operation operation)
        {
            activityLogger.Info($"start calculation with operation: '{operation.OperationString()}'...calling calculation engine..");
            var result = Calculate(operation);

            if (result == null)
            {
                activityLogger.Info("result is empty..adding operation to queue..");

                AddOperationToQueue(operation);
            }
            else
            {
                activityLogger.Info($"result = '{result}' is recieved..sending result to UI..");
            }

            return(result);
        }
コード例 #15
0
 public void Handle(QueryResult <TDto> message)
 {
     IncrementCounters(message.Dtos.Length + message.FailedDtosCount);
     if (message.FailedDtosCount > 0)
     {
         _logger.WarnFormat("Failed to index {0} {1} entities", message.FailedDtosCount, _entityName);
     }
     foreach (TDto dto in message.Dtos)
     {
         IndexEntity(dto);
     }
     if (message.Dtos.Empty() && message.FailedDtosCount == 0)
     {
         OptimizeIndex();
         _onComplete(Data);
     }
     else if (GetCurrentDataWindowSize() == message.QueryResultCount)
     {
         _logger.Info("{0} {1} entities were indexed".Fmt(GetTotalRetrievedEntitiesCount(), _entityName));
         OptimizeIndex();
         _sendQuery(BuildQuery(GetTotalRetrievedEntitiesCount(), DataWindowSize));
         ResetCurrentDataWindowSize();
     }
 }
コード例 #16
0
        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());
        }
コード例 #17
0
 public void AddOperationToQueue(Operation operation)
 {
     activityLogger.Info("Add operation to Queue");
     repository.AddToQueue(operation);
     queueWatcher.AddWatcherUser(this);
 }
コード例 #18
0
 public void Handle(AccountRemovedMessage message)
 {
     _documentIndexProvider.ShutdownDocumentIndexes(new PluginContextSnapshot(message.AccountName, new ProfileName(string.Empty), _context.PluginName), new DocumentIndexShutdownSetup(forceShutdown: true, cleanStorage: true), _log);
     _log.Info(string.Format("Account {0} removed with all indexes", message.AccountName));
 }
コード例 #19
0
		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);
			}
		}
コード例 #20
0
 public void SendResultByEmail(Operation operation, double?result)
 {
     activityLogger.Info($"SendResultByEmail: your operation '{operation.OperationString()}' was calculated, result = {result}");
 }
コード例 #21
0
 public void Handle(AccountRemovedMessage message)
 {
     _documentIndexProvider.ShutdownDocumentIndexes(message.AccountName, new DocumentIndexShutdownSetup(forceShutdown: true, cleanStorage: true));
     _log.Info(string.Format("Account {0} removed with all indexes", message.AccountName));
 }