随笔-19  评论-321  文章-0  trackbacks-7
  置顶随笔
摘要: 1. RapidSL框架基于WCF RIAService + EF + MVVM,UI采用了DomainService + RiaControls + EasySL Controls,对sl传统的开发方式进行了集成和封装,核心模块基于View,ViewModel模型,基本上只需要修改View视图就可以完成CRUD操作,提供了非常便捷的快速开发方式;2. 已经实现了轻量级的权限管理,上传模块,内容管理,简历管理,作为实例,涉及到了sl开发的各种技术难点和技巧,既可以作为学习,也可以作为项目开发的原型;3. RapidSL框架主攻快速开发领域,力求做到LightSwitch,而EasySL主要是容阅读全文
posted @ 2011-05-31 09:03 guozili@163.com 阅读(3911) 评论(35) 编辑
  2011年6月3日

RapidSL框架基于WCF RIAService + EF + MVVM,UI 采用了DomainService + RiaControls + EasySL Controls,对sl传统的开发方式进行了集成和封装,核心模块基于View,ViewModel模型,基本上只需要修改View视图就可以完成 CRUD操作,提供了非常便捷的快速开发方式;

一. Model(Domain Model)

1. RIA Service端通过EF生成

2. 然后在sl项目选中“WCF RIA Services link”,


3. 会自动生成UI Model,省去了DTO,保存在Generated_Code


二. ViewModel

1. 使用了LightMVVM,继承自ViewModelBase

2.  作为前端绑定的业务实体如:

protected bool isShowDataFormPanel;
public virtual bool IsShowDataFormPanel
{
get
{
return isShowDataFormPanel;
}
set
{
isShowDataFormPanel
= value;
RaisePropertyChanged(
"IsShowDataFormPanel");
}
}

3. 作为视图绑定事件通知的RelayCommand

protected ICommand itemEdit;
public virtual ICommand ItemEdit
{
get
{
if (itemEdit == null)
itemEdit
= new RelayCommand(() =>
{
this.IsShowDataFormPanel = true;
});

return itemEdit;
}
}

4.注入ViewModel到App资源,[StaticResource(Key..., 和在App.xaml里写资源是一样的

namespace RapidSL.UI.ViewModels
{
[StaticResource(
"MainViewModel")]
public partial class MainViewModel : MyViewModelBase

5. 我实现了一个通用的带CRUD ViewModel:

三. View

1. 赋DataContext为对应的ViewModel

<UserControl.DataContext>
<Binding Source="{StaticResource Article_ItemViewModel}"/>
</UserControl.DataContext>

2. Binding和Command

<Button Command="{Binding ItemDelete}" IsShow="{Binding IsShowDataFormPanel, Mode=TwoWay}">

下载:http://easysl.codeplex.com/releases/view/26522
预览:http://rapidsl.guozili.25u.com/  (guest/guest  admin/admin  请不要删除资料)

RapidSL - a efficient and fast Infrastructure for silverlight development
Produced by xiaoyi
/www.guozili.25u.com/guozili@163.com

posted @ 2011-06-03 11:59 guozili@163.com 阅读(1039) 评论(2) 编辑
  2011年5月31日

1. RapidSL框架基于WCF RIAService + EF + MVVM,UI采用了DomainService + RiaControls + EasySL Controls,对sl传统的开发方式进行了集成和封装,核心模块基于View,ViewModel模型,基本上只需要修改View视图就可以完成CRUD操作,提供了非常便捷的快速开发方式;

2. 已经实现了轻量级的权限管理,上传模块,内容管理,简历管理,作为实例,涉及到了sl开发的各种技术难点和技巧,既可以作为学习,也可以作为项目开发的原型;

3. RapidSL框架主攻快速开发领域,力求做到LightSwitch,而EasySL主要是容易和传统的三层架构进行无缝整合,在复杂的CRUD项目中运用;

4. 唯一需要配置是web.config里的connectionStrings的sqlserver2008地址,默认为.\SQLEXPRESS;












下载:http://easysl.codeplex.com/releases/view/26522
预览:http://rapidsl.guozili.25u.com/  (guest/guest  admin/admin  请不要删除资料)

RapidSL - a efficient and fast Infrastructure for silverlight development
Produced by xiaoyi
/www.guozili.25u.com/guozili@163.com
 
posted @ 2011-05-31 09:03 guozili@163.com 阅读(3911) 评论(35) 编辑
  2011年3月21日
虽然codeplex已经有一些多文件,带进度条的上传控件,但是觉得都不是很好用,所以基于上面的控件重新设计了一个上传控件,更好的交互,属性绑定和管理文件。

 

 

1. 客户端使用:

<mycontrol:FileUploadControl x:Name="uploader" Filter="文本文件|*.txt" RemoveText="取消" AddText="上传本地文件"/>
<TextBox Text="{Binding ReturnUrl, ElementName=uploader,......
<Image Source=
"{Binding ReturnUrl, ElementName=uploader......

属性设置:
Filter: 允许上传的文件类型
RemoveText: 当撤销上传时button的文字
AddText: 上传button的文字
MaximumUpload: 文件大小限制
UploadChunkSize:分段的大小
ReturnUrl:上传完成后返回的Url,如Files/UploadFiles/20110320/123.txt

2. 服务器端设置:FileUpload.ashx
主要实现fileUpload_FileUploadCompleted里的对文件的处理:
比如对文件定义保存的路径,对图片文件进行缩略图处理

3. 源码点击下载

4. 在线Demo: 点击预览

 

posted @ 2011-03-21 10:40 guozili@163.com 阅读(2669) 评论(21) 编辑
  2011年1月19日

 

代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.ComponentModel;
using System.Threading;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace HuoChePiao
{
    
class Program
    {
        
private static HashSet<string> results;
        
private static WebClient wc;
        
private static List<Site> sites;
        
private static int index;
        
private static bool isFirstRound;
        
        
static void Main(string[] args)
        {
            sites 
= new List<Site>();
            
            sites.Add(
new Site()
            {
                Name 
= "火车票网",
                Url 
= "http://www.huochepiao.com/City/SearchCheCi.asp?leixing=%D7%AA%C8%C3&zhuti=t189&psearch=%C7%F3%B9%BA%2F%D7%AA%C8%C3%BC%EC%CB%F7",
                RegexPattern 
= @"· <A href=(.*?) target=_blank>(.*?)</a>",
                Encoding 
= Encoding.Default
            });
            
            sites.Add(
new Site()
            {
                Name 
= "百姓网",
                Url 
= "http://beijing.baixing.com/huochepiao/?%E8%BD%A6%E6%AC%A1=T189",
                RegexPattern 
= @""" ><a href=""/(.*?)"">(.*?)</a></td>",
                Encoding 
= Encoding.UTF8,
                Domain 
= "http://beijing.baixing.com/",
                Keys 
= new string[] { "" }
            });

            sites.Add(
new Site()
            {
                Name 
= "百姓网",
                Url 
= "http://beijing.baixing.com/huochepiao/?%E8%BD%A6%E6%AC%A1=T5",
                RegexPattern 
= @""" ><a href=""/(.*?)"">(.*?)</a></td>",
                Encoding 
= Encoding.UTF8,
                Domain 
= "http://beijing.baixing.com/",
                Keys 
= new string[] { "" }
            });
   
            sites.Add(
new Site()
            {
                Name 
= "酷讯网",
                Url 
= "http://huoche.kuxun.cn/zhuanrang-checi-beijing-T189.html?type=1",
                RegexPattern 
= @"<span class=""col_11 left""><a target=""_blank"" href=""(.*)"">(.*)</a>",
                Encoding 
= Encoding.UTF8
            });

            sites.Add(
new Site()
            {
                Name 
= "酷讯网",
                Url 
= "http://huoche.kuxun.cn/zhuanrang-checi-beijing-T5.html?type=1",
                RegexPattern 
= @"<span class=""col_11 left""><a target=""_blank"" href=""(.*)"">(.*)</a>",
                Encoding 
= Encoding.UTF8
            });

            sites.Add(
new Site()
            {
                Name 
= "酷讯网",
                Url 
= "http://huoche.kuxun.cn/zhuanrang-checi-beijing-k185.html?type=1",
                RegexPattern 
= @"<span class=""col_11 left""><a target=""_blank"" href=""(.*)"">(.*)</a>",
                Encoding 
= Encoding.UTF8
            });

            sites.Add(
new Site()
            {
                Name 
= "清华网",
                Url 
= "http://www.newsmth.net/bbsbfind.php?q=1&board=Ticket&title=T189&title3=%C7%F3&dt=1",
                RegexPattern 
= @"<a href=""(bbscon.php.*)"">(.*)</a>",
                Encoding 
= Encoding.Default,
                Domain 
= "http://www.newsmth.net/"
            });

            sites.Add(
new Site()
            {
                Name 
= "清华网",
                Url 
= "http://www.newsmth.net/bbsbfind.php?q=1&board=Ticket&title=K185&title3=%C7%F3&dt=1",
                RegexPattern 
= @"<a href=""(bbscon.php.*)"">(.*)</a>",
                Encoding 
= Encoding.Default,
                Domain 
= "http://www.newsmth.net/"
            });
            
            results 
= new HashSet<string>();

            isFirstRound 
= true;

            wc 
= new WebClient();
            wc.Encoding 
= sites[index].Encoding;

            wc.DownloadStringCompleted 
+= new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
            wc.DownloadStringAsync(
new Uri(sites[index].Url));

            
int order;         
            
while (int.TryParse(Console.ReadLine(), out order))
            {
                OpenLink(results.ElementAt(order 
- 1));
                Console.ForegroundColor 
= ConsoleColor.Green;
            }
        }

        
static void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            
int i = 0;
            
            MatchCollection mc 
= Regex.Matches(e.Result, sites[index].RegexPattern);
            
foreach (Match m in mc)
            {
                
if (m.Success)
                {
                    
string result = sites[index].Domain + m.Groups[1].Value;
                    
string content = m.Groups[2].Value;
                    
if (!results.Contains(result))
                    {
                        
bool isContainKey = true;
                        
if (sites[index].Keys != null)
                        {
                            
foreach (string key in sites[index].Keys)
                            {
                                
if (!content.Contains(key))
                                {
                                    isContainKey 
= false;
                                    
break;
                                }
                            }
                        }

                        
if (!isContainKey)
                            
continue;

                        results.Add(result);

                        Console.ForegroundColor 
= isFirstRound ? ConsoleColor.Gray : ConsoleColor.White;

                        Console.WriteLine(
"{0} <{1}>  {2}.  {3}", DateTime.Now.ToShortTimeString(), sites[index].Name, results.Count, m.Groups[2].Value);

                        
if (!isFirstRound)
                        {
                            OpenLink(result);
                        }               
                    }
                }

                
if (i++ > sites[index].Numbers - 2)
                    
break;
            }

            Thread.Sleep(
1000);

            index 
= index + 1;
            
if (index == sites.Count)
            {
                index 
= 0;

                
if (isFirstRound)
                    isFirstRound 
= false;
            }

            wc.Encoding 
= sites[index].Encoding;
            wc.DownloadStringAsync(
new Uri(sites[index].Url));
        }

        
static void OpenLink(string url)
        {
            Process.Start(url, 
"_blank");
        }
    }

    
public class Site
    {
        
//站点名称
        public string Name { getset; }
        
//站点的网址
        public string Url { getset; }
        
//正则表达式
        public string RegexPattern { getset; }
        
//编码
        public Encoding Encoding { getset; }
        
//网站名称
        public string Domain { getset; }
        
//包含关键字
        public string[] Keys { getset; }
        
//取前面多少条
        public int Numbers { getset; }

        
public Site()
        {
            
this.Numbers = 3;
        }
    }
}

 

 

每年都用这个抢到票了,今天也不例外,分享给大家:

1. 里面的规则你可以自己添加,我已经写好了很多,你把网址里德车次改下就行了

2. 初始化会抓取最新的信息,但是不弹出网页,你可以在控制台输入id号,弹出对应id号的网址

3. 后面会自动循环捕获每个站点的新信息,并弹出网页

 

快就一个字,希望大家都能买到火车票,安心回家

 

posted @ 2011-01-19 14:43 guozili@163.com 阅读(21183) 评论(43) 编辑
  2010年9月10日
摘要: 最近研究了下RIA Services+EF自动生成Silverlight context代码非常方便,但是只有使用EF/Linqtosql + LinqToEntitiesDomainService的方式才能同Silverlight结合的很好,且可控性不是很好,在领域模型耦合度还是比较高,难以同传统的三层架构无缝结合。 然后回顾了自己的EasySL框架,究其量也只是个轻量级的DomainService,所以提取出核心的数据传输服务,作为独立的版本发布,如果不适应 RIA Services的开发方式,可以借以了解下EasySL.阅读全文
posted @ 2010-09-10 12:34 guozili@163.com 阅读(1355) 评论(5) 编辑
  2010年6月3日
摘要: 最近3年的SL相关开发中,积累了大量的SL控件,在一些企业级项目中得到充分的应用。 但是大部分不够规范,来不及整理,这次闲来一些时间,整理了几个有代表性的控件加入到最新的版本中,并且修复了一些bug和机制,同大家分享交流。阅读全文
posted @ 2010-06-03 09:16 guozili@163.com 阅读(3152) 评论(27) 编辑
  2010年6月1日
摘要: U can access it by following url:1.GMusic: http://gmusic2.guozili.25u.com http://www.guozili.25u.com/gmusic.htm2.ODPOnline: http://www.guozili.25u.com/ODPIndex.aspx3.Msnbc: http://www.guozili.25u.com/MsnbcIndex.aspx4.CCTV: http://www.guozili.25u.com/CCTV/index.htm5.SQM: http://www.guozili.25u.com/SQ阅读全文
posted @ 2010-06-01 10:55 guozili@163.com 阅读(423) 评论(5) 编辑
  2009年2月27日
摘要: 1classProgram2{3staticvoidMain(string[]args)4{5//异步委托方法一6Func<int,int>func=newFunc<int,int>(Square);7IAsyncResultar1=func.BeginInvoke(10,null,null);8while(!ar1.IsCompleted)9Console.WriteLine(func.EndInvoke(ar1));1011//异步委托方法二12IAsyncResultar2=func.BeginInvoke(20,null,null);13ar2.AsyncWai阅读全文
posted @ 2009-02-27 17:45 guozili@163.com 阅读(429) 评论(3) 编辑
  2008年11月23日
摘要: 接上篇“基于Silverlight的精简框架之解析”,最近研究了ExtJs,发现其虽然外观很酷,但是开发难度比较大,大量JS不易维护,于是乎想起基于EasySL框架,实现ExtJs的部分功能。比较起来SL的UI和异步机制很容易实现,特别是SL类似于winform的控件开发方式,给开发丰富的RIA提供强大的支持。一、此次主要是展示一个后台管理UI: 1. 登陆、列表、分页、添...阅读全文
posted @ 2008-11-23 19:01 guozili@163.com 阅读(6458) 评论(54) 编辑
  2008年11月7日
摘要: 接上篇“基于Silverlight的精简框架之介绍”,Silverlight的数据请求需要架设wcf、webservice或者webclient,而且中间数据需要序列化和反序列化,或者自己用linq解析,易用性不是很强,且比较麻烦,基于目前还没有统一和规范的silverlight开发模式,所以从五六个自己做过的基于Silverlight的中型项目,抽出核型代码形成一套精简框架,方便调用,扩充和分布...阅读全文
posted @ 2008-11-07 16:25 guozili@163.com 阅读(3140) 评论(6) 编辑
仅列出标题  下一页