Friday, October 17, 2008

统计油耗的在线工具

最近写了个统计油耗的在线工具,主要是想玩玩python和google app engine. 刚刚有点成型,希望以后自己能不断完善。里面顺便也调用了google chart api.

http://gastics.appspot.com/

Thursday, July 31, 2008

如何快速测试数据库连接

在一台没有任何开发环境的服务器上,怎样以最简便的方法测试你的数据库连接字符串是否正确?
我这里介绍的方法不需要任何开发工具,一个干净的Windows即可。

1. 创建一个文本文件。
2. 修改文件的后缀名为 udl
3. 双击该文件运行

后面的不用我多说乐吧,这个方法好几年前就用过了,不过后来一直想不起来后缀名应该是什么,今天终于在google上找到。

Monday, February 25, 2008

configuration数据库的信息

今天一个同事问我怎么得到一个farm的configuration数据库的信息,我搜索了一下,发现:

using Microsoft.SharePoint;

using Microsoft.SharePoint.Administration;

using (SPSite site = new SPSite("http://basesmcdev/tester1"))
{

SPProcessIdentity pi = site.WebApplication.Farm.TimerService.ProcessIdentity;
string userName = pi.Username;
object configDB = pi.GetType().GetProperty("ConfigurationDatabase", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pi, null);
SPServer server = (SPServer)configDB.GetType().GetProperty("Server").GetValue(configDB, null);
string serverName = server.Name;

}


但是我没有测试过。很诡异的办法。

Monday, January 21, 2008

如何禁止掉SharePoint页面个性化?

转:


如何禁止掉SharePoint页面个性化?

如何彻底禁止对SharePoint页面的个性化?

使用SharePoint Designer打开,或者创建一个新的Master Page,找到SPWebPartManager控件,如下所示,修改它的属性“Personalization-Enabled”为“false”即可。

image

让SharePoint站点使用此Master Page之后,就会看到“编辑页面”这个按钮已经变成灰色,无法选择了:

image

Tuesday, December 18, 2007

"No access" site in MOSS2007

If you access a readlocked site.


1. This is by design: if you access an existing page, like /default.aspx or /_layouts/settings.aspx, you will get error message:

Access to this Web site has been blocked.
Please contact the administrator to resolve this problem.

In this condition, MOSS will check the permission on page first then throw the above error if the site is locked.

But if you access a folder, like / or /subsite or /doclib, you will get

403 FORBIDDEN

Or

404 NOT FOUND

In this condition, MOSS will check redirection function first, then throw the above error if the site is locked.

2.WSS/MOSS does not support custom error pages, the only customization can be made is for 404 (File not found error) on web application. You can check this:

SPWebApplication.FileNotFoundPage Property

http://msdn2.microsoft.com/en-gb/library/microsoft.sharepoint.administration.spwebapplication.filenotfoundpage.aspx

Windows SharePoint Services does not support the custom error pages that are typically used in IIS applications. There can only be one file per SharePoint Web application, which must be in HTML and cannot contain dynamic ASP.NET controls.

do whatever you want with Farm level administrators permissions.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
// do whatever you want with Farm level administrators permissions.
}

Thursday, November 22, 2007

event handler

if you want to add a event handler for a site or web, you can't use feature to install the handler, you must use API to install it. for example, you want to overwrite the webdeleting event.

Tuesday, November 06, 2007

How to get SharePoint Central Administration webapplication URL?

Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local.Sites.VirtualServer.Url.ToString();