using SteamWare;
using System;
using System.Configuration;

namespace NKC_WF.WebUserControls
{
    public partial class cmp_footer : BaseUserControl
    {
        public event EventHandler eh_doRefresh;
        protected void Page_Load(object sender, EventArgs e)
        {
            // sistemo le stringhe...
            lblApp.Text = string.Format("<b>{0}</b> v.{1}", ConfigurationManager.AppSettings.Get("appName"), System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
            setTimer();
            setClock();
        }
        /// <summary>
        /// imposta il tempo di scadenza del timer x il refresh della pagina (della parte top) per evitare che la sessione sul server scada
        /// </summary>
        private void setTimer()
        {
            Timer1.Interval = SteamWare.memLayer.ML.confReadInt("intUpdatePagina_ms");
        }
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            setClock();
            // se qualcuno ascolta sollevo evento nuovo valore...
            if (eh_doRefresh != null)
            {
                eh_doRefresh(this, new EventArgs());
            }
        }

        private void setClock()
        {
            lblDateTime.Text = DateTime.Now.ToString("ddd dd.MM.yyyy, HH:mm:ss");
            lblCodOperatore.Text = $"{user_std.UtSn.CognomeNome} ({Page.User.Identity.Name})";
        }
    }
}