Exemple #1
0
        /// <summary>
        /// Populates a Composite type by looping through it's children, finding corresponding Elements
        /// among the children of the given Element, and calling parse(Type, Element) for each.
        /// </summary>
        ///
        /// <param name="datatypeObject">   The datatype object. </param>
        /// <param name="datatypeElement">  Element describing the datatype. </param>

        private void ParseComposite(IComposite datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            if (datatypeObject is GenericComposite)
            {
                //elements won't be named GenericComposite.x
                System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
                int compNum = 0;
                for (int i = 0; i < children.Count; i++)
                {
                    if (System.Convert.ToInt16(children.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element)
                    {
                        Parse(datatypeObject[compNum], (System.Xml.XmlElement)children.Item(i));
                        compNum++;
                    }
                }
            }
            else
            {
                IType[] children = datatypeObject.Components;
                for (int i = 0; i < children.Length; i++)
                {
                    System.Xml.XmlNodeList matchingElements =
                        datatypeElement.GetElementsByTagName(MakeElementName(datatypeObject, i + 1));
                    if (matchingElements.Count > 0)
                    {
                        Parse(children[i], (System.Xml.XmlElement)matchingElements.Item(0));
                        //components don't repeat - use 1st
                    }
                }
            }
        }
        public static List <RecordLine> ReadFromXmlFile(String _XmlFilename)
        {
            List <RecordLine> result = new List <RecordLine>();

            if (!String.IsNullOrEmpty(_XmlFilename))
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(_XmlFilename);

                System.Xml.XmlNodeList lines = doc.GetElementsByTagName("RecordLine");
                foreach (System.Xml.XmlNode line in lines)
                {
                    System.Xml.XmlElement lineEle = line as System.Xml.XmlElement;
                    String palletizer             = lineEle.GetAttribute("PalletizerName");
                    String readMarkDevice         = lineEle.GetAttribute("ReadMarkDevice");
                    String plateCodeDevice        = lineEle.GetAttribute("PlateCodeDevice");

                    System.Xml.XmlNodeList records = lineEle.GetElementsByTagName("Record");
                    if (records.Count > 0)
                    {
                        RecordLine recordLine = new RecordLine(palletizer, readMarkDevice, plateCodeDevice);
                        foreach (System.Xml.XmlNode record in records)
                        {
                            System.Xml.XmlElement recordEle = record as System.Xml.XmlElement;
                            String boxCodeDevice            = recordEle.GetAttribute("BoxCodeDevice");
                            String amountDevice             = recordEle.GetAttribute("AmountDevice");
                            recordLine.AddRecord(new Record(boxCodeDevice, amountDevice));
                        }
                        result.Add(recordLine);
                    }
                }
            }

            return(result);
        }
Exemple #3
0
 /// <summary> Populates a Composite type by looping through it's children, finding corresponding
 /// Elements among the children of the given Element, and calling parse(Type, Element) for
 /// each.
 /// </summary>
 private void  parseComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement)
 {
     if (datatypeObject is GenericComposite)
     {
         //elements won't be named GenericComposite.x
         //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
         System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
         int compNum = 0;
         for (int i = 0; i < children.Count; i++)
         {
             if (System.Convert.ToInt16(children.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element)
             {
                 parse(datatypeObject.getComponent(compNum), (System.Xml.XmlElement)children.Item(i));
                 compNum++;
             }
         }
     }
     else
     {
         Type[] children = datatypeObject.Components;
         for (int i = 0; i < children.Length; i++)
         {
             System.Xml.XmlNodeList matchingElements = datatypeElement.GetElementsByTagName(makeElementName(datatypeObject, i + 1));
             if (matchingElements.Count > 0)
             {
                 parse(children[i], (System.Xml.XmlElement)matchingElements.Item(0));                          //components don't repeat - use 1st
             }
         }
     }
 }
Exemple #4
0
 private void  parseReps(Segment segmentObject, System.Xml.XmlElement segmentElement, System.String fieldName, int fieldNum)
 {
     System.Xml.XmlNodeList reps = segmentElement.GetElementsByTagName(fieldName);
     for (int i = 0; i < reps.Count; i++)
     {
         parse(segmentObject.getField(fieldNum, i), (System.Xml.XmlElement)reps.Item(i));
     }
 }
Exemple #5
0
 public static System.Xml.XmlElement GetXmlElementByTagName(System.Xml.XmlElement parent, string name)
 {
     foreach (System.Xml.XmlElement el in parent.GetElementsByTagName(name))
     {
         return(el);
     }
     return(null);
 }
Exemple #6
0
        protected override void LoadUserData(System.Xml.XmlElement node)
        {
            this.isLoading = true;
            for (int i = 0; i < this.camViews.Count; i++)
            {
                System.Xml.XmlNodeList camViewElemQuery = node.GetElementsByTagName("CamView_" + i);
                if (camViewElemQuery.Count == 0)
                {
                    continue;
                }

                System.Xml.XmlElement camViewElem = camViewElemQuery[0] as System.Xml.XmlElement;
                this.camViews[i].LoadUserData(camViewElem);
            }
            for (int i = 0; i < this.objViews.Count; i++)
            {
                System.Xml.XmlNodeList objViewElemQuery = node.GetElementsByTagName("ObjInspector_" + i);
                if (objViewElemQuery.Count == 0)
                {
                    continue;
                }

                System.Xml.XmlElement objViewElem = objViewElemQuery[0] as System.Xml.XmlElement;
                this.objViews[i].LoadUserData(objViewElem);
            }
            if (this.logView != null)
            {
                System.Xml.XmlNodeList logViewElemQuery = node.GetElementsByTagName("LogView_0");
                if (logViewElemQuery.Count > 0)
                {
                    System.Xml.XmlElement logViewElem = logViewElemQuery[0] as System.Xml.XmlElement;
                    this.logView.LoadUserData(logViewElem);
                }
            }
            if (this.sceneView != null)
            {
                System.Xml.XmlNodeList sceneViewElemQuery = node.GetElementsByTagName("SceneView_0");
                if (sceneViewElemQuery.Count > 0)
                {
                    System.Xml.XmlElement sceneViewElem = sceneViewElemQuery[0] as System.Xml.XmlElement;
                    this.sceneView.LoadUserData(sceneViewElem);
                }
            }
            this.isLoading = false;
        }
        private static Dictionary <string, Dictionary <int, string> > LazyLoadMessages()
        {
            if (_Messages != null)
            {
                return(_Messages);
            }

            _Messages = new Dictionary <string, Dictionary <int, string> >();

            string fileName = System.IO.Path.GetDirectoryName(typeof(RestrictionMessages).Assembly.CodeBase).Replace("file:\\", "");

            fileName = System.IO.Path.Combine(fileName, "Restrictions");
            fileName = System.IO.Path.Combine(fileName, "RestrictionMessages.xml");

            if (System.IO.File.Exists(fileName))
            {
                System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
                xdoc.Load(fileName);
                System.Xml.XmlElement root = xdoc["RestrictionMessages"];
                if (root != null)
                {
                    foreach (System.Xml.XmlElement message in root.GetElementsByTagName("Message"))
                    {
                        string key = message.GetAttribute("for");
                        if (!string.IsNullOrEmpty(key))
                        {
                            int lcid = int.Parse(message.GetAttribute("lcid"));
                            if (lcid > 0)
                            {
                                string content = message.InnerText;

                                Dictionary <int, string> local;
                                if (_Messages.TryGetValue(key, out local))
                                {
                                    if (local.ContainsKey(lcid))
                                    {
                                        local[lcid] = content;
                                    }
                                    else
                                    {
                                        local.Add(lcid, content);
                                    }
                                }
                                else
                                {
                                    local = new Dictionary <int, string>();
                                    local.Add(lcid, content);
                                    _Messages.Add(key, local);
                                }
                            }
                        }
                    }
                }
            }

            return(_Messages);
        }
        public static tmTreeNode LoadProfile(string file)
        {
            tmTreeNode tree = new tmTreeNode("Root");   //root

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(file);
            System.Xml.XmlNodeList nodeList = doc.GetElementsByTagName("items");
            if (nodeList.Count == 0)
            {
                throw new System.Exception("Invalid profile,couldn't find \"items\" element.");
            }
            System.Xml.XmlElement element = nodeList[0] as System.Xml.XmlElement;
            if (element == null)
            {
                throw new System.Exception("Invalid profile,item is not a element.");
            }
            nodeList = element.GetElementsByTagName("item");
            foreach (System.Xml.XmlNode n in nodeList)
            {
                element = n as System.Xml.XmlElement;
                TestItem aItem = new TestItem();
                foreach (System.Xml.XmlAttribute a in element.Attributes)
                {
                    aItem[a.Name] = a.InnerText;
                }
                tmTreeNode keyNode = new tmTreeNode(aItem);
                tree.AddChildNode(keyNode);   //add group item

                //List child item
                System.Xml.XmlNodeList childList = element.GetElementsByTagName("subitem");
                foreach (System.Xml.XmlNode c in childList)
                {
                    element = c as System.Xml.XmlElement;
                    TestItem child = new TestItem();
                    foreach (System.Xml.XmlAttribute a in element.Attributes)
                    {
                        child[a.Name] = a.InnerText;
                    }
                    keyNode.AddChildNode(new tmTreeNode(child));
                }
            }
            return(tree);
        }
Exemple #9
0
 public void Load(System.Xml.XmlElement element)
 {
     foreach (var property in this.GetType().GetProperties())
     {
         var nodes = element.GetElementsByTagName(property.Name);
         if (nodes != null && nodes.Count > 0)
         {
             property.SetValue(this, nodes[0].InnerText, null);
         }
     }
 }
Exemple #10
0
        }        //ParameterSetting

        /// <summary>
        /// 設定値をXMLファイルから読み出す。
        /// </summary>
        private void ReadParameter()
        {
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(parameter_file);

                System.Xml.XmlElement root = doc.DocumentElement;

                this.Width     = Int32.Parse(root.GetElementsByTagName("Width").Item(0).InnerText);
                this.Height    = Int32.Parse(root.GetElementsByTagName("Height").Item(0).InnerText);
                this.lines     = Int32.Parse(root.GetElementsByTagName("Lines").Item(0).InnerText);
                this.vertex    = Int32.Parse(root.GetElementsByTagName("Vertex").Item(0).InnerText);
                this.wait_time = Int32.Parse(root.GetElementsByTagName("WaitTime").Item(0).InnerText);
            }
            catch (Exception)
            {
                this.Width     = LineArtForm.default_width;
                this.Height    = LineArtForm.default_height;
                this.lines     = LineArtForm.default_lines;
                this.vertex    = LineArtForm.default_vertex;
                this.wait_time = LineArtForm.default_wait;
            }
        }        //ReadParameter
Exemple #11
0
        private string getText(System.Xml.XmlElement elem, string elemName)
        {
            System.Xml.XmlNodeList list = elem.GetElementsByTagName(elemName);
            if (list.Count == 0)
            {
                return(null);
            }
            string t = list[0].InnerText;

            if (t.Length == 0)
            {
                return(null);
            }
            return(t);
        }
Exemple #12
0
        protected override void LoadUserData(System.Xml.XmlElement node)
        {
            this.isLoading = true;
            for (int i = 0; i < this.camViews.Count; i++)
            {
                System.Xml.XmlNodeList camViewElemQuery = node.GetElementsByTagName("CamView_" + i);
                if (camViewElemQuery.Count == 0)
                {
                    continue;
                }

                System.Xml.XmlElement camViewElem = camViewElemQuery[0] as System.Xml.XmlElement;
                this.camViews[i].LoadUserData(camViewElem);
            }
            this.isLoading = false;
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fixedRecordDataElement"></param>
        public HLAFixedRecordData(System.Xml.XmlElement fixedRecordDataElement)
            : base(fixedRecordDataElement)
        {
            Encoding       = fixedRecordDataElement.GetAttribute("encoding");
            EncodingNotes  = fixedRecordDataElement.GetAttribute("encodingNotes");
            Semantics      = ReplaceNewLines(fixedRecordDataElement.GetAttribute("semantics"));
            SemanticsNotes = fixedRecordDataElement.GetAttribute("semanticsNotes");

            System.Xml.XmlNodeList nl = fixedRecordDataElement.GetElementsByTagName("field");
            for (int i = 0; i < nl.Count; i++)
            {
                System.Xml.XmlElement enumeratorElement = (System.Xml.XmlElement)nl.Item(i);
                HLARecordField        field             = new HLARecordField(enumeratorElement);
                fields.Add(field);
            }
        }
Exemple #14
0
        /// <summary>
        /// Build a new instance using  XML data
        /// </summary>
        /// <param name="enumeratedDataElement"></param>
        public HLAEnumeratedData(System.Xml.XmlElement enumeratedDataElement)
            : base(enumeratedDataElement)
        {
            Representation      = enumeratedDataElement.GetAttribute("representation");
            RepresentationNotes = enumeratedDataElement.GetAttribute("representationNotes");
            Semantics           = ReplaceNewLines(enumeratedDataElement.GetAttribute("semantics"));
            SemanticsNotes      = enumeratedDataElement.GetAttribute("semanticsNotes");

            System.Xml.XmlNodeList nl = enumeratedDataElement.GetElementsByTagName("enumerator");
            for (int i = 0; i < nl.Count; i++)
            {
                System.Xml.XmlElement enumeratorElement = (System.Xml.XmlElement)nl.Item(i);
                HLAEnumerator         enumerator        = new HLAEnumerator(enumeratorElement);
                enumerators.Add(enumerator);
            }
        }
Exemple #15
0
        protected internal static QName GetTypeReference(System.Xml.XmlElement templateTag)
        {
            string typeRefNs = "";

            System.Xml.XmlNodeList typeReferenceTags = templateTag.GetElementsByTagName("typeRef");

            if (typeReferenceTags.Count > 0)
            {
                var    messageRef    = (System.Xml.XmlElement)typeReferenceTags.Item(0);
                string typeReference = messageRef.GetAttribute("name");
                if (messageRef.HasAttribute("ns"))
                {
                    typeRefNs = messageRef.GetAttribute("ns");
                }
                return(new QName(typeReference, typeRefNs));
            }
            return(Error.FastConstants.ANY_TYPE);
        }
Exemple #16
0
        private Scalar ParseSequenceLengthField(QName name, System.Xml.XmlElement sequence, bool optional, ParsingContext parent)
        {
            System.Xml.XmlNodeList lengthElements = sequence.GetElementsByTagName("length");

            if (lengthElements.Count == 0)
            {
                var implicitLength = new Scalar(Global.CreateImplicitName(name), FASTType.U32, Operator.Operator.NONE, ScalarValue.UNDEFINED, optional)
                {
                    Dictionary = parent.Dictionary
                };
                return(implicitLength);
            }

            var length  = (System.Xml.XmlElement)lengthElements.Item(0);
            var context = new ParsingContext(length, parent);

            return((Scalar)sequenceLengthParser.Parse(length, optional, context));
        }
Exemple #17
0
        System.Xml.XmlNode GetServiceNode(string moduleId, System.Xml.XmlElement xmlElm)
        {
            System.Xml.XmlNode service = null;
            foreach (System.Xml.XmlNode item in xmlElm.GetElementsByTagName("ServiceInformation"))
            {
                foreach (System.Xml.XmlNode node in item.ChildNodes)
                {
                    if (node.Name != "ModuleID")
                    {
                        continue;
                    }
                    if (!string.Equals(moduleId, node.InnerText, StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }
                    service = item;
                    break;
                }
                if (service != null)
                {
                    break;
                }
            }
            if (service == null)
            {
                service = xmlElm.OwnerDocument.CreateElement("ServiceInformation", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);

                var node = service.OwnerDocument.CreateElement("ServiceName", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);
                service.AppendChild(node);
                node = service.OwnerDocument.CreateElement("ModuleID", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);
                service.AppendChild(node);
                node = service.OwnerDocument.CreateElement("ServiceDescription", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);
                service.AppendChild(node);
                node = service.OwnerDocument.CreateElement("BOServiceContract", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);
                service.AppendChild(node);
                node = service.OwnerDocument.CreateElement("BOServiceBindingConfiguration", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);
                service.AppendChild(node);
                node = service.OwnerDocument.CreateElement("RegisteredServiceProviders", xmlElm.OwnerDocument.DocumentElement.NamespaceURI);
                service.AppendChild(node);

                xmlElm.AppendChild(service);
            }
            return(service);
        }
Exemple #18
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Double totalvenda   = 0;
                Double totalimposto = 0;

                DirectoryInfo Dir = new DirectoryInfo("C:\\ACBrMonitorPLUS\\Arqs\\SAT\\Vendas\\" + this.cnpj + "\\" + cb_periodo.SelectedItem.ToString().Split('/')[1] + cb_periodo.SelectedItem.ToString().Split('/')[0]);
                //DirectoryInfo Dir = new DirectoryInfo(@"C:\Users\Natanniel\Desktop\cancelamentos_201708");
                // Busca automaticamente todos os arquivos em todos os subdiretórios
                FileInfo[] Files       = Dir.GetFiles("*", SearchOption.AllDirectories);
                DataTable  dt_produtos = new DataTable();

                String[,] itens = new String[5000, 2];

                int linha = 0;

                foreach (FileInfo File in Files)
                {
                    System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
                    xml.Load(File.FullName);
                    System.Xml.XmlElement  root     = xml.DocumentElement;
                    System.Xml.XmlNodeList nodeList = root.GetElementsByTagName("total");

                    totalvenda += Double.Parse(nodeList[0]["vCFe"].InnerText, System.Globalization.CultureInfo.InvariantCulture);
                }

                lbl_total.Text = "R$ " + totalvenda;

                //dt_produtos = new DataTable();
                //dt_produtos.Columns.Add("Código Produto", typeof(string));
                //dt_produtos.Columns.Add("Quantidade Produto", typeof(string));
                //
                //for (int x = 0; x < linha; x++)
                //{
                //    dt_produtos.Rows.Add(itens[x, 0], itens[x, 1]);
                //}
                //
                //super_grid spg = new super_grid(dt_produtos);
                //spg.ShowDialog();
            }
            catch { }
        }
Exemple #19
0
        public GlobalizationAspect(Type dataType)
            : base(dataType)
        {
            string fileName = System.IO.Path.GetDirectoryName(dataType.Assembly.CodeBase);

            fileName = fileName.Replace("file:\\", "");
            fileName = System.IO.Path.Combine(fileName, "Globalization");
            fileName = System.IO.Path.Combine(fileName, dataType.FullName + ".xml");


            if (System.IO.File.Exists(fileName))
            {
                System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
                xdoc.Load(fileName);
                System.Xml.XmlElement globalization = xdoc["Globalization"];
                if (globalization != null)
                {
                    foreach (System.Xml.XmlElement element in globalization.GetElementsByTagName("Aspect"))
                    {
                        int lcid = int.Parse(element.GetAttribute("culture"));
                        foreach (System.Xml.XmlElement child in element.ChildNodes)
                        {
                            string name    = child.LocalName;
                            int    ordinal = GetOrdinal(name);
                            if (ordinal >= 0)
                            {
                                GlobalizationAspectMember member = base[ordinal];
                                foreach (System.Xml.XmlAttribute attribute in child.Attributes)
                                {
                                    member.SetTerm(attribute.Name, lcid, attribute.Value);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #20
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Double totalvenda   = 0;
                Double totalimposto = 0;

                DirectoryInfo Dir = new DirectoryInfo("C:\\ACBrMonitorPLUS\\Arqs\\SAT\\Vendas\\" + this.cnpj + "\\" + cb_periodo.SelectedItem.ToString().Split('/')[1] + cb_periodo.SelectedItem.ToString().Split('/')[0]);
                //DirectoryInfo Dir = new DirectoryInfo(@"C:\Users\Natanniel\Desktop\cancelamentos_201708");
                // Busca automaticamente todos os arquivos em todos os subdiretórios
                FileInfo[] Files       = Dir.GetFiles("*", SearchOption.AllDirectories);
                DataTable  dt_produtos = new DataTable();

                String[,] itens = new String[5000, 2];

                int     linha   = 0;
                Decimal vltotal = 0;
                int     file    = 0;

                StringBuilder sb = new StringBuilder();
                foreach (FileInfo File in Files)
                {
                    file++;
                    System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
                    xml.Load(File.FullName);
                    System.Xml.XmlElement  root     = xml.DocumentElement;
                    System.Xml.XmlNodeList nodeList = root.GetElementsByTagName("total");

                    Decimal total = Decimal.Parse(nodeList[0]["vCFe"].InnerText, System.Globalization.CultureInfo.InvariantCulture);
                    vltotal += Decimal.Parse(nodeList[0]["vCFe"].InnerText, System.Globalization.CultureInfo.InvariantCulture);
                    String data = File.CreationTime.ToString();



                    sb.AppendLine("INSERT INTO Vendas ");
                    sb.AppendLine("(ven_cliente,ven_dataVenda,ven_usuario,ven_formaPagamento ");
                    sb.AppendLine(",ven_qtdParcelas,ven_valorTotal,ven_observacao,ven_desconto ");
                    sb.AppendLine(",ven_percentualDesconto,ven_valorFinal,ven_status,ven_tipo ");
                    sb.AppendLine(",ven_vendedor,ven_diaSemana,ven_contratoimpresso,ven_ticket ");
                    sb.AppendLine(",IDAber,cpfcnpj,sessao,xml,nserieSAT)VALUES(1,'" + data.Split('/')[1] + "/" + data.Split('/')[0] + "/" + data.Split('/')[2] + "',1,null,");
                    sb.AppendLine(" null," + total.ToString().Replace(',', '.') + ",null,0, ");
                    sb.AppendLine("0," + total.ToString().Replace(',', '.') + ",'Ativo','Venda',");
                    sb.AppendLine("0,null,null,0 ");
                    sb.AppendLine(",0 ,'' ,'1' ,'' ,''); ");
                }

                Contexto   c   = new Contexto();
                SqlCommand sql = new SqlCommand();
                sql.CommandText = sb.ToString();
                c.ExecutaComando(sql);

                //dt_produtos = new DataTable();
                //dt_produtos.Columns.Add("Código Produto", typeof(string));
                //dt_produtos.Columns.Add("Quantidade Produto", typeof(string));
                //
                //for (int x = 0; x < linha; x++)
                //{
                //    dt_produtos.Rows.Add(itens[x, 0], itens[x, 1]);
                //}
                //
                //super_grid spg = new super_grid(dt_produtos);
                //spg.ShowDialog();
            }
            catch { }
        }
Exemple #21
0
        /// <summary> Parses the beepd element in the configuration file and loads the
        /// classes for the specified profiles.
        /// 
        /// </summary>
        /// <param name="serverConfig">&ltbeepd&gt configuration element.
        /// </param>
        private Beepd(Element serverConfig)
        {
            reg = new ProfileRegistry();

            if (serverConfig.HasAttribute("port") == false)
            {
                throw new System.Exception("Invalid configuration, no port specified");
            }

            port = System.Int32.Parse(serverConfig.GetAttribute("port"));

            // Parse the list of profile elements.
            NodeList profiles = serverConfig.GetElementsByTagName("profile");
            for (int i = 0; i < profiles.Count; ++i)
            {
                if (profiles[i].NodeType != System.Xml.XmlNodeType.Element)
                {
                    continue;
                }

                Element profile = (Element) profiles[i];

                if (profile.Name.ToUpper().Equals("profile".ToUpper()) == false)
                {
                    continue;
                }

                string uri;
                string className;
                //string requiredProperites;
                //string tuningProperties;

                if (profile.HasAttribute("uri") == false)
                {
                    throw new System.Exception("Invalid configuration, no uri specified");
                }

                uri = profile.GetAttribute("uri");

                if (profile.HasAttribute("class") == false)
                {
                    throw new System.Exception("Invalid configuration, no class " + "specified for profile " + uri);
                }

                className = profile.GetAttribute("class");

                // parse the parameter elements into a ProfileConfiguration
                ProfileConfiguration profileConfig = parseProfileConfig(profile.GetElementsByTagName("parameter"));

                // load the profile class
                IProfile p;
                try
                {
                    p = (IProfile) new beepcore.beep.profile.echo.EchoProfile(); //SupportClass.CreateNewInstance(System.Type.GetType(className));
                    //p = (IProfile) Activator.CreateInstance(Type.GetType(className, true, true));
                }
                catch (System.InvalidCastException)
                {
                    throw new System.Exception("class " + className + " does not " + "implement the " + "beepcore.beep.profile.Profile " + "interface");
                }
                catch (System.Exception e)
                {
                    throw new System.Exception("Class " + className + " not found - " + e.ToString());
                }

                SessionTuningProperties tuning = null;

                if (profile.HasAttribute("tuning"))
                {
                    string tuningString = profile.GetAttribute("tuning");
                    System.Collections.Hashtable hash = new System.Collections.Hashtable();
                    string[] tokens = tuningString.Split(":=".ToCharArray());

                    for(int tki=0; tki+1<tokens.Length; tki+=2) {
                        string parameter = tokens[tki];
                        string paramvalue = tokens[tki+1];

                        hash[parameter] = paramvalue;
                    }

                    tuning = new SessionTuningProperties(hash);
                }

                // Initialize the profile and add it to the advertised profiles
                reg.addStartChannelListener(uri, p.Init(uri, profileConfig), tuning);
            }

            thread = new Thread(new ThreadStart(this.ThreadProc));
        }
Exemple #22
0
 /// <summary>
 /// Calculate the number of child nodes in an XML element with a specified tag
 /// </summary>
 /// <param name="xmlElement">The XML element to be checked</param>
 /// <param name="tag">The specified tag</param>
 /// <returns></returns>
 private int GetQuantityOfTag(System.Xml.XmlElement xmlElement, string tag)
 {
     return(xmlElement.GetElementsByTagName(tag).Count);
 }