예제 #1
0
        private void LoadNetwork()
        {
            var parser = new InpParser();

            Network = parser.Parse(new Network(), InpPath);
        }
예제 #2
0
        /// <summary>Report options dialog constructor.</summary>
        public ReportOptions(string inpFile, string msxFile) : this()
        {
            if (inpFile == null)
            {
                return;
            }

            _fileInp = inpFile;
            _net     = new EpanetNetwork();

            try {
                InputParser inpParser;

                string extension = Path.GetExtension(inpFile);

                switch (extension.ToLowerInvariant())
                {
                case ".inp":
                    inpParser = new InpParser();
                    break;

                case ".net":
                    inpParser = new NetParser();
                    break;

                case ".xml":
                    inpParser = new XmlParser(false);

                    break;

                case ".gz":
                    inpParser = new XmlParser(true);
                    break;

                default:
                    inpParser = new InpParser();
                    break;
                }

                _net = inpParser.Parse(new EpanetNetwork(), inpFile);
            }
            catch (ENException ex) {
                MessageBox.Show(
                    ex.Message + "\nCheck epanet.log for detailed error description",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

                return;
            }

            if (msxFile == null)
            {
                return;
            }

            _fileMsx  = msxFile;
            _epanetTk = new EnToolkit2(_net);
            _netMsx   = new EpanetMSX(_epanetTk);

            try {
                ErrorCodeType ret = _netMsx.Load(_fileMsx);
                if (ret != 0)
                {
                    MessageBox.Show("MSX parsing error " + ret, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _fileMsx  = null;
                    _netMsx   = null;
                    _epanetTk = null;
                }
            }
            catch (IOException) {
                MessageBox.Show(
                    "IO error while reading the MSX file",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                _fileMsx  = null;
                _netMsx   = null;
                _epanetTk = null;
            }
        }