XAF-通知模块概述 web+win

通知模块概述

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) 文件中也需要做这个。

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

时间: 2024-08-04 02:29:06

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

openstack七大模块概述

前言 OpenStack主要由七部分组成,分别是Identify, Image, Network, Compute, Block Storage, Object Storage, Dashboard,分别表示认证模块,镜像模块,网络模块,计算模块,块存储模块,对象存储模块和管理模块. Identify(Keystone) 为其他几个模块提供认证服务,所有的认证操作都会通过keystone来进行. 整个keystone其实就是在数据库中建立用户(user).角色(role).Tenant.服务(s

maven 之分模块构建web项目 及 聚合与继承特性

说明:一下总结文档 工具为:Eclipse , 框架:spring + springMVC + Mybatis + maven 为什么要分模块开发? 很简单提高代码的清晰和重用. 先给大家看一下分模块项目目录架构(如图) 介绍:如上图有一个父项目(user-parent)聚合很多子项目 (user-dao, user-service, user-web).每个项目,不管是父子,都含有一个pom.xml文件.而且要注意的是,每个模块都标出了打包类型. 注意:父项目是pom,也只能是pom.子项目有

eclipse中创建多模块maven web项目

本文讲述在eclipse中创建分模块maven web项目. 暂时将一个项目分为controller:service:dao以及父类模块四部分. 1.创建父类模块. 创建一个简单的maven project打包类型设置为pom. 创建一个web模块.选中six-roo项目右键new maven module 将maven web项目转成eclipse支持的web项目 具体步骤见下面文章 http://www.cnblogs.com/HanShisi/p/5523998.html 按照上述方法创建

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

Java开源生鲜电商平台-通知模块设计与架构(源码可下载) 说明:对于一个生鲜的B2B平台而言,通知对于我们实际的运营而言来讲分为三种方式:           1. 消息推送:(采用极光推送)           2. 主页弹窗通知.(比如:现在有什么新的活动,有什么新的优惠等等)           3. 短信通知.(对于短信通知,这个大家很熟悉,我们就说下我们如何从代码层面对短信进行分层的分析与架构) 1. 消息推送 说明:目前市场上的推送很多,什么极光推送,环信,网易云等等,都可以实现秒

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

<system.webServer> <!--添加--> <modules runAllManagedModulesForAllRequests="true"></modules> </system.webServer> by:http://stackoverflow.com/questions/6941718/asp-net-mvc-on-iis-falls-through-to-the-static-file-handle

Zabbix使用Pycurl模块监控web页面状态

由于网络的问题,zabbix自带web模块用不了,后台研发2b,老是更新正式环境安装包,导致一直出问题,老是给他们擦屁股,早说过这事,他们不配合,现在出问题了,挺爽,这锅我表示不背,就找了pycurl这个模块写个监控. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 c = pycurl.Curl()    #创建一个curl对象  c.setopt(pycurl.CONNECTTIMEOUT, 5)   

服务器运维常用的python模块概述

最近开始复习python的使用,把服务器运维常用的模块的用法进行了实例化概述. ==========sort========================= python 排序: ls=[1,31,13,141,41] ls.sort() print ls 元组sort: >>> lst=[('wyl',24),('hjj',25),('zs',22),('lisi',14)] >>> sorted(lst,key=lambda lst:lst[1],reverse=

pycurl 模块监控web服务质量应用

做过运维的应该都做过http服务了.像一些电子商城,或者是一些互联网公司,web的服务之类是至关重要的,近期看了刘天斯大哥的书觉得自己运维平台应该也可以这样去监控服务之类,今天学习了pycurl模块,这里记录一下: 模块相关说明: c = pycurl.Curl()    #创建一个curl对象   c.setopt(pycurl.CONNECTTIMEOUT, 5)    #连接的等待时间,设置为0则不等待   c.setopt(pycurl.TIMEOUT, 5)    #请求超时时间  

使用Arduino UART-WiFi模块做web服务器

一.硬件准备 1.选择硬件,主要有2种: 一种是官方推荐的Arduino WiFi Shield(比较贵,大概要300~400块 淘宝网 :但是资料齐全): 一种是UART-WiFi模块,不仅支持Arduino,而且支持所有串口的单片机都可以和其模块通信(大概100块左右,淘宝网,资料较少). 最后选择了UART-WIFI模块,也走了条坎坷的路,也许到了不少东东. 2.   UART-WIFI模块介绍 图片 接口   双排(2 x 4)插针式接口   支持波特率范围:1200~115200bps