コード例 #1
0
        public IndexResult AddGeneralIndex(GeneralDTO general)
        {
            if (general.GeneralID == null)
            {
                return(new IndexResult());
            }
            if (Exists <EntityDocument>(general.GeneralID.Value, DocumentIndexTypeToken.Entity))
            {
                if (_profile.Initialized)
                {
                    _log.WarnFormat("CANNOT PROCESS '{0}CreatedMessage' FOR ENTITY #{1} - '{2}'. ENTITY HAS ALREADY BEEN ADDED ON PROFILE INITIALIZATION OR ENTITY CREATION !!!", general.EntityTypeName, general.GeneralID.GetValueOrDefault(), general.Name);
                }
                else
                {
                    _log.ErrorFormat("CANNOT PROCESS '{0}CreatedMessage' FOR ENTITY #{1} - '{2}'. ENTITY HAS ALREADY BEEN ADDED !!!", general.EntityTypeName, general.GeneralID.GetValueOrDefault(), general.Name);
                }
                return(new IndexResult());
            }
            IDocumentIndex entityIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.Entity);
            EntityDocument document    = _documentFactory.CreateGeneral(general);
            IndexResult    indexResult = document == null ? new IndexResult() : entityIndex.Index(document, false);

            if (indexResult.DocNumber != -1)
            {
                IDocumentIndex projectContextIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityProject);
                projectContextIndex.Index(indexResult.DocNumber, _documentIdFactory.EncodeProjectId(general.ParentProjectID));
                Maybe <string> maybeEntityTypeName = _entityTypeProvider.GetEntityTypeName(general.EntityTypeID);
                string         entityTypeName      = maybeEntityTypeName.FailIfNothing(() => new ApplicationException("Entity type name was not found {0}".Fmt(general.EntityTypeID)));
                IDocumentIndex entityTypeIndex     = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityType);
                entityTypeIndex.Index(indexResult.DocNumber, entityTypeName);
            }
            _log.Debug(string.Format("Added {0} #{1} - '{2}':{3}", general.EntityTypeName, general.GeneralID.GetValueOrDefault(), general.Name, indexResult.WordsAdded.Any() ? string.Format(" added words - {0};", string.Join(",", indexResult.WordsAdded.Keys)) : " NO WORDS ADDED;"));
            return(indexResult);
        }
コード例 #2
0
 public StreamFactoryResult OpenStreamIfModified(Uri uri, LastModifyResult lastModifyResult, bool passiveMode)
 {
     if (uri == null)
     {
         _log.Error("OpenStreamIfModified method uri member is null");
         throw new ArgumentNullException("uri");
     }
     try
     {
         return(OpenStreamIfModified(WebRequest.Create(uri), lastModifyResult, passiveMode));
     }
     catch (UriFormatException ex)
     {
         _log.ErrorFormat("Specified path has invalid format: {0}", ex.Message);
         throw new ApplicationException(string.Format("Specified path has invalid format: {0}", ex.Message), ex);
     }
     catch (NotSupportedException ex)
     {
         _log.ErrorFormat(string.Format("Specified path has invalid format: {0}", ex.Message), ex);
         throw new ApplicationException(
                   string.Format("The request scheme specified in requestUri is not registered: {0}", ex.Message), ex);
     }
     catch (SecurityException ex)
     {
         _log.ErrorFormat("The caller does not have permission to connect to the requested URI or a URI that the request is redirected to: {0}", ex.Message);
         throw new ApplicationException(
                   string.Format(
                       "The caller does not have permission to connect to the requested URI or a URI that the request is redirected to: {0}",
                       ex.Message), ex);
     }
 }
        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");
        }
コード例 #4
0
        public void Handle(IndexExistingEntitiesLocalMessage message)
        {
            try
            {
                foreach (var tpSagaEntity in ObjectFactory.GetInstance <IStorageRepository>().Get <ISagaEntity>())
                {
                    if (!(tpSagaEntity is IndexExistingEntitiesSagaData))
                    {
                        continue;
                    }

                    if (tpSagaEntity.Id != Data.Id)
                    {
                        _sagaPersister.Complete(tpSagaEntity);
                    }
                }
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Failed to complete Running Saga When start to rebuild indexed, error: ", e.Message);
            }
            _documentIndexProvider.ShutdownDocumentIndexes(_pluginContext.AccountName,
                                                           new DocumentIndexShutdownSetup(forceShutdown: true, cleanStorage: true));

            Data.OuterSagaId            = message.OuterSagaId;
            Data.GeneralsRetrievedCount = 0;
            Data.CommentsRetrievedCount = 0;

            Send(new GeneralQuery {
                Hql = string.Format(GeneralsHql, Data.SkipGenerals, PageSize), IgnoreMessageSizeOverrunFailure = true, Params = _param
            });
        }
コード例 #5
0
 private bool TryGetChangedBugsChunk(int[] ids, out bugCollection bugs)
 {
     try
     {
         bugs = _bugzillaService.GetBugs(ids);
         return(true);
     }
     catch (Exception e)
     {
         _logger.ErrorFormat("Retrieving changed bugs (with ids: {0}) failed. Bugzilla IDs: {1}",
                             string.Join(",", ids.Select(i => i.ToString()).ToArray()), e.Message);
         bugs = new bugCollection();
         return(false);
     }
 }
コード例 #6
0
        public void Apply(BugzillaBug bugzillaBug, ConvertedBug convertedBug)
        {
            var value = GetBugzillaValue(bugzillaBug);

            if (string.IsNullOrEmpty(value))
            {
                return;
            }

            if (Map != null && Map[value] != null)
            {
                SetFieldFromMapping(value, convertedBug);
            }
            else
            {
                SetFieldFromStorage(value, convertedBug);
            }

            if (!convertedBug.ChangedFields.Contains(BugField))
            {
                _logger.ErrorFormat("{0} mapping failed. {1}; Value: {2}", BugFieldName, bugzillaBug.ToString(), value);
            }
        }
コード例 #7
0
 public bool TryCompleteInprogressSaga <TSaga>(Guid sagaId)
 {
     try
     {
         foreach (ISagaEntity candidate in _storageRepository.Get <ISagaEntity>())
         {
             if (!(candidate is TSaga))
             {
                 continue;
             }
             if (candidate.Id != sagaId)
             {
                 _sagaPersister.Complete(candidate);
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         _logger.ErrorFormat("Failed to complete Running Saga When start to rebuild indexed, error: ", e.Message);
     }
     return(false);
 }
		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);
			}
		}