コード例 #1
0
ファイル: XmlFunction.cs プロジェクト: afacchin73/Mamoli
        public String ServicePathOut = AppDomain.CurrentDomain.BaseDirectory + @"\OutBound\"; // percorso installazione servizio

        #region ORDINE
        public Boolean Deserialize_ORDERS(String FilenameComplete)
        {
            ev.WriteEventToMyLog(Source + "Deserialize Orders", "deserializzo " + FilenameComplete, EventLogEntryType.Information, 1);

            XmlSerializer deserializer = new XmlSerializer(typeof(pAXORDERS));
            TextReader    Txtreader    = new StreamReader(FilenameComplete);
            object        obj          = deserializer.Deserialize(Txtreader);
            pAXORDERS     ordine       = (pAXORDERS)obj;


            order_testata ordT = new order_testata();
            order_riga    ordR = new order_riga();

            try
            {
                foreach (pAXORDERSPAXDocumentHeader v in ordine.pAXDocumentHeader)
                {
                    foreach (pAXORDERSPAXDocumentHeaderPAXDateTimes dt in v.pAXDateTimes)
                    {
                        string tipoData = dt.DateTimeType;
                        if (tipoData.ToLower() == "desireddate")
                        {
                            ordT.DesiredDate = Convert.ToDateTime(dt.DateAndTime).ToString();
                            break;
                        }
                    }

                    ordT.DocHeaderID    = v.DocHeaderID;
                    ordT.DocumentType   = v.DocumentType;
                    ordT.DocumentDate   = Convert.ToDateTime(v.DocumentDate).ToShortDateString();
                    ordT.DocumentNumber = v.DocumentNumber;



                    foreach (pAXORDERSPAXDocumentHeaderPAXDocumentLine dl in v.pAXDocumentLine)
                    {
                        ordR.DocLineID        = dl.DocLineID;
                        ordR.ParentID         = dl.ParentID;
                        ordR.PositionNoSender = dl.PositionNoSender.ToString().Replace(",", ".");
                        ordR.PartIDSender     = dl.PartIDSender;
                        ordR.EAN                  = dl.EAN;
                        ordR.PartDesc             = dl.PartDesc1;
                        ordR.Quantity             = dl.Quantity.ToString();
                        ordR.PositionSequentialNo = dl.PositionSequentialNo.ToString();
                    }
                }

                Txtreader.Close();
                ev.WriteEventToMyLog(Source + "Insert Orders", "Inserisco " + FilenameComplete, EventLogEntryType.Information, 2);
            }
            catch (Exception ex)
            {
                Txtreader.Close();
                ev.WriteEventToMyLog(Source + "Insert Orders", "ERRORE:\nFile: " + FilenameComplete + "\n--------\n" + ex.ToString(), EventLogEntryType.Error, 92);
                return(false);
            }
            Boolean res = Insert_Orders(ordT, ordR);

            return(res);
        }
コード例 #2
0
ファイル: XmlFunction.cs プロジェクト: afacchin73/Mamoli
        private Boolean Insert_Orders(order_testata ordT, order_riga ordR)
        {
            OdbcConnection cn  = new OdbcConnection();
            OdbcCommand    cmd = new OdbcCommand();


            try
            {
                String ConnectionString = Properties.Settings.Default.CnStriSeries;


                cn.ConnectionString = ConnectionString;
                cmd.Connection      = cn;
                cmd.Parameters.Clear();

                // TESTATE
                ev.WriteEventToMyLog(Source + "Insert Header", "inserimento testata", EventLogEntryType.Information, 3);

                String queryT = "INSERT INTO ORDERST (DOCID,DOCTYPE,DOCNUMBER,DOCDATE,DESDATE)"
                                + " VALUES(@DOCID,@DOCTYPE,@DOCNUMBER,@DOCDATE,@DESDATE)";

                queryT = queryT.Replace("@DOCID", "'" + ordT.DocHeaderID + "'")
                         .Replace("@DOCTYPE", "'" + ordT.DocumentType + "'")
                         .Replace("@DOCNUMBER", "'" + ordT.DocumentNumber + "'")
                         .Replace("@DESDATE", "'" + ordT.DesiredDate + "'")
                         .Replace("@DOCDATE", "'" + ordT.DocumentDate + "'");


                cmd.CommandText = queryT;
                cn.Open();
                cmd.ExecuteNonQuery();

                // RIGHE
                ev.WriteEventToMyLog(Source + "Insert Row", "inserimento riga", EventLogEntryType.Information, 4);

                String queryR = "INSERT INTO ORDERSR (DOCLINEID,PARENTID,POSSEQNO,POSNOSENDER,PARTIDSENDER,EAN,PARTDESC,QUANTITY)"
                                + " VALUES(@DOCLINEID,@PARENTID,@POSSEQNO,@POSNOSENDER,@PARTIDSENDER,@EAN,@PARTDESC,@QUANTITY)";

                queryR = queryR.Replace("@DOCLINEID", "'" + ordR.DocLineID + "'")
                         .Replace("@PARENTID", "'" + ordR.ParentID + "'")
                         .Replace("@POSSEQNO", "'" + ordR.PositionSequentialNo + "'")
                         .Replace("@POSNOSENDER", "'" + ordR.PositionNoSender + "'")
                         .Replace("@PARTIDSENDER", "'" + ordR.PartIDSender + "'")
                         .Replace("@EAN", "'" + ordR.EAN + "'")
                         .Replace("@PARTDESC", "'" + ordR.PartDesc + "'")
                         .Replace("@QUANTITY", "'" + ordR.Quantity + "'");

                cmd.CommandText = queryR;
                cmd.ExecuteNonQuery();

                cn.Close();
            }
            catch (Exception ex)
            {
                if (cn.State == ConnectionState.Open)
                {
                    cn.Close();
                }

                sendAlert("Insert_Orders<br><hr><br>ERRORE:" + ordT.DocHeaderID.ToString() + "<br>" + ex.ToString());
                ev.WriteEventToMyLog(Source + "Insert Orders", "ERRORE: " + ordT.DocHeaderID.ToString() + "\n" + ex.ToString(), EventLogEntryType.Error, 99);

                return(false);
            }

            return(true);
        }