Ejemplo n.º 1
0
        private void LoadPackages(ICancelProgressHandler progress)
        {
            MFOutputPackage mfout = new MFOutputPackage()
            {
                Owner = this
            };

            AddInSilence(mfout);

            foreach (var pck in Packages.Values)
            {
                if (pck is IMFPackage)
                {
                    try
                    {
                        if (pck.State != ModelObjectState.Ready)
                        {
                            pck.Clear();
                            pck.Initialize();
                            var loaded = pck.Load(progress);
                            if (loaded)
                            {
                                (pck as IMFPackage).CompositeOutput(mfout);
                                pck.AfterLoad();
                                // progress.Progress("Modflow", 1, "\t" + pck.Name + " loaded");
                            }
                            else
                            {
                                //var msg = string.Format("\tFailed to load {0}. Error message: {1}", pck.Name, pck.Message);
                                //progress.Progress("Modflow", 1, msg);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var msg = string.Format("\tFailed to load {0}. Error message: {1}", pck.Name, ex.Message);
                        progress.Progress("Modflow", 1, msg);
                    }
                }
            }
            var oc = (Packages[OCPackage.PackageName] as OCPackage);

            oc.CompositeOutput(mfout);
            mfout.Initialize();
        }
Ejemplo n.º 2
0
        public override bool New(ICancelProgressHandler progress)
        {
            bool            succ  = true;
            MFOutputPackage mfout = new MFOutputPackage()
            {
                Owner = this
            };

            AddInSilence(mfout);

            var list_info = _MFNameManager.GetList(100, Project.Name);

            _MFNameManager.Add(list_info);
            foreach (var pck in ModflowService.SupportedPackages)
            {
                if (pck.IsMandatory && pck is IMFPackage)
                {
                    var pckinfo = pck.PackageInfo;
                    pckinfo.FID           = _MFNameManager.NextFID();
                    pckinfo.FileName      = string.Format("{0}{1}{2}", InputDic, Project.Name, pckinfo.FileExtension);
                    pckinfo.WorkDirectory = this.WorkDirectory;
                    //must be called here
                    _MFNameManager.Add(pck.PackageInfo);
                    pck.FileName = pckinfo.FileName;
                    pck.Owner    = this;
                    pck.Clear();
                    pck.Initialize();
                    pck.New();
                    AddInSilence(pck);
                }
            }
            foreach (var pck in Packages.Values)
            {
                if (pck is IMFPackage)
                {
                    (pck as IMFPackage).CompositeOutput(mfout);
                }
            }
            mfout.Initialize();
            return(succ);
        }