示例#1
0
 /// <summary>
 /// Caricamento canali
 /// </summary>
 private void Fetch()
 {
     using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
     {
         this.grdChannels.DataSource = ws.GetAdminChannelList(this.IdAdmin);
         this.grdChannels.DataBind();
     }
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idInstance"></param>
        private void FetchEvents(int idInstance)
        {
            using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
            {
                ws.Url = Properties.Settings.Default.PublisherWebServices;

                this.grdEvents.DataSource = ws.GetEventList(idInstance);
                this.grdEvents.DataBind();
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        private void Fetch()
        {
            using (Publisher.Proxy.PublisherWebService ws = new Publisher.Proxy.PublisherWebService())
            {
                ws.Url = Properties.Settings.Default.PublisherWebServices;

                this.grdInstances.DataSource = ws.GetAdminChannelList(this.IdAdmin);
                this.grdInstances.DataBind();
            }
        }
示例#4
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;
            }
        }
示例#5
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();
            }
        }
示例#6
0
 /// <summary>
 /// Avvio del canale di pubblicazione su un server remoto
 /// </summary>
 /// <param name="channelRef"></param>
 /// <param name="publisherServiceUrl"></param>
 private static void StartRemoteChannel(ChannelRefInfo channelRef, string publisherServiceUrl)
 {
     try
     {
         using (Publisher.Proxy.PublisherWebService realWs = CreatePublisherInstance(publisherServiceUrl))
         {
             realWs.StartChannelById(channelRef.Id);
         }
     }
     catch (PublisherException pubEx)
     {
         throw pubEx;
     }
     catch (Exception ex)
     {
         throw new PublisherException(ErrorCodes.START_CHANNEL_ON_REMOTE_SERVER_ERROR,
                                      string.Format(ErrorDescriptions.START_CHANNEL_ON_REMOTE_SERVER_ERROR, ex.ToString()));
     }
 }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void PerformActionDeleteEvent(DataGridCommandEventArgs e)
        {
            Publisher.Proxy.EventInfo eventInfo = this.GetEvent(this.GetEventId(e.Item));

            using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
            {
                eventInfo = ws.RemoveEvent(eventInfo);
            }

            this.SelectedChannel = this.GetChannel(this.SelectedChannel.Id);

            // Reperimento id del canale di pubblicazione selezionato
            //int idChannel = this.GetChannelId(this.grdChannels.SelectedItem);

            this.grdEvents.CurrentPageIndex = 0;
            this.grdEvents.EditItemIndex    = -1;
            this.grdEvents.SelectedIndex    = -1;

            this.FetchEvents(this.SelectedChannel.Id);
        }
示例#8
0
        /// <summary>
        /// Azione di salvataggio dei dati
        /// </summary>
        public Publisher.Proxy.ChannelRefInfo SaveData()
        {
            this.Channel.SubscriberServiceUrl = this.txtSubscriberUrl.Text;
            this.Channel.ChannelName          = this.cboSubscribers.SelectedItem.Text;

            DateTime date;

            if (DateTime.TryParse(this.txtComputeFrom.Text, out date))
            {
                date = date.Add(this.txtComputeFromTime.GetTimeSpan());

                this.Channel.StartLogDate = date;
            }

            this.Channel.ExecutionConfiguration = this.GetExecutionConfigurations();

            using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
            {
                this.Channel = ws.SaveChannel(this.Channel);
            }

            return(this.Channel);
        }
示例#9
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));
 }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void PerformActionUpdateEvent(DataGridCommandEventArgs e)
        {
            int eventId = this.GetEventId(e.Item);

            Publisher.Proxy.EventInfo eventInfo = null;

            if (eventId > 0)
            {
                // Reperimento evento
                eventInfo = this.SelectedChannel.Events.Where(itm => itm.Id == eventId).First();
            }
            else
            {
                // Nuovo evento
                eventInfo = new Publisher.Proxy.EventInfo {
                    IdChannel = this.SelectedChannel.Id
                };
            }

            eventInfo.ObjectType         = this.GetObjectTypesDropDown(e.Item).SelectedValue;
            eventInfo.ObjectTemplateName = this.GetObjectTemplatesDropDown(e.Item).SelectedValue;
            eventInfo.EventName          = this.GetObjectLogsDropDown(e.Item).SelectedValue;

            if (eventInfo.ObjectType == ObjectTypes.DOCUMENTO)
            {
                CheckBox chkLoadFile = (CheckBox)e.Item.FindControl("chkLoadFile");
                eventInfo.LoadFileIfDocumentType = chkLoadFile.Checked;
            }

            // Aggiornamento dati
            using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
                eventInfo = ws.SaveEvent(eventInfo);

            this.SelectedChannel = this.GetChannel(this.SelectedChannel.Id);

            // Aggiornamento eventi

            this.grdEvents.EditItemIndex = -1;
            this.grdEvents.SelectedIndex = -1;

            // Caricamento eventi
            this.FetchEvents(this.SelectedChannel.Id);


            //int idChannel = this.GetChannelId(this.grdChannels.SelectedItem);

            //int eventId = this.GetEventId(e.Item);

            //Publisher.Proxy.EventInfo eventInfo = null;

            //if (eventId > 0)
            //{
            //    // Reperimento evento
            //    eventInfo = this.GetEvent(this.GetEventId(e.Item));
            //}
            //else
            //{
            //    // Nuovo evento
            //    eventInfo = new Publisher.Proxy.EventInfo { IdChannel = idChannel };
            //}

            //eventInfo.ObjectType = this.GetObjectTypesDropDown(e.Item).SelectedValue;
            //eventInfo.ObjectTemplateName = this.GetObjectTemplatesDropDown(e.Item).SelectedValue;
            //eventInfo.EventName = this.GetObjectLogsDropDown(e.Item).SelectedValue;

            //if (eventInfo.ObjectType == ObjectTypes.DOCUMENTO)
            //{
            //    CheckBox chkLoadFile = (CheckBox) e.Item.FindControl("chkLoadFile");
            //    eventInfo.LoadFileIfDocumentType = chkLoadFile.Checked;
            //}

            //// Aggiornamento dati
            //using (Publisher.Proxy.PublisherWebService ws = PublisherServiceFactory.Create())
            //    eventInfo = ws.SaveEvent(eventInfo);

            //// Aggiornamento eventi



            //this.grdEvents.EditItemIndex = -1;
            //this.grdEvents.SelectedIndex = -1;

            //// Caricamento eventi
            //this.FetchEvents(idChannel);
        }
示例#11
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);
                }
            }
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdEvents_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            int id;

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

            int idInstance;

            Int32.TryParse(((Label)e.Item.FindControl("lblIdInstance")).Text, out idInstance);

            if (e.CommandName == "Select")
            {
                this.grdEvents.EditItemIndex = e.Item.ItemIndex;

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

                    Publisher.Proxy.EventInfo ev = ws.GetEvent(id);
                    ev = ws.RemoveEvent(ev);

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

                    Publisher.Proxy.EventInfo ev = null;

                    if (id != 0)
                    {
                        ev = ws.GetEvent(id);
                    }
                    else
                    {
                        Int32.TryParse(((Label)this.grdInstances.SelectedItem.FindControl("lblId")).Text, out idInstance);

                        ev = new Proxy.EventInfo
                        {
                            IdChannel = idInstance
                        };
                    }

                    ev.ObjectType             = ((TextBox)e.Item.FindControl("txtObjectType")).Text;
                    ev.ObjectTemplateName     = ((TextBox)e.Item.FindControl("txtObjectTemplateName")).Text;
                    ev.EventName              = ((TextBox)e.Item.FindControl("txtEventName")).Text;
                    ev.DataMapperFullClass    = ((TextBox)e.Item.FindControl("txtDataMapper")).Text;
                    ev.LoadFileIfDocumentType = ((CheckBox)e.Item.FindControl("chkLoadFile")).Checked;

                    ev = ws.SaveEvent(ev);

                    this.grdEvents.EditItemIndex = -1;
                    this.FetchEvents(idInstance);
                }
            }
            else if (e.CommandName == "Cancel")
            {
                this.grdEvents.EditItemIndex = -1;
                this.FetchEvents(idInstance);
            }
        }
示例#13
0
 /// <summary>
 /// Creazione servizio per la pubblicazione
 /// </summary>
 /// <returns></returns>
 public static Publisher.Proxy.PublisherWebService Create()
 {
     Publisher.Proxy.PublisherWebService instance = new Publisher.Proxy.PublisherWebService();
     instance.Url = ServiceUrl;
     return(instance);
 }
示例#14
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");
        }
示例#15
0
        /// <summary>
        /// Sospende l'esecuzione di un canale di pubblicazione
        /// </summary>
        /// <param name="channelRef"></param>
        public static void StopChannel(ChannelRefInfo channelRef)
        {
            //DocsPaUtils.LogsManagement.Debugger.Write("StopChannel - INIT");

            // Aggiornamento stato del canale
            RefreshChannelState(channelRef);

            if (channelRef.State == ChannelStateEnum.Started ||
                channelRef.State == ChannelStateEnum.UnexpectedStopped)
            {
                // Il canale di pubblicazione risulta avviato su un server diverso da quello attuale
                if (string.Compare(channelRef.MachineName, ApplicationContext.GetMachineName(), false) != 0)
                {
                    // Si sta tentando di fermare un canale di pubblicazione avviato da un altro computer.
                    // Viene richiamato il servizio di pubblicazione da cui è stato avviato per fermarne correttamente lo stato.
                    using (Publisher.Proxy.PublisherWebService realWs = CreatePublisherInstance(channelRef.PublisherServiceUrl))
                    {
                        try
                        {
                            // Fermo del canale nel server di pubblicazione in cui risulta avviato
                            realWs.StopChannelById(channelRef.Id);
                        }
                        catch (PublisherException pubEx)
                        {
                            throw pubEx;
                        }
                        catch (Exception ex)
                        {
                            //DocsPaUtils.LogsManagement.Debugger.Write(ex);

                            // Si è verificato un errore, il server remoto di pubblicazione non risulta raggiungibile,
                            // pertanto viene forzato lo stato di fermo del servizio sul database
                            using (DocsPaDB.TransactionContext tx = new DocsPaDB.TransactionContext())
                            {
                                channelRef = DataAccess.PublisherDataAdapter.StopService(channelRef);

                                tx.Complete();
                            }

                            //throw new PublisherException(ErrorCodes.STOP_CHANNEL_ON_REMOTE_SERVER_ERROR,
                            //                            string.Format(ErrorDescriptions.STOP_CHANNEL_ON_REMOTE_SERVER_ERROR, ex.ToString()));
                        }
                    }
                }
                else
                {
                    using (DocsPaDB.TransactionContext tx = new DocsPaDB.TransactionContext())
                    {
                        // Impostazione dello stato di fermo del servizio
                        channelRef = DataAccess.PublisherDataAdapter.StopService(channelRef);

                        StopTimer(channelRef);

                        tx.Complete();
                    }
                }
            }
            else
            {
                // L'istanza risulta già fermata
                throw new PublisherException(ErrorCodes.OPERATION_NOT_ALLOWED_PER_SERVICE_STOPPED, ErrorDescriptions.OPERATION_NOT_ALLOWED_PER_SERVICE_STARTED);
            }

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