Beispiel #1
0
        private void FillUIFromConfig()
        {
            this.txtAppIdentifier.Text  = appConfig.AppIdentifier;
            this.txtSelfConnStr.Text    = appConfig.SelfConnStr;
            this.txtGrabInterval.Value  = (decimal)appConfig.GrabInterval;
            this.txtOracleKeywords.Text = appConfig.OracleKeywords;
            this.ckStartup.Checked      = appConfig.Startup;

            ByoGraber add = new ByoGraber()
            {
                MachineCode = "→点击新增化验设备←",
                TableName   = "",
                PrimaryKeys = "",
                ConnStr     = "",
            };

            if (appConfig.AssayGrabers.Count(a => a.MachineCode == "→点击新增化验设备←") <= 0)
            {
                appConfig.AssayGrabers.Add(add);
            }

            this.Instruments.DataSource    = null;
            this.Instruments.DataSource    = appConfig.AssayGrabers;
            this.Instruments.DisplayMember = "MachineCode";
            this.Instruments.SelectedIndex = 0;
        }
Beispiel #2
0
        private ADGSAppConfig()
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(ConfigXmlPath);

            this.AppIdentifier  = xdoc.SelectSingleNode("root/AppIdentifier").InnerText;
            this.SelfConnStr    = xdoc.SelectSingleNode("root/SelfConnStr").InnerText;
            this.GrabInterval   = Convert.ToInt32(xdoc.SelectSingleNode("root/GrabInterval").InnerText);
            this.OracleKeywords = xdoc.SelectSingleNode("root/OracleKeywords").InnerText;
            this.Startup        = (xdoc.SelectSingleNode("root/Startup").InnerText.ToLower() == "true");

            foreach (XmlNode xNode in xdoc.SelectNodes("/root/Instruments/*"))
            {
                if (xNode.Name == "ByoGraber")
                {
                    ByoGraber byoGraber = new ByoGraber();

                    foreach (XmlNode xnParam in xNode.SelectNodes("Param"))
                    {
                        byoGraber.Parameters.Add(xnParam.Attributes["Key"].Value, xnParam.Attributes["Value"].Value);
                    }

                    this.AssayGrabers.Add(byoGraber);
                }
                else if (xNode.Name == "CustomGraber")
                {
                    // 提取类
                    string gaberType = xNode.SelectSingleNode("Param[@Key='GaberType']").Attributes["Value"].Value;

                    AssayGraber customGraber = (AssayGraber)Assembly.GetExecutingAssembly().CreateInstance(gaberType, false, BindingFlags.Default, null, null, null, null);
                    if (customGraber == null)
                    {
                        continue;
                    }

                    foreach (XmlNode xnParam in xNode.SelectNodes("Param"))
                    {
                        customGraber.Parameters.Add(xnParam.Attributes["Key"].Value, xnParam.Attributes["Value"].Value);
                    }

                    this.AssayGrabers.Add(customGraber);
                }
            }
        }