2010年10月12日

继承windows service的安装类出现的多余服务被安装的问题

最近开发了两个windows service的程序,由于有共同之处,因此我在第二个service的安装类中直接继承了第一个service的安装类。 结果发现用installutil工具对第二个service进行安装的时候,有多余的service被安装上去。

 

ProjectInStaller 是继承了System.Configuration.Install.Installer. 它们在构造函数里面有一个InitializeComponent函数,而在这个函数里面他们加载了SerivceInstaller,因此,如果第二service继承了第一个service,它就有两个ServiceInstall,因此会安装一个多余的service。解决方法很简单:在子类中的构造函数里面去掉InitializeComponent 就可以了。

 

 

posted @ 2010-10-12 10:07 ASTAR Coming Now 阅读(112) 评论(0) 编辑

2010年8月5日

List Sort 使用的注意几点

以前有个哥们好像写过类似的文章。当时没有注意,今天才发现有时候Sort时候真会带来麻烦。说说我遇到的麻烦:

我需要监控一个机器的状态,得到的数据类似:

1-PRD 8:30:00

2-STD 8:30:00

3-PRD 9:30:00

4-STD 9:31:00

 

我把数据都放在一个List<StateItem>容器里面,同时StateItem实现了IComparable接口,是datetime来排序。其实数据过来时候也是按照时间来排序,但是我仍然做了Sort操作。

结果问题出现了,我出来的统计报表跟以前跑的报表由差距。

PRD time : (2)-(1)+(4)-(3) = 1 Min

STD time : (3)-(2) = 1 hour

 

结果排序后,数据顺序成了(1)和(2)调换了,

 

1-STD 8:30:00

2-PRD 8:30:00

3-PRD 9:30:00

4-STD 9:31:00

PRD time : (4)-(2) = 1 hour +1min

STD time : 0

 

结果大相径庭。 :(

总结:排序的时候要考虑到相同rank的情况。

 

另外一种情况是由于比较数接近造成的问题

int IComparable.CompareTo( stateItem item)
        {

            return Convert.Int32((this.datetime – item.datetime).TotalMinutes);
         }

 

好像没有错。但请考虑当totalMinutes<1为小数的情况,则无法判断两个对象的次序。

 

OK,转成

return this.datetime.ticks.CompareTo(item.datetime.ticks);

 

enn….

 

关于排序的接口有2个:

1 IComparable

子项完成。

2. IComparer

容器完成

除此,Sort支持直接调用方法

 

ListExample.Sort(Method1);

 

public int Method1(item X, item Y)

{

…..

}

posted @ 2010-08-05 22:10 ASTAR Coming Now 阅读(82) 评论(0) 编辑

2010年3月4日

Three collaboration teamwork Tools

- IBM Lotus Quickr (C/S, need license )

Introduction :

https://slater.warwick.ac.uk/lotus/quickr/!ut/p/c0/04_SB8K8xLLM9MSSzPy8xBz9CP0os_hQJ29XlzBnI0N3YyNzAyMv51CngMBAI5MAY_2CbEdFAAPfjLs!/

 

- Office Groove(C/S, P2P, need license)

http://office.microsoft.com/en-us/groove/HA101656331033.aspx

 

- Collanos (P2P, freeware).

http://www.collanos.com/en/products/workplace/tour

 

In this kind of software, the share workspace is a good start. You can start a work with different people in different workspace. And it includes some tools like discussion, IM and meeting. In this virtual office, you could do your work with other people, manage your documents, arrange your schedule and align the team goal.

 

The collaboration software market grow faster and bigger. Cause people have to and like to work together to complete a work than before. So P2P tech is very important for this kind of tool, cause most of middle companies won’t buy new server(including hardware or software), they want to reduce non-core cost. They want to install the software and start to use not do much work on setup.

Actually it’s a trend of SOA, the user don’t care what you setup, they just want to use.

posted @ 2010-03-04 15:39 ASTAR Coming Now 阅读(31) 评论(0) 编辑

2010年3月3日

How to do ‘undo’ in TortoiseSVN

In one project, I found current revision had some errors and want to come back a old revision, so I use ‘update to revision’, but It looks like it don’t work as I think.

so how to roll back to a previous revision? en… now

Looking at TortoiseSVN’s menu or going through the list of command-line options you’ll see … gasp! … subversion forgot a roll-back feature! How could they do that?

http://jacwright.com/blog/75/how-to-roll-back-changes-using-subversion/

this article tell us how to do that, but he use merge to do that. I don’t think it’s a good way, the following I will show you what I did to roll back to old version.

There some different scenarios that need us to return back old revision.

1) You just want an earlier version of the code to use but not commit on.
2) You want to rewind the codebase to an earlier version and then be able to work with/commit using the earlier version as a starting point.
3) You want to rewind the codebase to an earlier version and then be able to work with and merge the changes with one revision after the earlier version.

Regarding the different requirements, we’ll choose different ways to handle. However, the actions that we used to use are revert to revision and update to revision 

If you want to do 2,3, then I think revert to revision is your best choice.

if you want to do 1, then update to revision is your choice.

Please see the following description, you will understand why I said that. Let’s go…..

First, we do some changes and commit it to repository.

imageimage

Check the revision, Now it’s 290.

Revert to revision

OK, we’d like to return back(Roll back) to the first revision, we look at it by selecting Tortoise SVN – > show log, And I found this revision and click Revert to this revision

image 

Now, we come back to previous revision, but please notice even the CONTENT of test.cxx comes back to previous revision, but the current SVN revision of this file is still current- 290. it’s very important. see

image

Now we change it again And commit changes. OK, it meets my requirement.

image image

 

Update to revision

image image

image

Here please pay attention to this revision flag, it was 287 not current 290.

image image

Now, I found the CONTENT of file return back to previous. It’s ok. then we do some changes and commit it again!

image

You will find this error when you want to commit it. [out-of-date]

image

Yes, it’s correct for SVN. Because you return back to revision 287 it’s an old revision. If you want to ‘undo’, obviously you choose an error function. Don’t use update to revision to do UNDO, but use revert to revision.

So if you insist to commit it, you have to do an update, before committing successfully.

That’s all  I have. Enjoy it!

posted @ 2010-03-03 11:22 ASTAR Coming Now 阅读(49) 评论(0) 编辑

How to resolve conflicts in TortoiseSVN

Sometimes, after we update our files from repository, we’ll meet this problem.

image_thumb31 image_thumb

If you open file, you will find it’s hard to understand and correct them.

<<<<<<< .mine
3 modifuy=======
2 modify>>>>>>> .r288

 

In fact, TortoiseSVN provides a good tool to help us resolve this issue. First, we need to Edit conflicts.

image_thumb33

There are three working regions, the left is from repository, the right is from my working file. the bottom you know, it’s the last result after your editing.

image_thumb35

I click one line and click right button of mouse, look here is context menu . You can choose to use this block or merge yours into the file,

image_thumb37

The merge result was changed according my decision. I click save and check the content of file in my PC, now it have been changed. But the flag of conflict still exist.

image_thumb39

Now, we click resolved.and now we can commit successfully.

image_thumb41

 

 

posted @ 2010-03-03 11:19 ASTAR Coming Now 阅读(23) 评论(0) 编辑

2009年10月29日

如何:.NET 组件/控件在设计时的调试

本文主要介绍如何在设计时对组件的调试,多数情况开发人员用MessgeBox来弹出信息进行调试,但无法进入到代码内部。因此本文以图解的方式来介绍。本文参考了微软MSDN中《演练:设计时调试自定义 Windows 窗体控件》,鉴于其中文版翻译很晦涩,建议大家参考本文

 

背景知识介绍

需要了解组件和控件的区别, 组件编程的大概方向,以及.NET提供哪些服务(组件)来支持组件编程及设计时的事件。

image

有兴趣可以参考:

.net控件编程 - 资料篇

 

STEP BY STEP 调试

组件设计时的调试对象为两个:
一种对象是我们关注的组件本身。另一种则是组件的设计器。

举例一个组件MyComponet有一个属性,我需要在设置值的时候,进行调试更踪。

    private string demoStringValue = null;
        [Browsable(true)]
        public string DemoString
        {
            get
            {
                return this.demoStringValue;
            }
            set
            {
                demoStringValue = value; //设置æ-­ç‚¹
            }
        }

准备工作
1.创建一个library,并创建MyComponent组件,添入以上代码,并编译。
2.加入一个调试用的windows application项目TestMyComponent.
3. 设置library项目为启动项目,在属性中调试中设置启动外部程序,
设定VS的位置:
如:
D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe

image

继续下去   

1. 按F5开始调试过程。这时会有一个新的VS.NET实例被启动。我们在新vs中重新加载此解决方案。

image

4. 在windows application工程中,双击Form1打开之。
5.     在工具栏中拖入MyComponent到Form1,   
6. 在属性页中,改变DemoString属性的值为Good bye。   
7. 此时应当步入断点所在处。

image

我们已经介绍了调试组件本身。

有时候,我们会自定义设计器来实现一些特定的功能。

比如:我们要捕捉组件被加入的事件,组件被移除的事件。要解决的是访问设计时的服务。

让某控件或组件都可以通过定义设计器标签来制定自定义的设计器。

clip_image001

而在设计器中要想触发对应的事件,就必须取得服务对象并挂接对应事件。

自定义设计器必须从ControlDesigner或者ComponentDesigner继承

clip_image002

自定义初始化,并加入一个初始化化服务对象的私有方法:

clip_image003

可以访问的服务:

clip_image004

比如:我们关注的控件的加入或移除事件

clip_image005

ComponentAdded的事件

clip_image006

在这里设置断点,并重复刚才的调试动作。所不同的最后两部,

我们将控件或组件,拖入到form1时候,这时候调试进入到了Designer中。

到此为止,两种类型调试结束了。

posted @ 2009-10-29 16:56 ASTAR Coming Now 阅读(97) 评论(0) 编辑

Outlook2007 addin开发必读-菜单定制篇

介绍
自从微软开始推出VSTO以后,我们就更容易在此基础上面开发Add-in程序。对VSTO的介绍,大家可以看看这篇文章:VSTO简介及发展。本文例子是基于VSTO 3.0上进行的开发。
本文是在微软《Customizing the Ribbon in Outlook 2007》 基础上加入自己的实践和想法,供大家参考。

这段文字是来至于:
Http://msdn.microsoft.com/zh-cn/library/bb226712(en-us).aspx
Customizing the Ribbon in Outlook 2007

The Microsoft Office Fluent user interface (UI) is the terminology used to describe the new UI for the 2007 Microsoft Office system. The Ribbon is a component of the Microsoft Office Fluent UI.
Ribbon是新的Microsoft办公软件舒适?的界面组件。

Unlike other applications in the 2007 Microsoft Office system, such as Microsoft Office Word, Microsoft Office Excel, and Microsoft Office PowerPoint, which rely exclusively on the Ribbon, Microsoft Office Outlook 2007 uses both the Ribbon and command bars. Additionally, Outlook does not support document-level customizations of the Ribbon. You can customize the Ribbon only by implementing the IRibbonExtensibility interface in an Outlook add-in.
OutLook有区别于其他Office程序(word,excel,powerPoint),它不像它们完成依赖于Ribbon,outLook 2007同时存在两种样式菜单-Ribbon和command bars。此外,Outlook 2007不支持页面级(关于页面级的说明请参看:VSTO简介及发展)Ribbon的定制。你只能通过实现一个IRibbonExtensibility接口在Outlook add-in项目来定制Ribbon。

 

一个OutLook 2007 add-in项目只能实现一个Ribbon

一个Ribbon可以有多个Ribbon Tab。
Ribbon对象是怎么跟Add-in结合起来的?
在add-in class中通过下面任意方法Hook上的。
方法一:

protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() { return new Ribbon(); } 

方法二:

private Ribbon _ribbon;
protected override object RequestService(Guid serviceGuid)
{

if (serviceGuid==typeof(Office.IRibbonExtensibility).GUID)
{
if (_ribbon == null)
_ribbon = new Ribbon();
return _ribbon;
}
return base.RequestService(serviceGuid);
}

 

一个Ribbon可以出现在多个Item窗体上(什么是item?Message,contact,appointment 等等)如果只让Ribbon出现某几个Item窗体上?

 

#region IRibbonExtensibility Members
public string GetCustomUI(string ribbonID) { return GetResourceText("emailFinder.Ribbon.xml"); }
#endregion
//如果只让它出现在撰写邮件的窗体上
public string GetCustomUI(string ribbonID) {
if(ribbonID=="Microsoft.Outlook.Mail.Compoase") return GetResourceText("emailFinder.Ribbon.xml");
else
return string.Empty; }
 
*注意:ribbonID你可以在vs2008 ribbon组件视图设计器中得到
image 
 
ribbon视觉设计项的作用?
image 
 

它的作用是完成视觉设计并导出成为ribbon的标准XML。
而代码工作都是在ribbon类中手工完成

 

In the main application window, Outlook displays the command bars that are familiar to users of earlier versions of Microsoft Office.
在OutLook 2007主窗体中,我们使用以前版本很像是的command bars

In item windows, such as a mail message window where authoring is the central user experience, Outlook uses the new Ribbon.
在子项窗体里,比如邮件消息窗体(其编辑功能是用户体验核心),Outlook使用新的Ribbon

To provide the best authoring experience for end-users, Outlook item windows display item-specific Ribbons. From an object model perspective, an Outlook item window is an Inspector object. If you have existing code that uses the object returned by the Inspector.CommandBars property to customize command bars for standard or custom item types, this article describes how Ribbon extensibility improves your existing customizations of command bars for an Outlook Inspector.
对于更佳的需要客户体验编辑窗体来说,我们使用Ribbon。它是观察者(Inspector)对象,通过Inspector.CommandBars 属性来获取定制的菜单。

The main application window, known as an Explorer object, still uses command bars introduced in earlier versions of Office.
For an Outlook Explorer, you continue to use the object returned by the Explorer.CommandBars property to customize the Outlook window. As a prerequisite for this article, you must know how to write code for the Office CommandBars object model so that I will not spend much time discussing the CommandBars object model.

对主窗体来说,是一个浏览对象,而且可以继续使用Explorer.CommandBars属性来取得command bars对象。而我也不用花大量时间来介绍CommandBars对象模型。

There are several excellent blogs and technical articles that discuss Ribbon extensibility in detail on MSDN. For a comprehensive view of all aspects of the Ribbon, a must-read is Jensen Harris: An Office User Interface Blog. For developer information about Ribbon extensibility for tabs, groups, and controls, see Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3), Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3), and Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3) by Frank Rice. I urge you to view these references because I do not repeat the comprehensive listing of Ribbon XML Schema and callback signatures that you can find on MSDN. In this article, I focus on what you have to know about the Outlook implementation of the Ribbon.

介绍了在主窗体和item窗体后,我再说一下上下文菜单的定制,也就是通常说的右键菜单。

image

通过观察和阅读其他文章,我认为上下文菜单是可以通过Explorer.CommandBars获取, 理由是在主窗体中Outlook 2007依然使用以前的菜单模型。

posted @ 2009-10-29 16:35 ASTAR Coming Now 阅读(532) 评论(0) 编辑

2009年10月13日

Perl 对象化编程的实现

摘要: 缘由 最近反过头来看Perl,一方面是我的客户厂家用Perl开发了很多东西,另一方面在了解过程中,又复习了Perl语言,并且有了一些心得。记录下来,供大家参考。 我在做一个小程序,就是解析一个文本文件,将其中的内容进行处理,并保存在另一个文件。 背景知识 1. Perl的对象化编程实现 请参考阅读: O'Reilly - Advanced Perl Programming.pdf - 第7章 [...阅读全文

posted @ 2009-10-13 12:55 ASTAR Coming Now 阅读(241) 评论(0) 编辑

2009年9月28日

VC++ 6.0 与VS2008 C++ DEBUG工具(Windows)介绍

摘要: 在VC++ 6.0 里面,debug工具有这些: 请看大图展示: 这里面几个工具都是经常用到的。比如:上下文信息,可以查看当前变量的值和地址Memory: 可以输入地址查看里面的内容。对调试和检查指针特别有用。 在vs2008里面,debug做为单独的主要菜单出现了。 1.Autos自动显示目前执行语句与上一行的各个参数2.locals显示当前函数内所有变量的情况3.watch,输入变量查看这三...阅读全文

posted @ 2009-09-28 23:15 ASTAR Coming Now 阅读(625) 评论(0) 编辑

2009年9月27日

C++ 如何获取目录下面的文件/文件的创建时间

摘要: 我手上有一个C++程序会生成一些临时文件,过期以后希望能够删除. 到达成这个目的,我需要做到: 根据提供的路径, 列取所有文件,并比较现在时间跟其创建时间的差,如果超过N天,则删除. 问题分解开来是: 1. 取得某个目录下面所有文件 2. 取得文件的创建日期 3. 取得当前日期跟其创建的日期差 4. 删除文件 为此,我写了一个小程序来测试 1: // TestFileFunction.cpp :...阅读全文

posted @ 2009-09-27 16:51 ASTAR Coming Now 阅读(1113) 评论(0) 编辑

导航

<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

公告

kingastar@G妹.com欢迎交流
技术不是全部

昵称:ASTAR Coming Now
园龄:8年
粉丝:1
关注:0

搜索

 
 

常用链接

随笔分类

随笔档案

文章分类

相册

博之友

其他链接

积分与排名

  • 积分 - 163707
  • 排名 - 554

最新评论

阅读排行榜

评论排行榜

推荐排行榜