1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
/* Microsoft SQL Server Integration Services Script Component
* Write scripts using Microsoft Visual C#*2008.
* ScriptMain is the entry point class of the script.*/
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Xml;
using System.Linq;
using System.Xml.Linq;
using System.Globalization;
using System.Threading;
using System.Text;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void PreExecute()
{
base.PreExecute();
/*
Add your code here for preprocessing or remove if not needed
*/
}
public override void PostExecute()
{
base.PostExecute();
/*
Add your code here for postprocessing or remove if not needed
You can set read/write variables here, for example:
Variables.MyIntVar = 100
*/
}
public override void Entrée0_ProcessInputRow(Entrée0Buffer Row)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fr-FR");
/*
Add your code here
*/
XmlDocument xml = new XmlDocument();
string x = System.Text.Encoding.GetEncoding(1252).GetString(Row.DMESSAGEDETAILS.GetBlobData(0, (int)Row.DMESSAGEDETAILS.Length));//System.Text.Encoding.Unicode.GetString(((Row.DMESSAGEDETAILS.GetBlobData(0, (int)Row.DMESSAGEDETAILS.Length))));
//if (x.ToUpper().Contains("(E)</PROFESSION>"))
if (x.Contains("(<DateEmission>"))
System.Windows.Forms.MessageBox.Show(x);
XDocument doc = XDocument.Parse(x);
var reqs = from Donnees in doc.Descendants("Donnees")
select new
{
IdentifiantUnique = Donnees.Element("IdentifiantUnique") == null ? "" : Donnees.Element("IdentifiantUnique").Value,
CodeProcessus = Donnees.Element("CodeProcessus") == null ? "" : Donnees.Element("CodeProcessus").Value,
Produit = Donnees.Element("Produit") == null ? "" : Donnees.Element("Produit").Value,
LibelleProduit = Donnees.Element("LibelleProduit") == null ? "" : Donnees.Element("LibelleProduit").Value,
DateEmission = Donnees.Element("DateEmission") == null ? DateTime.MinValue : DateTime.Parse(Donnees.Element("DateEmission").Value),
Civilite = Donnees.Element("Civilite") == null ? "" : Donnees.Element("Civilite").Value,
Nom = Donnees.Element("Nom") == null ? "" : Donnees.Element("Nom").Value,
Prenom = Donnees.Element("Prenom") == null ? "" : Donnees.Element("Prenom").Value,
CodePostal = Donnees.Element("CodePostal") == null ? "" : Donnees.Element("CodePostal").Value,
Ville = Donnees.Element("Ville") == null ? "" : Donnees.Element("Ville").Value,
AdresseLigne1 = Donnees.Element("AdresseLigne1") == null ? "" : Donnees.Element("AdresseLigne1").Value,
};
try
{
foreach (var req in reqs)
{
Row.IdentifiantUnique = req.IdentifiantUnique.Trim();
Row.CodeProcessus = req.CodeProcessus.Trim();
Row.Produit = req.Produit.Trim();
Row.LibelleProduit = req.LibelleProduit.Trim();
Row.DateEmission = req.DateEmission;
Row.AdresseLigne1 = req.AdresseLigne1.Trim();
Row.Civilite = req.Civilite.Trim();
Row.Nom = req.Nom.Trim();
Row.Prenom = req.Prenom.Trim();
Row.Ville = req.Ville.Trim();
Row.CodePostal = req.CodePostal.Trim();
}
}
catch (System.Xml.XPath.XPathException ePath)
{
//System.Windows.Forms.MessageBox.Show(ePath.Message + " : " + ePath.InnerException.ToString());
}
catch (Exception e)
{
//System.Windows.Forms.MessageBox.Show(e.Message + " : " + e.InnerException.ToString());
}
}
} |
Partager