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
|
public void XMLInsertIntoDB()
{
using (DAO.Entities XMLRKCContext = new RemoteAgent.DAO.Entities())
{
try
{
XDocument doc = XDocument.Load(XMLFile);
var headers = (from header in doc.Descendants("header")
where !String.IsNullOrEmpty(header.Value)
select header.Elements()).First();
var details = (from detail in doc.Descendants("detail")
where !String.IsNullOrEmpty(detail.Value)
select detail.Elements()).First();
DAO.RAXMLRKC xml = new RemoteAgent.DAO.RAXMLRKC()
{
FILENAME = XMLFile,
INSERT_DATE = DateTime.Now,
H201 = Convert.ToInt32(headers.First(h => h.Name.ToString() == "h201").Value),
D502 = details.First(d => d.Name.ToString() == "d502").Value
};
XMLRKCContext.AddToRAXMLRKC(xml);
XMLRKCContext.SaveChanges();
}
catch (EntitySqlException ex)
{
Console.WriteLine(ex.ToString());
}
}
RaiseStateFile(this, new StateEvent("OK", true, _File.Name));
} |
Partager