Example #1
0
        public static prevent.verifica.Out MakeDelete(string codice)
        {
            UltimoErrore = null;

            PreventWebServices.WebReferencePrevent.WSPreventService wsp = new PreventWebServices.WebReferencePrevent.WSPreventService();
            string risposta = string.Empty;

            try
            {
                string richiesta = string.Format(@"<?xml version='1.0' encoding='utf-8'?><Parametri CodiceTransWinTicket=""{0}""></Parametri>", codice);

                Console.WriteLine("WS_URL: " + wsp.Url);

                risposta = wsp.delete("WinTicket", WsConfig.Username, WsConfig.Password, richiesta);
            }
            catch (Exception ex)
            {
                UltimoErrore = new prevent.verifica.Out();
                UltimoErrore.DescrizioneErrore = string.Format("Risposta non corretta dal servizio remoto: {0}: {1}", ex.Source, ex.Message);
                UltimoErrore.ReturnCode        = "997";

                risposta = string.Empty;
            }

            if (!string.IsNullOrEmpty(risposta))
            {
                Console.WriteLine(risposta);

                try
                {
                    MemoryStream         stream = new MemoryStream(Encoding.UTF8.GetBytes(risposta));
                    XmlSerializer        xml    = new XmlSerializer(typeof(prevent.verifica.Out));
                    prevent.verifica.Out dati   = (prevent.verifica.Out)xml.Deserialize(stream);

                    if (dati.ReturnCode == "00" || dati.ReturnCode == "51" || dati.ReturnCode == "52")
                    {
                        return(dati);
                    }
                    else
                    {
                        UltimoErrore = dati;
                    }
                }
                catch (Exception ex)
                {
                    UltimoErrore = new prevent.verifica.Out();
                    UltimoErrore.DescrizioneErrore = String.Format("Risposta non corretta dal servizio remoto: {0} ({1})", (risposta.Length < 200 ? risposta : string.Empty), ex.Message);
                    UltimoErrore.ReturnCode        = "996";
                }
            }

            return(null);
        }
Example #2
0
        private static void TaskAsincrono(object data)
        {
            RichiestaVerifica item = (RichiestaVerifica)data;

            try
            {
                PreventWebServices.WebReferencePrevent.WSPreventService wsp = new PreventWebServices.WebReferencePrevent.WSPreventService();
                item.XmlRisposta = wsp.book("WinTicket", WsConfig.Username, WsConfig.Password, "V", item.XmlRichiesta);
                //item.XmlRisposta = wsp.book("WinTicket", "Luca", "3292285430", "V", item.XmlRichiesta);
                item.DataRisposta = DateTime.Now;

                Console.WriteLine(item.XmlRichiesta);
                Console.WriteLine(item.XmlRisposta);

                MemoryStream         stream   = new MemoryStream(Encoding.UTF8.GetBytes(item.XmlRisposta));
                XmlSerializer        xml      = new XmlSerializer(typeof(prevent.verifica.Out));
                prevent.verifica.Out risposta = (prevent.verifica.Out)xml.Deserialize(stream);

                item.CodiceErrore = risposta.DescrizioneErrore;
                if (risposta.ReturnCode == "00")
                {
                    item.Disponibile = true;
                }
                else
                {
                    item.Disponibile = false;
                }
            }
            catch (Exception ex)
            {
                item.CodiceErrore = ex.Message;
                item.XmlRisposta  = string.Empty;
                item.DataRisposta = DateTime.Now;
                item.Disponibile  = false;
            }

            lock (SyncRoot)
            {
                Elenco.Add(item);
            }
        }
Example #3
0
        public static bool Prenota(prevent.prenotazione.Parametri parametri, prevent.get.Out vecchiaprenotazione)
        {
            UltimoErrore = null;
            PreventWebServices.WebReferencePrevent.WSPreventService wsp = new PreventWebServices.WebReferencePrevent.WSPreventService();
            string richiesta = GetXmlRichiesta(parametri);

            if (vecchiaprenotazione != null)
            {
                richiesta = GetXmlRichiesta(CreaUpdate(parametri, vecchiaprenotazione));
            }
            string risposta = string.Empty;

            try
            {
                if (vecchiaprenotazione != null)
                {
                    risposta = wsp.book("WinTicket", WsConfig.Username, WsConfig.Password, "U", richiesta);
                }
                else
                {
                    risposta = wsp.book("WinTicket", WsConfig.Username, WsConfig.Password, "P", richiesta);
                }
            }
            catch (Exception)
            {
                risposta = string.Empty;
            }

            Console.WriteLine(richiesta);
            Console.WriteLine(risposta);

            parametri.CodiceTransWinTicket = string.Empty;

            if (risposta.Contains(@"ReturnCode=""00"""))
            {
                if (vecchiaprenotazione != null)
                {
                    parametri.CodiceTransWinTicket = vecchiaprenotazione.NumeroPrenotazione;
                }
                else
                {
                    int len1 = @"<NumeroPrenotazione>".Length;
                    int pos1 = risposta.IndexOf(@"<NumeroPrenotazione>");
                    int pos2 = risposta.IndexOf(@"</NumeroPrenotazione>");

                    parametri.CodiceTransWinTicket = risposta.Substring(pos1 + len1, pos2 - pos1 - len1);

                    Console.WriteLine(String.Format("PRENOTAZIONE:[{0}]", parametri.CodiceTransWinTicket));
                }

                return(true);
            }
            else
            {
                if (!string.IsNullOrEmpty(risposta))
                {
                    // errore
                    MemoryStream  stream = new MemoryStream(Encoding.UTF8.GetBytes(risposta));
                    XmlSerializer xml    = new XmlSerializer(typeof(prevent.verifica.Out));
                    UltimoErrore = (prevent.verifica.Out)xml.Deserialize(stream);
                }

                return(false);
            }
        }
Example #4
0
        public static prevent.get.Out MakeGet()
        {
            UltimoErrore = null;

            PreventWebServices.WebReferencePrevent.WSPreventService wsp = new PreventWebServices.WebReferencePrevent.WSPreventService();
            string risposta = string.Empty;

            try
            {
                Console.WriteLine("WS_URL: " + wsp.Url);
                risposta = wsp.book("WinTicket", WsConfig.Username, WsConfig.Password, "G", string.Empty);
            }
            catch (Exception ex)
            {
                UltimoErrore = new prevent.verifica.Out();
                UltimoErrore.DescrizioneErrore = string.Format("Risposta non corretta dal servizio remoto: {0}: {1}", ex.Source, ex.Message);
                UltimoErrore.ReturnCode        = "998";

                risposta = string.Empty;
            }

            if (!string.IsNullOrEmpty(risposta))
            {
                Console.WriteLine(risposta);
                risposta = risposta.Replace("+01:00", string.Empty);
                risposta = risposta.Replace("+02:00", string.Empty);

                try
                {
                    if (!risposta.Contains("ReturnCode"))
                    {
                        MemoryStream    stream = new MemoryStream(Encoding.UTF8.GetBytes(risposta));
                        XmlSerializer   xml    = new XmlSerializer(typeof(prevent.get.Out));
                        prevent.get.Out dati   = (prevent.get.Out)xml.Deserialize(stream);

                        dati.MostraTipo = "0";

                        var mostra = new int[] { 277, 278, 279 };

                        foreach (var num in mostra)
                        {
                            if (risposta.Contains(string.Format("<IdTipoBiglietto>{0}</IdTipoBiglietto>", num)))
                            {
                                dati.MostraTipo = "1";
                            }
                        }

                        return(dati);
                    }
                    else
                    {
                        // errore
                        MemoryStream  stream = new MemoryStream(Encoding.UTF8.GetBytes(risposta));
                        XmlSerializer xml    = new XmlSerializer(typeof(prevent.verifica.Out));
                        UltimoErrore = (prevent.verifica.Out)xml.Deserialize(stream);
                    }
                }
                catch (Exception ex)
                {
                    UltimoErrore = new prevent.verifica.Out();
                    UltimoErrore.DescrizioneErrore = String.Format("Risposta non corretta dal servizio remoto: {0} ({1})", (risposta.Length < 200 ? risposta : string.Empty), ex.Message);
                    UltimoErrore.ReturnCode        = "999";
                }
            }

            return(null);
        }
        private void barButtonItemAnnulla_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!m_Vendita.PossoEliminarla())
            {
                XtraMessageBox.Show("Non puoi eliminare questa vendita perchè è già stata inserita in un report contabile.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!Program.UtenteCollegato.Amministratore)
            {
                if (m_Vendita.Postazione.Oid != Program.Postazione.Oid)
                {
                    XtraMessageBox.Show("Non puoi eliminare questa vendita perchè è stata effettuata da un'altra postazione e non sei amministratore.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (m_Vendita.EsistonoCardMyFE())
            {
                if (XtraMessageBox.Show("Attenzione, esistono delle Card MyFE associate a questa vendita. Vuoi proseguire ugualmente (IMPLICA IL RECUPERO DELLE CARD) ?", "Conferma", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
            }

            if (m_Vendita.EsistonoEntrate())
            {
                if (XtraMessageBox.Show("Attenzione, esistono delle entrate associate a questa vendita. Vuoi proseguire ugualmente ?", "Conferma", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
            }

            if (XtraMessageBox.Show(string.Format("Confermi l'eliminazione di TUTTA la vendita ({0:c} persone {1}) ?", m_Vendita.TotaleImporto, m_Vendita.TotalePersone), "Conferma", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (string.IsNullOrEmpty(m_Vendita.CodicePrevent))
                {
                    using (Session delSession = new Session())
                    {
                        Vendita toDelete = delSession.GetObjectByKey <Vendita>(m_Vendita.Oid);
                        if (toDelete != null)
                        {
                            Messaggio msg = new Messaggio(delSession);
                            msg.Autore       = delSession.GetObjectByKey <Utente>(Program.UtenteCollegato.Oid);
                            msg.Data         = DateTime.Now;
                            msg.Oggetto      = "Eliminazione " + toDelete.CodiceLeggibile;
                            msg.TestoEsteso  = String.Format("L'utente {0} ha eliminato la vendita {1} di importo totale {2:c} dalla postazione {3}.", Program.UtenteCollegato.FullName, toDelete.CodiceLeggibile, toDelete.TotaleImporto, Program.Postazione.Nome);
                            msg.TestoEsteso += Descrizione(toDelete);
                            msg.Tipologia    = EnumTipoMessaggio.Eliminazione;
                            msg.Save();

                            toDelete.EliminaVendita();
                        }
                    }

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    if (XtraMessageBox.Show(string.Format("La prenotazione {0} verrà ripristinata al suo stato originario. Vuoi proseguire ?", m_Vendita.CodicePrevent), "Conferma", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        // RIPRISTINO PRENOTAZIONE
                        prevent.verifica.Out obj = RichiestaDelete.MakeDelete(m_Vendita.CodiceLeggibile);
                        if (obj != null && (obj.ReturnCode == "00" || obj.ReturnCode == "51" || obj.ReturnCode == "52"))
                        {
                            using (Session delSession = new Session())
                            {
                                Vendita toDelete = delSession.GetObjectByKey <Vendita>(m_Vendita.Oid);
                                if (toDelete != null)
                                {
                                    Messaggio msg = new Messaggio(delSession);
                                    msg.Autore       = delSession.GetObjectByKey <Utente>(Program.UtenteCollegato.Oid);
                                    msg.Data         = DateTime.Now;
                                    msg.Oggetto      = String.Format("Eliminazione {0} con prenotazione {1}", toDelete.CodiceLeggibile, toDelete.CodicePrevent);
                                    msg.TestoEsteso  = String.Format("L'utente {0} ha eliminato la vendita {1} di importo totale {2:c} dalla postazione {3} associata alla prenotazione {4}.", Program.UtenteCollegato.FullName, toDelete.CodiceLeggibile, toDelete.TotaleImporto, Program.Postazione.Nome, toDelete.CodicePrevent);
                                    msg.TestoEsteso += Descrizione(toDelete);
                                    msg.Tipologia    = EnumTipoMessaggio.EliminazioneConPrenotazione;
                                    msg.Save();

                                    toDelete.EliminaVendita();
                                }
                            }

                            DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            XtraMessageBox.Show(
                                String.Format("Errore: {0}", RichiestaDelete.UltimoErrore.DescrizioneErrore,
                                              String.Format("Errore Web: {0}", RichiestaDelete.UltimoErrore.ReturnCode), MessageBoxButtons.OK, MessageBoxIcon.Error));
                        }
                    }
                }
            }
        }