2

我需要一个流程,将日常数据编译成 PDF,然后附加到电子邮件中。我已经在正在开发的应用程序中使用 MSSQL 发送电子邮件,并希望继续使用 MSSQL 作为电子邮件处理器。

在我的研究中,我发现这可以通过创建 Windows 服务来实现。但是,因为我真的只希望这个过程每天运行一次;保持始终处于活动状态的 Windows 服务似乎有点过头了。

我从来没有使用任务调度程序来运行自建应用程序。我想确保我以正确的方式去做。据我了解,我将不得不...

  1. 在 Visual Studio 中创建一个新项目(Project X)
  2. 程序(项目 X)生成 PDF 并与 MSSQL 交互以发送电子邮件
  3. 将(项目 X)构建成 EXE
  4. 使用任务计划程序安排 EXE 以按我需要的任何计划运行。

有什么我应该关注的安全方面吗?只有我能想到的加密我的 MSSQL 连接字符串;当然,将 EXE 保留在 Web 应用程序所在的 Web 可访问目录之外。

提前感谢您的帮助/确认,因为我知道有些人会认为这是一个愚蠢的问题。

4

3 回答 3

1

我可以看到您没有考虑的唯一一件事是任务计划程序将运行您的 EXE 的身份,但是看到您似乎如何控制环境中的所有内容,这应该不是太大的问题。

于 2009-01-07T01:05:28.590 回答
1

As Esteban notes: will this just be running under your account and will you just stay signed on to the machine? If so, that is your biggest security risk. You can use a screen saver to force a login prompt and it is largely true that this is no less secure than logging out. However, I doubt that this would be considered "best practices."

I would consider building a Windows Service that simply wakes up once a day. They are truly not very difficult to build although you'll want to be sure to have a good testing mechanism (an independent class that you compile into a Unit-testable dll is a good idea) since testing them once they are running is very difficult. But don't let the "mystery" of service apps or the idea of resource usage put you off. You'll be surprised how easy they are. As far as resources go...you are spending more resources keeping a full Winforms app running!

于 2009-01-07T01:15:20.117 回答
0

如果要构建 Windows 服务,可以将其设置为在服务器(数据库所在的服务器)启动时启动。我有一个用于发送电子邮件的外部跟踪系统,可能在一个单独的数据库中。当服务器启动时,您的服务也会启动。服务检查今天是否已发送电子邮件。如果没有,请构建电子邮件,发送电子邮件,然后在日志中标记它(我假设的 db 表)。然后让服务休眠 24 小时,然后让它再次检查(使用事件)。重复。

于 2009-01-07T01:08:06.167 回答