Esempio n. 1
0
        public ActivityListSummary parse()
        {
            ActivityListSummary activityList = new ActivityListSummary();
            XmlDocument         dom          = new XmlDocument();

            dom.Load(this.xmlFile);
            XmlNode xNode = dom.DocumentElement;

            if ((xNode.Name == Constants.ACTIVITIES_SUMMARY_ELEMENT) && (xNode.HasChildNodes))
            {
                foreach (XmlNode iNode in xNode.ChildNodes)
                {
                    //Console.WriteLine(iNode.Name);

                    //parsing file information
                    if (iNode.Name == Constants.ACTIVITY_ELEMENT)
                    {
                        ActivitySummary a = new ActivitySummary();
                        foreach (XmlNode jNode in iNode.ChildNodes)
                        {
                            //Console.WriteLine(jNode.Name);

                            foreach (XmlAttribute jAttribute in jNode.Attributes)
                            {
                                if (jAttribute.Name == Constants.NAME_ATTRIBUTE)
                                {
                                    a.Name = jAttribute.Value;
                                }
                                else if (jAttribute.Name == Constants.START_TIME_ATTRIBUTE)
                                {
                                    a.StartTime = Convert.ToDouble(jAttribute.Value);
                                }
                                else if (jAttribute.Name == Constants.END_TIME_ATTRIBUTE)
                                {
                                    a.EndTime = Convert.ToDouble(jAttribute.Value);
                                }
                                else if (jAttribute.Name == Constants.VALUE_ATTRIBUTE)
                                {
                                    a.Percent = Convert.ToInt32(jAttribute.Value);
                                }
                            }
                        }

                        activityList.Activities.Add(a);
                    }
                }
            }

            return(activityList);
        }
Esempio n. 2
0
        public ActivityListSummary parse()
        {
            ActivityListSummary activityList = new ActivityListSummary();
            XmlDocument dom = new XmlDocument();
            dom.Load(this.xmlFile);
            XmlNode xNode = dom.DocumentElement;
            if ((xNode.Name == Constants.ACTIVITIES_SUMMARY_ELEMENT) && (xNode.HasChildNodes))
            {

                foreach (XmlNode iNode in xNode.ChildNodes)
                {
                    //Console.WriteLine(iNode.Name);

                    //parsing file information
                    if (iNode.Name == Constants.ACTIVITY_ELEMENT)
                    {
                        ActivitySummary a = new ActivitySummary();
                        foreach (XmlNode jNode in iNode.ChildNodes)
                        {
                            //Console.WriteLine(jNode.Name);

                            foreach (XmlAttribute jAttribute in jNode.Attributes)
                            {
                                if (jAttribute.Name == Constants.NAME_ATTRIBUTE)
                                    a.Name = jAttribute.Value;
                                else if (jAttribute.Name == Constants.START_TIME_ATTRIBUTE)
                                    a.StartTime = Convert.ToDouble(jAttribute.Value);
                                else if (jAttribute.Name == Constants.END_TIME_ATTRIBUTE)
                                    a.EndTime = Convert.ToDouble(jAttribute.Value);
                                else if (jAttribute.Name == Constants.VALUE_ATTRIBUTE)
                                    a.Percent =  Convert.ToInt32(jAttribute.Value);
                            }

                        }

                        activityList.Activities.Add(a);
                    }
                }
            }

            return activityList;
        }