Пример #1
0
 private void cboServer_SelectedIndexChanged(object sender, EventArgs e)
 {
     DataRow[] drs = dt.Select("IP='" + cboServer.Text.Trim() + "'");
     if (drs.Length > 0)
     {
         cboUser.Text     = drs[0]["User"].ToString();
         txtPassword.Text = DESEncryptHelper.Decrypt(drs[0]["Pwd"].ToString(), "test332211");
     }
 }
Пример #2
0
        /// <summary>
        /// 初始化日志表
        /// </summary>
        /// <param name="strExistsTbSql">判断日志表是否存在的sql语句</param>
        /// <param name="strTbName">表名</param>
        /// <param name="strDbName">数据库名</param>
        /// <returns></returns>
        private bool InitLogTable(string strExistsTbSql, string strTbName, string strDbName)
        {
            bool    flag    = true;
            string  strConn = DESEncryptHelper.Decrypt(txtConnection.Text.Trim(), "test332211");
            SqlType sqlType = SqlType.SQLite;

            if (cboLogType.Text == "sqlite")
            {
                sqlType = SqlType.SQLite;
            }
            else if (cboLogType.Text == "sqlserver")
            {
                sqlType = SqlType.SqlServer;
            }
            else if (cboLogType.Text == "mysql")
            {
                sqlType = SqlType.MySql;
            }

            IDbHelper dbHelper = LoggerHelper.GetDBHelper(sqlType, strConn);

            if (dbHelper != null)
            {
                dbHelper.CreateCommand(strExistsTbSql);
                int intResult = dbHelper.ExecuteQuery().Rows.Count;
                if (intResult > 0)
                {
                    if (MessageBox.Show("已经存在日志记录表" + strTbName + ",是否删除重新建立?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        string strDropTable = "DROP TABLE " + strTbName + "";
                        dbHelper.CreateCommand(strDropTable);
                        try
                        {
                            dbHelper.ExecuteNonQuery();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("删除失败");
                            flag = false;
                        }
                        flag = DoCreateTable(dbHelper);
                    }
                }
                else
                {
                    flag = DoCreateTable(dbHelper);
                }
            }
            return(flag);
        }
Пример #3
0
        /// <summary>获取日志存储库连接字符串
        ///
        /// </summary>
        /// <returns></returns>
        public static string GetConn()
        {
            string conn = string.Empty;

            if (!string.IsNullOrEmpty(StaticInfoHelper.ConnString))
            {
                conn = StaticInfoHelper.ConnString;
            }
            else
            {
                string strFilePath = Application.StartupPath + "\\log.ini";
                if (File.Exists(strFilePath))
                {
                    conn = INIOperationHelper.INIGetStringValue(strFilePath, "LogConnection", "Connection", null);
                    conn = DESEncryptHelper.Decrypt(conn, "test332211");
                    StaticInfoHelper.ConnString = conn;
                }
            }

            return(conn);
        }