Exemplo n.º 1
0
        public string[] GetNeedFirstSettedArguments(string beginSubProduct)
        {
            List <string> needFirstSettedArgs = new List <string>();
            List <string> initedArgs          = new List <string>();
            SubProductDef firstSubProduct     = _monitoringProduct.Definition.GetSubProductDefByIdentify(beginSubProduct);

            if (firstSubProduct != null && firstSubProduct.IsNeedCurrentRaster)
            {
                needFirstSettedArgs.Add(GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE);
            }
            if (_monitoringProduct.SubProducts != null)
            {
                string         rstFileName = _contextEnvironment.GetContextVar(GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE);
                RasterIdentify rstIdentify = new RasterIdentify();
                if (rstFileName != null)
                {
                    rstIdentify = new RasterIdentify(rstFileName);
                    initedArgs.Add(GeoDo.RSS.MIF.Core.ContextEnvironment.ENV_VAR_NAME_CURRENT_RASTER_FILE);
                }
                foreach (IMonitoringSubProduct subprd in _monitoringProduct.SubProducts)
                {
                    AlgorithmDef alg = subprd.Definition.Algorithms[0];
                    if (subprd.Definition.IsNeedCurrentRaster && subprd.Definition.Algorithms.Count() > 0)
                    {
                        ExtractAlgorithmIdentify id = new ExtractAlgorithmIdentify();
                        id.Satellite = rstIdentify.Satellite;
                        id.Sensor    = rstIdentify.Sensor;
                        alg          = subprd.Definition.GetAlgorithmDefByAlgorithmIdentify(id);
                        if (alg == null)
                        {
                            alg = subprd.Definition.Algorithms[0];
                        }
                    }
                    //子产品不存在实例
                    if (subprd.Definition.SubProductInstanceDefs == null)
                    {
                        foreach (ArgumentDef arg in alg.Arguments.Where((a) => { return(a is ArgumentDef); }))
                        {
                            if (arg.IsOptional)
                            {
                                continue;
                            }
                            if (arg.RefType == "file" && arg.FileProvider == null)
                            {
                                if (!needFirstSettedArgs.Contains(arg.Name))
                                {
                                    needFirstSettedArgs.Add(arg.Name);
                                }
                            }
                            else if (arg.RefType == "file")
                            {
                                if (arg.FileProvider.Contains("ContextEnvironment:"))
                                {
                                    string[] parts = arg.FileProvider.Split(':');
                                    if (!initedArgs.Contains(parts[1]) && !needFirstSettedArgs.Contains(parts[1]))
                                    {
                                        needFirstSettedArgs.Add(parts[1]);
                                    }
                                }
                            }
                        }
                    }
                    //子产品有实例
                    else
                    {
                        foreach (SubProductInstanceDef ist in subprd.Definition.SubProductInstanceDefs)
                        {
                            if (ist.FileProvider.Contains("ContextEnvironment:"))
                            {
                                string[] parts = ist.FileProvider.Split(':');
                                if (!initedArgs.Contains(parts[1]) && !needFirstSettedArgs.Contains(parts[1]))
                                {
                                    needFirstSettedArgs.Add(parts[1]);
                                }
                            }
                        }
                    }
                    //
                    initedArgs.Add(subprd.Identify);
                }
            }
            return(needFirstSettedArgs.Count > 0 ? needFirstSettedArgs.ToArray() : null);
        }
Exemplo n.º 2
0
        private SubProductDef CreatSubProduct(XElement element)
        {
            SubProductDef sub   = new SubProductDef();
            string        value = element.Attribute("name").Value;

            if (!String.IsNullOrEmpty(value))
            {
                sub.Name = value;
            }
            value = element.Attribute("identify").Value;
            if (!String.IsNullOrEmpty(value))
            {
                sub.Identify = value;
            }
            value = AttributeValue(element, "isuseaoitemplate");
            if (!String.IsNullOrEmpty(value))
            {
                sub.IsUseAoiTemplate = value == "true";
            }
            value = AttributeValue(element, "iskeepusercontrol");
            if (!String.IsNullOrEmpty(value))
            {
                sub.IsKeepUserControl = value == "true";
            }
            value = AttributeValue(element, "aoitemplates");
            if (!String.IsNullOrEmpty(value))
            {
                sub.AoiTemplates = value;
            }
            value = AttributeValue(element, "color");
            if (!String.IsNullOrEmpty(value))
            {
                sub.Color = GetColor(value);
            }
            value = AttributeValue(element, "isdisplaypanel");
            if (!String.IsNullOrEmpty(value))
            {
                sub.IsDisplayPanel = value == "true";
            }
            value = AttributeValue(element, "visiablesavebtn");
            if (!String.IsNullOrEmpty(value))
            {
                sub.VisiableSaveBtn = value == "true";
            }
            value = AttributeValue(element, "isneedcurrentraster");
            if (!String.IsNullOrEmpty(value))
            {
                sub.IsNeedCurrentRaster = value.ToLower() == "true";
            }
            value = AttributeValue(element, "aoiseconaryinfofromarg");
            if (!String.IsNullOrEmpty(value))
            {
                sub.AOISecondaryInfoFromArg = value;
            }
            value = AttributeValue(element, "isautogenerate");
            if (!String.IsNullOrEmpty(value))
            {
                sub.IsAutoGenerate = bool.Parse(value);
            }
            value = AttributeValue(element, "autogenerategroup");
            if (!String.IsNullOrEmpty(value))
            {
                string[] groupIds = value.Split(',');
                if (groupIds != null)
                {
                    sub.AutoGenerateGroup = groupIds;
                }
            }
            //algorithms
            IEnumerable <XElement> elements = element.Element("Algorithms").Elements();

            if (elements != null && elements.Count() != 0)
            {
                AlgorithmDef        alg;
                List <AlgorithmDef> algs = new List <AlgorithmDef>();
                foreach (XElement ele in elements)
                {
                    alg = CreatAlgorithm(ele);
                    if (alg != null)
                    {
                        algs.Add(alg);
                    }
                }
                if (algs != null && algs.Count != 0)
                {
                    sub.Algorithms = algs.ToArray();
                }
            }
            //instances
            sub.SubProductInstanceDefs = ParseSubProductInstanceDefs(element.Element("Instances"));
            return(sub);
        }