/// <summary>
        /// 这个函数使用统一的ConfigManager来配置串口参数,如果项目中没有ConfigManager类,需要将此函数注释
        /// </summary>
        public static void resetStaticSerialPort()
        {
            SerialPort sp = StaticSerialPort.comport;

            if (sp == null)
            {
                return;
            }
            bool biniOpened = sp.IsOpen;

            if (biniOpened)
            {
                sp.Close();
                //MessageBox.Show("请先关闭串口!");
                //return;
            }
            try
            {
                sp.PortName = ConfigManager.GetItemValue("PortName");
                sp.BaudRate = int.Parse(ConfigManager.GetItemValue("BaudRate"));
                sp.DataBits = int.Parse(ConfigManager.GetItemValue("DataBits"));
                sp.StopBits = (StopBits)Enum.Parse(typeof(StopBits), ConfigManager.GetItemValue("StopBits"));
                sp.Parity   = (Parity)Enum.Parse(typeof(Parity), ConfigManager.GetItemValue("Parity"));
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("配置文件出现错误!" + ex.Message);
            }
        }
 void LoadConfig()
 {
     try
     {
         string portname = ConfigManager.GetItemValue("PortName");
         //string portname = ConfigManager.GetItemValue("PortName");
         if (null == portname)
         {
             cmbPortName.SelectedIndex = -1;
         }
         else
         {
             cmbPortName.SelectedIndex = cmbPortName.Items.IndexOf(portname);
         }
         string baudRate = ConfigManager.GetItemValue("BaudRate");
         //string baudRate = ConfigManager.GetItemValue("BaudRate");
         if (null != baudRate)
         {
             cmbBaudRate.SelectedIndex = cmbBaudRate.Items.IndexOf(baudRate);
         }
         else
         {
             cmbBaudRate.SelectedIndex = -1;
         }
         string parity = ConfigManager.GetItemValue("Parity");
         //string parity = ConfigManager.GetItemValue("Parity");
         if (null != parity)
         {
             cmbParity.SelectedIndex = cmbParity.Items.IndexOf(parity);
         }
         else
         {
             cmbParity.SelectedIndex = -1;
         }
         string stopbites = ConfigManager.GetItemValue("StopBits");
         //string stopbites = ConfigManager.GetItemValue("StopBits");
         if (null != stopbites)
         {
             cmbStopBits.SelectedIndex = cmbStopBits.Items.IndexOf(stopbites);
         }
         else
         {
             cmbStopBits.SelectedIndex = -1;
         }
         string databits = ConfigManager.GetItemValue("DataBits");
         //string databits = ConfigManager.GetItemValue("DataBits");
         if (null != databits)
         {
             cmbDataBits.SelectedIndex = cmbDataBits.Items.IndexOf(databits);
         }
         else
         {
             cmbDataBits.SelectedIndex = -1;
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public static string GetLockMemSecret()
        {
            string strR   = null;
            string secret = ConfigManager.GetItemValue("secret");

            if (null != secret)
            {
                strR = Encrypter.GetDecryptString(secret, Encrypter.PublicEncryptKey);
            }
            return(strR);
        }
        /// <summary>
        /// 获取当前使用的数据库类型
        /// </summary>
        /// <returns>sqlite sqlserver</returns>
        public static DBType GetCurrentDBType()
        {
            string dbType = null;

            dbType = ConfigManager.GetItemValue("dbType");
            if (null == dbType || dbType == string.Empty)
            {
                dbType = DBType.sqlite.ToString();
                SaveConfigItem("dbType", dbType);
            }
            return((DBType)Enum.Parse(typeof(DBType), dbType));
        }
 public static void SetSerialPort(ref SerialPort sp)
 {
     try
     {
         sp.PortName = ConfigManager.GetItemValue("PortName");
         sp.BaudRate = int.Parse(ConfigManager.GetItemValue("BaudRate"));
         sp.DataBits = int.Parse(ConfigManager.GetItemValue("DataBits"));
         sp.StopBits = (StopBits)Enum.Parse(typeof(StopBits), ConfigManager.GetItemValue("StopBits"));
         sp.Parity   = (Parity)Enum.Parse(typeof(Parity), ConfigManager.GetItemValue("Parity"));
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("配置文件出现错误!" + ex.Message);
     }
 }