private WorkspaceDef[] Load(string defDir)
        {
            if (!Directory.Exists(defDir))
            {
                return(null);
            }
            string[]            files = Directory.GetFiles(defDir, "*.xml", SearchOption.AllDirectories);
            List <WorkspaceDef> defs  = new List <WorkspaceDef>();

            foreach (string file in files)
            {
                WorkspaceDef def = LoadConfig(file);
                if (def != null)
                {
                    defs.Add(def);
                }
            }
            if (defs.Count == 0)
            {
                return(null);
            }
            else
            {
                return(defs.ToArray());
            }
        }
示例#2
0
        public static string GetStrategyXmlName(WorkspaceDef wksdef)
        {
            string wkddir   = MifEnvironment.GetWorkspaceDir();
            string identify = wksdef.Identify;
            string filedir  = Path.Combine(wkddir, identify);
            string filename = Path.Combine(filedir, string.Format("StrategyFilter_{0}.xml", identify));

            return(filename);
        }
        private WorkspaceDef LoadConfig(string workspaceDef)
        {
            XDocument doc = XDocument.Load(workspaceDef);

            if (doc == null)
            {
                return(null);
            }
            XElement ele = doc.Element("Workspace");

            if (ele == null)
            {
                return(null);
            }
            WorkspaceDef wksDef = GetWorkspaceDef(ele);

            return(wksDef);
        }
示例#4
0
        public static StrategyFilter StrategyFilter(WorkspaceDef wksdef)
        {
            string filename = GetStrategyXmlName(wksdef);

            StrategyFilter strategyFilter;

            if (!File.Exists(filename))
            {
                strategyFilter         = new StrategyFilter();
                strategyFilter.Days    = 1;
                strategyFilter.Sensors = new string[] { "AVHRR", "MERSI", "MODIS", "VISSR", "VIRR" };
                var str = UXmlConvert.GetString(strategyFilter);
                UIO.SaveFile(str, filename);
            }
            else
            {
                var str = UIO.ReadFile(filename);
                strategyFilter = UXmlConvert.GetObject <StrategyFilter>(str);
            }
            return(strategyFilter);
        }
        private WorkspaceDef GetWorkspaceDef(XElement ele)
        {
            string       text     = GetStringAttValue(ele, "text");
            string       identify = GetStringAttValue(ele, "identify");
            bool         enabled  = GetBoolAttValue(ele, "isenabled");
            WorkspaceDef wks      = new WorkspaceDef(text, identify, enabled);
            var          eles     = ele.Elements();

            if (eles != null)
            {
                foreach (XElement e in eles)
                {
                    CatalogDef catalog = GetCatalogDef(e);
                    if (catalog != null)
                    {
                        wks.CatalogDefs.Add(catalog);
                    }
                }
            }
            return(wks);
        }