public bool ControlloCarenzeMagazzino(string conNection, string percorso) //string percorso = Server.MapPath("~/");
        {
            var conn = new MailUtilityCon();
            var lst  = conn.GetMaterialiMancantiCon(conNection);

            if (lst.Count > 0)
            {
                _proccessSmsQueueTask = Task.Run(() => DoWorkAsync(lst, percorso, lst.Count, conNection));
            }
            return(true);
        }
        public void OnTimer(object sender, ElapsedEventArgs args)
        {
            // TODO: Insert monitoring activities here.
            //eventLog1.WriteEntry("Monitoring the System", EventLogEntryType.Information, eventId++);
            DateTime now = DateTime.Now;

            if (now.Hour > 6 && now.Hour < 20)
            {
                try
                {
                    var r = new MailUtilityCon();
                    r.ControlloCarenzeMagazzino(conNection, "");
                }
                catch (Exception)
                {
                }
            }
        }
        protected override void OnStart(string[] args)
        {
            try
            {
                var r = new MailUtilityCon();
                r.ControlloCarenzeMagazzino(conNection, "");
            }
            catch (Exception)
            {
            }

            Timer timer = new Timer();

            timer.Interval = Convert.ToDouble(360000); // 360000 seconds = 1 Ora
            timer.Elapsed += new ElapsedEventHandler(this.OnTimer);
            timer.Start();

            //eventLog1.WriteEntry("In OnStart.");
        }