コード例 #1
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;
            }
        }
コード例 #2
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();
            }
        }
コード例 #3
0
 /// <summary>
 /// Reperimento dati canale di pubblicazione
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 private Publisher.Proxy.ChannelRefInfo GetChannel(int id)
 {
     using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
         return(ws.GetChannel(id));
 }
コード例 #4
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);
                }
            }
        }
コード例 #5
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");
        }