示例#1
0
        /// <summary>
        /// Back up for bundled database;
        /// </summary>
        public void BackUpBundledDataBase()
        {
            bool result = false;

            Console.WriteLine("*****Start to back up bundled Database*****");
            string sourceDBPath = AppConfigOper.getConfigValue("DB_Bundled_Path");
            string targetDBPath = AppConfigOper.getConfigValue("DB_Bundled_Backup_Path");

            if (!Directory.Exists(sourceDBPath))
            {
                BackUpResult = false;
                return;
            }
            //First delete the exsited directory.
            if (Directory.Exists(targetDBPath))
            {
                Directory.Delete(targetDBPath, true);
            }
            //Then create new directory with the same name.
            Directory.CreateDirectory(targetDBPath);
            //Restore the files.

            CopyDir(sourceDBPath, targetDBPath);
            result = true;
            Console.WriteLine("*****Finish to back up bundled Database*****");
            BackUpResult = result;
        }
示例#2
0
        /// <summary>
        /// Get the database connection strin from Devices.ini.
        /// </summary>
        /// <returns>connString</returns>
        public string GetDBConnString()
        {
            string DS         = AppConfigOper.getConfigValue("DB_SQL_Server_Name");
            string UN         = AppConfigOper.getConfigValue("DB_SQL_User_Name");
            string PWD        = AppConfigOper.getConfigValue("DB_SQL_Password");
            string connString = "Data Source=" + DS + ";" + "Initial Catalog=master;" + "User ID=" + UN + ";" + "Password="******";";

            return(connString);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandstr"></param>
        public static void GenerateData(string commandstr)
        {
            string strApplicationName = AppConfigOper.getConfigValue(commandstr);

            Console.WriteLine("Command is: " + strApplicationName);
            Process  clrpro  = new Process();
            FileInfo clrfile = new FileInfo(strApplicationName);

            clrpro.StartInfo.WorkingDirectory = clrfile.Directory.FullName;
            clrpro.StartInfo.FileName         = strApplicationName;
            clrpro.StartInfo.CreateNoWindow   = false;
            clrpro.Start();
            clrpro.WaitForExit();
        }
示例#4
0
        /// <summary>
        /// Check the SNMP devices in the Devices.ini are available or not.
        /// If some devices are unavailable, the Devices.ini should be changed to give
        /// tester all available devices.
        /// </summary>
        /// <returns>list</returns>
        public static List <String> CheckSNMPDeviceAvailable()
        {
            List <string> notAvailable = new List <string>();
            int           timeout      = 3;
            VersionCode   version      = VersionCode.V1;
            IPEndPoint    endpoint     = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 161);
            OctetString   community    = new OctetString("public");

            ObjectIdentifier objectId = new ObjectIdentifier("1.3.6.1.2.1.11.1.0");
            Variable         var      = new Variable(objectId);
            IList <Variable> varlist  = new System.Collections.Generic.List <Variable>();

            varlist.Add(var);
            Variable         data;
            IList <Variable> resultdata;
            Hashtable        DeviceInfo = new Hashtable();

            string DeviceConfigFile = AppConfigOper.getConfigValue("DeviceConfig");

            DeviceInfo = AppConfigOper.GetDevicesInfo("snmp", DeviceConfigFile);

            foreach (string deviceIp in DeviceInfo.Values)
            {
                try
                {
                    endpoint.Address = IPAddress.Parse(deviceIp);
                    resultdata       = Messenger.Get(version, endpoint, community, varlist, timeout);
                    data             = resultdata[0];
                    Console.WriteLine("The device:" + deviceIp + "is availabe");
                }
                catch (Exception ex)
                {
                    notAvailable.Add(deviceIp);
                    Console.WriteLine("There is no device in this ip address." + deviceIp);
                    string log = ex.ToString();
                    continue;
                }
            }
            return(notAvailable);
        }
示例#5
0
        /// <summary>
        /// Check the velocity devices in the Devices.ini are available or not.
        /// If some devices are unavailable, the Devices.ini should be changed to give
        /// tester all available devices.
        /// </summary>
        /// <returns>list</returns>
        public static List <String> CheckVelocityDeviceAvailable()
        {
            // There are all devices in Device.ini.
            List <string> notAvailable = new List <string>();
            Hashtable     DeviceInfo   = new Hashtable();

            string DeviceConfigFile = AppConfigOper.getConfigValue("DeviceConfig");

            DeviceInfo = AppConfigOper.GetDevicesInfo("velocity", DeviceConfigFile);
            string      NformPath = "";
            RegistryKey Key;

            Key = Registry.LocalMachine;
            //Nform in Register table
            RegistryKey myreg = Key.OpenSubKey("software\\Wow6432Node\\Liebert\\Nform");

            NformPath = myreg.GetValue("InstallDir").ToString();
            myreg.Close();
            Console.WriteLine("NformPath:" + NformPath);

            ClientEngine ve      = ClientEngine.GetClientEngine();
            string       GDDpath = System.IO.Path.Combine(NformPath, @"bin\mds");

            System.IO.Directory.CreateDirectory(GDDpath);
            int startupflag = ve.Startup(GDDpath);

            Console.WriteLine("GDDPath:" + GDDpath);
            Console.WriteLine("startupflag:" + startupflag);

            CommsChannel channel = null;

            try
            {
                channel = ve.OpenChannel(CommStack.BACnetIp);
            }
            catch (Exception e)
            {
                Console.WriteLine("Can not open this channel! because: " + e.StackTrace.ToString());
            }
            foreach (string deviceIp in DeviceInfo.Values)
            {
                if (channel != null)
                {
                    DeviceNode node = channel.StrToEntity(deviceIp);
                    if (node != null)
                    {
                        Console.WriteLine("The device:" + deviceIp + " is availabe");
                    }
                    else
                    {
                        notAvailable.Add(deviceIp);
                        Console.WriteLine("There is no device in this ip address." + deviceIp + "!");
                    }
                }
                else
                {
                    Console.WriteLine("This channel is not available!");
                }
            }
            channel.Dispose();
            return(notAvailable);
        }