有没有一种好方法可以为 ASP.NET 站点创建重复导入?
我正在处理的站点运行的是 Windows Server 2003 和 SQL Server 8(2000?)以及 ASP.NET 3.5。
我需要运行某种脚本或应用程序来将数据从 FTP 文本文件导入到数据库中。 计算机上已经有一个正在运行的站点,该站点使用当前数据库。 我可以使用计划任务可靠地启动某种将导入数据的 .aspx 页面吗? 或者有更好的方法吗?
如何确保其他人无法访问运行导入的页面? 我不希望随机用户运行导入!
提前致谢!
PS 在插入数据之前需要对数据进行一些处理。 即查找、条件等,因此数据库工具不够强大(我认为)。 我讨厌DTS,而且我认为SSIS在这个版本中不可用。
The site I'm working on is running Windows Server 2003 and SQL Server 8 (2000?), and ASP.NET 3.5.
I need to have some sort of script or application run to import data from an FTP'd text file, into the database. There is already a site running on the machine, that uses the current database. Can I use a scheduled task to reliably kick off some sort of .aspx page that will import the data? Or is there a better approach?
What about making sure that no one else can access the page that runs the import? I don't want random users running the import!
Thanks in advance!
P.S. some processing needs to occur on the data before its inserted. i.e. lookups, conditionals, etc, so the DB tools aren't robust enough (I think). I hate DTS, and I SSIS is not available in this version I think.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
正如其他人所说,对于这种情况,单独的控制台应用程序(由计划任务触发)或 Windows 服务可能是最佳选择。
另一方面,如果您已经拥有在服务器上运行的 Web 应用程序中可用的所有必需功能,那么您可能可以设置一个计划任务,该任务启动一个脚本(VBscript、JScript),该脚本依次调用一个页面网络应用程序。
为了具有某种安全性(例如,防止任何用户可以调用该页面),您可以向页面添加一些代码,以检查是否使用 http://localhost。 这至少可以防止从远程客户端调用该页面。
As others have said, probably a separate console application (triggered by a scheduled task) or a windows service would be the best option for this scenario.
On the other hand, if you already have all the required functionality available in the web app running on the server, then you could probably set up a scheduled task, that starts a script (VBscript, JScript), which in turn calls a page of the web app.
To have some sort of security (e.g. preventing that any user can call that page), you could add some code to the page, that checks if the page was called with http://localhost. This would at least prevent the page from being called from a remote client.
如果您想让 C# 应用程序处理您的导入,我建议您使用带有 oa 表单的 Windows 应用程序 (exe)(比控制台应用程序更好,因为它在运行时不会弹出任何 UI)。 让它通过计划任务每隔一段时间(每分钟)运行一次。
If you want to have a C# App handle your import I would suggest a windows application (exe) w/o a form (better than a console app because it does not pop up any UI whenever it runs). Have it run every so often (every minute) by a scheduled task.
为什么要使用 ASP.NET? 根据作业的复杂性,您可以将其直接加载到数据库(批量加载),或者如果需要更复杂的处理,则可以使用 DTS (SQL Server 2000) 或 SSIS (SQL Server 2005/2008)。
Why would you use ASP.NET? Depending on the complexity of the job you could either load it directly to the database (BULK LOAD) or use DTS (SQL Server 2000) or SSIS (SQL Server 2005/2008) if more complex processing is needed.
作业中的 DTS 和存储过程。
作业中的 BCP 和存储过程。
您说您需要进行大量查找和转换? SQL 擅长于此——而且擅长快速完成。 乍一看似乎有点吓人,但这并不难。
DTS and stored procedures in a job.
BCP and stored procedures in a job.
You say you need to do alot of lookups and conversions? SQL is good at that - and good at doing it fast. It can seem a little intimidating at first, but it's not hard.
运行 BULK INSERT 或 bcp 来导入数据,请参阅此处 http://msdn.microsoft.com/en-us/library/aa173839(SQL.80).aspx
run a BULK INSERT or bcp to import the data instead, see here http://msdn.microsoft.com/en-us/library/aa173839(SQL.80).aspx
我会在这里回应其他人 - 你不希望计划任务点击网页。 SQL Server 提供了一些很好的数据导入选项,或者您可以编写一个简单的 Windows 程序并将其作为计划任务运行。
另一种选择是编写一个 Windows 服务来监视 FTP 目录并进行导入。
I'll echo other people here - you don't want to have a scheduled task hit a web page. SQL Server provides some good data import options, or you could just write a simple windows program and run it as a scheduled task.
Another option would be to write a windows service that watches your FTP directory and does the import.