コード例 #1
0
        /// <summary>
        /// git value from app.config for script. such as this format: $Ip_address$
        /// </summary>
        /// <param name="name">name</param>
        /// <returns>value</returns>
        public static string parseToValue(string name)
        {
            if (name.Equals(""))
            {
                return("");
            }
            var    configs = mainOp.configs;
            string addr    = name;

            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string    key      = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                          "Devices.ini"));
                string result = null;

                if (configs.ContainsKey(key))
                {
                    result = configs[key];
                }
                else
                {
                    result = configs["Default"];
                }

                addr = result;

                confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                "UsedDevices.ini"));
                confFile.WriteString("AvailableDevices", key, result);
            }

            return(addr.Replace("\"", ""));
        }
コード例 #2
0
ファイル: LxDBOper.cs プロジェクト: kwangkkim/NformTestMain
        /// <summary>
        /// Parse the value from Devices.ini.
        /// </summary>
        public string ParseToValue(string GroupName, string key)
        {
            LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                      "Devices.ini"));
            string def    = confFile.GetString(GroupName, "Default", "null");
            string result = confFile.GetString(GroupName, key, def);

            return(result);
        }
コード例 #3
0
        //**********************************************************************
        /// <summary>
        /// Replace the name with value refer to ini file
        /// </summary>
        public string parseToValue(string name)
        {
            string addr = name;

            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string    key      = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                          "Devices.ini"));
                string def = confFile.GetString("AvailableDevices", "Default", "10.146.83.50");

                string result = confFile.GetString("AvailableDevices", key, def);
                addr = result;
            }

            return(addr.Replace("\"", ""));
        }
コード例 #4
0
        /// <summary>
        /// git value from app.config for script. such as this format: $Ip_address$
        /// </summary>
        /// <param name="name">name</param>
        /// <returns>value</returns>
        public string parseToValue(string name)
        {
            if (name.Equals(""))
            {
                return("");
            }
            string addr = name;

            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string    key      = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                          "Devices.ini"));
                string result = null;
                if (key.ToUpper().StartsWith("SNMP") || key.ToUpper().StartsWith("VELOCITY"))
                {
                    result = ParseIP(key);
                }
                else if (configs.ContainsKey(key))
                {
                    result = configs[key];
                }
                else
                {
                    result = configs["Default"];
                }

                addr = result;

                confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                "UsedDevices.ini"));
                confFile.WriteString("AvailableDevices", key, result);
            }

            if (addr == null)
            {
                return(addr);
            }
            return(addr.Replace("\"", ""));
        }
コード例 #5
0
ファイル: LxScriptItem.cs プロジェクト: YouwenYao/private
        //**********************************************************************
        /// <summary>
        /// Replace the name with value refer to ini file
        /// </summary>
        public string parseToValue(string name)
        {
            string addr = name;
            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string key = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "Devices.ini"));
                string def = confFile.GetString("AvailableDevices", "Default", "10.146.83.50");

                string result = confFile.GetString("AvailableDevices", key, def);
                addr = result;
            }

            return addr.Replace("\"","");
        }
コード例 #6
0
ファイル: LxDeviceAvailable.cs プロジェクト: YouwenYao/Alex
 //**********************************************************************
 /// <summary>
 /// Parse the value from Devices.ini.
 /// Author: Sashimi.
 /// </summary>
 public static string myparseToValue(string GroupName, string key)
 {
     LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                          "Devices.ini"));
       string def = confFile.GetString(GroupName, "Default", "null");
       string result = confFile.GetString(GroupName, key, def);
       return result;
 }
コード例 #7
0
ファイル: LxSetup.cs プロジェクト: YouwenYao/NformTestMain
		/// <summary>
		/// git value from app.config for script. such as this format: $Ip_address$
		/// </summary>
		/// <param name="name">name</param>
		/// <returns>value</returns>
		public string parseToValue(string name)
        {
            if (name.Equals(""))
            {
                return "";
            }
            string addr = name;
            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string key = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "Devices.ini"));
                string result = null; 
                if(key.ToUpper().StartsWith("SNMP")|| key.ToUpper().StartsWith("VELOCITY"))
                {
                	result = ParseIP(key);
                }
                else if(configs.ContainsKey(key))
                {
                	result = configs[key];
                }
                else
                {
                	result = configs["Default"];
                }                              
               
                addr = result;
                
                confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "UsedDevices.ini"));
                confFile.WriteString("AvailableDevices",key,result);
            }

            if (addr==null)
            	return addr;
            return addr.Replace("\"","");
        }
コード例 #8
0
ファイル: LxGenericAction.cs プロジェクト: YouwenYao/Alex
        //**********************************************************************
        /// <summary>
        /// Replace the name with value refer to app.config
        /// </summary>
        public static string parseToValue(string name)
        {
            if (name.Equals(""))
            {
                return "";
            }

            LxSetup mainOp = LxSetup.getInstance();
            var configs = mainOp.configs;
            string addr = name;
            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string key = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "Devices.ini"));
                string result = null;

                if(configs.ContainsKey(key))
                {
                    result = configs[key];
                }
                else
                {
                    result = configs["Default"];
                }

                addr = result;

                confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "UsedDevices.ini"));
                confFile.WriteString("AvailableDevices",key,result);
            }

            return addr.Replace("\"","");
        }
コード例 #9
0
ファイル: LxScriptItem.cs プロジェクト: YouwenYao/Alex
        //**********************************************************************
        /// <summary>
        /// Replace the name with value refer to app.config
        /// </summary>
        public string parseToValue(string name)
        {
            if (name.Equals(""))
            {
                return "";
            }

            LxSetup mainOp = LxSetup.getInstance();
            var configs = mainOp.configs;
            string addr = name;
            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string key = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "Devices.ini"));
                string result = null;

                if(configs.ContainsKey(key))
                {
                    result = configs[key];
                }
                else
                {
                    result = configs["Default"];
                }

                /*
                string def = null;
                if(key.IndexOf("SNMP")!=-1)
                {
                    def = confFile.GetString("SNMPDevices","Default","10.146.83.50");
                    result = confFile.GetString("SNMPDevices",key,def);
                }

                else if(key.IndexOf("Velocity")!=-1)
                {
                    def = confFile.GetString("VelocityDevices","Default","126.4.200.116");
                    result = confFile.GetString("VelocityDevices",key,def);
                }

                else if(key.IndexOf("Trap")!=-1)
                {
                    def = confFile.GetString("TrapInfo","Default","-1:2:1:1.3.6.1.4.1.476.1.42.3.2.1.38.4");
                    result = confFile.GetString("TrapInfo",key,def);
                }

                 else if(key.IndexOf("Sys")!=-1)
                {
                    def = confFile.GetString("NformSysInfo","Default","Nform");
                    result = confFile.GetString("NformSysInfo",key,def);
                }

                 else if(key.IndexOf("DB")!=-1)
                {
                    def = confFile.GetString("Database","Default","Nform");
                    result = confFile.GetString("Database",key,def);
                }

                 else if(key.IndexOf("Try")!=-1)
                {
                    def = confFile.GetString("TryToRunTimes","Default","3");
                    result = confFile.GetString("TryToRunTimes",key,def);
                }
                */

                addr = result;

                confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                 "UsedDevices.ini"));
                confFile.WriteString("AvailableDevices",key,result);
            }

            return addr.Replace("\"","");
        }
コード例 #10
0
        //**********************************************************************
        /// <summary>
        /// Replace the name with value refer to app.config
        /// </summary>
        public string parseToValue(string name)
        {
            if (name.Equals(""))
            {
                return("");
            }

            LxSetup mainOp  = LxSetup.getInstance();
            var     configs = mainOp.configs;
            string  addr    = name;

            if (name.Substring(0, 1) == "$" && name.Substring(name.Length - 1, 1) == "$")
            {
                string    key      = name.Substring(1, name.Length - 2);
                LxIniFile confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                          "Devices.ini"));
                string result = null;

                if (configs.ContainsKey(key))
                {
                    result = configs[key];
                }
                else
                {
                    result = configs["Default"];
                }

                /*
                 * string def = null;
                 * if(key.IndexOf("SNMP")!=-1)
                 * {
                 *      def = confFile.GetString("SNMPDevices","Default","10.146.83.50");
                 *      result = confFile.GetString("SNMPDevices",key,def);
                 * }
                 *
                 * else if(key.IndexOf("Velocity")!=-1)
                 * {
                 *      def = confFile.GetString("VelocityDevices","Default","126.4.200.116");
                 *      result = confFile.GetString("VelocityDevices",key,def);
                 * }
                 *
                 * else if(key.IndexOf("Trap")!=-1)
                 * {
                 *      def = confFile.GetString("TrapInfo","Default","-1:2:1:1.3.6.1.4.1.476.1.42.3.2.1.38.4");
                 *      result = confFile.GetString("TrapInfo",key,def);
                 * }
                 *
                 * else if(key.IndexOf("Sys")!=-1)
                 * {
                 *      def = confFile.GetString("NformSysInfo","Default","Nform");
                 *      result = confFile.GetString("NformSysInfo",key,def);
                 * }
                 *
                 * else if(key.IndexOf("DB")!=-1)
                 * {
                 *      def = confFile.GetString("Database","Default","Nform");
                 *      result = confFile.GetString("Database",key,def);
                 * }
                 *
                 * else if(key.IndexOf("Try")!=-1)
                 * {
                 *      def = confFile.GetString("TryToRunTimes","Default","3");
                 *      result = confFile.GetString("TryToRunTimes",key,def);
                 * }
                 */

                addr = result;

                confFile = new LxIniFile(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                                "UsedDevices.ini"));
                confFile.WriteString("AvailableDevices", key, result);
            }

            return(addr.Replace("\"", ""));
        }