C#ASP.NET中的提醒 [英] Reminders in c# ASP.NET

查看:60
本文介绍了C#ASP.NET中的提醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要c#提醒生成的代码,我不想通过Windows服务实现提醒,我只想当到期日提前5天时,我想通过电子邮件向用户数发送提醒在c#asp.NEt中,请为此提供指导或向我发送有用的代码

I need a code in c# of reminder generation, i don''t want to implement reminders through windows service, i just want that when due date is 5 days ahead i want to send a reminder to the number of users via email in c# asp.NEt, please guide me or send me a useful code in this regard

推荐答案

您可以为此目的使用Microsoft Task Scheduler.

参见:
http://msdn.microsoft.com/en-us/library/aa383614 (v = VS.85).aspx [ http://msdn.microsoft.com/en-us/library/aa383608 (v = VS.85).aspx [ http://en.wikipedia.org/wiki/At_(Windows) [ http://technet.microsoft.com/en-us/library/bb490866.aspx [ ^ ].

SchTasks.EXE:
http://en.wikipedia.org/wiki/Schtasks [ http://technet.microsoft.com/en-us/library/bb490996.aspx [ ^ ].

—SA
You can use Microsoft Task Scheduler for this purpose.

See:
http://msdn.microsoft.com/en-us/library/aa383614(v=VS.85).aspx[^],
http://msdn.microsoft.com/en-us/library/aa383608(v=VS.85).aspx[^].


As Parwej Ahamad pointed out, you may not need ASP.NET application for this purpose. You might create a simple application just sending e-mail. You can start this application using available Scheduler service without programming, just using available application AT.EXE or SchTasks.EXE.

See:

AT.EXE:
http://en.wikipedia.org/wiki/At_(Windows)[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^].

SchTasks.EXE:
http://en.wikipedia.org/wiki/Schtasks[^],
http://technet.microsoft.com/en-us/library/bb490996.aspx[^].

—SA


我认为有一种使用工作流处理此问题的简单方法.

这是可以做到的..

1.创建一个具有延迟"活动和另一个活动的顺序工作流,以根据应用程序的需要发送电子邮件.
2.将其置于条件设置为True
的while活动中 3.在global.asax.cs文件中,添加Application_Start事件的流式代码

I think there is a simpler way to handle this using workflows.

here is how it can be done..

1. Create a sequential workflow with a Delay activity and another activity to send e-mail as needed by your app.
2. Place this inside a while activity with condition set to True
3. In the global.asax.cs file add floowing code for Application_Start event

System.Workflow.Runtime.WorkflowRuntime workflowRuntime = new System.Workflow.Runtime.WorkflowRuntime();

System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService manualService =
    new System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService();
workflowRuntime.AddService(manualService);

workflowRuntime.StartRuntime();

Application["WorkflowRuntime"] = workflowRuntime;

ManualWorkflowSchedulerService manualScheduler =
    workflowRuntime.GetService(typeof(ManualWorkflowSchedulerService))
    as ManualWorkflowSchedulerService;

//WorkflowInvoker.Invoke(new Workflow1());
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1));

instance.Start();
manualScheduler.RunWorkflow(instance.InstanceId);




在Application_End事件中添加以下代码:




in Application_End event add following code:

    System.Workflow.Runtime.WorkflowRuntime workflowRuntime =
Application["WorkflowRuntime"] as System.Workflow.Runtime.WorkflowRuntime;
    workflowRuntime.StopRuntime();



假设Workflow1是您创建的工作流的名称.

这将具有以下优点
1.轻松的等待工作流程,不会造成任何开销
2.重新启动asp.net应用程序也将重新启动工作流服务.



Assuming Workflow1 is the name of the workflow you have created.

This would be with following advantages
1. Light wait workflow and would not cause any overhead
2. Restarting the asp.net applciaiton would restart the workflow service as well.


这篇关于C#ASP.NET中的提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆