摘要: 特别提示:Window Azure 从明天开始就停止使用了,所以前面提供的控件的在线演示和XgCalendar的在线演示也无法提供了。 XgCalendar 最新还是做了一些更新: 2009-12...阅读全文
posted @ 2010-01-31 21:57 假正经哥哥 阅读(950) 评论(5) 编辑
摘要: 基于jQuery 的日历控件,方便快捷,性能表现良好,兼容性强,操作方式和样式参考Google Calendar Demo中的服务器端采用MS ASP.NET MVC V1,事实上可替换成其他任何一种服务器端技术(包括PHP,ASP,...阅读全文
posted @ 2009-11-24 13:47 假正经哥哥 阅读(9225) 评论(226) 编辑

大家可以到http://www.icsharpcode.net/opensource/sharpziplib/ 下载SharpZiplib的最新版本,本文使用的版本为0.86.0.518,支持Zip, GZip, BZip2 和Tar格式,其实没啥好说的直接上代码

    /// <summary>
    /// Zip压缩与解压缩 
    /// </summary>
    public class ZipHelper
    {
        /// <summary>
        /// 压缩单个文件
        /// </summary>
        /// <param name="fileToZip">要压缩的文件</param>
        /// <param name="zipedFile">压缩后的文件</param>
        /// <param name="compressionLevel">压缩等级</param>
        /// <param name="blockSize">每次写入大小</param>
        public static void ZipFile(string fileToZip, string zipedFile, int compressionLevel, int blockSize)
        {
            //如果文件没有找到,则报错
            if (!System.IO.File.Exists(fileToZip))
            {
                throw new System.IO.FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!");
            }
 
            using (System.IO.FileStream ZipFile = System.IO.File.Create(zipedFile))
            {
                using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile))
                {
                    using (System.IO.FileStream StreamToZip = new System.IO.FileStream(fileToZip, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                    {
                        string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
 
                        ZipEntry ZipEntry = new ZipEntry(fileName);
 
                        ZipStream.PutNextEntry(ZipEntry);
 
                        ZipStream.SetLevel(compressionLevel);
 
                        byte[] buffer = new byte[blockSize];
 
                        int sizeRead = 0;
 
                        try
                        {
                            do
                            {
                                sizeRead = StreamToZip.Read(buffer, 0, buffer.Length);
                                ZipStream.Write(buffer, 0, sizeRead);
                            }
                            while (sizeRead > 0);
                        }
                        catch (System.Exception ex)
                        {
                            throw ex;
                        }
 
                        StreamToZip.Close();
                    }
 
                    ZipStream.Finish();
                    ZipStream.Close();
                }
 
                ZipFile.Close();
            }
        }
 
        /// <summary>
        /// 压缩单个文件
        /// </summary>
        /// <param name="fileToZip">要进行压缩的文件名</param>
        /// <param name="zipedFile">压缩后生成的压缩文件名</param>
        public static void ZipFile(string fileToZip, string zipedFile)
        {
            //如果文件没有找到,则报错
            if (!File.Exists(fileToZip))
            {
                throw new System.IO.FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!");
            }
 
            using (FileStream fs = File.OpenRead(fileToZip))
            {
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                fs.Close();
 
                using (FileStream ZipFile = File.Create(zipedFile))
                {
                    using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile))
                    {
                        string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
                        ZipEntry ZipEntry = new ZipEntry(fileName);
                        ZipStream.PutNextEntry(ZipEntry);
                        ZipStream.SetLevel(5);
 
                        ZipStream.Write(buffer, 0, buffer.Length);
                        ZipStream.Finish();
                        ZipStream.Close();
                    }
                }
            }
        }
 
        /// <summary>
        /// 压缩多层目录
        /// </summary>
        /// <param name="strDirectory">The directory.</param>
        /// <param name="zipedFile">The ziped file.</param>
        public static void ZipFileDirectory(string strDirectory, string zipedFile)
        {
            using (System.IO.FileStream ZipFile = System.IO.File.Create(zipedFile))
            {
                using (ZipOutputStream s = new ZipOutputStream(ZipFile))
                {
                    ZipSetp(strDirectory, s, "");
                }
            }
        }
 
        /// <summary>
        /// 递归遍历目录
        /// </summary>
        /// <param name="strDirectory">The directory.</param>
        /// <param name="s">The ZipOutputStream Object.</param>
        /// <param name="parentPath">The parent path.</param>
        private static void ZipSetp(string strDirectory, ZipOutputStream s, string parentPath)
        {
            if (strDirectory[strDirectory.Length - 1] != Path.DirectorySeparatorChar)
            {
                strDirectory += Path.DirectorySeparatorChar;
            }           
            Crc32 crc = new Crc32();
 
            string[] filenames = Directory.GetFileSystemEntries(strDirectory);
 
            foreach (string file in filenames)// 遍历所有的文件和目录
            {
 
                if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
                {
                    string pPath = parentPath;
                    pPath += file.Substring(file.LastIndexOf("\\") + 1);
                    pPath += "\\";
                    ZipSetp(file, s, pPath);
                }
 
                else // 否则直接压缩文件
                {
                    //打开压缩文件
                    using (FileStream fs = File.OpenRead(file))
                    {
 
                        byte[] buffer = new byte[fs.Length];
                        fs.Read(buffer, 0, buffer.Length);
 
                        string fileName = parentPath + file.Substring(file.LastIndexOf("\\") + 1);
                        ZipEntry entry = new ZipEntry(fileName);
 
                        entry.DateTime = DateTime.Now;
                        entry.Size = fs.Length;
 
                        fs.Close();
 
                        crc.Reset();
                        crc.Update(buffer);
 
                        entry.Crc = crc.Value;
                        s.PutNextEntry(entry);
 
                        s.Write(buffer, 0, buffer.Length);
                    }
                }
            }
        }
 
        /// <summary>
        /// 解压缩一个 zip 文件。
        /// </summary>
        /// <param name="zipedFile">The ziped file.</param>
        /// <param name="strDirectory">The STR directory.</param>
        /// <param name="password">zip 文件的密码。</param>
        /// <param name="overWrite">是否覆盖已存在的文件。</param>
        public void UnZip(string zipedFile, string strDirectory, string password, bool overWrite)
        {
 
            if (strDirectory == "")
                strDirectory = Directory.GetCurrentDirectory();
            if (!strDirectory.EndsWith("\\"))
                strDirectory = strDirectory + "\\";
 
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipedFile)))
            {
                s.Password = password;
                ZipEntry theEntry;
 
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = "";
                    string pathToZip = "";
                    pathToZip = theEntry.Name;
 
                    if (pathToZip != "")
                        directoryName = Path.GetDirectoryName(pathToZip) + "\\";
 
                    string fileName = Path.GetFileName(pathToZip);
 
                    Directory.CreateDirectory(strDirectory + directoryName);
 
                    if (fileName != "")
                    {
                        if ((File.Exists(strDirectory + directoryName + fileName) && overWrite) || (!File.Exists(strDirectory + directoryName + fileName)))
                        {
                            using (FileStream streamWriter = File.Create(strDirectory + directoryName + fileName))
                            {
                                int size = 2048;
                                byte[] data = new byte[2048];
                                while (true)
                                {
                                    size = s.Read(data, 0, data.Length);
 
                                    if (size > 0)
                                        streamWriter.Write(data, 0, size);
                                    else
                                        break;
                                }
                                streamWriter.Close();
                            }
                        }
                    }
                }
 
                s.Close();
            }
        }
 
    }

代码来自网络,略作修改,修改为静态方法,修改文件夹递归压缩时的bug..

posted @ 2011-10-19 09:34 假正经哥哥 阅读(422) 评论(1) 编辑
摘要: 前文我已经说了,为了能够让大家更好的理解xjplugin如何在asp.net mvc中应用,我编写了这样一个demo,本篇博文简要的说明下xEasy的结构,讲解一下ASP.NET MVC 和xjplugin 之外的东西。从这里下载到代码。要求安装了VS2010 和ASP.NETMVC3.0.打开解决方案,我们可以看到有两个主要的项目和一个解决方案文件夹,如下图所示: 其中xEasyApp.Web为网站, 包括视图,控制器,视图所需的特殊的Model 和js,css,image等文件。 xEasyApp.Core则包含项目的业务逻辑层,数据访问层,和一起一些公用的类,如异常,配置读取类等。MVC阅读全文
posted @ 2011-06-30 22:49 假正经哥哥 阅读(1010) 评论(4) 编辑

之前发布了一些基于jquery的js插件,旨在方便大家能够方便快捷的搭建客户端UI界面,最初的目的是希望能够提供一个脱离服务器端控件的UI解决办法,之前我单独写了各个控件的简要实现方法和调用说明,并提供了一个demo来演示控件的使用 ,大家可以通过http://code.google.com/p/xjplugin 的svn处获取最新的代码,其实所有的js 最新代码也可以到我即将发布的xEasyApp 的demo里获得。

前面提到了xEasyApp,是个什么东西呢,其实我想说它只是一个demo,目的是如果使用xjplugin和ASP.NET MVC结合构建基于web的应用系统,本demo实现了一个完整的权限管理模块,我想也是一个应用系统必备的模块,选择这样一个模块,是因为第一它比较通用,基本上所有的应用系统都需要,那么大家在开始编码的时候可以直接在这个demo的基础上开始工作了。第二这个模块说简单不简单,说复杂呢也不算复杂,所包含的界面我想基本上涵盖了常用的几种列表和表单情况,但愿能说明问题。

哈哈,任何系统从登陆开始,这个登录页虽然是我最后做的,但是最先介绍,我觉得还蛮有意思的,但愿有人能懂

image

 

登录成功之后,进去页面的主界面,这是一个看上去单页面的系统,其实本质不是单页面,中间其实是用iframe加载各自的页面,页面风格类似EXTJS,如果大家有比较好的美工和js基础可以替换和图片css技能实现换肤,但是我觉得还蛮顺眼的,来看看界面吧

image

可以看到主界面用到两个前面提到的控件一个是tree(打造基于jQuery的高性能TreeView),另外一个是tabpanel(基于jQuery打造TabPanel),首页我留白了,在实际系统中大家可以丰富首页的部分。

 

image

点击左侧的用户管理菜单可在右侧主区域新增一个选项卡,并自动加载用户管理的界面。 主界面还是分为两栏左侧是部门列表,右侧为用户列表,这种结构的界面,基本上所有的主从表结构的表单可以都支持了。右侧的列表使用flexigrid,在写这个demo的同时,我也对flexigrid也进行了一些修改,比如这里添加了行号的功能;增加往服务端发送列信息。以便更好和后端配合,避免后端的字段必须和前端顺序一样的尴尬问题。同时这里我新增了操作列,并放弃来原来一直使用的右键菜单(简简单单右键菜单)的方式。

image

 

点击编辑按钮弹出编辑窗口(其实是div模仿的模态窗口) ,使用的控件是jquery.ifrmdailog(这个控件之前没有介绍过,但是在xgcalendar中有使用过,很多同学来问过我代码,有空的话我单独介绍一下这个控件的使用)

image

点击移动 可变更用户所属的组织,此处在窗口中又弹出了一个选择框(以前我一般都会采用模态对话框),这里这个控件还是jquery.ifrmdailog(注意哦,这里没有边框哦) ,本demo中有很多个这种应用,还有更复杂的比如多选等等。如下图所示

image

上图是往角色中添加人员的选择界面。

表单中客户端验证是非常实用的功能不能没有,这里使用的控件是大名鼎鼎的jQuery Validation (这可不是我写的),当然那个很酷的提示消息是我的杰作,哈哈。。

image

最后一个比较常用的界面布局就是查询页了,查询页可以参考操作日志查询界面

 

 

image

查询条件可分为一行和多行,根据的实际条件树调整,下面是日志列表还是flexigrid。

本来我是给datepicker(打造基于jQuery的日期选择控件)添加了一个选择时分秒的功能,哈哈但是没有地方应用了(忽然想到上面的这个页面可以加上哦。。等后面加上去)

整个代码可以从这里获得http://code.google.com/p/xeasyapp/downloads/list ,接着我会通过几篇博文,更加细化的介绍各个控件在实际使用中如何和服务端交互,并且介绍一下我在demo中提供的快捷方法。我觉得非常好的编程方式和体验。大家也欢迎大家对此demo提出自己的意见和建议,同时也欢迎批评之声。如果反响好的话,我再介绍下如何在webform中更好的使用xjplugin。

 

你的支持就是我继续写作的动力!

 

本文地址:http://www.cnblogs.com/xuanye/archive/2011/06/27/xEasyApp_ByXjplugin.html 

转载请保留

另外做个广告哦,我的微博(http://weibo.com/redhu) 欢迎大家围观.

posted @ 2011-06-27 22:48 假正经哥哥 阅读(2416) 评论(34) 编辑

新增了针对php实现的demo,方便自会php或者类似脚本语言的同学理解xgcalendar,代码可能比较丑陋,请大家不吝指教

下载地址:http://code.google.com/p/xgcalendar/downloads/list

 

另有gae python版本的demo,不过因为gae对查询的限制,没有实现完整版本,如果有需要的同学可以到svn中获取。

 

另请有能力的同学提供以下jsp版本的demo 。本人实在精力有限。。

 

以下为 xgcalendar 更新历史

1:修改跨日日程,实际选择的时间不到一天时,计算间隔的bug
2009-11-23
2:在Demo中新增日程时可选择日程的颜色分类
2009-11-24
3: 添加对不同时区的处理,服务器端也要对应做调整
2009-11-25
4:修正了本地缓存在边缘处理不当的
2009-11-25
5:修正了缓冲处理的几个bug
2009-11-25
6:修正了时区问题遗留的bug
2009-11-30
7:修正了时区问题遗留bug,修正了demo,firefox 时间下拉无法展开的问题

2009-12-02
8:修正了缓存处理时,对于跨视图区域的处理

2009-12-11
9:修改了Title的显示,修正了缓存的问题,修正了demo中获取指定时间段日程的bug

2009-12-15
10: 修改Demo的数据访问为Subsonic
Subsonic 相关问题 http://Subsonicproject.com/

2009-12-18
11:在QuickAdd提交请求时,将exparams参数也提交到后台,以便做判断

2009-12-21
12:修正了demo中第一次访问,跨时区判断是否跨日的问题。

2010-1-10
13:修正了当点击快速新增后,重新点击某个日程,会出现两个提示框的bug

2010-1-20
14:新增了本地化支持,默认实现中文和英文
15:新增从月视图点击日期到日视图
16:修正了快速新增时只点击一点多出现的“-”符号

2010-1-29
15:本地化支持增加澳洲英语(主要是日期格式不同)
16:修正了月视图下当当前日期在下月不存在(如1月29日的下一个2月29日不存在)时,计算的bug
17:替换了若干中文符号为因为符号。

2010-02-01
19: 修正了在en-US语言环境下MVC 自动转换URL 参数日期格式到Datetime类型的转换错误

2010-02-05
20: 修正了datepicker的几处中文硬编码

2010-07-05
21:修正了在月视图单日有多个日程显示不下时,点击 【另外n个】按钮 显示日期错误的bug

2010-10-26
22:新增时间显示格式的控制,支持12小时制和24小时制的显示控制

2011-01-25
23:脚本压缩调整为使用Google Closure.Compiler 测试下来效果还不错
24:脚本文件更名 文件名jquery.calendar.js 修改为xgcalendar.js

2011-02-17
25:修正了月视图下 底部一栏 如果日程太多,显示不全时点击更多 显示错位的问题
修改了js 和css文件
26:修正了月视图下,所有日程的开始时间都是相同时,新增日程报错的问题

2011-04-28
27 新增php和python代码示例

posted @ 2011-04-28 19:57 假正经哥哥 阅读(422) 评论(14) 编辑

需求:公司域名从aep.com 修改为casoo.com 原域名仍可接收邮件,但是希望发到原域名的邮件 自动回复发送者告知:邮件域名已变更

 

原有的传输规则无法实现上述功能,那就只有自定义了。

首先copy 两个dll到开发服务器上

Microsoft.Exchange.Data.Transport.dll ,Microsoft.Exchange.Data.Common.dll (C:\Program Files\Microsoft\Exchange Server\Public directory) 

你可以编写两种传输规则:SmtpReceiveAgent,RoutingAgent

这里使用 后者 开始编码了,新建一个类库项目

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Exchange.Data.Transport;
using Microsoft.Exchange.Data.Transport.Routing;
using System.Diagnostics;

namespace AutoReplayForCustomerDomainRule
{
    public sealed class AutoReplayForCustomerDomainRoutingAgentFactory : RoutingAgentFactory
    {
        public override RoutingAgent CreateAgent(SmtpServer server)
        {
            return new AutoReplayForCustomerDomainRoutingAgent();
        }
    }

    public class AutoReplayForCustomerDomainRoutingAgent : RoutingAgent
    {
        public AutoReplayForCustomerDomainRoutingAgent()
        {
            base.OnSubmittedMessage += new SubmittedMessageEventHandler(AutoReplayForCustomerDomainRoutingAgent_OnSubmittedMessage);
            //base.OnResolvedMessage += new ResolvedMessageEventHandler(AutoReplayForCustomerDomainRoutingAgent_OnResolvedMessage);
        }

        void AutoReplayForCustomerDomainRoutingAgent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
        {
            if (e.MailItem.FromAddress.IsValid)
            {
                string rpdomain = string.Format("{0}@{1}", e.MailItem.FromAddress.LocalPart, e.MailItem.FromAddress.DomainPart);
                bool isNeedReply = false;
                //e.MailItem.Message.Subject += rpdomain;
                //e.MailItem.Message.Subject += "|" + AppConfig.AutoReplyDomain;
                foreach (EnvelopeRecipient ep in e.MailItem.Recipients)
                {
                    if (ep.Address.IsValid && ep.Address.DomainPart.ToLower() ==AppConfig.AutoReplyDomain)
                    {
                        isNeedReply = true;
                        break;
                    }
                }

                if (isNeedReply)
                { 
                    //                  
                    EWSService.Create().SendMail(AppConfig.AutoReplySubject, AppConfig.AutoReplyMessage, new string[] { rpdomain });
                }
                
            }
        }             
      
    }
}

 

部署:

打开Exchange命令行

执行下面的命令:

net stop msexchangetransport # to stop the exchange transport service

install-transportagent -name "autoreply_v1" -assemblypath c:\Transrule\AutoReplayForCustomerDomainRule.dll -transportagentfactory AutoReplayForCustomerDomainRule.AutoReplayForCustomerDomainRoutingAgentFactory
enable-transportagent -identity "autoreply_v1"

get-transportagent -identity "autoreply_v1"

net start msexchangetransport

posted @ 2011-04-17 12:02 假正经哥哥 阅读(168) 评论(0) 编辑
摘要: 今早收到一份老外的邮件,说我的xgcalendar插件被人盗版了,问我是否提供给了对方授权,并提供了对方的网站,如果没有他只是告诉我有这样一件事件 http://www.web-delicious.com/jquery-plugins/  (访问该站点竟然还要翻墙)   其实我在1-2个月前就见过wdcalendar(拷贝xgcalendar的插件,连抄袭都不能算),界面几...阅读全文
posted @ 2010-09-09 13:34 假正经哥哥 阅读(912) 评论(10) 编辑
摘要: 停了许久,终于有时间继续下一篇,这次我们要实现的控件时Tab控件,在实际的应用中也比较多,如大量信息查看,当网页多窗口框架等都会用到,现在网上基于jquery Tab控件,其实也蛮多了,我以前用过的i...阅读全文
posted @ 2010-05-21 23:23 假正经哥哥 阅读(5590) 评论(32) 编辑
摘要: 前几天装了个新版的office 2010beta版,一切都不错,界面也很漂亮,速度也不错。正happying,昨天打开代码,编写网页代码时忽然假死,重启,重新设置都不能解决,首先还以为是VSS 的问题(公司的VSS实在太慢了),后来发现并非如此,打开单个文件都会假死,又怀疑是某个插件的问题,吧GhostDoc, Resharper都卸载了都没有办法解决,恨不得重装系统了。只有怀疑是我windows...阅读全文
posted @ 2010-03-10 15:11 假正经哥哥 阅读(720) 评论(0) 编辑
摘要: 什么是 Python 语言 Python 语言是一种计算机编程语言,作用类似于 c/c++/java/perl/VB/Delphi 等等计算机编程语言,据有非常清晰易读的语法特点,并且是一种高级面向...阅读全文
posted @ 2010-02-25 17:26 假正经哥哥 阅读(900) 评论(11) 编辑
摘要: 想把xgcalendar的demo迁移到Google App Engine上,但是杯具的是它的存储竟然不支持 类似 SELECT * FROM Calendar WHERE (start_date>=:1 and start_date<:2) or (end_date>=:1 and end_date<:2) or (start_date<:1 and end_d...阅读全文
posted @ 2010-02-03 22:36 假正经哥哥 阅读(375) 评论(2) 编辑