This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,59 @@
using System.Collections.Generic;
using Kreta.Client.Mdsz.Dto;
using Kreta.Resources;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
using RestSharp.Authenticators;
namespace Kreta.Client
{
public class MdszClient
{
private readonly Dictionary<string, string> HibakodList = new Dictionary<string, string>
{
{"101", ErrorResource.ASzolgaltatasJelenlegNemEretheto},
{"102", ErrorResource.HibasFelhasznalonevEsVagyJelszo},
{"103", ErrorResource.AFelhasznaloLetiltasraKerult},
{"104", ErrorResource.AFelhasznalonakNincsMegfeleloJogosultsagaAFunkcioHasznalatahoz},
{"200", ErrorResource.ACsomagErtelmezeseSikertelen},
{"210", ErrorResource.NincsIskola},
{"211", ErrorResource.NincsAzIskolanakOMAzonositoja},
{"212", ErrorResource.IskolaOMAzonositojaNemMegfeleloFormatumu},
{"213", ErrorResource.AMegadottOMAzonositovalEsSorszammalRendelkezoIntezmenyNemTalalhato},
{"214", ErrorResource.AMukodesiHelyAzonositojaNincsMegadvaAzEkretaRendszerben },
{"220", ErrorResource.NincsTanarMegadva},
{"221", ErrorResource.NincsMegadvaVagyHibasATanarPedagogusAzonositoja},
{"222", ErrorResource.HibaAFelhasznaloLetrehozasanal},
{"223", ErrorResource.NincsMegadvaVagyNemMegfeleloFormatumuAFelhasznaloEmailCime},
{"230", ErrorResource.NincsDiakMegadva},
{"231", ErrorResource.NincsMegadvaVagyHibasADiakOktatasiAzonositoja},
{"250", ErrorResource.EmailKuldesiHiba},
{"300", ErrorResource.EgyebVaratlanNemKezeltHiba}
};
string Url { get; }
public MdszClient(string url)
{
this.Url = url;
}
public string SendData(MdszDto model, string felhaszNev, string jelszo)
{
var client = new RestClient(Url) { Authenticator = new HttpBasicAuthenticator(felhaszNev, jelszo) };
var request = new RestRequest(Method.POST);
request.AddParameter("application/json", JsonConvert.SerializeObject(model), ParameterType.RequestBody);
var response = client.Execute(request);
var responseJson = JObject.Parse(response.Content);
if (responseJson["url"] != null && responseJson["csomag_azon"] != null)
{
return AdminisztracioResource.AKuldesSikeresVolt;
}
return HibakodList[responseJson["hiba_kod"].ToString()];
}
}
}

View file

@ -0,0 +1,149 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Kreta.Client.Mdsz.Dto
{
public class MdszDto
{
[JsonProperty(PropertyName = "iskola")]
public IskolaDto Iskola { get; set; }
[JsonProperty(PropertyName = "tanar")]
public TanarDto Tanar { get; set; }
[JsonProperty(PropertyName = "diakok")]
public List<DiakDto> Diakok { get; set; }
public class IskolaDto
{
[JsonProperty(PropertyName = "om")]
public string Om { get; set; }
[JsonProperty(PropertyName = "nev")]
public string Nev { get; set; }
[JsonProperty(PropertyName = "rovid_nev")]
public string RovidNev { get; set; }
[JsonProperty(PropertyName = "adoszam")]
public string Adoszam { get; set; }
[JsonProperty(PropertyName = "url")]
public string Url { get; set; }
[JsonProperty(PropertyName = "tel")]
public string Telefon { get; set; }
[JsonProperty(PropertyName = "fax")]
public string Fax { get; set; }
[JsonProperty(PropertyName = "e-mail")]
public string Email { get; set; }
[JsonProperty(PropertyName = "vezeto_nev")]
public string VezetoNeve { get; set; }
[JsonProperty(PropertyName = "cim_irsz")]
public string CimIrsz { get; set; }
[JsonProperty(PropertyName = "cim_telep")]
public string CimVaros { get; set; }
[JsonProperty(PropertyName = "cim_utca")]
public string CimKozteruletNevJelleg { get; set; }
[JsonProperty(PropertyName = "cim_hsz")]
public string CimHsz { get; set; }
[JsonProperty(PropertyName = "int_nev")]
public string IntezmenyNev { get; set; }
[JsonProperty(PropertyName = "int_rovid_nev")]
public string IntezmenyRovidNev { get; set; }
[JsonProperty(PropertyName = "int_adoszam")]
public string IntezmenyAdoszam { get; set; }
[JsonProperty(PropertyName = "int_url")]
public string IntezmenyUrl { get; set; }
[JsonProperty(PropertyName = "int_tel")]
public string IntezmenyTelefon { get; set; }
[JsonProperty(PropertyName = "int_fax")]
public string IntezmenyFax { get; set; }
[JsonProperty(PropertyName = "int_e-mail")]
public string IntezmenyEmail { get; set; }
[JsonProperty(PropertyName = "int_vezeto_nev")]
public string IntezmenyVezetoNev { get; set; }
[JsonProperty(PropertyName = "int_cim_irsz")]
public string IntezmenyCimIrsz { get; set; }
[JsonProperty(PropertyName = "int_cim_telep")]
public string IntezmenyCimVaros { get; set; }
[JsonProperty(PropertyName = "int_cim_utca")]
public string IntezmenyCimKozteruletNevJelleg { get; set; }
[JsonProperty(PropertyName = "int_cim_hsz")]
public string IntezmenyCimHsz { get; set; }
[JsonProperty(PropertyName = "int_tip")]
public string IntezmenyTip { get; set; }
[JsonProperty(PropertyName = "int_azonosito")]
public string IntezmenyAzon { get; set; }
}
public class TanarDto
{
[JsonProperty(PropertyName = "om")]
public string Om { get; set; }
[JsonProperty(PropertyName = "nev")]
public string Nev { get; set; }
[JsonProperty(PropertyName = "login")]
public string Login { get; set; }
[JsonProperty(PropertyName = "e-mail")]
public string Email { get; set; }
[JsonProperty(PropertyName = "tel")]
public string Telefon { get; set; }
[JsonIgnore]
public int Id { get; set; }
}
public class DiakDto
{
[JsonProperty(PropertyName = "om")]
public string Om { get; set; }
[JsonProperty(PropertyName = "nev")]
public string Nev { get; set; }
[JsonProperty(PropertyName = "szuletesi_nev")]
public string SzuletesiNev { get; set; }
[JsonProperty(PropertyName = "szuletesi_hely")]
public string SzuletesiHely { get; set; }
[JsonProperty(PropertyName = "szuletesi_ido")]
public string SzuletesiIdo { get; set; }
[JsonProperty(PropertyName = "anyja_neve")]
public string AnyjaNeve { get; set; }
[JsonProperty(PropertyName = "nem")]
public string Neme { get; set; }
[JsonIgnore]
public int Id { get; set; }
}
}
}