/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void Publish(object sender, Schedule.ScheduledEventArgs e) { logger.Debug("START Publish"); string disabled = System.Configuration.ConfigurationManager.AppSettings["PUBLISHER_DISABLED"].ToString().ToLower(); if (!string.IsNullOrEmpty(disabled)) { bool disa = false; Boolean.TryParse(disabled, out disa); if (disa) { logger.Debug("Publisher disabled [PUBLISHER_DISABLED] key is set to true, to enable it, remove key or set to false"); return; } } // Esecuzione di ogni singolo task schedulato ChannelRefInfo channel = (ChannelRefInfo)sender; // Reperimento dati dell'istanza channel = DataAccess.PublisherDataAdapter.GetChannel(channel.Id); // Aggiornamento stato istanza RefreshChannelState(channel); logger.DebugFormat("Canale {0} stato {1}", channel.ChannelName, channel.State.ToString()); if (channel.State == ChannelStateEnum.Started) { Mutex mutex = null; try { logger.Debug("chiamo CreateMutex"); // Creazione o reperimento del mutex mutex = CreateMutex(channel); logger.DebugFormat("Mutex Chiamato"); if (mutex.WaitOne()) { logger.Debug("Pubblicazione Canale"); // Pubblicazione istanza IInstancePublisher publisher = new VtDocs.InstancePublisher(); publisher.Publish(channel); logger.Debug("Canale Pubblicato"); } } catch (Exception ex) { throw ex; } finally { if (mutex != null) { mutex.ReleaseMutex(); mutex.Close(); mutex = null; logger.Debug("Mutex Rimosso"); } } } }
public bool GetParameterValue(ParameterInfo pi, int ParameterLoc, ref object parameter) { switch (pi.ParameterType.Name.ToLower()) { case "datetime": parameter = _time; return(true); case "object": parameter = _sender; return(true); case "scheduledeventargs": parameter = new ScheduledEventArgs(_time); return(true); case "eventargs": parameter = new ScheduledEventArgs(_time); return(true); } return(false); }