Ejemplo n.º 1
0
        /// <summary>
        /// Notifica evento al SubScriber
        /// </summary>
        /// <param name="channelRef"></param>
        /// <param name="logInfo"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected virtual Subscriber.Proxy.ListenerResponse NotifyEvent(ChannelRefInfo channelRef, VtDocs.LogInfo logInfo, Subscriber.Proxy.PublishedObject obj)
        {
            logger.Debug("Start. " + channelRef.ChannelName);
            Subscriber.Proxy.EventInfo eventInfo = new Subscriber.Proxy.EventInfo
            {
                EventName = logInfo.EventCode,
                EventDate = DateTime.Now,
                Author    = new Subscriber.Proxy.EventAuthorInfo
                {
                    Name     = logInfo.UserName,
                    RoleName = logInfo.RoleDescription
                },
                PublishedObject = obj
            };
            logger.DebugFormat("Eventname: {0}, Eventdate: {1}, Author user: {2}, Role {3}", eventInfo.EventName, eventInfo.EventDate.ToString(), eventInfo.Author.Name, eventInfo.Author.RoleName);
            Subscriber.Proxy.ListenerResponse response = null;

            Subscriber.Proxy.ChannelInfo channelInfo = null;

            using (Subscriber.Proxy.SubscriberWebService subscriber = new Subscriber.Proxy.SubscriberWebService())
            {
                subscriber.Url = channelRef.SubscriberServiceUrl;
                logger.DebugFormat("Sub Url: {0}. Prelievo canali", subscriber.Url);
                Subscriber.Proxy.ChannelInfo[] channels = subscriber.GetChannelList();

                if (channels != null)
                {
                    logger.Debug("Channel trovati. N " + channels.Length + "");
                    for (int i = 0; i < channels.Length; i++)
                    {
                        logger.Debug(channels[i].Name);
                    }
                    channelInfo = channels.Where(e => e.Name == channelRef.ChannelName).First();

                    if (channelInfo == null)
                    {
                        // Istanza di pubblicazione non trovata nel subscriber collegato
                        logger.Debug("Istanza di pubblicazione non trovata nel subscriber collegato");
                        throw new PublisherException(ErrorCodes.PUBLISH_CHANNEL_NOT_FOUND, ErrorDescriptions.PUBLISH_CHANNEL_NOT_FOUND);
                    }
                }
                logger.Debug("Chiamo il notify Event");
                response = subscriber.NotifyEvent(
                    new Subscriber.Proxy.ListenerRequest
                {
                    ChannelInfo = channelInfo,
                    EventInfo   = eventInfo
                }
                    );
            }

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdInstances_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                this.grdInstances.EditItemIndex = e.Item.ItemIndex;

                this.FetchInstances();

                Label lblId = (Label)e.Item.FindControl("lblId");

                if (!string.IsNullOrEmpty(lblId.Text))
                {
                    this.FetchRules(Convert.ToInt32(lblId.Text));
                }
            }
            else if (e.CommandName == "Edit")
            {
            }
            else if (e.CommandName == "Update")
            {
                Label lblId = (Label)e.Item.FindControl("lblId");

                int id = Convert.ToInt32(lblId.Text);

                using (Subscriber.Proxy.SubscriberWebService da = this.CreateService())
                {
                    Subscriber.Proxy.ChannelInfo instance = new Subscriber.Proxy.ChannelInfo();
                    instance.Id           = id;
                    instance.Name         = ((TextBox)e.Item.FindControl("txtName")).Text;
                    instance.Description  = ((TextBox)e.Item.FindControl("txtDescription")).Text;
                    instance.SmtpHost     = ((TextBox)e.Item.FindControl("txtSmtpHost")).Text;
                    instance.SmtpPort     = Convert.ToInt32(((TextBox)e.Item.FindControl("txtSmtpPort")).Text);
                    instance.SmtpSsl      = ((CheckBox)e.Item.FindControl("txtSmtpSsl")).Checked;
                    instance.SmtpUserName = ((TextBox)e.Item.FindControl("txtSmtpUserName")).Text;
                    instance.SmtpPassword = ((TextBox)e.Item.FindControl("txtSmtpPassword")).Text;
                    instance.SmtpMail     = ((TextBox)e.Item.FindControl("txtSmtpMail")).Text;

                    instance = da.SaveChannel(instance);
                }

                this.grdInstances.EditItemIndex = -1;

                this.FetchInstances();
            }
            else if (e.CommandName == "Delete")
            {
                Label lblId = (Label)e.Item.FindControl("lblId");

                int id = Convert.ToInt32(lblId.Text);

                using (Subscriber.Proxy.SubscriberWebService da = this.CreateService())
                {
                    da.DeleteChannel(id);
                }

                this.FetchInstances();
            }
            else if (e.CommandName == "Cancel")
            {
                this.grdInstances.EditItemIndex = -1;

                this.FetchInstances();
            }
        }