Ejemplo n.º 1
0
        /// <summary>
        /// Replace the name with value refer to app.config
        /// </summary>
        /// <param name="name">name</param>
        /// <returns>String</returns>
        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"];
                }
                addr = result;

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

            return(addr.Replace("\"", ""));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Return the only one instance of this class
 /// </summary>
 /// <returns>m_instance</returns>
 public static LxSetup getInstance()
 {
     if (m_instance == null)
     {
         m_instance = new LxSetup();
     }     // end if
     return(m_instance);
 }         // end getInstance
Ejemplo n.º 3
0
        //**********************************************************************
        /// <summary>
        /// Map the action and call executeCommand to run script's steps.
        /// </summary>
        public static bool performScripts(ArrayList stepList)
        {
            LxSetup mainOp = LxSetup.getInstance();

            // Map action
            m_ActionMap.Clear();
            m_ActionMap.Add("InputKeys", new object[] { "PressKeys", "1" });
            m_ActionMap.Add("Click", new object[] { "Click", "0" });
            m_ActionMap.Add("Set", new object[] { "Check", "0" });
            m_ActionMap.Add("Clear", new object[] { "Uncheck", "0" });
            // m_ActionMap.Add("UnverifiedClickTab", new object[] {"Click","0"});
            m_ActionMap.Add("DoubleClick", new object[] { "DoubleClick", "0" });
            m_ActionMap.Add("Collapse", new object[] { "CollapseAll", "0" });
            m_ActionMap.Add("Expand", new object[] { "ExpandAll", "0" });
            m_ActionMap.Add("Select", new object[] { "SelectedItemText", "S1" });
            m_ActionMap.Add("CellContentClick", new object[] { "Click", "S2" });
            m_ActionMap.Add("SetTextValue", new object[] { "PressKeys", "S3" });
            m_ActionMap.Add("ClickItem", new object[] { "Click", "S4" });
            m_ActionMap.Add("VerifyToolTips", new object[] { "MoveTo", "S5" });
            m_ActionMap.Add("VerifyContains", new object[] { "Verify", "S6" });
            m_ActionMap.Add("VerifyNotContains", new object[] { "Verify", "S7" });
            m_ActionMap.Add("MoveTo", new object[] { "MoveTo", "S8" });
            m_ActionMap.Add("ClickCell", new object[] { "Click", "S9" });
            m_ActionMap.Add("DoubleClickItem", new object[] { "DoubleClick", "S10" });
            m_ActionMap.Add("RightClick", new object[] { "RightClick", "S11" });

            // Run the item in stepList
            foreach (LxScriptItem item in stepList)
            {
                bool resultFlag = true;
                try
                {
                    resultFlag = executeCommand(item);
                }
                catch (Exception e)
                {
                    resultFlag = false;
                    LxLog.Error("Error", e.Message.ToString());
                }

                // Log each step is pass or not
                mainOp.opXls.writeCell(Convert.ToInt32(item.m_Index) + 1, 14, resultFlag == true?"Pass":"******");
                LxLog.Info("Info", item.m_Index + " " + item.m_Component + " " + item.m_Action + " " + (resultFlag == true?"Success":"Failure"));
//				if(resultFlag == false)
//				{
//					return false;
//				}
            }
            return(true);
        }
Ejemplo n.º 4
0
        }         // end getInstance

        /// <summary>
        /// Replace the name with value refer to app.config
        /// </summary>
        /// <param name="name">name</param>
        /// <returns>string</returns>
        private string parseToValue(string name)
        {
            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);
                string result = null;
                if (configs.ContainsKey(key))
                {
                    result = configs[key];
                }
                else
                {
                    result = configs["Default"];
                }
                addr = result;
            }

            return(addr.Replace("\"", ""));
        }
Ejemplo n.º 5
0
 //**********************************************************************
 /// <summary>
 /// Return the only one instance of this class
 /// </summary>
 public static LxSetup getInstance()
 {
     if ( m_instance == null )
     {
         m_instance = new LxSetup();
     } // end if
     return m_instance;
 }
Ejemplo n.º 6
0
        //**********************************************************************
        /// <summary>
        /// Map the action and call executeCommand to run script's steps.
        /// </summary>
        public static bool performScripts(ArrayList stepList)
        {
            LxSetup mainOp = LxSetup.getInstance();

            // Map action
            m_ActionMap.Clear();
            m_ActionMap.Add("InputKeys", new object[] { "PressKeys", "1" });
            m_ActionMap.Add("Click", new object[] { "Click", "0" });
            m_ActionMap.Add("Set", new object[] { "Check", "0" });
            m_ActionMap.Add("Clear", new object[] { "Uncheck", "0" });
            // m_ActionMap.Add("UnverifiedClickTab", new object[] {"Click","0"});
            m_ActionMap.Add("DoubleClick", new object[] { "DoubleClick", "0" });
            m_ActionMap.Add("Collapse", new object[] { "CollapseAll", "0" });
            m_ActionMap.Add("Expand", new object[] { "ExpandAll", "0" });
            m_ActionMap.Add("Select", new object[] { "SelectedItemText", "S1" });
            m_ActionMap.Add("CellContentClick", new object[] { "Click", "S2" });
            m_ActionMap.Add("SetTextValue", new object[] { "PressKeys", "S3" });
            m_ActionMap.Add("ClickItem", new object[] { "Click", "S4" });
            m_ActionMap.Add("VerifyToolTips", new object[] { "MoveTo", "S5" });
            m_ActionMap.Add("VerifyContains", new object[] { "Verify", "S6" });
            m_ActionMap.Add("VerifyNotContains", new object[] { "Verify", "S7" });
            m_ActionMap.Add("MoveTo", new object[] { "MoveTo", "S8" });
            m_ActionMap.Add("ClickCell", new object[] { "Click", "S9" });
            m_ActionMap.Add("DoubleClickItem", new object[] { "DoubleClick", "S10" });
            m_ActionMap.Add("RightClick", new object[] { "RightClick", "S11" });
            m_ActionMap.Add("InputCell", new object[] { "Click", "S12" });
            m_ActionMap.Add("ClickLocation", new object[] { "Click", "S13" });

            // Run the item in stepList
            // If wrongCount =3, it means that the command fails three times continuously.
            int    wrongTime  = 3;
            int    wrongCount = 0;
            string groupName  = "TryToRunTimes";
            string key        = "Try_Times";

            wrongTime = int.Parse(myparseToValue(groupName, key));
            //        MessageBox.Show("wrong Time ="+wrongTime);


            bool finalResult = true;

            foreach (LxScriptItem item in stepList)
            {
                bool resultFlag = true;
                try
                {
                    resultFlag = executeCommand(item);
                    wrongCount = 0;
                }
                catch (Exception e)
                {
                    wrongCount++;
                    resultFlag  = false;
                    finalResult = false;
                    LxLog.Error("Error", e.Message.ToString());
                }

                // Log each step is pass or not
                mainOp.opXls.writeCell(Convert.ToInt32(item.m_Index) + 1, 14, resultFlag == true?"Pass":"******");
                LxLog.Info("Info", item.m_Index + " " + item.m_Component + " " + item.m_Action + " " + (resultFlag == true?"Success":"Failure"));

                //If this script fails three times continuously, break this execution.
                if (wrongCount == wrongTime)
                {
                    break;
                }
            }

            return(finalResult);
        }
Ejemplo n.º 7
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("\"", ""));
        }