/// <summary> /// 点击一键上传之前检查文件夹 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void CheckFolderUploadToDb(string forderPath, FileManager.Model.UserModel user) { try { string dirPath = forderPath; if (!Directory.Exists(dirPath)) { MessageBox.Show("服务器配置路径不正确,请联系管理员处理!"); return; } ClearCache(); // 获取配置信息 Model.SystemConfig config = SystemConfigBll.GetConfig(); // 设置数据库连接 string conn = string.Format("server={0};uid={1};pwd={2};database={3};", config.DbAddress, config.DbUser, config.DbPassword, config.DbName); // 打开连接 using (connection = new System.Data.SqlClient.SqlConnection(conn)) { // 此处查询出所有文件内容 DirectoryInfo rootDirInfo = new DirectoryInfo(dirPath); this.textBox1.AppendText("\r\n文件夹:" + dirPath); CheckFolderUploadAllToDb(rootDirInfo, 0, user.UserName, user.CurProject.ID); } } catch (Exception ex) { LogHelper.WriteLog(ex.Message, ex); } }
/// <summary> /// 系统检查 /// </summary> public static void SystemCheck() { // 获取配置信息 Model.SystemConfig config = SystemConfigBll.GetConfig(); // 设置数据库连接 string conn = string.Format("server={0};uid={1};pwd={2};database={3};", config.DbAddress, config.DbUser, config.DbPassword, config.DbName); DbHelperSQL.SetConnectionString(conn); string fileContentConn = string.Format("server={0};uid={1};pwd={2};database={3};", config.DbFileContentAddress, config.DbFileContentUser, config.DbFileContentPassword, config.DbFileContentName); DbHelperFileContentSQL.SetConnectionString(fileContentConn); }
/// <summary> /// 服务器连接检查 /// </summary> /// <returns></returns> public static bool SystemLinkCheckSys() { try { // 获取配置信息 Model.SystemConfig config = SystemConfigBll.GetConfig(); // 设置数据库连接 string conn = string.Format("server={0};uid={1};pwd={2};database={3};Connect Timeout=3", config.DbAddress, config.DbUser, config.DbPassword, config.DbName); return(SystemBll.SystemLinkCheck(conn)); } catch (Exception ex) { return(false); } }