コード例 #1
0
        protected override Boolean Run(XmlElement state)
        {
            XmlReader xmlRead = null;
            Boolean   bProcessDescriptionsValidated = false;
            Int32     nGroupItem   = 0;
            Int32     nProcessItem = 0;

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

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType          = ValidationType.Schema;
                String strValidateFile = this.GetInputValue("ProcessDescriptionsValidateFile") as String;
                settings.Schemas.Add(null, strValidateFile);

                lock (_obj)
                {
                    if (1 != _state && 4 != _state)
                    {
                        RunException ex = new RunException();
                        throw ex;
                    }
                }

                String strValue = this.GetState(state, "IsValidateProcessDescriptionsFile");
                if (!String.IsNullOrEmpty(strValue))
                {
                    bProcessDescriptionsValidated = Boolean.Parse(strValue);
                }
                String strProcessListFile = "";
                if (!bProcessDescriptionsValidated)
                {
                    strProcessListFile = this.GetInputValue("ProcessListFile") as String;
                    xmlRead            = XmlReader.Create(strProcessListFile, settings);
                    while (xmlRead.Read())
                    {
                    }
                    xmlRead.Close();
                    xmlRead = null;

                    bProcessDescriptionsValidated = true;
                }

                lock (_obj)
                {
                    if (1 != _state && 4 != _state)
                    {
                        RunException ex = new RunException();
                        throw ex;
                    }
                }

                //验证分组文件
                settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType          = ValidationType.Schema;
                strValidateFile = this.GetInputValue("GroupValidateFile") as String;
                settings.Schemas.Add(null, strValidateFile);

                strValue = this.GetState(state, "GroupValidateItem");
                if (!String.IsNullOrEmpty(strValue))
                {
                    nGroupItem = Int32.Parse(strValue);
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(strProcessListFile);
                XmlElement  xmlListFile      = doc.DocumentElement;
                XmlNodeList nodeLists        = xmlListFile.GetElementsByTagName("Group");
                String      strFile          = "";
                String      strBaseDirectory = InstanceManager.Instance.Context.GetVariable("BaseDirectory") as String;
                XmlNode     node             = null;
                for (; nGroupItem < nodeLists.Count; ++nGroupItem)
                {
                    lock (_obj)
                    {
                        if (1 != _state && 4 != _state)
                        {
                            RunException ex = new RunException();
                            throw ex;
                        }
                    }

                    node    = nodeLists[nGroupItem];
                    strFile = strBaseDirectory + "../Config/ProcessGroups/" + node.InnerText + ".xml";
                    strFile = System.IO.Path.GetFullPath(strFile);
                    xmlRead = XmlReader.Create(strFile, settings);
                    while (xmlRead.Read())
                    {
                    }
                    xmlRead.Close();
                    xmlRead = null;

                    //验证地理空间处理文件
                    XmlReaderSettings settings2 = new XmlReaderSettings();
                    settings2.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                    settings2.ValidationType          = ValidationType.Schema;
                    strValidateFile = this.GetInputValue("ProcessDescriptionValidateFile") as String;
                    settings2.Schemas.Add(null, strValidateFile);

                    strValue     = this.GetState(state, "ProcessValidateItem");
                    nProcessItem = 0;
                    if (!String.IsNullOrEmpty(strValue))
                    {
                        nProcessItem = Int32.Parse(strValue);
                    }

                    doc = new XmlDocument();
                    doc.Load(strFile);
                    XmlElement  xmlGroupFile = doc.DocumentElement;
                    XmlNodeList processLists = xmlGroupFile.GetElementsByTagName("ProcessDescription");
                    for (; nProcessItem < processLists.Count; ++nProcessItem)
                    {
                        lock (_obj)
                        {
                            if (1 != _state && 4 != _state)
                            {
                                RunException ex = new RunException();
                                throw ex;
                            }
                        }

                        node    = processLists[nProcessItem];
                        strFile = strBaseDirectory + "../Config/ProcessDescriptions/" + node.InnerText + ".xml";
                        strFile = System.IO.Path.GetFullPath(strFile);
                        xmlRead = XmlReader.Create(strFile, settings);
                        while (xmlRead.Read())
                        {
                        }
                        xmlRead.Close();
                        xmlRead = null;
                    }
                }

                PushOutputValue();
                return(true);
            }
            catch (RunException rex)
            {
                //                if (this.Pausing != null)
                {
                    lock (_obj)
                    {
                        if (2 == _state)
                        {
                            return(false);
                        }
                        else if (3 == _state)
                        {
                            XmlDocument  doc       = new XmlDocument();
                            XmlElement   stateNode = doc.CreateElement("process");
                            XmlAttribute xattri    = doc.CreateAttribute("name");
                            xattri.Value = this.Name;
                            stateNode.Attributes.Append(xattri);
                            xattri       = doc.CreateAttribute("id");
                            xattri.Value = this.ID.ToString();
                            stateNode.Attributes.Append(xattri);

                            SetState(stateNode, "IsValidateProcessDescriptionsFile", bProcessDescriptionsValidated.ToString());
                            SetState(stateNode, "GroupValidateItem", nGroupItem.ToString());
                            SetState(stateNode, "ProcessValidateItem", nProcessItem.ToString());
                        }
                    }
                }
                //if (this.Pausing != null)
                //{
                //    PausingEventArgs e = new PausingEventArgs();
                //    Pausing(this, e);
                //}
            }
            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);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        /// <!--
        /// <process name="" id="">
        ///     <state key="" value="" />
        ///     <state key="" value="" />
        /// </process>
        /// -->
        protected override Boolean Run(XmlElement state)
        {
            XmlReader xmlRead    = null;
            Int32     nIndexFile = 0;

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

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType          = ValidationType.Schema;
                String _strValidateFile = this.GetInputValue("ValidateFile") as String;
                settings.Schemas.Add(null, _strValidateFile);

                lock (_obj)
                {
                    if (1 != _state && 4 != _state)
                    {
                        RunException ex = new RunException();
                        throw ex;
                    }
                }

                Int32    nStartIndex = 0;
                String[] _fileArray  = this.GetInputValue("FileArray") as String[];
                String   strValue    = this.GetState(state, "StartFile");
                if (!String.IsNullOrEmpty(strValue))
                {
                    nStartIndex = Int32.Parse(strValue);
                }

                nIndexFile = nStartIndex;
                String file = String.Empty;
                for (; nIndexFile < _fileArray.Length; ++nIndexFile)
                {
                    lock (_obj)
                    {
                        if (1 != _state && 4 != _state)
                        {
                            RunException ex = new RunException();
                            throw ex;
                        }
                    }

                    file    = _fileArray[nIndexFile];
                    xmlRead = XmlReader.Create(file, settings);
                    while (xmlRead.Read())
                    {
                    }
                    xmlRead.Close();
                    xmlRead = null;
                }

                PushOutputValue();
                return(true);
            }
            catch (RunException rex)
            {
//                if (this.Pausing != null)
                {
                    lock (_obj)
                    {
                        if (2 == _state)
                        {
                            return(false);
                        }
                        else if (3 == _state)
                        {
                            XmlDocument  doc       = new XmlDocument();
                            XmlElement   stateNode = doc.CreateElement("process");
                            XmlAttribute xattri    = doc.CreateAttribute("name");
                            xattri.Value = this.Name;
                            stateNode.Attributes.Append(xattri);
                            xattri       = doc.CreateAttribute("id");
                            xattri.Value = this.ID.ToString();
                            stateNode.Attributes.Append(xattri);

                            SetState(stateNode, "StartFile", nIndexFile.ToString());
                        }
                    }
                }
                //if (this.Pausing != null)
                //{
                //    PausingEventArgs e = new PausingEventArgs();
                //    Pausing(this, e);
                //}
            }
            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);
        }
コード例 #3
0
        protected override Boolean Run(XmlElement state)
        {
            XmlReader xmlRead = null;
            Boolean bProcessDescriptionsValidated = false;
            Int32 nGroupItem = 0;
            Int32 nProcessItem = 0;

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

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType = ValidationType.Schema;
                String strValidateFile = this.GetInputValue("ProcessDescriptionsValidateFile") as String;
                settings.Schemas.Add(null, strValidateFile);

                lock (_obj)
                {
                    if (1 != _state && 4 != _state)
                    {
                        RunException ex = new RunException();
                        throw ex;
                    }
                }

                String strValue = this.GetState(state, "IsValidateProcessDescriptionsFile");
                if (!String.IsNullOrEmpty(strValue))
                {
                    bProcessDescriptionsValidated = Boolean.Parse(strValue);
                }
                String strProcessListFile = "";
                if (!bProcessDescriptionsValidated)
                {
                    strProcessListFile = this.GetInputValue("ProcessListFile") as String;
                    xmlRead = XmlReader.Create(strProcessListFile, settings);
                    while (xmlRead.Read())
                    {
                    }
                    xmlRead.Close();
                    xmlRead = null;

                    bProcessDescriptionsValidated = true;
                }

                lock (_obj)
                {
                    if (1 != _state && 4 != _state)
                    {
                        RunException ex = new RunException();
                        throw ex;
                    }
                }

                //验证分组文件
                settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType = ValidationType.Schema;
                strValidateFile = this.GetInputValue("GroupValidateFile") as String;
                settings.Schemas.Add(null, strValidateFile);

                strValue = this.GetState(state, "GroupValidateItem");
                if (!String.IsNullOrEmpty(strValue))
                {
                    nGroupItem = Int32.Parse(strValue);
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(strProcessListFile);
                XmlElement xmlListFile = doc.DocumentElement;
                XmlNodeList nodeLists = xmlListFile.GetElementsByTagName("Group");
                String strFile = "";
                String strBaseDirectory = InstanceManager.Instance.Context.GetVariable("BaseDirectory") as String;
                XmlNode node = null;
                for (; nGroupItem < nodeLists.Count; ++nGroupItem)
                {
                    lock (_obj)
                    {
                        if (1 != _state && 4 != _state)
                        {
                            RunException ex = new RunException();
                            throw ex;
                        }
                    }

                    node = nodeLists[nGroupItem];
                    strFile = strBaseDirectory + "../Config/ProcessGroups/" + node.InnerText + ".xml";
                    strFile = System.IO.Path.GetFullPath(strFile);
                    xmlRead = XmlReader.Create(strFile, settings);
                    while (xmlRead.Read())
                    {
                    }
                    xmlRead.Close();
                    xmlRead = null;

                    //验证地理空间处理文件
                    XmlReaderSettings settings2 = new XmlReaderSettings();
                    settings2.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                    settings2.ValidationType = ValidationType.Schema;
                    strValidateFile = this.GetInputValue("ProcessDescriptionValidateFile") as String;
                    settings2.Schemas.Add(null, strValidateFile);

                    strValue = this.GetState(state, "ProcessValidateItem");
                    nProcessItem = 0;
                    if (!String.IsNullOrEmpty(strValue))
                    {
                        nProcessItem = Int32.Parse(strValue);
                    }

                    doc = new XmlDocument();
                    doc.Load(strFile);
                    XmlElement xmlGroupFile = doc.DocumentElement;
                    XmlNodeList processLists = xmlGroupFile.GetElementsByTagName("ProcessDescription");
                    for (; nProcessItem < processLists.Count; ++nProcessItem)
                    {
                        lock (_obj)
                        {
                            if (1 != _state && 4 != _state)
                            {
                                RunException ex = new RunException();
                                throw ex;
                            }
                        }

                        node = processLists[nProcessItem];
                        strFile = strBaseDirectory + "../Config/ProcessDescriptions/" + node.InnerText + ".xml";
                        strFile = System.IO.Path.GetFullPath(strFile);
                        xmlRead = XmlReader.Create(strFile, settings);
                        while (xmlRead.Read())
                        {
                        }
                        xmlRead.Close();
                        xmlRead = null;
                    }
                }

                PushOutputValue();
                return true;
            }
            catch (RunException rex)
            {
                //                if (this.Pausing != null)
                {
                    lock (_obj)
                    {
                        if (2 == _state)
                        {
                            return false;
                        }
                        else if (3 == _state)
                        {
                            XmlDocument doc = new XmlDocument();
                            XmlElement stateNode = doc.CreateElement("process");
                            XmlAttribute xattri = doc.CreateAttribute("name");
                            xattri.Value = this.Name;
                            stateNode.Attributes.Append(xattri);
                            xattri = doc.CreateAttribute("id");
                            xattri.Value = this.ID.ToString();
                            stateNode.Attributes.Append(xattri);

                            SetState(stateNode, "IsValidateProcessDescriptionsFile", bProcessDescriptionsValidated.ToString());
                            SetState(stateNode, "GroupValidateItem", nGroupItem.ToString());
                            SetState(stateNode, "ProcessValidateItem", nProcessItem.ToString());
                        }
                    }
                }
                //if (this.Pausing != null)
                //{
                //    PausingEventArgs e = new PausingEventArgs();
                //    Pausing(this, e);
                //}
            }
            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;
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        /// <!--
        /// <process name="" id="">
        ///     <state key="" value="" />
        ///     <state key="" value="" />
        /// </process>
        /// -->
        protected override Boolean Run(XmlElement state)
        {
            XmlReader xmlRead = null;
            Int32 nIndexFile = 0;

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

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType = ValidationType.Schema;
                String _strValidateFile = this.GetInputValue("ValidateFile") as String;
                settings.Schemas.Add(null, _strValidateFile);

                lock (_obj)
                {
                    if (1 != _state && 4 != _state)
                    {
                        RunException ex = new RunException();
                        throw ex;
                    }
                }

                Int32 nStartIndex = 0;
                String[] _fileArray = this.GetInputValue("FileArray") as String[];
                String strValue = this.GetState(state, "StartFile");
                if (!String.IsNullOrEmpty(strValue))
                {
                    nStartIndex = Int32.Parse(strValue);
                }

                nIndexFile = nStartIndex;
                String file = String.Empty;
                for (; nIndexFile < _fileArray.Length; ++nIndexFile)
                {
                    lock (_obj)
                    {
                        if (1 != _state && 4 != _state)
                        {
                            RunException ex = new RunException();
                            throw ex;
                        }
                    }

                    file = _fileArray[nIndexFile];
                    xmlRead = XmlReader.Create(file, settings);
                    while (xmlRead.Read())
                    {
                    }
                    xmlRead.Close();
                    xmlRead = null;
                }

                PushOutputValue();
                return true;
            }
            catch (RunException rex)
            {
            //                if (this.Pausing != null)
                {
                    lock (_obj)
                    {
                        if (2 == _state)
                        {
                            return false;
                        }
                        else if (3 == _state)
                        {
                            XmlDocument doc = new XmlDocument();
                            XmlElement stateNode = doc.CreateElement("process");
                            XmlAttribute xattri = doc.CreateAttribute("name");
                            xattri.Value = this.Name;
                            stateNode.Attributes.Append(xattri);
                            xattri = doc.CreateAttribute("id");
                            xattri.Value = this.ID.ToString();
                            stateNode.Attributes.Append(xattri);

                            SetState(stateNode, "StartFile", nIndexFile.ToString());
                        }
                    }
                }
                //if (this.Pausing != null)
                //{
                //    PausingEventArgs e = new PausingEventArgs();
                //    Pausing(this, e);
                //}
            }
            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;
        }