Beispiel #1
0
        internal void ParseXMLFile(XmlDocument xmlDocument)

        {
            Dictionary <string, string> jobElements = new Dictionary <string, string>();

            XmlDocument doc       = new XmlDocument();
            XmlDocument periodDoc = new XmlDocument();

            foreach (XmlElement job in xmlDocument.GetElementsByTagName("job"))
            {
                doc.LoadXml(job.OuterXml);
                foreach (var tag in Config.RequiredTags)
                {
                    foreach (XmlElement tagData in doc.GetElementsByTagName(tag))
                    {
                        if (tagData.Name == "period")
                        {
                            periodDoc.LoadXml(tagData.OuterXml);
                            jobElements.Add("from", periodDoc.GetElementsByTagName("from")[0].InnerText);
                            jobElements.Add("to", periodDoc.GetElementsByTagName("to")[0].InnerText);
                            //Console.WriteLine(periodDoc.GetElementsByTagName("from")[0].InnerText);
                            //Console.WriteLine(periodDoc.GetElementsByTagName("to")[0].InnerText);
                        }
                        else
                        {
                            jobElements.Add(tagData.Name, tagData.InnerText);
                            //Console.WriteLine(tagData.Name);
                            //Console.WriteLine(tagData.InnerText);
                        }
                    }
                }
                Console.Write("Job : " + jobElements["jobid"]);
                var empHistoryId = SqlServer.CheckJobExists(Convert.ToInt32(jobElements["jobid"]));
                if (empHistoryId != 0)
                {
                    SqlServer.UpdateJob(jobElements, empHistoryId);
                }
                else
                {
                    SqlServer.InsertJob(jobElements);
                }
                jobElements.Clear();
            }
        }
Beispiel #2
0
        private static void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            XMLParser parser = new XMLParser();

            Console.Write("Parsing XML files Started......");
            Console.WriteLine(DateTime.Now.ToString());

            if (SqlServer.GetConnection() != null)
            {
                parser.XmlDataParser();
                Console.WriteLine("Press enter to exit...!");
            }
            else
            {
                parser.XmlDataParserToLog();
                Console.WriteLine("Press enter to exit...!");
            }
            _timer.Interval = Config.TimeInterval;
        }