通知模块概述

1.支持 WinForms和ASP.NET程序.

2.支持调度模块或自定义业务对象.

3.功能:在指定的时间,弹出一个窗口,用户可以查看提醒.也可以取消或推迟.

如需演示项目的源码,可以在留言中留下邮箱!

要使用通知模块,需要使用下面的模块.

第一步:

第二步:

第三步:

Windows Form下面的效果,在底部,出现下图所示的小图标:

在ASP.NET下效果如下:

如何使用自定义类实现通知?

1.假如下面是你的业务类:

[DefaultClassOptions]
public class Task {
[Browsable(false)]
public int Id { get; private set; }
public string Subject { get; set; }
public DateTime DueDate { get; set; }
}

先来实现ISupportNotifications 接口:

[DefaultClassOptions]
public class Task : ISupportNotifications {
// ... #region ISupportNotifications members
private DateTime? alarmTime;
[Browsable(false)]
public DateTime? AlarmTime {
get { return alarmTime; }
set {
alarmTime = value;
if (value == null) {
RemindIn = null;
IsPostponed = false;
}
}
}
[Browsable(false)]
public bool IsPostponed { get; set; }
[Browsable(false), NotMapped]
public string NotificationMessage {
get { return Subject; }
}
public TimeSpan? RemindIn { get; set; }
[Browsable(false), NotMapped]
public object UniqueId {
get { return Id; }
}
#endregion
}

再来实现IXafEntityObject,在保存时设置AlarmTime

[DefaultClassOptions]
public class Task : ISupportNotifications, IXafEntityObject {
// ...
#region IXafEntityObject members
public void OnCreated() { }
public void OnLoaded() { }
public void OnSaving() {
if (RemindIn.HasValue) {
AlarmTime = DueDate - RemindIn.Value;
}
else {
AlarmTime = null;
}
if (AlarmTime == null) {
RemindIn = null;
IsPostponed = false;
}
}
#endregion
}

运行,输入数据:

效果:

如何让为指定的用户指定通知?

[DefaultClassOptions]
public class Task : ISupportNotifications, IXafEntityObject {
// ...
public virtual Employee AssignedTo { get; set; }
}

下面是员工对象,下面是EF的例子,xpo区别的也不大:

using System.ComponentModel;
using DevExpress.Persistent.Base;
// ...
[DefaultClassOptions, DefaultProperty("UserName")]
public class Employee : DevExpress.Persistent.BaseImpl.EF.User {
public Employee() {
Tasks = new List<Task>();
}
public virtual IList<Task> Tasks { get; set; }
}
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp.Notifications;
using DevExpress.Persistent.Base.General;
// ...
public override void Setup(XafApplication application) {
base.Setup(application);
application.LoggedOn += new EventHandler<LogonEventArgs>(application_LoggedOn);
}
void application_LoggedOn(object sender, LogonEventArgs e) {
NotificationsModule notificationsModule = Application.Modules.FindModule<NotificationsModule>();
DefaultNotificationsProvider notificationsProvider = notificationsModule.DefaultNotificationsProvider;
notificationsProvider.CustomizeNotificationCollectionCriteria += notificationsProvider_CustomizeNotificationCollectionCriteria;
}
void notificationsProvider_CustomizeNotificationCollectionCriteria(
object sender, CustomizeCollectionCriteriaEventArgs e) {
if (e.Type == typeof(Task)) {
e.Criteria = CriteriaOperator.Parse("AssignedTo is null || AssignedTo.Id == CurrentUserId()");
    //可以看到,这里有个过滤条件,即,通知时,使用什么条件进行过滤.
}
}

如果使用调度模块,则可以使用下面的代码:

using DevExpress.ExpressApp.Scheduler;
// ...
void application_LoggedOn(object sender, LogonEventArgs e) {
SchedulerModuleBase schedulerModule = Application.Modules.FindModule<SchedulerModuleBase>();
NotificationsProvider notificationsProvider = schedulerModule.NotificationsProvider;
notificationsProvider.CustomizeNotificationCollectionCriteria += notificationsProvider_CustomizeNotificationCollectionCriteria;
}

默认情况下,通知刷新间隔是 5 分钟。出于测试目的,可以减少此时间间隔。

双击WIN应用程序项目的 WinApplication.cs(vb) 文件,在模块部分的模块设计器中选择NotificationsModule。在属性窗口中,将 NotificationsModule.NotificationsRefreshInterval 设置为 10 秒。

同样的,在WEB项目的WebApplication.cs(vb) 文件中也需要做这个。

如需演示项目的源码,可以在留言中留下邮箱!

XAF-通知模块概述 web+win的更多相关文章

  1. XAF-BI.Dashboard模块概述 web/win

    Dashboard模块介绍了在ASP.NET XAF 和 WinForms 应用程序中简单的集成 DevExpress Dashboard控件的方法. 其实不仅仅是控件,利用了现有的XAF数据模型,这 ...

  2. openstack七大模块概述

    前言 OpenStack主要由七部分组成,分别是Identify, Image, Network, Compute, Block Storage, Object Storage, Dashboard, ...

  3. 使用nodejs的http模块创建web服务器

    使用nodejs的http模块创建web服务器 laiqun@msn.cn Contents 1. web服务器基础知识 2. Node.js的Web 服务器 3. 代码实现 1. web服务器基础知 ...

  4. spark概念、编程模型和模块概述

    http://blog.csdn.net/pipisorry/article/details/50931274 spark基本概念 Spark一种与 Hadoop 相似的通用的集群计算框架,通过将大量 ...

  5. Java开源生鲜电商平台-通知模块设计与架构(源码可下载)

    Java开源生鲜电商平台-通知模块设计与架构(源码可下载) 说明:对于一个生鲜的B2B平台而言,通知对于我们实际的运营而言来讲分为三种方式:           1. 消息推送:(采用极光推送)   ...

  6. eclipse中创建多模块maven web项目

    本文讲述在eclipse中创建分模块maven web项目. 暂时将一个项目分为controller:service:dao以及父类模块四部分. 1.创建父类模块. 创建一个简单的maven proj ...

  7. 用 requests 模块从 Web 下载文件

    用 requests 模块从 Web 下载文件 requests 模块让你很容易从 Web 下载文件,不必担心一些复杂的问题,诸如网络错误.连接问题和数据压缩.requests 模块不是 Python ...

  8. [HeadFrist-HTMLCSS学习笔记]第三章构建模块:Web页面建设

    [HeadFrist-HTMLCSS学习笔记]第三章构建模块:Web页面建设 敲黑板!! <q>元素添加短引用,<blockquote>添加长引用 在段落里添加引用就使用< ...

  9. IIS7 404 模块 IIS Web Core 通知 MapRequestHandler 处理程序 StaticFile 错误代码 0x80070002

    <system.webServer> <!--添加--> <modules runAllManagedModulesForAllRequests="true&q ...

随机推荐

  1. git用法-打补丁

    1. git cherry-pick 作用:从一个branch上选择一个commit,添加该commit到另一个branch上. 1. 切换到你想添加commit的分支上. git checkout ...

  2. "table" is not mapped 解决方法

    现象:使用hql="from person" 出现" person is not mapped " 错误 配置文件如下:<hibernate-mappin ...

  3. 简单C程序,迷宫

    #include<stdio.h> #include <stdlib.h> int visit(int, int); ][] = { {, , , , , , , , ,}, ...

  4. jQuery_第二章_定时器

  5. 纪中集训 Day 5

    不知不觉已经day 5了啊 今天早上醒来,觉得要AK的节奏,结果就立flag了 - - 30分QAQ 其实第一题应该得想得到的,还有T2也能够解决的(话说后来看别人的代码写的好赞啊QAQ) 然后下午就 ...

  6. Hibernate执行流程和关系映射

    一.Hibernate的执行流程 hibernate作为一个ORM框架,它封装了大量数据库底层的sql语句操作的方法,这样在执行hibernate的过程中理解hibernate的执行流程很有必要. 由 ...

  7. c3p0获取连接Connection后的Close()---释疑

    论题: java c3p0获取连接Connnection 之后, 调用 con.close( ) 是否真的关闭了物理连接 ? 简答: c3p0采用连接池, 目的就是提前预置一定数量的连接, 在使用时候 ...

  8. 裸机(Bare Metal)安装CoreOS

    本文以 1235.9.0-stable 为例,在WMWare中进行安装. 1.获取安装资源 https://coreos.com/releases/ 通过"Browse Images&quo ...

  9. Hibernate一对一主键映射

    Hibernate一对一主键映射                        ------------------------------                            -- ...

  10. 《Django By Example》第八章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:还有4章!还有4章全书就翻译完成了 ...