Skip to content

Commit

Permalink
Dodati obrazovanje zaposlenih
Browse files Browse the repository at this point in the history
  • Loading branch information
bvujovic committed Jun 16, 2023
1 parent bd5edfa commit cefb20a
Show file tree
Hide file tree
Showing 15 changed files with 2,272 additions and 524 deletions.
9 changes: 5 additions & 4 deletions JISP/Classes/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ public static void AdjustWidth(this ComboBox cmb)
cmb.DropDownWidth = (int)maxWidth + 5;
}

public static async System.Threading.Tasks.Task PreuzmiDokumentResenja(Controls.UcDGV dgv, DataGridViewCellEventArgs e)
public static async System.Threading.Tasks.Task PreuzmiDokument(Controls.UcDGV dgv, DataGridViewCellEventArgs e)
{
var res = dgv.CurrDataRow<Data.Ds.ResenjaRow>();
if (res.IsDokumentNull())
var docIdColName = "DokumentId";
var row = (dgv.CurrentRow.DataBoundItem as System.Data.DataRowView).Row;
if (row == null || row.IsNull(docIdColName))
return;
var cell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];
var originalText = (string)cell.Value;
Expand All @@ -218,7 +219,7 @@ public static async System.Threading.Tasks.Task PreuzmiDokumentResenja(Controls.
{
var filePath = GetDownloadsFolder(originalText);
await Data.WebApi.PostForFile(filePath, "Upload/PreuzmiDokument"
, $"{{'documentId':'{res.DokumentId}'}}", true);
, $"{{'documentId':'{row[docIdColName]}'}}", true);
}
catch (Exception ex) { ShowMbox(ex, "Preuzimanje rešenja"); }
cell.Value = originalText;
Expand Down
35 changes: 34 additions & 1 deletion JISP/Data/DataGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,40 @@ public static async Task GetResenjaAsync(IEnumerable<Ds.ZaposlenjaRow> zaposlenj
}
}

/// <summary>Učitava podateke u tabelu Sistematizacija.</summary>
/// <summary>Dohvatanje dela podataka u tabelu Obrazovanja.</summary>
public static async Task GetObrazovanjaAsync(int idZaposlenog)
{
var url = "https://jisp.mpn.gov.rs/webapi/api/Zaposleni/VratiStecenaObrazovanjaZaposlenog";
var json = await WebApi.PostForJson(url, $"{{\"regZapZaposleniId\":{idZaposlenog}}}");
dynamic arr = Newtonsoft.Json.Linq.JArray.Parse(json);
foreach (var obj in arr)
{
Ds.ObrazovanjaRow o = AppData.Ds.Obrazovanja.FindByIdObrazovanja((int)obj.id);
bool novo;
if (novo = o == null)
o = AppData.Ds.Obrazovanja.NewObrazovanjaRow();

o.IdZaposlenog = idZaposlenog;
o.IdObrazovanja = obj.id;
o.NoksNivo = obj.noksNivo != null;
o.Klasnoks = obj.klasnoks != null;
o.Stepen = obj.stepen != null;
o.NazivSteceneKvalifikacije = obj.nazivSteceneKvalifikacije;
o.StrucniAkademskiNazivIzDiplome = obj.strucniAkademskiNazivIzDiplome;
o.DatumSticanjaDiplome = obj.datumSticanjaDiplome;
o.DrzavaZavrseneSkole = obj.drzavaZavrseneSkole;
o.MestoZavrseneSkoleNaziv = obj.mestoZavrseneSkoleSlobodanUnos;
o.NazivSkole = obj.nazivSkole;
o.JezikNaKomJeStecenoObrazovanje = obj.jezikNaKomJeStecenoObrazovanje != null;
o.DokumentId = obj.dokumentId;
o.DokumentNaziv = obj.dokumentNaziv;

if (novo)
AppData.Ds.Obrazovanja.AddObrazovanjaRow(o);
}
}

/// <summary>Učitava podatke u tabelu Sistematizacija.</summary>
public static async Task GetSistematizacijaAsync()
{
var json = await WebApi.GetJson(WebApi.ReqEnum.Zap_Sistematizacija);
Expand Down
1,793 changes: 1,407 additions & 386 deletions JISP/Data/Ds.Designer.cs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions JISP/Data/Ds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace JISP.Data
{
partial class Ds
{
partial class ObrazovanjaDataTable
{
}

partial class ObracunZaradaRow
{
/// <summary>Ukupan broj meseci po formuli: 12*Godina + MesecBroj</summary>
Expand Down
46 changes: 36 additions & 10 deletions JISP/Data/Ds.xsd

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions JISP/Data/WebApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using System.Threading.Tasks;
using static JISP.Data.WebApi;

namespace JISP.Data
{
Expand Down Expand Up @@ -102,13 +104,11 @@ public static async Task<string> GetJson(ReqEnum reqEnum, string param = null)
return await GetJson(UrlForReq(reqEnum, param));
}

/// <summary>Dohvata (POST) JSON podatke od JISP WebAPI-a.</summary>
public static async Task<string> PostForJson(ReqEnum reqEnum, string body, string param = null)
public static async Task<string> PostForJson(string url, string body)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
var url = UrlForReq(reqEnum, param);
var content = new StringContent(body, System.Text.Encoding.UTF8, "application/json");
var res = await client.PostAsync(url, content);

Expand All @@ -119,17 +119,30 @@ public static async Task<string> PostForJson(ReqEnum reqEnum, string body, strin
}
}

/// <summary>Dohvata (POST) JSON podatke od JISP WebAPI-a.</summary>
public static async Task<string> PostForJson(ReqEnum reqEnum, string body, string param = null)
{
return await PostForJson(UrlForReq(reqEnum, param), body);
}

/// <summary>Dohvata (POST) trazeni objekat od JISP WebAPI-a.</summary>
public async static Task<T> PostForObject<T>(ReqEnum reqEnum, string param = null)
{
var json = await PostForJson(reqEnum, param);
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
}

///// <summary>Dohvata (POST) listu trazenih objekata od JISP WebAPI-a.</summary>
//public async static Task<List<T>> PostForList<T>(ReqEnum reqEnum, string body, string param = null)
//{
// var json = await PostForJson(reqEnum, body, param);
// return DeserializeList<T>(json);
//}

/// <summary>Dohvata (POST) listu trazenih objekata od JISP WebAPI-a.</summary>
public async static Task<List<T>> PostForList<T>(ReqEnum reqEnum, string body, string param = null)
public async static Task<List<T>> PostForList<T>(string url, string body)
{
var json = await PostForJson(reqEnum, body, param);
var json = await PostForJson(url, body);
return DeserializeList<T>(json);
}

Expand Down
Loading

0 comments on commit cefb20a

Please sign in to comment.