示例#1
0
        public Boolean Serialize_DESADV(BOLLE00F bolla)
        {
            DateTime bolla_Datetime   = DateTime.ParseExact(bolla.dtBolla, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);
            DateTime docdata_datetime = DateTime.ParseExact(bolla.original_DOCDATA, "dd/mm/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);
            //DateTime bolla_Datetime = Convert.ToDateTime(bolla.dtBolla.Substring(0, 4) +"."+ bolla.dtBolla.Substring(4, 2) + "." + bolla.dtBolla.Substring(6, 2));
            // DateTime docdata_datetime = Convert.ToDateTime(bolla.original_DOCDATA.Substring(0, 4) + "." + bolla.original_DOCDATA.Substring(4, 2) + "." + bolla.original_DOCDATA.Substring(6, 2));


            String dataDesadv = String.Empty;

            DateTime dt = DateTime.Now;

            // formattazione data per nome file univoco
            dataDesadv = String.Format("{0:yyyy.MM.dd_HH.mm.ss.fff.zzz}", dt);
            dataDesadv = dataDesadv.Replace(":", "");
            TextWriter writer = new StreamWriter(ServicePathOut + @"Desadv_" + dataDesadv + ".xml");

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

                pAXDESADV desadv = new pAXDESADV();


                desadv.pAXTransmissionHeader    = new pAXDESADVPAXTransmissionHeader[1];
                desadv.pAXTransmissionHeader[0] = new pAXDESADVPAXTransmissionHeader
                {
                    TransmissionNormInternal = "pAX",
                    MessageTypeInternal      = "DESADV",
                    TransmissionNo           = 0,
                    TransmissionDateTime     = DateTime.Now
                };



                desadv.pAXTransmissionSender    = new pAXDESADVPAXTransmissionSender[1];
                desadv.pAXTransmissionSender[0] = new pAXDESADVPAXTransmissionSender
                {
                    SenderType = "PartnerID",
                    SenderID   = "705452"
                };



                desadv.pAXTransmissionReceiver = new pAXDESADVPAXTransmissionReceiver[2];

                desadv.pAXTransmissionReceiver[0] = new pAXDESADVPAXTransmissionReceiver
                {
                    ReceiverType = "PartnerID",
                    ReceiverID   = "7612158000004"
                };


                desadv.pAXTransmissionReceiver[1] = new pAXDESADVPAXTransmissionReceiver
                {
                    ReceiverType = "PartnerID",
                    ReceiverID   = "705452"
                };


                desadv.pAXDocumentHeader    = new pAXDESADVPAXDocumentHeader[1];
                desadv.pAXDocumentHeader[0] = new pAXDESADVPAXDocumentHeader
                {
                    DocHeaderID  = bolla.original_DOCID,
                    DocumentType = "L",
                    // ParentID = bolla.original_DOCID,
                    InternalDocID  = Convert.ToInt32(bolla.nInterno),
                    DocumentDate   = bolla_Datetime.Date,
                    DocumentNumber = bolla.original_DOCNR,
                    ParticipantReceiverIdentifier = "7612158000004"
                };
                desadv.pAXDocumentHeader[0].pAXAddress    = new pAXDESADVPAXDocumentHeaderPAXAddress[2];
                desadv.pAXDocumentHeader[0].pAXAddress[0] = new pAXDESADVPAXDocumentHeaderPAXAddress
                {
                    ParentID    = bolla.original_DOCID,
                    AddressType = "CONTACT-ADDRESS",
                    Name1       = "MAMOLI",
                    EMail       = "*****@*****.**",
                    Phone1      = "xxxxxxxxxxx"
                };
                desadv.pAXDocumentHeader[0].pAXAddress[1] = new pAXDESADVPAXDocumentHeaderPAXAddress
                {
                    ParentID    = bolla.original_DOCID,
                    AddressType = "DELIVERY-ADDRESS",
                    Name1       = "COMPANY ABCD",
                    Name2       = "",
                    Name3       = "",
                    Street1     = "street",
                    City        = "city",
                    PostCode    = "7001",
                    State       = "IT"
                };



                desadv.pAXDocumentHeader[0].pAXReference    = new pAXDESADVPAXDocumentHeaderPAXReference[1];
                desadv.pAXDocumentHeader[0].pAXReference[0] = new pAXDESADVPAXDocumentHeaderPAXReference
                {
                    ReferenceType = "PurchOrder",
                    ReferenceID   = bolla.nBolla,
                    ReferenceDate = Convert.ToDateTime(docdata_datetime)
                };



                desadv.pAXDocumentHeader[0].pAXDateTimes    = new pAXDESADVPAXDocumentHeaderPAXDateTimes[2];
                desadv.pAXDocumentHeader[0].pAXDateTimes[0] = new pAXDESADVPAXDocumentHeaderPAXDateTimes
                {
                    ParentID     = bolla.original_DOCID,
                    DateTimeType = "DeliveryDate",
                    DateAndTime  = bolla_Datetime
                };

                desadv.pAXDocumentHeader[0].pAXDateTimes[1] = new pAXDESADVPAXDocumentHeaderPAXDateTimes
                {
                    ParentID     = bolla.original_DOCID,
                    DateTimeType = "ShippingDate",
                    DateAndTime  = bolla_Datetime
                };

                ///////////////

                pAXDESADVPAXDocumentHeaderPAXDocumentHeader dch_dch = new pAXDESADVPAXDocumentHeaderPAXDocumentHeader();
                desadv.pAXDocumentHeader[0].pAXDocumentHeader    = new pAXDESADVPAXDocumentHeaderPAXDocumentHeader[1];
                desadv.pAXDocumentHeader[0].pAXDocumentHeader[0] = dch_dch;

                // sono dati interni duplicati dall'header fuori
                dch_dch.DocHeaderID    = bolla.original_DOCID;
                dch_dch.DocumentType   = "L";
                dch_dch.ParentID       = bolla.original_DOCID;
                dch_dch.InternalDocID  = Convert.ToInt32(bolla.nInterno);
                dch_dch.DocumentDate   = bolla_Datetime.Date;
                dch_dch.DocumentNumber = bolla.original_DOCNR;
                dch_dch.ParticipantReceiverIdentifier = "7612158000004";

                dch_dch.pAXAddress    = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXAddress[1];
                dch_dch.pAXAddress[0] = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXAddress
                {
                    ParentID    = bolla.original_DOCID,
                    AddressType = "DELIVERY-ADDRESS",
                    Name1       = "COMPANY ABCD",
                    Name2       = "",
                    Name3       = "",
                    Street1     = "street",
                    City        = "city",
                    PostCode    = "7001",
                    State       = "IT"
                };

                //////////////////////



                dch_dch.pAXDateTimes = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDateTimes[2];

                dch_dch.pAXDateTimes[0] = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDateTimes
                {
                    ParentID     = bolla.original_DOCID,
                    DateTimeType = "DeliveryDate",
                    DateAndTime  = bolla_Datetime
                };
                dch_dch.pAXDateTimes[1] = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDateTimes
                {
                    ParentID     = bolla.original_DOCID,
                    DateTimeType = "ShippingDate",
                    DateAndTime  = bolla_Datetime
                };
                dch_dch.pAXReference    = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXReference[1];
                dch_dch.pAXReference[0] = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXReference
                {
                    ParentID      = bolla.original_DOCID,
                    ReferenceType = "PurchOrder",
                    ReferenceID   = bolla.original_DOCNR,
                    // AdditionalReferenceID = bolla.nInterno,
                    ReferenceDate = bolla_Datetime.Date
                };


                /// DOCUMENT LINE
                dch_dch.pAXDocumentLine    = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDocumentLine[1];
                dch_dch.pAXDocumentLine[0] = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDocumentLine
                {
                    DocLineID            = bolla.original_RIGID,
                    ParentID             = bolla.original_DOCID,
                    PositionSequentialNo = Convert.ToInt32(bolla.original_POSSEQNBR),
                    PositionNoSender     = Convert.ToDecimal(bolla.original_POSNOSENDER),
                    SubPosition          = false,
                    EAN                   = bolla.original_EAN,
                    PartDesc1             = bolla.descrizione,
                    PartDesc2             = "",
                    PartDesc3             = "",
                    PartDesc4             = "",
                    PackagingQuantityUnit = "0",
                    WeightNet             = 0,
                    WeightGross           = 0,
                    PackagingQuantity     = Convert.ToDecimal(bolla.qta),
                    Quantity              = Convert.ToDecimal(bolla.qta)
                };

                dch_dch.pAXDocumentLine[0].pAXReference    = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDocumentLinePAXReference[1];
                dch_dch.pAXDocumentLine[0].pAXReference[0] = new pAXDESADVPAXDocumentHeaderPAXDocumentHeaderPAXDocumentLinePAXReference
                {
                    ParentID              = bolla.original_RIGID,
                    ReferenceType         = "PurchOrder",
                    ReferenceID           = bolla.original_DOCNR,
                    AdditionalReferenceID = "1",
                    ReferenceDate         = bolla_Datetime.Date
                };
                ////////////



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

            writer.Close();
            return(true);
        }
示例#2
0
        public void read_BOLLE00F()
        {
            ev.WriteEventToMyLog(Source + "Out Bolle", "Lettura e conversione Bolle", 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 BOLLE00F";



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

            while (rd.Read())
            {
                BOLLE00F row = new BOLLE00F
                {
                    nInterno             = rd.GetValue(0).ToString(),
                    rBolla               = rd.GetValue(1).ToString(),
                    Raggr_Magazzino      = rd.GetValue(2).ToString(),
                    Gruppo_numero        = rd.GetValue(3).ToString(),
                    nBolla               = rd.GetValue(4).ToString(),
                    dtBolla              = rd.GetValue(5).ToString(),
                    articolo             = rd.GetValue(6).ToString(),
                    descrizione          = rd.GetValue(7).ToString(),
                    qta                  = rd.GetValue(8).ToString(),
                    original_DOCID       = rd.GetValue(9).ToString(),
                    original_DOCNR       = rd.GetValue(10).ToString(),
                    original_DOCDATA     = rd.GetValue(11).ToString(),
                    original_RIGID       = rd.GetValue(12).ToString(),
                    original_EAN         = rd.GetValue(13).ToString(),
                    original_POSSEQNBR   = rd.GetValue(14).ToString(),
                    original_POSNOSENDER = rd.GetValue(15).ToString().Replace(".", separator.ToString()).Replace(",", separator.ToString())
                };

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


                Boolean res = Serialize_DESADV(row);

                if (res)
                {
                    Delete_row_BOLLE00F(row.original_DOCID);
                }
            }
            cn.Close();
        }