118 lines
2.4 KiB
C#
118 lines
2.4 KiB
C#
using MapoDb;
|
|
using MapoSDK;
|
|
using Newtonsoft.Json;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace ES3.WebUserControls
|
|
{
|
|
public partial class cmp_calStop : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// URL di base x chiamate remote
|
|
/// </summary>
|
|
protected string remoteApi = memLayer.ML.CRS("remoteApi");
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
setLimitDDl();
|
|
}
|
|
}
|
|
private void setLimitDDl()
|
|
{
|
|
int anno = DateTime.Now.Year;
|
|
hfMinAnno.Value = anno.ToString();
|
|
hfMaxAnno.Value = (anno + 3).ToString();
|
|
}
|
|
/// <summary>
|
|
/// Dim pagina
|
|
/// </summary>
|
|
public int pageSize
|
|
{
|
|
get
|
|
{
|
|
return grView.PageSize;
|
|
}
|
|
set
|
|
{
|
|
grView.PageSize = value;
|
|
doUpdate();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Forza update controllo
|
|
/// </summary>
|
|
public void doUpdate()
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Anno selezionato
|
|
/// </summary>
|
|
public int anno
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(ddlAnno.SelectedValue, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
ddlAnno.SelectedValue = value.ToString();
|
|
grView.DataBind();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Anno selezionato
|
|
/// </summary>
|
|
public int mese
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(ddlMese.SelectedValue, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
ddlMese.SelectedValue = value.ToString();
|
|
grView.DataBind();
|
|
}
|
|
}
|
|
|
|
protected void lbtGetHolidays_Click(object sender, EventArgs e)
|
|
{
|
|
// scarico elenco da web
|
|
string remoteUrl = $"{remoteApi}api/Holiday/{anno}";
|
|
// chiamo
|
|
string rawResult = ES3.callUrl(remoteUrl);
|
|
if (!string.IsNullOrEmpty(rawResult))
|
|
{
|
|
// deserializzo
|
|
//var elenco = JsonConvert.DeserializeObject<List<EventDetail>>(rawResult);
|
|
var elenco = MSDK_utils.deserEvDetString(rawResult);
|
|
if (elenco.Count > 0)
|
|
{
|
|
foreach (var item in elenco)
|
|
{
|
|
// upsert!
|
|
DataLayer.obj.taPlanCalStop.upsert(item.when, "", item.what);
|
|
}
|
|
}
|
|
|
|
}
|
|
// update!
|
|
doUpdate();
|
|
}
|
|
|
|
}
|
|
} |