我想创建一个服务,该服务移动文档并根据SQL查询可以使用的表重命名它。我有相同的代码,使用按钮按下并执行需要完成的工作。但是,当我运行该服务时,它会看到文档,但随后它会去获取文档的 ID,但它在 SQL 查询处停止并且不会继续。如果我取出SQL调用,它会移动文档并将其重命名为我可以分配的通用名称。我想自动执行此操作并使用SQL查询。 public void OnTimer(object sender, System.Timers.ElapsedEventArgs args) { eventLog1.WriteEntry("Monitoring the System.", EventLogEntryType.Information, eventId++); try { string dest = @"F:\Temp2\"; foreach (var file in Directory.EnumerateFiles(@"F:\Temp\")) { List<Document> ld = new List<Document>(); SQLImport si = new SQLImport(); string fileName = Path.GetFileName(file.ToString()); ld = si.getDocID(); int docID = ld[0].DocID; int newDocName = docID + 1; int accountNumber = 1; string docStatus = "New Import"; string fileName2 = docRetrieval.doc(newDocName.ToString()); string newdocName = fileName2 + ".pdf"; string nameChange = file.Replace(fileName, newdocName); si.setDocumentInformation(newDocName, accountNumber, dest, docStatus); string destFile = Path.Combine(dest, Path.GetFileName(nameChange)); if (!File.Exists(destFile)) File.Move(file, destFile); } } catch (Exception) { eventLog1.WriteEntry("The process failed: {0}"); } }SQLImport/Export: public List<Document> getDocID() { using (IDbConnection connection = new SqlConnection(helper.CnnVal("WorkflowConfiguration"))) { var output4 = connection.Query<Document>($"Select DocID From [Workflow Creation].[dbo].[CustomerDoc] ORDER BY DocID DESC").ToList(); return output4; } }什么被忽视了?
- 1 回答
- 0 关注
- 88 浏览
添加回答
举报
0/150
提交
取消