コード例 #1
0
        protected override Boolean Run(XmlElement state)
        {
            try
            {
                if (!this.IsReady())
                {
                    return(false);
                }
                PopInputValue();

                String strModelFile = this.GetInputValue("ModelFile") as String;
                if (!System.IO.File.Exists(strModelFile))
                {
                    return(false);
                }
                IProcessListParser processList = InstanceManager.Instance.ProcessListParser;
                if (null == processList)
                {
                    return(false);
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(strModelFile);
                XmlElement               root   = doc.DocumentElement;
                ParaItem                 para   = null;
                XmlAttribute             attri  = null;
                ProcessDefineDescription pdd    = null;
                ParaItem[]               inputs = null;
                ParaItem                 pid    = null;
                foreach (XmlNode node in root.GetElementsByTagName("operation"))
                {
                    pdd = processList.GetProcess(node.Attributes["name"].Value);
                    if (null == pdd)
                    {
                        continue;
                    }
                    inputs = pdd.Inputs;
                    foreach (XmlNode item in node.SelectSingleNode("inputs").ChildNodes)
                    {
                        if (String.IsNullOrEmpty(item.Attributes["variable"].Value))
                        {
                            para = new ParaItem(node.Attributes["name"].Value + "." + node.Attributes["id"].Value + "." + item.Attributes["name"].Value, item.Attributes["type"].Value);
                            pid  = FindPara(inputs, item.Attributes["name"].Value);
                            if (null != pid)
                            {
                                para.Abstract = pid.Abstract;
                                para.UIType   = pid.UIType;
                                para.Option   = pid.Option;
                                para.Title    = pid.Title;
                            }
                            attri = item.Attributes["title"];
                            if (null != attri)
                            {
                                para.Title = attri.Value;
                            }
                            _parameters.Add(para);
                        }
                    }
                }

                PushOutputValue();
                return(true);
            }
            catch (Exception ex)
            {
                IRunningLogger logger = InstanceManager.Instance.Context.GetVariable("RunningLogger") as IRunningLogger;
                if (null != logger)
                {
                    logger.Error("sample.ProcessValidateModelFile", ex.Message);
                }
            }
            finally
            {
            }

            return(false);
        }
コード例 #2
0
        protected override Boolean Run(XmlElement state)
        {
            XmlReader xmlRead = null;

            try
            {
                if (!this.IsReady())
                {
                    return(false);
                }
                PopInputValue();

                String strModelFile = this.GetInputValue("ModelFile") as String;
                if (!System.IO.File.Exists(strModelFile))
                {
                    return(false);
                }
                String strProcessListFile = this.GetInputValue("ProcessListFile") as String;
                if (!System.IO.File.Exists(strProcessListFile))
                {
                    return(false);
                }

                IProcessListParser processListParser = InstanceManager.Instance.ProcessListParser;
                if (null == processListParser)
                {
                    return(false);
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(strModelFile);
                XmlElement rootModelFile = doc.DocumentElement;
                doc.Load(strProcessListFile);
                XmlElement rootProcessListFile = doc.DocumentElement;

                ProcessDefineDescription pdd = null;
                String   strProcessName      = String.Empty;
                String   strParaName         = String.Empty;
                ParaItem para        = null;
                String   strParaType = String.Empty;
                foreach (XmlNode node in rootModelFile.GetElementsByTagName("operation"))
                {
                    strProcessName = node.Attributes["name"].Value;
                    pdd            = processListParser.GetProcess(strProcessName);
                    if (null == pdd)
                    {
                        _strValidationInfo += strProcessName + "不存在;";
                        continue;
                    }

                    ParaItem[] inputs = pdd.Inputs;
                    foreach (XmlNode nodeInput in node.SelectSingleNode("inputs").SelectNodes("input"))
                    {
                        strParaName = nodeInput.Attributes["name"].Value;
                        para        = FindPara(inputs, strParaName);
                        if (null == para)
                        {
                            _strValidationInfo += strProcessName + "的参数\"" + strParaName + "\"不正确;";
                        }
                        strParaType = nodeInput.Attributes["type"].Value;
                        if (String.Compare(strParaType, para.DataType, true) != 0)
                        {
                            _strValidationInfo += strProcessName + "的参数\"" + strParaName + "\"的类型不正确;";
                        }
                    }
                }

                PushOutputValue();
                return(true);
            }
            catch (Exception ex)
            {
                IRunningLogger logger = InstanceManager.Instance.Context.GetVariable("RunningLogger") as IRunningLogger;
                if (null != logger)
                {
                    logger.Error("sample.ProcessValidateModelFile", ex.Message);
                }
            }
            finally
            {
                if (null != xmlRead)
                {
                    xmlRead.Close();
                }
            }

            return(false);
        }