Ejemplo n.º 1
0
        public void read_CONORD0F()
        {
            ev.WriteEventToMyLog(Source + "Out ConOrdine", "Lettura e conversione conferma ordine", EventLogEntryType.Information, 7);

            OdbcConnection cn  = new OdbcConnection();
            OdbcCommand    cmd = new OdbcCommand();

            String ConnectionString = Properties.Settings.Default.CnStriSeries;



            cn.ConnectionString = ConnectionString;
            cmd.Connection      = cn;



            String query = @"SELECT * FROM CONORD0F";



            cmd.CommandText = query;
            cn.Open();
            OdbcDataReader rd = cmd.ExecuteReader();

            while (rd.Read())
            {
                CONORD0F row = new CONORD0F
                {
                    prefisso             = rd.GetValue(0).ToString(),
                    nOrdine              = rd.GetValue(1).ToString(),
                    dtOrdine             = rd.GetValue(2).ToString(),
                    rigOrdine            = rd.GetValue(3).ToString(),
                    articolo             = rd.GetValue(4).ToString(),
                    descrizione          = rd.GetValue(5).ToString(),
                    qta                  = rd.GetValue(6).ToString(),
                    dtConsegna           = rd.GetValue(7).ToString(),
                    original_DOCID       = rd.GetValue(8).ToString(),
                    original_DOCNR       = rd.GetValue(9).ToString(),
                    original_DOCDATA     = rd.GetValue(10).ToString(),
                    original_RIGID       = rd.GetValue(11).ToString(),
                    original_EAN         = rd.GetValue(12).ToString(),
                    original_POSSEQNBR   = rd.GetValue(13).ToString(),
                    original_POSNOSENDER = rd.GetValue(14).ToString().Replace(".", separator.ToString()).Replace(",", separator.ToString())
                };

                // HO TROVATO ORIGINAL DOC DATA VUOTO!!!
                if (row.original_DOCDATA.Trim() == String.Empty)
                {
                    row.original_DOCDATA = row.dtOrdine;
                }

                Boolean res = Serialize_ORDERSP(row);

                if (res)
                {
                    Delete_row(row.original_DOCID);
                }
            }
            cn.Close();
        }
Ejemplo n.º 2
0
        public Boolean Serialize_ORDERSP(CONORD0F ConfermaOrdine)
        {
            DateTime Consegna_DateTime = DateTime.ParseExact(ConfermaOrdine.dtConsegna, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);        //Convert.ToDateTime(ConfermaOrdine.dtConsegna.Substring(0, 4) + "." + ConfermaOrdine.dtConsegna.Substring(4, 2) + "." + ConfermaOrdine.dtConsegna.Substring(6, 2));

            DateTime docdata_datetime = DateTime.ParseExact(ConfermaOrdine.original_DOCDATA, "dd/mm/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None); // Convert.ToDateTime(ConfermaOrdine.original_DOCDATA.Substring(0, 4) + "." + ConfermaOrdine.original_DOCDATA.Substring(4, 2) + "." + ConfermaOrdine.original_DOCDATA.Substring(6, 2));

            String dataOrdrsp = String.Empty;

            DateTime dt = DateTime.Now;

            // formattazione data per nome file univoco
            dataOrdrsp = String.Format("{0:yyyy.MM.dd_HH.mm.ss.fff.zzz}", dt);
            dataOrdrsp = dataOrdrsp.Replace(":", "");

            TextWriter writer = new StreamWriter(ServicePathOut + @"Ordrsp_" + dataOrdrsp + ".xml");

            try
            {
                XmlSerializer serialize = new XmlSerializer(typeof(pAXORDRSP));

                pAXORDRSP ordersp = new pAXORDRSP();

                // primo livello
                pAXORDRSPPAXTransmissionHeader   trh = new pAXORDRSPPAXTransmissionHeader();
                pAXORDRSPPAXTransmissionSender   trs = new pAXORDRSPPAXTransmissionSender();   //
                pAXORDRSPPAXTransmissionReceiver trr = new pAXORDRSPPAXTransmissionReceiver(); // sono 2
                pAXORDRSPPAXDocumentHeader       dch = new pAXORDRSPPAXDocumentHeader();

                //secondo livello ci sono 5 address
                pAXORDRSPPAXDocumentHeaderPAXAddress      add = new pAXORDRSPPAXDocumentHeaderPAXAddress();   //ci sono 4 address
                pAXORDRSPPAXDocumentHeaderPAXReference    rfr = new pAXORDRSPPAXDocumentHeaderPAXReference();
                pAXORDRSPPAXDocumentHeaderPAXDateTimes    dtt = new pAXORDRSPPAXDocumentHeaderPAXDateTimes(); //2 datetimes
                pAXORDRSPPAXDocumentHeaderPAXTax          tax = new pAXORDRSPPAXDocumentHeaderPAXTax();
                pAXORDRSPPAXDocumentHeaderPAXCurrency     cur = new pAXORDRSPPAXDocumentHeaderPAXCurrency();
                pAXORDRSPPAXDocumentHeaderPAXIncoTerm     inc = new pAXORDRSPPAXDocumentHeaderPAXIncoTerm();
                pAXORDRSPPAXDocumentHeaderPAXShippingType sht = new pAXORDRSPPAXDocumentHeaderPAXShippingType();
                pAXORDRSPPAXDocumentHeaderPAXText         txt = new pAXORDRSPPAXDocumentHeaderPAXText();
                pAXORDRSPPAXDocumentHeaderPAXDocumentLine dcl = new pAXORDRSPPAXDocumentHeaderPAXDocumentLine();
                pAXORDRSPPAXDocumentHeaderPAXSummation    sum = new pAXORDRSPPAXDocumentHeaderPAXSummation();

                // terzo livello in document line
                pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXReference dcl_ref = new pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXReference();
                pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXDateTimes dcl_dtt = new pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXDateTimes();
                pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXSummation dcl_sum = new pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXSummation();



                ordersp.pAXTransmissionHeader    = new pAXORDRSPPAXTransmissionHeader[1];
                ordersp.pAXTransmissionHeader[0] = trh;

                trh.TransmissionNormInternal = "pAX";
                trh.MessageTypeInternal      = "ORDRSP";
                trh.TransmissionNo           = 0;
                trh.TransmissionDateTime     = DateTime.Now;



                ordersp.pAXTransmissionSender    = new pAXORDRSPPAXTransmissionSender[1];
                ordersp.pAXTransmissionSender[0] = trs;

                trs.SenderType = "PartnerID";
                trs.SenderID   = "705452";


                ordersp.pAXTransmissionReceiver    = new pAXORDRSPPAXTransmissionReceiver[2];
                ordersp.pAXTransmissionReceiver[0] = trr;

                trr.ReceiverType = "GLN";
                trr.ReceiverID   = "7612158000004";
                ordersp.pAXTransmissionReceiver[1] = trr;
                trr.ReceiverType = "PartnerID";
                trr.ReceiverID   = "705452";

                ordersp.pAXDocumentHeader    = new pAXORDRSPPAXDocumentHeader[1];
                ordersp.pAXDocumentHeader[0] = dch;

                dch.DocHeaderID    = ConfermaOrdine.original_DOCID;
                dch.DocumentType   = "U";
                dch.ParentID       = ConfermaOrdine.original_DOCID;
                dch.InternalDocID  = Convert.ToInt32(ConfermaOrdine.prefisso + ConfermaOrdine.nOrdine);//?
                dch.DocumentDate   = Consegna_DateTime.Date;
                dch.DocumentNumber = ConfermaOrdine.prefisso + ConfermaOrdine.nOrdine;
                dch.ParticipantReceiverIdentifier = "7612158000004";



                dch.pAXReference    = new pAXORDRSPPAXDocumentHeaderPAXReference[1];
                dch.pAXReference[0] = rfr;

                rfr.ReferenceType = "Order";
                rfr.ReferenceID   = ConfermaOrdine.original_DOCNR;
                rfr.ReferenceDate = Convert.ToDateTime(docdata_datetime);
                rfr.ParentID      = ConfermaOrdine.original_RIGID;


                dch.pAXDocumentLine    = new pAXORDRSPPAXDocumentHeaderPAXDocumentLine[1];
                dch.pAXDocumentLine[0] = dcl;

                dcl.DocLineID            = ConfermaOrdine.original_RIGID;
                dcl.ParentID             = ConfermaOrdine.original_DOCID;
                dcl.PositionSequentialNo = Convert.ToInt32(ConfermaOrdine.original_POSSEQNBR);
                dcl.PositionNoSender     = Convert.ToDecimal(ConfermaOrdine.original_POSNOSENDER);
                dcl.PositionType         = "PartLine";
                dcl.SubPosition          = false;
                dcl.EAN                   = ConfermaOrdine.original_EAN.Trim();
                dcl.PartDesc1             = ConfermaOrdine.descrizione;
                dcl.PartDesc2             = "";
                dcl.PartDesc3             = "";
                dcl.PartDesc4             = "";
                dcl.Variant               = false;
                dcl.PackagingQuantity     = Convert.ToDecimal(ConfermaOrdine.qta);
                dcl.PackagingQuantityUnit = "0";
                dcl.Quantity              = Convert.ToDecimal(ConfermaOrdine.qta);
                dcl.WeightNet             = 0;
                dcl.WeightGross           = 0;



                // ultimo livello di document line
                dcl.pAXReference    = new pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXReference[1];
                dcl.pAXReference[0] = dcl_ref;

                dcl_ref.ParentID              = ConfermaOrdine.original_RIGID;
                dcl_ref.ReferenceType         = "Order";
                dcl_ref.ReferenceID           = ConfermaOrdine.original_DOCNR;
                dcl_ref.AdditionalReferenceID = "1";
                dcl_ref.ReferenceDate         = docdata_datetime.Date;



                dcl.pAXDateTimes    = new pAXORDRSPPAXDocumentHeaderPAXDocumentLinePAXDateTimes[3];
                dcl.pAXDateTimes[0] = dcl_dtt;

                dcl_dtt.ParentID     = ConfermaOrdine.original_RIGID;
                dcl_dtt.DateTimeType = "DeliveryDate";
                dcl_dtt.DateAndTime  = Consegna_DateTime.Date;



                serialize.Serialize(writer, ordersp);
            }
            catch (Exception ex)
            {
                writer.Close();
                ev.WriteEventToMyLog(Source + "Serialize ORDERSP", "Errore:\n" + ex.ToString() + "\n--\n" + ex.StackTrace + "\n--\n" + ex.Message, EventLogEntryType.Error, 99);
                return(false);
            }
            writer.Close();
            return(true);
        }