Files
Christoph Schwörer f045b99a25 Codebasis als Dateien ins Arbeitsrepo statt als Gitlink
QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142)
getrackt, ohne .gitmodules und ohne erreichbares Remote. Der
Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar
gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege
der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen.

Umstellung:
- Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert
  (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6)
- Gitlink aus dem Index entfernt
- Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB

Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte
bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
2026-08-26 07:43:51 +02:00

93 lines
3.9 KiB
C#

using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using Centron.BusinessLogic.Administration.Settings;
using Centron.BusinessLogic.IndexSearch;
using Centron.BusinessLogic.Sales.Support;
using Centron.BusinessLogic.WebServices.Sales.Support;
using Centron.DAO.AdoNETDataAccess;
using Centron.Data.Entities.Sales.Support;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.IndexSearch;
public class IndexSearchTests : EndToEndTest
{
public IndexSearchTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public override void Execute()
{
// First, index everything
this.WithSession(s => s.GetBL<IndexSearchBL>().UpdateAllIndexes(default));
this.Verifier.VerifySql("Index_Count", "SELECT Count = COUNT(*) FROM dbo.ObjectFulltextIndex");
this.Verifier.VerifySql("IndexStats_Count", "SELECT Count = COUNT(*) FROM dbo.ObjectFulltextIndexStats");
// Remove a ticket (it should get removed from the index)
this.Sql("DELETE FROM dbo.hlpdsk_requests WHERE I3D = 10");
// Set one ticket to "update requested"
this.UpdateTicket();
// Now, update all indexes again
var sqlStatements = SqlDiagnosticObserver.Start(() =>
{
this.WithSession(s => s.GetBL<IndexSearchBL>().UpdateAllIndexes(default));
});
this.Verifier.Verify("Statements", sqlStatements.Select(f => NormalizeSqlAliasNumbers(f.CommandText)));
// Try querying something
var result = this.WithSession(s => s.GetBL<IndexSearchBL>().SearchIndex("gmbh ve"));
this.Verifier.Verify("Search_Result", result.Select(f => new { Kind = f.Kind, ObjectI3D = f.ObjectI3D, }).Distinct().OrderBy(f => f.ObjectI3D));
// Query tickets
this.QueryTickets();
}
private void UpdateTicket()
{
var ticket = this.WithSession(s => s.GetBL<HelpdeskWebServiceBL>().GetHelpdeskByI3D(11, this.GetLoggedInUser())).ThrowIfError();
this.WithSession(s => s.GetBL<HelpdeskWebServiceBL>().SaveHelpdesk(ticket, this.GetLoggedInUser()));
}
private static string NormalizeSqlAliasNumbers(string sqlStatement)
{
return Regex.Replace(sqlStatement, @"\b([A-Za-z][A-Za-z0-9]*\d+)_\d+_", "$1_alias_");
}
private void QueryTickets()
{
var filter = new HelpdeskFilter
{
SearchText = "Dell telefoniert",
};
for (int i = 1; i <= 100; i++)
{
// Enable fulltext-search
var settings2 = this.WithSession(s => s.GetBL<AppSettingsGroupBL>().GetFulltextIndexServiceSettings());
settings2.IsFulltextIndexServiceActive = true;
this.WithSession(s => s.GetBL<AppSettingsGroupBL>().UpdateFulltextIndexServiceSettings(settings2));
var indexSearchWatch = Stopwatch.StartNew();
var indexSearchTickets = this.WithSession(s => s.GetBL<HelpdeskSearchWebServiceBL>().GetHelpdesksThroughPaging(filter, HelpdeskSort.Number, true, 1, int.MaxValue, this.GetLoggedInUser()));
indexSearchWatch.Stop();
// Disable fulltext-search
var settings1 = this.WithSession(s => s.GetBL<AppSettingsGroupBL>().GetFulltextIndexServiceSettings());
settings1.IsFulltextIndexServiceActive = false;
this.WithSession(s => s.GetBL<AppSettingsGroupBL>().UpdateFulltextIndexServiceSettings(settings1));
var oldSearchWatch = Stopwatch.StartNew();
var oldSearchTickets = this.WithSession(s => s.GetBL<HelpdeskSearchWebServiceBL>().GetHelpdesksThroughPaging(filter, HelpdeskSort.Number, true, 1, int.MaxValue, this.GetLoggedInUser()));
oldSearchWatch.Stop();
this.TestOutputHelper.WriteLine($"Run {i}: {(oldSearchWatch.Elapsed < indexSearchWatch.Elapsed ? "old" : "new")}");
}
}
}