Esempio n. 1
0
        private enterprise readXmlFile(String uri) // function to the read a xml file from given uri
        {
            if (InvokeRequired)
                this.Invoke(new Action(() => this.clearOldData()));
            else
                this.clearOldData();
                
            Stopwatch timer = new Stopwatch(); // timer to give information about time taken to load IMS document
            timer.Start();
            enterprise enterPrise;
            try
            {
                enterPrise = XmlFile.Read(uri);
            }
            catch(Exception e)
            {
                if (this.IMSSettings.General.ProblemLister.LogLocation.Use)
                    this.logPath = this.IMSSettings.General.ProblemLister.LogLocation.Location;
                else
                    this.logPath = Path.GetDirectoryName(Application.ExecutablePath);

                try
                {
                    this.log = new WriteProblemLog(uri, this.logPath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error! " + ex.Message);
                }

                addProblem(new Error(-1, e.Message, "XML syntax", ErrorType.Error, "IMS Document"));
                MessageBox.Show(e.Message);
                enterPrise = null;
                return null;
            }

            timer.Stop();
            this.currentFileLoadTime = (int)timer.ElapsedMilliseconds;
            this.encoding = this.getXmlEncoding();

            return enterPrise;
        }
Esempio n. 2
0
        void bgwIMS_DoWork(object sender, DoWorkEventArgs e)
        {
            //read the xml file
            this.ep = this.readXmlFile(this.currentFilePath);
            //log to file if user allows it from settings
            if (this.log == null)
            {
                if (this.IMSSettings.General.ProblemLister.LogLocation.Use)
                    this.logPath = this.IMSSettings.General.ProblemLister.LogLocation.Location;
                else
                    this.logPath = Path.GetDirectoryName(Application.ExecutablePath);

                try
                {
                    this.log = new WriteProblemLog(this.currentFilePath, this.logPath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error! " + ex.Message);
                }
            }
            //start creating tree nodes
            this.setupEnterpriseList();
            this.newFile = true;
        }