Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        protected string GetServiceState(Publisher.Proxy.ChannelRefInfo instance)
        {
            string serviceState = string.Empty;

            if (instance.State == Publisher.Proxy.ChannelStateEnum.Started)
            {
                serviceState = string.Format("Servizio avviato dal: {0}<BR />Server: {1}<BR />Ultima pubbl.: {2}",
                                             instance.StartExecutionDate.ToString(),
                                             instance.MachineName,
                                             instance.LastExecutionDate.ToString());
            }
            else if (instance.State == Publisher.Proxy.ChannelStateEnum.UnexpectedStopped)
            {
                serviceState = string.Format("Servizio in stato fermo non valido<BR />Server: {0}<BR />Ultima pubbl.: {1}",
                                             instance.StartExecutionDate.ToString(),
                                             instance.MachineName,
                                             instance.LastExecutionDate.ToString());
            }
            else
            {
                serviceState = string.Format("Servizio fermato dal: {0}<BR />Ultima pubbl.: {1}",
                                             instance.EndExecutionDate.ToString(),
                                             instance.LastExecutionDate.ToString());
            }

            return(serviceState);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 protected string GetServiceStartDate(Publisher.Proxy.ChannelRefInfo instance)
 {
     if (instance.StartExecutionDate == DateTime.MinValue)
     {
         return(string.Empty);
     }
     else
     {
         return(instance.StartExecutionDate.ToString());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 protected string GetServiceState(Publisher.Proxy.ChannelRefInfo instance)
 {
     if (instance.State == Proxy.ChannelStateEnum.Started)
     {
         return("Avviato");
     }
     else
     {
         return("Fermato");
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 protected string GetExecutionInterval(Publisher.Proxy.ChannelRefInfo instance)
 {
     if (instance.Id != 0)
     {
         long ticks;
         long.TryParse(instance.ExecutionConfiguration.ExecutionTicks, out ticks);
         return(TimeSpan.FromTicks(ticks).TotalSeconds.ToString());
     }
     else
     {
         return(string.Empty);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Azione di stop del servizio di pubblicazione
        /// </summary>
        /// <param name="e"></param>
        private void PerformActionStopChannelService(DataGridCommandEventArgs e)
        {
            using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
            {
                Publisher.Proxy.ChannelRefInfo instance = ws.GetChannel(this.GetChannelId(e.Item));

                ws.StopChannel(instance);

                this.grdChannels.EditItemIndex = -1;
                this.Fetch();

                this.SelectedChannel = null;
                this.SelectedDetail  = SelectedDetailsEnum.None;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="channelRef"></param>
 /// <returns></returns>
 protected string GetServiceStateImageName(Publisher.Proxy.ChannelRefInfo channelRef)
 {
     if (channelRef.State == Publisher.Proxy.ChannelStateEnum.Started)
     {
         return("~/AdminTool/Images/started.gif");
     }
     else if (channelRef.State == Publisher.Proxy.ChannelStateEnum.UnexpectedStopped)
     {
         return("~/AdminTool/Images/unexpectedStopped.gif");
     }
     else
     {
         return("~/AdminTool/Images/stopped.gif");
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void PerformActionDeleteChannel(DataGridCommandEventArgs e)
        {
            this.SelectedChannel = null;

            using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
            {
                Publisher.Proxy.ChannelRefInfo instance = ws.GetChannel(this.GetChannelId(e.Item));

                ws.RemoveChannel(instance);

                this.grdChannels.CurrentPageIndex = 0;
                this.grdChannels.EditItemIndex    = -1;
                this.Fetch();

                this.PerformActionCloseEvents();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Azione di modifica dei dati
        /// </summary>
        /// <param name="idAdmin"></param>
        /// <param name="channel"></param>
        public void LoadData(int idAdmin, Publisher.Proxy.ChannelRefInfo channel)
        {
            this.Clear();

            this.Channel = channel;

            if (this.Channel.Id > 0)
            {
                // Modalità di modifica dati
                this.FetchSubscribers(this.Channel.SubscriberServiceUrl);
            }
            else
            {
                // Modalità di inserimento
            }

            // Caricamento dati del canale
            this.Fetch();
        }
Ejemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="channel"></param>
 /// <returns></returns>
 protected string GetTextEventsButton(Publisher.Proxy.ChannelRefInfo channel)
 {
     return(string.Format("Eventi ({0})", channel.Events.Length.ToString()));
 }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdInstances_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            int id;

            Int32.TryParse(((Label)e.Item.FindControl("lblId")).Text, out id);

            if (e.CommandName == "Select")
            {
                using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
                {
                    ws.Url = Properties.Settings.Default.PublisherWebServices;

                    this.grdInstances.EditItemIndex = e.Item.ItemIndex;
                    this.Fetch();

                    this.FetchSubscribers(this.grdInstances.Items[this.grdInstances.EditItemIndex]);

                    this.grdEvents.EditItemIndex = -1;
                    this.FetchEvents(id);
                }
            }
            else if (e.CommandName == "FetchSubscribers")
            {
                this.FetchSubscribers(e.Item);
            }
            else if (e.CommandName == "Start")
            {
                using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
                {
                    ws.Url = Properties.Settings.Default.PublisherWebServices;

                    Publisher.Proxy.ChannelRefInfo instance = ws.GetChannel(id);

                    ws.StartChannel(instance);

                    this.grdInstances.EditItemIndex = -1;
                    this.Fetch();

                    this.grdEvents.EditItemIndex = -1;
                    this.FetchEvents(id);
                }
            }
            else if (e.CommandName == "Stop")
            {
                using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
                {
                    ws.Url = Properties.Settings.Default.PublisherWebServices;

                    Publisher.Proxy.ChannelRefInfo instance = ws.GetChannel(id);

                    ws.StopChannel(instance);

                    this.grdInstances.EditItemIndex = -1;
                    this.Fetch();

                    this.grdEvents.EditItemIndex = -1;
                    this.FetchEvents(id);
                }
            }
            else if (e.CommandName == "Update")
            {
                using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
                {
                    ws.Url = Properties.Settings.Default.PublisherWebServices;

                    Publisher.Proxy.ChannelRefInfo instance = null;

                    if (id != 0)
                    {
                        instance = ws.GetChannel(id);
                    }
                    else
                    {
                        instance = new Proxy.ChannelRefInfo
                        {
                            Admin = new Proxy.AdminInfo
                            {
                                Id = this.IdAdmin
                            }
                        };
                    }

                    instance.SubscriberServiceUrl = Properties.Settings.Default.SubscriberWebServices;
                    instance.ChannelName          = ((DropDownList)e.Item.FindControl("cboSubscribers")).SelectedItem.Text;

                    TextBox txtExecutionInterval = (TextBox)e.Item.FindControl("txtExecutionInterval");
                    if (txtExecutionInterval != null)
                    {
                        int interval;
                        Int32.TryParse(txtExecutionInterval.Text, out interval);

                        instance.ExecutionConfiguration = new Proxy.JobExecutionConfigurations
                        {
                            IntervalType   = Proxy.IntervalTypesEnum.BySecond,
                            ExecutionTicks = TimeSpan.FromSeconds(interval).Ticks.ToString()
                        };
                    }

                    TextBox txtStartLogDate = (TextBox)e.Item.FindControl("txtStartLogDate");
                    if (txtStartLogDate != null)
                    {
                        DateTime startLogDate;
                        DateTime.TryParse(txtStartLogDate.Text, out startLogDate);
                        instance.StartLogDate = startLogDate;
                    }

                    instance = ws.SaveChannel(instance);

                    this.grdInstances.EditItemIndex = -1;
                    this.Fetch();

                    this.grdEvents.EditItemIndex = -1;
                    this.FetchEvents(id);
                }
            }
            else if (e.CommandName == "Delete")
            {
                using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
                {
                    ws.Url = Properties.Settings.Default.PublisherWebServices;

                    if (id != 0)
                    {
                        Publisher.Proxy.ChannelRefInfo instance = ws.GetChannel(id);

                        ws.RemoveChannel(instance);

                        this.grdInstances.EditItemIndex = -1;
                        this.Fetch();

                        this.grdEvents.EditItemIndex = -1;
                        this.FetchEvents(id);
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                this.grdInstances.EditItemIndex = -1;
                this.Fetch();

                this.grdEvents.EditItemIndex = -1;
                this.FetchEvents(id);
            }
            else if (e.CommandName == "GoToSubscriber")
            {
                Label lblSubscriberServiceUrl = (Label)e.Item.FindControl("lblSubscriberServiceUrl");

                if (lblSubscriberServiceUrl != null)
                {
                    Response.Redirect(string.Format("Subscribers.aspx?subscriberUrl={0}&idAdmin={1}&caller=Publishers.aspx",
                                                    lblSubscriberServiceUrl.Text, this.IdAdmin), false);
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Aggiornamento stato del canale di pubblicazione
        /// </summary>
        /// <param name="channelRef"></param>
        public static void RefreshChannelState(ChannelRefInfo channelRef)
        {
            //DocsPaUtils.LogsManagement.Debugger.Write("RefreshChannelState - BEGIN");

            try
            {
                if (IsChannelStartedOnRemoteMachine(channelRef))
                {
                    //DocsPaUtils.LogsManagement.Debugger.Write("RefreshChannelState - remote");

                    // Il canale di pubblicazione risulta avviato su un server remoto

                    // Creazione istanza del servizio di pubblicazione remoto
                    using (Publisher.Proxy.PublisherWebService realWs = CreatePublisherInstance(channelRef.PublisherServiceUrl))
                    {
                        Publisher.Proxy.ChannelRefInfo remoteChannel = null;

                        try
                        {
                            // Reperimento dei metadati del canale di pubblicazione
                            remoteChannel = realWs.GetChannel(channelRef.Id);
                        }
                        catch (PublisherException pubEx)
                        {
                            //DocsPaUtils.LogsManagement.Debugger.Write(pubEx);

                            throw pubEx;
                        }
                        catch (Exception ex)
                        {
                            //DocsPaUtils.LogsManagement.Debugger.Write(ex);

                            // Si è verificato un errore nell'esecuzione del servizio di pubblicazione remoto
                            remoteChannel = null;

                            channelRef.State = ChannelStateEnum.UnexpectedStopped;
                        }

                        if (remoteChannel != null)
                        {
                            // Aggiornamento dello stato del canale di pubblicazione
                            if (remoteChannel.State == Proxy.ChannelStateEnum.Started)
                            {
                                channelRef.State = ChannelStateEnum.Started;
                            }
                            else if (remoteChannel.State == Proxy.ChannelStateEnum.Stopped)
                            {
                                channelRef.State = ChannelStateEnum.Stopped;
                            }
                            else if (remoteChannel.State == Proxy.ChannelStateEnum.UnexpectedStopped)
                            {
                                channelRef.State = ChannelStateEnum.UnexpectedStopped;
                            }

                            channelRef.StartExecutionDate  = remoteChannel.StartExecutionDate;
                            channelRef.EndExecutionDate    = remoteChannel.EndExecutionDate;
                            channelRef.MachineName         = remoteChannel.MachineName;
                            channelRef.PublisherServiceUrl = remoteChannel.PublisherServiceUrl;
                        }
                    }
                }
                else
                {
                    StartedChannelTimer timer = GetTimer(channelRef.GetKey());

                    if (timer == null)
                    {
                        if (channelRef.State == ChannelStateEnum.Started &&
                            channelRef.MachineName == ApplicationContext.GetMachineName())
                        {
                            // Se il servizio risulta avviato nella base dati
                            // ma non risulta essere presente nella memoria del server,
                            // significa che è stato fermato in modo non previsto
                            // (es. il server è giù). Pertanto lo stato del servizio viene
                            // impostato a "UnexpectedStopped".
                            channelRef.State = ChannelStateEnum.UnexpectedStopped;
                        }
                    }
                    else
                    {
                        // Il timer è presente: aggiornamento dello stato del canale
                        channelRef.State = ChannelStateEnum.Started;
                        channelRef.StartExecutionDate  = timer.StartExecutionDate;
                        channelRef.EndExecutionDate    = DateTime.MinValue;
                        channelRef.MachineName         = timer.MachineName;
                        channelRef.PublisherServiceUrl = timer.PublisherServiceUrl;
                    }
                }
            }
            catch (Exception ex)
            {
                //DocsPaUtils.LogsManagement.Debugger.Write(ex);
                logger.Error(ex);
                throw new PublisherException(ErrorCodes.UNHANDLED_ERROR, ex.Message);
            }

            //DocsPaUtils.LogsManagement.Debugger.Write("RefreshChannelState - END");
        }