Beispiel #1
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);
        }
Beispiel #2
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);
            }
        }