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
354 lines
15 KiB
C#
354 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.EmployeeArea;
|
|
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
|
|
using Centron.BusinessLogic.Sales.Support;
|
|
using Centron.BusinessLogic.TaskManager;
|
|
using Centron.BusinessLogic.WebServices.Sales.Receipts;
|
|
using Centron.BusinessLogic.WebServices.Sales.Support;
|
|
using Centron.BusinessLogic.WebServices.TaskManager;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Data.Entities.Sales.Support;
|
|
using Centron.Data.Entities.TaskManager;
|
|
using Centron.Data.WebServices.Administration.Employees;
|
|
using Centron.Data.WebServices.EmployeeArea;
|
|
using Centron.Data.WebServices.Sales.CustomerAssets.Contracts;
|
|
using Centron.Data.WebServices.Sales.Customers;
|
|
using Centron.Data.WebServices.Sales.Support;
|
|
using Centron.Data.WebServices.TaskManager;
|
|
using Centron.Data.WebServices.TaskManager.Actions;
|
|
using Centron.Data.WebServices.TaskManager.Recurrence;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.Administration.Environment;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.Sales.Receipts.ContractLists;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.TaskHelpdeskAction
|
|
{
|
|
public class TaskHelpdeskActionTest : EndToEndTest
|
|
{
|
|
public const int CustomerI3D = 10022;
|
|
public const int FirstContractI3D = 10;
|
|
public const int SecondContractI3D = 35;
|
|
public const int ThirdContractI3D = 27;
|
|
public const int FirstSlaPrio = 1;
|
|
public const int SecondSlaPrio = 5;
|
|
public TaskHelpdeskActionTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
|
|
{
|
|
this.Verifier.Settings.IgnoreProperty<TaskManagementTaskDTO>(f => f.ChangedDate);
|
|
this.Verifier.Settings.IgnoreProperty<TaskManagementTaskDTO>(f => f.CreatedDate);
|
|
|
|
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PrepareDatabase();
|
|
var newTasksI3D = this.CreateTask();
|
|
this.ExecuteTasks();
|
|
//if you change the sla priority of a contract, tasks with this contract should be updated to use the new priority
|
|
this.ChangeContractPriority();
|
|
|
|
this.CheckTicketsFromTasksI3D(new[] { newTasksI3D.task0I3D, newTasksI3D.task1I3D,2, 3 }, true);
|
|
}
|
|
|
|
private void PrepareDatabase()
|
|
{
|
|
//make Markus Fischer the default contact person for tickets
|
|
this.Sql("UPDATE AccountAddressContacts SET DefaultTicket = 1 WHERE I3D = 3");
|
|
this.Sql("UPDATE TaskManagementAction SET ContactI3D = 4 WHERE I3D = 5");
|
|
|
|
//make a priority to sla
|
|
this.Sql($"UPDATE hlpdsk_prioritaeten SET IsSLA = 1 WHERE I3D ={FirstSlaPrio}");
|
|
|
|
// Change the priority of three contracts to SLA
|
|
this.Sql($"UPDATE dbo.VertragKopf SET SLAPriorityI3D = {SecondSlaPrio} WHERE I3D = {FirstContractI3D}");
|
|
this.Sql($"UPDATE dbo.VertragKopf SET SLAPriorityI3D = {SecondSlaPrio} WHERE I3D = {SecondContractI3D}");
|
|
this.Sql($"UPDATE dbo.VertragKopf SET SLAPriorityI3D = {SecondSlaPrio} WHERE I3D = {ThirdContractI3D}");
|
|
|
|
//Add contracts to existing tasks and set the Priority to sla
|
|
this.Sql($"UPDATE dbo.TaskManagementAction SET PriorityI3D = {SecondSlaPrio},ContractI3D = {FirstContractI3D} WHERE I3D = 8");
|
|
this.Sql($"UPDATE dbo.TaskManagementAction SET PriorityI3D = {SecondSlaPrio},ContractI3D = {ThirdContractI3D} WHERE I3D = 2");
|
|
|
|
// Make sure to execute task 2 only in the next 13 days
|
|
// Task 2 creates tickets on every sunday, so usually it creates 1 helpdesk
|
|
// But if the test is executed on a sunday, it will create 2 helpdesks, so the test is flaky
|
|
// Setting "ExecuteDaysBefore" to 13 makes the result consistent regardless of weekday
|
|
this.Sql($"UPDATE dbo.TaskManagementRecurrence SET ExecuteDaysBefore = 13 WHERE I3D = 2");
|
|
|
|
//Remove the end date, so the task generate tickets
|
|
this.Sql("UPDATE dbo.TaskManagementRecurrence SET EndTime = NULL,NumberOfRecurrence = 10 WHERE I3D = 2");
|
|
}
|
|
|
|
public (int task0I3D, int task1I3D) CreateTask()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
var taskStarted0 = new TaskManagementTaskDTO
|
|
{
|
|
Name = "Aktiver Task",
|
|
Description = "-Klopf, klopf" +
|
|
"-Wer ist da ?" +
|
|
"-Po" +
|
|
"-Po wer ?" +
|
|
"-Pointe, aber ich muss Sie warnen, ich bin ziemlich entäuschend",
|
|
Status = ProjectStatus.Started,
|
|
|
|
Action = new TaskManagementHelpdeskActionDTO()
|
|
{
|
|
Customer = new CustomerPreviewDTO
|
|
{
|
|
I3D = CustomerI3D
|
|
},
|
|
Category = new HelpdeskCategoryDTO()
|
|
{
|
|
I3D = 6
|
|
},
|
|
Contract = new ContractDTO()
|
|
{
|
|
I3D = SecondContractI3D
|
|
},
|
|
Priority = new HelpdeskPrioritiesDTO()
|
|
{
|
|
I3D = 1
|
|
},
|
|
Type = new HelpdeskTypeDTO()
|
|
{
|
|
I3D = 6
|
|
},
|
|
State = new HelpdeskStatusDTO()
|
|
{
|
|
I3D = 1
|
|
},
|
|
ResponsiblePerson = new EmployeePreviewDTO()
|
|
{
|
|
I3D = 22
|
|
},
|
|
Members = new List<TaskManagementActionMemberDTO>()
|
|
{
|
|
new TaskManagementActionMemberDTO
|
|
{
|
|
Employee = new EmployeeDTO() { I3D = 22 }
|
|
}
|
|
}
|
|
},
|
|
Recurrence = new TaskManagementDailyRecurrenceDTO
|
|
{
|
|
AppointmentStart = new DateTime(2020, 2, 2, 13, 0, 0),
|
|
StartTime = new DateTime(2020, 2, 2, 13, 0, 0),
|
|
DayInterval = 14,
|
|
NumberOfRecurrence = 53
|
|
},
|
|
};
|
|
|
|
|
|
var taskStarted1 = new TaskManagementTaskDTO
|
|
{
|
|
Name = "Auch ein aktiver Task",
|
|
Description = "-Klopf, klopf" +
|
|
"-Wer ist da ?" +
|
|
"-Anne" +
|
|
"-Anne wer ?" +
|
|
"-An'ne Schlüssel sollst du nächstes mal denken",
|
|
|
|
Status = ProjectStatus.Started,
|
|
Action = new TaskManagementHelpdeskActionDTO()
|
|
{
|
|
InternalNote = "What sound does a programmer frog make?"+
|
|
"Regex, regex",
|
|
|
|
Customer = new CustomerPreviewDTO
|
|
{
|
|
I3D = CustomerI3D
|
|
},
|
|
Category = new HelpdeskCategoryDTO()
|
|
{
|
|
I3D = 6
|
|
},
|
|
Contract = new ContractDTO()
|
|
{
|
|
I3D = SecondContractI3D
|
|
},
|
|
Priority = new HelpdeskPrioritiesDTO()
|
|
{
|
|
I3D = 1
|
|
},
|
|
Type = new HelpdeskTypeDTO()
|
|
{
|
|
I3D = 6
|
|
},
|
|
State = new HelpdeskStatusDTO()
|
|
{
|
|
I3D = 1
|
|
},
|
|
ResponsiblePerson = new EmployeePreviewDTO()
|
|
{
|
|
I3D = 22
|
|
},
|
|
Members = new List<TaskManagementActionMemberDTO>()
|
|
{
|
|
new TaskManagementActionMemberDTO
|
|
{
|
|
Employee = new EmployeeDTO() { I3D = 22 }
|
|
}
|
|
}
|
|
},
|
|
Recurrence = new TaskManagementDailyRecurrenceDTO
|
|
{
|
|
AppointmentStart = new DateTime(2020, 2, 2, 13, 0, 0),
|
|
StartTime = new DateTime(2020, 2, 2, 13, 0, 0),
|
|
DayInterval = 14,
|
|
NumberOfRecurrence = 80
|
|
},
|
|
};
|
|
|
|
var savedTask0 = session.GetBL<TaskManagementTaskWebServiceBL>().SaveOrUpdateTask(taskStarted0, user);
|
|
var savedTask1 = session.GetBL<TaskManagementTaskWebServiceBL>().SaveOrUpdateTask(taskStarted1, user);
|
|
|
|
this.Verifier.Verify("SavedTask0", savedTask0);
|
|
this.Verifier.Verify("SavedTask1", savedTask1);
|
|
|
|
return (savedTask0.Data.I3D, savedTask1.Data.I3D);
|
|
}
|
|
}
|
|
|
|
public void ExecuteTasks()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var activeHelpdeskTasks = session.GetBL<TaskManagementTaskWebServiceBL>().GetTasks(1, int.MaxValue, new GetTasksFilter()
|
|
{
|
|
Type = TaskManagementActionType.Helpdesk,
|
|
Status = ProjectStatus.Started
|
|
});
|
|
|
|
foreach (var helpdeskTask in activeHelpdeskTasks.Data.Result)
|
|
{
|
|
var result = session.GetBL<TaskManagementTaskWebServiceBL>().ExecuteTask(helpdeskTask.I3D, user);
|
|
}
|
|
|
|
this.CheckTicketsFromTasksI3D(activeHelpdeskTasks.Data.Result.Select(f => f.I3D));
|
|
}
|
|
}
|
|
|
|
public void CheckTicketsFromTasksI3D(IEnumerable<int> tasksI3D, bool afterChanges = false)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
foreach (var helpdeskTaskI3D in tasksI3D)
|
|
{
|
|
//check if the tickets have been created
|
|
var closedState = session.GetBL<HelpdeskSettingsBL>().GetClosedHelpdeskState();
|
|
var tickets = session.GetBL<HelpdeskSearchWebServiceBL>().GetHelpdesksThroughPaging(
|
|
new HelpdeskFilter()
|
|
{
|
|
CreatedByTasks = true,
|
|
CreatedFromObjectKind = CentronObjectKindNumeric.TaskManagementClass,
|
|
CreatedFromObjectI3D = helpdeskTaskI3D
|
|
},
|
|
HelpdeskSort.Number,
|
|
true,
|
|
1,
|
|
Int32.MaxValue,
|
|
new LoggedInUser(user)
|
|
);
|
|
|
|
|
|
if (afterChanges == false)
|
|
this.Verifier.Verify("TicketFromTask" + helpdeskTaskI3D, tickets);
|
|
else
|
|
this.Verifier.Verify("TicketFromTaskAfterChanges" + helpdeskTaskI3D, tickets);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeContractPriority()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
var contractNewVersion0 = session.GetBL<ReceiptWebServiceBL>().CreateNewVersion(
|
|
CentronObjectKindNumeric.ContractClass,
|
|
FirstContractI3D,
|
|
null,
|
|
null,
|
|
user,
|
|
new CreateNewVersionData
|
|
{
|
|
UpdateReceiptDate = false
|
|
});
|
|
|
|
var contract0 = (ReceiptContractDTO)contractNewVersion0.Data.Receipt;
|
|
contract0.SLAPriority = FirstSlaPrio;
|
|
|
|
var saveResult0 = new BLSession().GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
contract0,
|
|
user,
|
|
new SaveReceiptData()
|
|
{
|
|
UpdatePrioritiesOfTaskTickets = true
|
|
},
|
|
false,
|
|
CreatedThroughApplication.CentronNet,
|
|
null);
|
|
|
|
var contractNewVersion1 = session.GetBL<ReceiptWebServiceBL>().CreateNewVersion(
|
|
CentronObjectKindNumeric.ContractClass,
|
|
SecondContractI3D,
|
|
null,
|
|
null,
|
|
user,
|
|
new CreateNewVersionData
|
|
{
|
|
UpdateReceiptDate = false
|
|
});
|
|
|
|
var contract1 = (ReceiptContractDTO)contractNewVersion1.Data.Receipt;
|
|
contract1.SLAPriority = FirstSlaPrio;
|
|
|
|
var saveResult1 = new BLSession().GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
contract1,
|
|
user,
|
|
new SaveReceiptData()
|
|
{
|
|
UpdatePrioritiesOfTaskTickets = false
|
|
},
|
|
false,
|
|
CreatedThroughApplication.CentronNet,
|
|
null);
|
|
|
|
var contractNewVersion2 = session.GetBL<ReceiptWebServiceBL>().CreateNewVersion(
|
|
CentronObjectKindNumeric.ContractClass,
|
|
ThirdContractI3D,
|
|
null,
|
|
null,
|
|
user,
|
|
new CreateNewVersionData
|
|
{
|
|
UpdateReceiptDate = false
|
|
});
|
|
|
|
var contract2 = (ReceiptContractDTO)contractNewVersion2.Data.Receipt;
|
|
contract2.SLAPriority = FirstSlaPrio;
|
|
var saveResult2 = new BLSession().GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
contract2,
|
|
user,
|
|
new SaveReceiptData()
|
|
{
|
|
IgnoreCallbacks = true
|
|
},
|
|
false,
|
|
CreatedThroughApplication.CentronNet,
|
|
null);
|
|
}
|
|
}
|
|
}
|
|
} |