Beispiel #1
0
        private void BulkInsert(cafProductFeed model)
        {
            DataTable      dataTable   = model.dataFeed.prod.AsDataTable();
            SqlTransaction transaction = null;

            try
            {
                using (transaction = ConnectionAccess.SetTransaction())
                {
                    int merchantKeyId = daoMerchant.Insert(model.dataFeed.merchantElement, transaction);
                    daoProduct.BulkCopy(dataTable, merchantKeyId, transaction);
                    transaction.Commit();
                }
            }
            catch (Exception Ex)
            {
                transaction.Rollback();
                System.Windows.Forms.MessageBox.Show("Erreur : " + Ex.Message, "Erreur..", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void DeserialisationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string FileName    = "voyage.xml";
            string DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string FullPath    = Path.Combine(DesktopPath, FileName);
            string xmlContent  = new StringBuilder(File.ReadAllText(FullPath))
                                 .Replace("-<cafProductFeed", "<cafProductFeed")
                                 .Replace("-<datafeed", "<datafeed")
                                 .Replace("-<prod", "<prod")
                                 .Replace("-<price", "<price")
                                 .Replace("-<text", "<text")
                                 .Replace("-<uri", "<uri")
                                 .Replace("-<vertical", "<vertical")
                                 .Replace("&", "&amp;").ToString();
            XmlSerializer ser = new XmlSerializer(typeof(cafProductFeed));

            using (StringReader sr = new StringReader(xmlContent))
            {
                deserializedModel = (cafProductFeed)ser.Deserialize(sr);
            }
        }