2017-07-14 14:17:02 +02:00
using System ;
using System.Collections.Generic ;
2020-04-17 16:09:09 +02:00
using System.Linq ;
2020-08-19 12:15:10 +02:00
using System.IO ;
2020-08-17 15:50:00 +02:00
using System.Net ;
2017-07-14 14:17:02 +02:00
using System.Web.Mvc ;
using BeWo.Data.Access ;
using BeWo.Data.Entities ;
using BeWo.Service.ServiceImplementations ;
using BeWoPlanerMobil.Service ;
using BS.Shared ;
2020-08-17 15:50:00 +02:00
using Newtonsoft.Json ;
2022-08-12 10:16:19 +02:00
using System.ServiceModel.Syndication ;
using System.Xml ;
2017-09-05 09:23:53 +02:00
2017-07-14 14:17:02 +02:00
namespace BeWoPlanerMobil.Controllers
{
2017-08-08 13:13:22 +02:00
public class ChatController : Controller
2017-07-14 14:17:02 +02:00
{
2022-11-09 09:44:24 +01:00
protected static readonly log4net . ILog Log = log4net . LogManager . GetLogger ( System . Reflection . MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
2017-07-14 14:17:02 +02:00
public string Index ( )
{
2020-08-17 15:50:00 +02:00
return "Das ist die <b>Default</b> Aktion... Sie haben hier nix verloren;-)" ;
}
2026-01-30 19:24:40 +01:00
public String GetServerUrl ( string t , string k )
2020-08-17 15:50:00 +02:00
{
2026-01-30 19:24:40 +01:00
string url = String . Format ( "https://dict.ownchat.de/api/server/resolve/{0}/{1}" , t , k ) ;
2020-08-17 15:50:00 +02:00
WebRequest request = WebRequest . Create ( url ) ;
request . Credentials = CredentialCache . DefaultCredentials ;
WebResponse response = request . GetResponse ( ) ;
string responseFromServer = ReadStreamForChatCode ( response ) ;
var definition = new { status = "" , URL = "" , SYNCTYPE = "" } ;
var jsondaten = JsonConvert . DeserializeAnonymousType ( responseFromServer , definition ) ;
string serverUrl = jsondaten . URL ;
response . Close ( ) ;
return serverUrl ;
}
2022-08-25 12:51:53 +02:00
public ActionResult GetRssFeed ( )
2022-08-05 13:42:20 +02:00
{
2022-08-25 12:51:53 +02:00
try
{
2022-08-12 10:16:19 +02:00
string url = "https://apps.ownsoft.de/news/rss?evplaner[base_cat]=55" ;
2022-08-05 13:42:20 +02:00
WebRequest request = WebRequest . Create ( url ) ;
request . Credentials = CredentialCache . DefaultCredentials ;
WebResponse response = request . GetResponse ( ) ;
string responseFromServer = ReadStreamForChatCode ( response ) ;
response . Close ( ) ;
2022-08-12 10:16:19 +02:00
return this . Content ( responseFromServer , "text/xml" ) ;
2022-08-05 13:42:20 +02:00
}
catch ( Exception )
{
// throw(BeWo.Service.Core.Utils.ThrowBeWoFaultException(e));
return null ;
}
}
2022-11-09 09:44:24 +01:00
private static bool convertInProgress = false ;
public ActionResult UpdateFiles ( String list , String pwd )
{
try
{
if ( convertInProgress )
{
return this . Content ( "Schon gestartet" ) ;
}
convertInProgress = true ;
//list = "7000000000";
//pwd = "34vteWVTwegvn9wz4vn9";
if ( pwd = = "34vteWVTwegvn9wz4vn9" )
{
String [ ] nummern = list . Split ( ',' ) ;
foreach ( var knr in nummern )
{
System . Web . HttpContext . Current . Items . Remove ( "hibernateSession" ) ;
MobileSessionFacade . Tenant = knr ;
var isKundennummerVorhanden = ASPHibernateSessionManager . ConfigureHibernateSessionForWebService ( ) ;
if ( isKundennummerVorhanden )
{
Log . Debug ( $"Start UpdateFiles for {knr} -----------------------------------------------------------------------------------------------------------------------" ) ;
//var filePath = GetFilePath(12345678);
//Log.Debug($"File Path = {filePath}");
SaveAllFilesToDisk ( knr ) ;
Log . Debug ( $"Finished UpdateFiles for {knr} -----------------------------------------------------------------------------------------------------------------------" ) ;
//var os = new OperationsServiceImp();
//os.SaveAllFilesToDisk();
}
else
{
Log . Debug ( $"Kundennummer {knr} nicht vorhanden" ) ;
}
}
convertInProgress = false ;
return this . Content ( "Erfolgreich 4" ) ;
}
convertInProgress = false ;
return this . Content ( "Nicht authorisiert" ) ;
}
catch ( Exception ex )
{
convertInProgress = false ;
return this . Content ( "ERROR " + ex . Message ) ;
// throw(BeWo.Service.Core.Utils.ThrowBeWoFaultException(e));
return null ;
}
}
private void SaveAllFilesToDisk ( String knr )
{
var oid = DAOFactory . SearchDAO . GetMaxOidFromFileAttachment ( ) ;
for ( int i = 1 ; i < = oid ; i + + )
{
var file = DAOFactory . GenericDAO . LoadByID < FileAttachment > ( i ) ;
try
{
if ( file . Data ! = null )
{
Log . Debug ( $"Convert File {file.Oid}" ) ;
SaveFileToFileDirectory ( knr , file ) ;
}
else
{
Log . Debug ( $"Skip File {file.Oid}. Data = null" ) ;
}
}
catch ( Exception ex )
{
if ( ! ex . Message . Contains ( "No row with the given identifier exists" ) )
{
Log . Debug ( $"!!!! Error in SaveAllFilesToDisk " + ex . Message ) ;
}
//prüfe ob Datei existiert, sonst kommt ein Hibernate Fehler
}
}
}
private void SaveFileToFileDirectory ( String knr , FileAttachment fileAttachment )
{
if ( fileAttachment . Data ! = null )
{
CheckForFileRootDirectory ( knr ) ;
var filePath = GetFilePath ( knr , fileAttachment . Oid . Value ) ;
System . IO . File . WriteAllBytes ( filePath , fileAttachment . Data ) ;
if ( System . IO . File . Exists ( filePath ) & & fileAttachment . Data ! = null )
{
fileAttachment . Data = null ;
DAOFactory . GenericDAO . Update ( fileAttachment ) ;
}
}
}
private void CheckForFileRootDirectory ( String knr )
{
var fileRootDirectoryPath = GetFileRootDirectoryPath ( ) ;
var tenantPath = GetTenantFilePath ( knr ) ;
if ( ! Directory . Exists ( fileRootDirectoryPath ) )
{
Directory . CreateDirectory ( fileRootDirectoryPath ) ;
}
if ( ! Directory . Exists ( tenantPath ) )
{
Directory . CreateDirectory ( tenantPath ) ;
}
}
private string GetFilePath ( String knr , long fileAttachmentOid )
{
return Path . Combine ( GetTenantFilePath ( knr ) , fileAttachmentOid . ToString ( ) ) ;
}
private string GetFileRootDirectoryPath ( )
{
var fileRootDirectoryPath = System . Configuration . ConfigurationManager . AppSettings . Get ( BS . Shared . Core . SettingsKeys . FileRootDirectory ) ;
return fileRootDirectoryPath ;
}
private string GetTenantFilePath ( String kundennummer )
{
var fileRootDirectoryPath = GetFileRootDirectoryPath ( ) ;
return Path . Combine ( fileRootDirectoryPath , kundennummer ) ;
}
2020-08-17 15:50:00 +02:00
private static string ReadStreamForChatCode ( WebResponse response )
{
try
{
Stream dataStream = response . GetResponseStream ( ) ;
StreamReader reader = new StreamReader ( dataStream ) ;
string responseFromServer = reader . ReadToEnd ( ) ;
dataStream . Dispose ( ) ;
reader . Dispose ( ) ;
dataStream . Close ( ) ;
reader . Close ( ) ;
return responseFromServer ;
}
catch ( Exception e )
{
return null ;
}
2017-07-14 14:17:02 +02:00
}
2017-09-05 12:14:40 +02:00
[System.Web.Http.HttpPost]
public JsonResult LoginToken ( string kundennummer , string typ )
2017-07-14 14:17:02 +02:00
{
2017-09-05 12:14:40 +02:00
var apikey = Request [ "API-KEY" ] ;
2026-01-09 00:33:31 +01:00
#if DEBUG
kundennummer = "demo" ; // Test mit Autismus Köln Bonn
apikey = "SfTexuvxVGhNNyASiy43AnWa97VDcDsULyRTfxuWNC3YbNyLhzk48O7Hfzs7PNiy" ;
typ = "clients" ;
#endif
2017-09-05 12:14:40 +02:00
if ( kundennummer = = null )
2017-07-14 14:17:02 +02:00
{
return Json ( "99" , JsonRequestBehavior . AllowGet ) ;
}
MobileSessionFacade . Tenant = kundennummer ;
var isKundennummerVorhanden = ASPHibernateSessionManager . ConfigureHibernateSessionForWebService ( ) ;
if ( isKundennummerVorhanden )
{
2020-04-14 11:49:16 +02:00
var operationsServiceImp = new OperationsServiceImp ( ) ;
2017-09-05 12:14:40 +02:00
2020-04-14 11:49:16 +02:00
var mandator = operationsServiceImp . GetMandator2 ( false ) ;
2017-09-05 12:14:40 +02:00
if ( mandator . Apikey = = apikey ) {
2020-04-17 16:09:09 +02:00
2017-09-05 12:14:40 +02:00
Response . AddHeader ( "Content-Type" , "application/json" ) ; //; charset=utf8
2017-07-14 14:17:02 +02:00
#region Typ Verarbeitung
if ( typ ! = null )
{
if ( typ . Equals ( "clients" ) )
{
2020-04-17 16:09:09 +02:00
// Von Employee ausgehend -> Klienten, für die der Employee Hauptbetreuer ist oder wo die Rolle ownchat enthält
2017-08-08 13:13:22 +02:00
2020-04-17 16:09:09 +02:00
// Klientenbereich
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
var allCustomers = DAOFactory . GenericDAO . GetAllActive < Customer > ( ) ;
2017-07-14 14:17:02 +02:00
2026-01-09 00:33:31 +01:00
var allCustomerChatCodes = DAOFactory . GenericDAO . GetAllActive < CustomerAPPCode > ( ) ;
2017-09-22 11:43:39 +02:00
2020-04-14 11:49:16 +02:00
var input1 = new List < JsonInputKlient1 > ( ) ;
2017-08-08 13:13:22 +02:00
2026-01-09 00:33:31 +01:00
var appUser = DAOFactory . GenericDAO . GetAllActive < ApplicationUser > ( ) ;
2017-08-08 13:13:22 +02:00
// input 2 als liste übergeben und für jeden Mitarbeiter dem Customer zugeteilt ist
2020-04-17 16:09:09 +02:00
foreach ( var customer in allCustomers )
2017-08-08 13:13:22 +02:00
{
2020-04-14 11:49:16 +02:00
var chatcode = new CustomerAPPCode ( ) ;
2017-09-22 11:43:39 +02:00
2020-04-17 16:09:09 +02:00
foreach ( var code in allCustomerChatCodes )
2017-09-22 11:43:39 +02:00
{
2020-04-17 16:09:09 +02:00
if ( customer . Oid = = code . CustomerOid )
2017-09-22 11:43:39 +02:00
{
chatcode = code ;
}
}
2026-01-09 00:33:31 +01:00
2020-04-17 16:09:09 +02:00
var inputList = new List < JsonInputKlient2 > ( ) ;
2018-04-18 14:33:21 +02:00
// TODO: alle oder bestimmte Betreuer mitgeben und per Enum markieren
2026-01-09 00:33:31 +01:00
foreach ( var e2c in customer . Employee2CustomerList )
2017-08-08 13:13:22 +02:00
{
2026-01-09 00:33:31 +01:00
if ( ( ! e2c . StartDate . HasValue | | e2c . StartDate . Value . Date < = DateTime . Now . Date ) & & ( ! e2c . EndDate . HasValue | | e2c . EndDate . Value . Date > = DateTime . Now . Date ) )
{
foreach ( var v2o in e2c . ValueList )
{
if ( ( v2o . Entry . SystemEntryID . HasValue & & v2o . Entry . SystemEntryID . Value = = SystemEntryID . EmployeeRoleMainAttendant ) | | v2o . Entry . Value . ToLower ( ) . Contains ( "ownchat" ) )
2021-02-21 19:01:51 +01:00
{
2026-01-09 00:33:31 +01:00
foreach ( var applicationUser in appUser )
2017-08-08 13:13:22 +02:00
{
2026-01-09 00:33:31 +01:00
if ( e2c . EmployeeOid = = applicationUser . Employee ? . Oid )
2020-04-14 11:49:16 +02:00
{
2026-01-09 00:33:31 +01:00
string status ;
switch ( e2c . IsActive )
{
case ActivationTypeId . Deleted :
status = "3" ;
break ;
case ActivationTypeId . Archived :
status = "2" ;
break ;
default :
status = "1" ;
break ;
}
var input2 = new JsonInputKlient2 ( status ,
e2c . EmployeeOid . ToString ( ) ) ;
inputList . Add ( input2 ) ;
2020-04-14 11:49:16 +02:00
}
2017-08-08 13:13:22 +02:00
}
}
}
2026-01-09 00:33:31 +01:00
}
2017-08-08 13:13:22 +02:00
}
2020-04-14 11:49:16 +02:00
var mobilnummer = string . Empty ;
2020-04-17 16:09:09 +02:00
foreach ( var contact in customer . Person . Contacts )
2017-09-20 11:47:19 +02:00
{
if ( contact . Type = = ContactType . business_MobilePhone )
{
mobilnummer = contact . Value ;
}
}
2020-04-17 16:09:09 +02:00
var input = new JsonInputKlient1 ( customer . Oid . ToString ( ) , "1" ,
customer . Person . FirstName , customer . Person . LastName , customer . CustomerAlias , mobilnummer , chatcode . CustomerCode , chatcode . BenutzerName , chatcode . BCryptPassword , inputList ) ;
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
if ( customer . IsActive = = ActivationTypeId . Deleted )
2020-04-14 11:49:16 +02:00
{
input . Status = "3" ;
}
2020-04-17 16:09:09 +02:00
if ( customer . IsActive = = ActivationTypeId . Archived )
2020-04-14 11:49:16 +02:00
{
input . Status = "2" ;
}
2017-11-13 10:59:42 +01:00
2020-04-17 16:09:09 +02:00
if ( customer . TerminationDate ! = null & & customer . TerminationDate . Value . Date < DateTime . Now . Date )
2017-11-13 10:59:42 +01:00
{
input . Status = "2" ;
}
2018-10-08 11:57:16 +02:00
2020-04-17 16:09:09 +02:00
input1 . Add ( input ) ;
2018-10-08 11:57:16 +02:00
}
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
var result = new JsonRueckgabeKlient ( "0" , input1 ) ;
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
return Json ( result , JsonRequestBehavior . AllowGet ) ;
2017-07-14 14:17:02 +02:00
}
2017-08-08 13:13:22 +02:00
2020-04-17 16:09:09 +02:00
if ( typ . Equals ( "users" ) )
{
2017-09-05 09:23:53 +02:00
//Bitte alle Employees zurückgeben
2026-01-09 00:33:31 +01:00
var empChatCode = DAOFactory . GenericDAO . GetAllActive < EmployeeAPPCode > ( ) ;
2017-09-05 09:23:53 +02:00
2026-01-09 00:33:31 +01:00
var allEmployees = DAOFactory . GenericDAO . GetAllActive < Employee > ( ) ;
2017-08-08 13:13:22 +02:00
2026-01-09 00:33:31 +01:00
var applicationUser = DAOFactory . GenericDAO . GetAllActive < ApplicationUser > ( ) ;
2017-08-08 13:13:22 +02:00
2020-04-17 16:09:09 +02:00
var miInputList = new List < JsonRueckgabeMitarbeiterInput > ( ) ;
2017-08-08 13:13:22 +02:00
2021-10-13 14:38:51 +02:00
Dictionary < long? , ApplicationUser > applicationUsers = new Dictionary < long? , ApplicationUser > ( ) ;
foreach ( var au in applicationUser )
{
if ( au . Employee ! = null & & au . Employee . Oid . HasValue & & ! applicationUsers . ContainsKey ( au . Employee . Oid ) )
{
applicationUsers . Add ( au . Employee . Oid , au ) ;
}
}
//var applicationUsers2 = applicationUser.Where(appUser => appUser.Employee != null).ToDictionary(appUser => appUser.Employee.Oid);
2017-08-08 13:22:49 +02:00
2020-04-17 16:09:09 +02:00
foreach ( var employee in allEmployees )
2017-08-08 13:22:49 +02:00
{
2020-04-17 16:09:09 +02:00
var chatcode = new EmployeeAPPCode ( ) ;
2017-08-08 13:13:22 +02:00
2017-08-08 13:22:49 +02:00
foreach ( var code in empChatCode )
{
2020-04-17 16:09:09 +02:00
if ( employee . Oid = = code . EmployeeOid )
2017-08-08 13:22:49 +02:00
{
chatcode = code ;
}
}
2017-08-08 13:13:22 +02:00
2017-08-08 13:22:49 +02:00
DateTime ? insTs = null ;
2017-08-08 13:13:22 +02:00
2020-04-17 16:09:09 +02:00
foreach ( var img in employee . Person . Images )
2017-08-08 13:22:49 +02:00
{
2020-04-17 16:09:09 +02:00
insTs = img . InsTs ;
2017-08-08 13:22:49 +02:00
}
2017-08-08 13:13:22 +02:00
2017-08-08 13:22:49 +02:00
JsonRueckgabeMitarbeiterInput miInput ;
2017-08-08 13:13:22 +02:00
2020-04-17 16:09:09 +02:00
if ( employee . IsActive = = ActivationTypeId . Deleted )
2017-08-08 13:22:49 +02:00
{
2020-04-17 16:09:09 +02:00
miInput = new JsonRueckgabeMitarbeiterInput ( "" , employee . Oid . ToString ( ) , "3" , "" , "" , "" , "" , "" , "" , "" , "" ) ;
2017-08-08 13:22:49 +02:00
}
2020-04-17 16:09:09 +02:00
else if ( employee . IsActive = = ActivationTypeId . Archived )
{
miInput = new JsonRueckgabeMitarbeiterInput ( "" , employee . Oid . ToString ( ) , "2" , "" , "" , "" , "" , "" , "" , "" , "" ) ;
}
else
{
string handy = null ;
foreach ( var contact in employee . Person . Contacts )
{
if ( contact . Type = = ContactType . business_MobilePhone )
{
//das ist die Handynummer
handy = contact . Value ;
}
}
2017-08-08 13:22:49 +02:00
2020-04-17 16:09:09 +02:00
var instsStr = string . Empty ;
if ( insTs . HasValue )
{
instsStr = insTs . Value . ToString ( "dd.MM.yyyy" ) ;
}
2021-05-24 21:40:02 +02:00
//if (employee.Person.LastName == "Rapko")
//{
// int test = 0;
//}
2020-04-17 16:09:09 +02:00
if ( applicationUsers . ContainsKey ( employee . Oid ) )
{
miInput = new JsonRueckgabeMitarbeiterInput ( applicationUsers [ employee . Oid ] . Oid . ToString ( ) , employee . Oid . ToString ( ) , "1" , applicationUsers [ employee . Oid ] . LoginName ,
applicationUsers [ employee . Oid ] . BCryptPassword , employee . Person . FirstName ,
employee . Person . LastName , chatcode . EmployeeCode , handy , employee . Person . Oid . ToString ( ) , instsStr ) ;
}
else
{
miInput = new JsonRueckgabeMitarbeiterInput ( "" , employee . Oid . ToString ( ) , "1" , "" , "" , employee . Person . FirstName , employee . Person . LastName ,
chatcode . EmployeeCode , handy , employee . Person . Oid . ToString ( ) , instsStr ) ;
2017-08-08 13:22:49 +02:00
}
2020-04-17 16:09:09 +02:00
if ( insTs ! = null )
{
miInput . PictureId = insTs . ToString ( ) ;
}
2017-08-08 13:13:22 +02:00
2020-04-17 16:09:09 +02:00
miInputList . Add ( miInput ) ;
}
}
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
var mi = new JsonRueckgabeMitarbeiter ( "0" , miInputList ) ;
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
return Json ( mi , JsonRequestBehavior . AllowGet ) ;
}
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
if ( typ . Equals ( "teams" ) )
{
//Mitarbeiter Team Bereich
var allTeams = DAOFactory . GenericDAO . GetAllActive < Team > ( ) ;
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
var jrtmi = new List < JsonRueckgabeTeamMitarbeiterInput > ( ) ;
2017-07-14 14:17:02 +02:00
2017-09-05 09:23:53 +02:00
var applicationUser = DAOFactory . GenericDAO . GetAllActiveAndArchived < ApplicationUser > ( ) ;
2021-10-15 17:32:32 +02:00
2025-12-11 00:26:11 +01:00
Dictionary < long? , ApplicationUser > employeeOid2AppUser = new Dictionary < long? , ApplicationUser > ( ) ;
2021-10-15 17:32:32 +02:00
foreach ( var au in applicationUser )
{
2025-12-11 00:26:11 +01:00
if ( au . Employee ! = null & & au . Employee . Oid . HasValue & & ! employeeOid2AppUser . ContainsKey ( au . Employee . Oid ) )
2021-10-15 17:32:32 +02:00
{
2025-12-11 00:26:11 +01:00
employeeOid2AppUser . Add ( au . Employee . Oid , au ) ;
2021-10-15 17:32:32 +02:00
}
}
//var appUserOid2AppUser = applicationUser.Where(appUser => appUser.Employee != null).ToDictionary(appUser => appUser.Employee.Oid);
2017-08-28 08:42:00 +02:00
2020-04-17 16:09:09 +02:00
foreach ( var team in allTeams )
2017-08-28 08:42:00 +02:00
{
2020-04-17 16:09:09 +02:00
var mtInputList = new List < JsonRueckgabeTeamMitarbeiterInput2 > ( ) ;
2026-01-09 00:33:31 +01:00
bool isReadOnly = false ;
bool teamIsEmployee = true ;
2020-04-17 16:09:09 +02:00
2025-12-11 00:26:11 +01:00
if ( team . IsOwnChatTeam )
2019-11-14 16:13:41 +01:00
{
2025-12-11 00:26:11 +01:00
foreach ( var p2t in team . OwnChatMember )
2020-04-17 16:09:09 +02:00
{
2026-01-09 00:33:31 +01:00
var isWriter = ! p2t . OwnChatRole . HasValue | | p2t . OwnChatRole . Value = = 0 ;
if ( ! isWriter )
{
isReadOnly = true ;
}
2025-12-11 00:26:11 +01:00
if ( p2t . Person . Type = = PersonType . Employee )
2020-04-17 16:09:09 +02:00
{
2025-12-11 00:26:11 +01:00
var emp = DAOFactory . SearchDAO . FindEmployeeWithPersonOid ( p2t . Person . Oid . Value ) ;
2026-01-09 00:33:31 +01:00
var mtInput2 = new JsonRueckgabeTeamMitarbeiterInput2 ( "1" , emp . Oid . ToString ( ) , true , isWriter ) ;
2025-12-11 00:26:11 +01:00
if ( emp . IsActive = = ActivationTypeId . Deleted )
{
mtInput2 . Status = "3" ;
}
if ( emp . IsActive = = ActivationTypeId . Archived )
{
mtInput2 . Status = "2" ;
}
mtInputList . Add ( mtInput2 ) ;
2020-04-17 16:09:09 +02:00
}
2025-12-11 00:26:11 +01:00
else
2020-04-17 16:09:09 +02:00
{
2026-01-09 00:33:31 +01:00
teamIsEmployee = false ;
var c = DAOFactory . SearchDAO . FindCustomerWithPersonOid ( p2t . PersonOid . Value ) ;
2020-04-17 16:09:09 +02:00
2026-01-09 00:33:31 +01:00
var mtInput2 = new JsonRueckgabeTeamMitarbeiterInput2 ( "1" , c . Oid . ToString ( ) , false , isWriter ) ;
2025-12-11 00:26:11 +01:00
2026-01-09 00:33:31 +01:00
if ( c . IsActive = = ActivationTypeId . Deleted )
{
mtInput2 . Status = "3" ;
}
2025-12-11 00:26:11 +01:00
2026-01-09 00:33:31 +01:00
if ( c . IsActive = = ActivationTypeId . Archived )
{
mtInput2 . Status = "2" ;
}
mtInputList . Add ( mtInput2 ) ;
2025-12-11 00:26:11 +01:00
}
2020-04-17 16:09:09 +02:00
}
2025-12-11 00:26:11 +01:00
}
else
{
foreach ( var member in team . MemberList . Where ( teamMember = > teamMember . Oid . HasValue ) )
2020-04-17 16:09:09 +02:00
{
2025-12-11 00:26:11 +01:00
2026-01-09 00:33:31 +01:00
var mtInput2 = new JsonRueckgabeTeamMitarbeiterInput2 ( "1" , member . Oid . ToString ( ) , true , true ) ;
2020-04-17 16:09:09 +02:00
if ( member . IsActive = = ActivationTypeId . Deleted )
{
mtInput2 . Status = "3" ;
}
if ( member . IsActive = = ActivationTypeId . Archived )
{
mtInput2 . Status = "2" ;
}
mtInputList . Add ( mtInput2 ) ;
}
2026-01-30 19:24:40 +01:00
if ( team . Leader ! = null )
{
//if (!mtInputList.Count(m => m.))
}
2019-11-14 16:13:41 +01:00
}
2025-12-11 00:26:11 +01:00
2020-04-17 16:09:09 +02:00
var mtInput1 = new JsonRueckgabeTeamMitarbeiterInput ( team . Oid . ToString ( ) , "1" , team . Name , mtInputList ) ;
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
if ( team . IsActive = = ActivationTypeId . Deleted )
{
mtInput1 . Status = "3" ;
}
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
if ( team . IsActive = = ActivationTypeId . Archived )
{
mtInput1 . Status = "2" ;
}
2026-01-09 00:33:31 +01:00
mtInput1 . is_read_only = isReadOnly ? "1" : "0" ;
//mtInput1.isemployee = teamIsEmployee ? "1" : "0";
2020-04-17 16:09:09 +02:00
jrtmi . Add ( mtInput1 ) ;
}
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
var mt = new JsonRueckgabeTeamMitarbeiter ( "0" , jrtmi ) ;
2017-07-14 14:17:02 +02:00
2020-04-17 16:09:09 +02:00
return Json ( mt , JsonRequestBehavior . AllowGet ) ;
}
// Falls typ nicht stimmt
2017-09-05 09:23:53 +02:00
System . Threading . Thread . Sleep ( 5000 ) ;
2017-09-26 14:08:38 +02:00
return Json ( new Fehler ( "1" ) , JsonRequestBehavior . AllowGet ) ;
2017-07-14 14:17:02 +02:00
}
2017-09-05 09:23:53 +02:00
#endregion
2020-04-17 16:09:09 +02:00
// Falls typ nicht vorhanden
2017-09-05 09:23:53 +02:00
System . Threading . Thread . Sleep ( 5000 ) ;
2017-09-26 14:08:38 +02:00
return Json ( new Fehler ( "1" ) , JsonRequestBehavior . AllowGet ) ;
2017-07-14 14:17:02 +02:00
}
2020-04-17 16:09:09 +02:00
// Gib json zurück {"STATE":1}
System . Threading . Thread . Sleep ( 5000 ) ;
return Json ( new Fehler ( "1" ) , JsonRequestBehavior . AllowGet ) ;
2017-07-14 14:17:02 +02:00
}
2020-04-17 16:09:09 +02:00
// Gib json zurück {"STATE":99}
2017-09-26 14:08:38 +02:00
return Json ( new Fehler ( "99" ) , JsonRequestBehavior . AllowGet ) ;
2017-07-14 14:17:02 +02:00
}
2017-09-05 09:41:56 +02:00
[System.Web.Mvc.HttpPost]
2017-09-05 12:14:40 +02:00
public JsonResult BildUrl ( )
2017-07-14 14:17:02 +02:00
{
2017-09-05 12:14:40 +02:00
var oid = Request [ "oid" ] ;
var img = DAOFactory . GenericDAO . GetByID < Person > ( Convert . ToInt64 ( oid ) ) ;
2017-07-14 14:17:02 +02:00
2017-09-05 09:23:53 +02:00
if ( img . Images . Count > 0 )
2020-04-14 11:49:16 +02:00
{
return Json ( img . Images [ 0 ] . SmallThumbnail , JsonRequestBehavior . AllowGet ) ;
2017-09-05 09:23:53 +02:00
}
2017-07-14 14:17:02 +02:00
2020-04-14 11:49:16 +02:00
System . Threading . Thread . Sleep ( 5000 ) ;
return Json ( new Fehler ( "1" ) , JsonRequestBehavior . AllowGet ) ;
}
2017-07-14 14:17:02 +02:00
}
#region Klient
public class JsonRueckgabeKlient
{
public string State { get ; set ; }
2017-09-05 09:23:53 +02:00
public List < JsonInputKlient1 > Data { get ; set ; }
2017-07-14 14:17:02 +02:00
2017-09-05 09:23:53 +02:00
public JsonRueckgabeKlient ( string state , List < JsonInputKlient1 > data )
2017-07-14 14:17:02 +02:00
{
State = state ;
2017-09-05 09:23:53 +02:00
Data = data ;
2017-07-14 14:17:02 +02:00
}
}
//klienten input
public class JsonInputKlient1
{
public string Oid { get ; set ; }
public string Status { get ; set ; }
public string Firstname { get ; set ; }
public string LastName { get ; set ; }
public string Alias { get ; set ; }
2017-09-20 11:47:19 +02:00
public string Mobile { get ; set ; }
2017-09-22 11:43:39 +02:00
public string ChatCode { get ; set ; }
2017-10-13 14:07:44 +02:00
public string Login { get ; set ; }
public string Password { get ; set ; }
2017-09-22 11:43:39 +02:00
2017-09-20 11:47:19 +02:00
public List < JsonInputKlient2 > Guardians { get ; set ; }
2017-07-14 14:17:02 +02:00
2017-10-13 14:07:44 +02:00
public JsonInputKlient1 ( string oid , string status , string firstname , string lastname , string alias , string mobile , string chatCode , string login , string password , List < JsonInputKlient2 > guardians )
2017-07-14 14:17:02 +02:00
{
2017-09-22 11:43:39 +02:00
Oid = "C" + oid ;
2017-07-14 14:17:02 +02:00
Status = status ;
Firstname = firstname ;
LastName = lastname ;
Alias = alias ;
2017-09-20 11:47:19 +02:00
Mobile = mobile ;
2017-09-22 11:43:39 +02:00
ChatCode = chatCode ;
2017-10-13 14:07:44 +02:00
Login = login ;
Password = password ;
2017-09-20 11:47:19 +02:00
Guardians = guardians ;
2017-07-14 14:17:02 +02:00
}
}
public class JsonInputKlient2
{
public string Status { get ; set ; }
2017-09-22 11:43:39 +02:00
2017-07-14 14:17:02 +02:00
public string EmployeeOid { get ; set ; }
2017-09-22 11:43:39 +02:00
public JsonInputKlient2 ( string status , string employeeOid )
2017-07-14 14:17:02 +02:00
{
2017-09-22 11:43:39 +02:00
Status = status ;
EmployeeOid = "E" + employeeOid ;
2017-07-14 14:17:02 +02:00
}
}
#endregion
#region Mitarbeiter
public class JsonRueckgabeMitarbeiter
{
public string State { get ; set ; }
2017-09-05 09:23:53 +02:00
public List < JsonRueckgabeMitarbeiterInput > Data { get ; set ; }
2017-07-14 14:17:02 +02:00
2017-09-05 09:23:53 +02:00
public JsonRueckgabeMitarbeiter ( string state , List < JsonRueckgabeMitarbeiterInput > data )
2017-07-14 14:17:02 +02:00
{
State = state ;
2017-09-05 09:23:53 +02:00
Data = data ;
2017-07-14 14:17:02 +02:00
}
}
public class JsonRueckgabeMitarbeiterInput
2017-09-22 11:43:39 +02:00
{
2017-07-14 14:17:02 +02:00
public string EmployeeOid { get ; set ; }
public string Status { get ; set ; }
public string Login { get ; set ; }
public string Password { get ; set ; }
public string Firstname { get ; set ; }
public string LastName { get ; set ; }
public string ChatCode { get ; set ; }
public string Mobile { get ; set ; }
public string Picture { get ; set ; }
public string PictureId { get ; set ; }
public JsonRueckgabeMitarbeiterInput ( string useroid , string employeeOid , string status , string login , string password ,
string firstname , string lastname , string chatcode , string mobile , string picture , string pictureId )
{
2017-09-22 11:43:39 +02:00
EmployeeOid = "E" + employeeOid ;
2017-07-14 14:17:02 +02:00
Status = status ;
Login = login ;
Password = password ;
Firstname = firstname ;
LastName = lastname ;
ChatCode = chatcode ;
Mobile = mobile ;
Picture = picture ;
PictureId = pictureId ;
}
}
#endregion
#region TeamMitarbeiter
public class JsonRueckgabeTeamMitarbeiter
{
public string State { get ; set ; }
2017-09-05 09:23:53 +02:00
public List < JsonRueckgabeTeamMitarbeiterInput > Data { get ; set ; }
2017-07-14 14:17:02 +02:00
2017-09-05 09:23:53 +02:00
public JsonRueckgabeTeamMitarbeiter ( string state , List < JsonRueckgabeTeamMitarbeiterInput > data )
2017-07-14 14:17:02 +02:00
{
State = state ;
2017-09-05 09:23:53 +02:00
Data = data ;
2017-07-14 14:17:02 +02:00
}
}
public class JsonRueckgabeTeamMitarbeiterInput
{
public string Oid { get ; set ; }
public string Status { get ; set ; }
public string Name { get ; set ; }
2026-01-09 00:33:31 +01:00
public string is_read_only { get ; set ; }
public List < JsonRueckgabeTeamMitarbeiterInput2 > Members { get ; set ; }
2017-07-14 14:17:02 +02:00
2017-09-05 09:23:53 +02:00
public JsonRueckgabeTeamMitarbeiterInput ( string oid , string status , string name , List < JsonRueckgabeTeamMitarbeiterInput2 > members )
2017-07-14 14:17:02 +02:00
{
2017-09-22 11:43:39 +02:00
Oid = "T" + oid ;
2017-07-14 14:17:02 +02:00
Name = name ;
2017-09-05 09:23:53 +02:00
Members = members ;
2017-07-14 14:17:02 +02:00
Status = status ;
2026-01-09 00:33:31 +01:00
is_read_only = "0" ;
2017-07-14 14:17:02 +02:00
}
}
public class JsonRueckgabeTeamMitarbeiterInput2
{
public string Status { get ; set ; }
2017-09-22 11:43:39 +02:00
2017-07-14 14:17:02 +02:00
public string EmployeeOid { get ; set ; }
2026-01-09 00:33:31 +01:00
public string IsEmployee { get ; set ; }
public string is_writer { get ; set ; }
public JsonRueckgabeTeamMitarbeiterInput2 ( string status , string oid , bool isEmployee , bool isWriter )
2017-07-14 14:17:02 +02:00
{
Status = status ;
2017-09-22 11:43:39 +02:00
2026-01-09 00:33:31 +01:00
if ( isEmployee )
{
EmployeeOid = "E" + oid ;
IsEmployee = "1" ;
}
else
{
EmployeeOid = "C" + oid ;
IsEmployee = "0" ;
}
is_writer = isWriter ? "1" : "0" ;
2017-07-14 14:17:02 +02:00
}
}
2017-09-26 14:08:38 +02:00
#endregion
2017-07-14 14:17:02 +02:00
2017-09-26 14:08:38 +02:00
#region fehlermeldung
public class Fehler
{
public string STATE { get ; set ; }
2017-07-14 14:17:02 +02:00
2017-09-26 14:08:38 +02:00
public Fehler ( string fehler )
{
STATE = fehler ;
}
}
#endregion
2022-08-12 10:16:19 +02:00
2022-08-12 10:19:10 +02:00
//public class RssActionResult : ActionResult
//{
// public SyndicationFeed Feed { get; set; }
// public override void ExecuteResult(ControllerContext context)
// {
// context.HttpContext.Response.ContentType = "application/rss+xml";
// Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(Feed);
// using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
// {
// rssFormatter.WriteTo(writer);
// }
// }
//}
2017-07-14 14:17:02 +02:00
}