/// <summary> /// 报告数据导入数据库 /// </summary> /// <param name="dirPath"></param> /// <param name="formId"></param> /// <param name="reportId"></param> /// <returns></returns> public Result AddReportItem(string dirPath = "D:\\Shared\\弘阳报告", long formId = 8374570001, long reportId = 15581150001) { return(RunFun(logpath => { string path = "\\Survey\\ExportReports\\";// 根目录 // 获取表单GUID并拼接路径 string sqlStr = "SELECT * FROM AskForm_Form WHERE FormID = " + formId; DataTable dt = DbContent.GetTable(sqlStr); string companyId = ""; string appId = ""; if (dt.HasItems(c => c.Columns.Contains("FormGuid"))) { path += dt.Rows[0]["FormGuid"] + "\\" + reportId + "\\"; companyId = dt.Rows[0]["CompanyID"] + ""; appId = dt.Rows[0]["FormApplicationID"] + ""; } else { return Res; } // 获取文件夹下所有文件 if (Directory.Exists(dirPath)) { string[] pdfArr = Directory.GetFiles(dirPath); foreach (var pdf in pdfArr) { string fileName = ToolFile.GetFileName(pdf, false); string name = ToolFile.GetFileName(pdf); sqlStr = string.Format(@"INSERT AskForm_FormReportItem SELECT {0},{1},'{2}','','{3}',0,{4},{5},{6},0,GETDATE(),GETDATE()" , reportId, ToolString.GetRandomStr(12, 6), name, path + fileName, companyId, appId, formId); DbContent.ExecuteNonQuery(sqlStr); WriteLog(logpath, sqlStr); } } return Res; })); }