72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.ServiceUtils;
|
|
using BS.Shared.Translation;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BeWo.Service.Reporting
|
|
{
|
|
public class ExportAndPrintHelper
|
|
{
|
|
// Hier ist der Code, der die StringArrays für den Excel-Export und die Print-Versionen des Exports erstellt
|
|
public virtual string[] PrepareHeaderArrayForUserExport()
|
|
{
|
|
return new string[]{ "Mitarbeiter", "Login", "zugeordnete Benutzergruppen" };
|
|
}
|
|
|
|
public virtual string[][] PrepareContentArrayForUserExport(long[] pSortedOids)
|
|
{
|
|
var lUser = DAOFactory.GenericDAO.LoadByIDs<ApplicationUser>(pSortedOids);
|
|
|
|
string[][] lContent = new string[lUser.Count][];
|
|
|
|
for (int iRowCount = 0; iRowCount < lUser.Count; iRowCount++)
|
|
{
|
|
lContent[iRowCount] = new string[3];
|
|
if (lUser[iRowCount].Employee != null)
|
|
{
|
|
lContent[iRowCount][0] = lUser[iRowCount].Employee.Person.ToString();
|
|
}
|
|
else
|
|
{
|
|
lContent[iRowCount][0] = "";
|
|
}
|
|
|
|
lContent[iRowCount][1] = lUser[iRowCount].LoginName;
|
|
lContent[iRowCount][2] = string.Join(", ", lUser[iRowCount].UserGroups.Select(ug => ug.Name).ToArray());
|
|
}
|
|
|
|
return lContent;
|
|
}
|
|
|
|
public virtual string[] PrepareHeaderArrayForUserGroupExport()
|
|
{
|
|
return new string[] { "Name", "Beschreibung", "zugeordnete Rechte" };
|
|
}
|
|
|
|
public virtual string[][] PrepareContentArrayForUserGroupExport(long[] pSortedOids)
|
|
{
|
|
Translator t = new Translator(new ServiceTranslator());
|
|
|
|
var lUserGroups = DAOFactory.GenericDAO.LoadByIDs<UserGroup>(pSortedOids);
|
|
|
|
string[][] lContent = new string[lUserGroups.Count][];
|
|
|
|
for (int iRowCount = 0; iRowCount < lUserGroups.Count; iRowCount++)
|
|
{
|
|
lContent[iRowCount] = new string[3];
|
|
|
|
lContent[iRowCount][0] = lUserGroups[iRowCount].Name;
|
|
lContent[iRowCount][1] = lUserGroups[iRowCount].Description;
|
|
lContent[iRowCount][2] = string.Join(", ", lUserGroups[iRowCount].Rights.Select(r => BS.Shared.Core.EnumTranslations.UserRightType2Translations[r.RightType]).OrderBy(s => s).ToArray());
|
|
}
|
|
|
|
return lContent;
|
|
}
|
|
}
|
|
}
|