Archive for the 'IT' Category

reference: http://www.codeproject.com/KB/cs/DelegatesOMy.aspx

Example:

List<Employee> employeeList = GetEmployeeListSomeWhere();

employeeList.Sort((x,y)=>Compare<string>.Default.Compare(x.Name, y.Name));

Deploying ASP.NET MVC applications to IIS 6 always causes confusion at first. You’ve been coding in Visual Studio 2008, seeing your lovely clean URLs work nicely in the built-in web server, you stick the code on some Windows Server 2003 machine, and then wham! It’s all like 404 Not found  and you’re like hey dude that’s not cool.

image

This happens because IIS 6 only invokes ASP.NET when it sees a “filename extension” in the URL that’s mapped to aspnet_isapi.dll (which is a C/C++ ISAPI filter responsible for invoking ASP.NET). Since routing is a .NET IHttpModule called UrlRoutingModule, it doesn’t get invoked unless ASP.NET itself gets invoked, which only happens when aspnet_isapi.dll gets invoked, which only happens when there’s a .aspx in the URL. So, no .aspx, no UrlRoutingModule, hence the 404.

I’d say you’ve got four ways around this:

Option 1: Use a wildcard mapping for aspnet_isapi.dll

This tells IIS 6 to process all requests using ASP.NET, so routing is always invoked, and there’s no problem. It’s dead easy to set up: open IIS manager, right-click your app, go to Properties, then Home Directory tab, then click Configuration. Under Wildcard application maps, click Insert (not Add, which is confusingly just above),  then enter C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for “Executable”, and uncheck Verify that file exists.

Done! Routing now just behaves as it always did in VS2008’s built-in server.

Unfortunately, this also tells IIS to use ASP.NET to serve all requests, including for static files. It will work, because ASP.NET has a built-in DefaultHttpHandler that does it, but depending on what you do during the request, it might use StaticFileHandler to serve the request. StaticFileHandler is much less efficient than IIS natively. You see, it always reads the files from disk for every request, not caching them in memory. It doesn’t send Cache-Control headers that you might have configured in IIS, so browsers won’t cache it properly. It doesn’t do HTTP compression. However, if you can avoid interfering with the request, DefaultHttpHandler will pass control back to IIS for native processing, which is much better.

For small intranet applications, wildcard mappings are probably the best choice. Yes, it impacts performance slightly, but that might not be a problem for you. Perhaps you have better things to worry about.

For larger public internet applications, you may need a solution that delivers better performance.

Update: It turns out that you can disable wildcard maps on selected subfolders, which may give you the best of both worlds.

Option 2: Put .aspx in all your route entries’ URL patterns

If you don’t mind having .aspx in your URLs, just go through your routing config, adding .aspx before a forward-slash in each pattern. For example, use {controller}.aspx/{action}/{id} or myapp.aspx/{controller}/{action}/{id}. Don’t put .aspx inside the curly-bracket parameter names, or into the ‘default’ values, because it isn’t really part of the controller name – it’s just in the URL to satisfy IIS.

Now your application will be invoked just like a traditional ASP.NET app. IIS still handles static files. This is probably the easiest solution in shared hosting scenarios. Unfortunately, you’ve spoiled your otherwise clean URL schema.

Options 3: Use a custom filename extension in all your URL patterns

This is the same as the above, except substituting something like .mvc instead of .aspx. It doesn’t really create any advantage, other than showing off that you’re using ASP.NET MVC.

Just update your route entries as described above, except putting .mvc instead of .aspx. Next, register a new ISAPI mapping: Open IIS manager, right-click your app, go to Properties, then Home Directory tab, then click Configuration. On the Mappings tab, click Add, then enter C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for “Executable”, .mvc (or whatever extension you’re using) for “Extension”, and uncheck Verify that file exists. Leave Script engine checked (unless your app has Execute permission) and leave All verbs selected unless you specifically want to filter HTTP methods.

That’s it – you’re now using a custom extension. Unfortunately, it’s still a bit of an eyesore on your otherwise clean URL schema.

Option 4: Use URL rewriting

This is a trick to make IIS think there’s a filename extension in the URL, even though there isn’t. It’s the hardest solution to implement, but the only one that gives totally clean URLs without any significant drain on performance.

Ben Scheirman came up with a great post on this subject, but I’m adapting the technique slightly so as to avoid needing to change my routing configuration in any way. Here’s how it works for me:

1. As an extensionless request arrives, we have a 3rd-party ISAPI filter that rewrites the request to add a known extension: .aspx.

2. IIS sees the extension, and maps it to aspnet_isapi.dll, and hence into ASP.NET

3. Before routing sees the request, we have an Application_BeginRequest() handler that rewrites the URL back to its original, extensionless form

4. Routing sees the extensionless URL and behaves normally.

Since the URL gets un-rewritten in step 3, you don’t have to do anything funny to make outbound URL generation work.

How to do it

First, download and install Helicon’s ISAPI_Rewrite. You can use the freeware edition, version 2, though beware this will affect all the sites on your server. If you need to localize the rewriting to a particular app or virtual directory, you’ll need one of the paid-for editions.

Now edit ISAPI_Rewrite’s configuration (Start -> All programs -> Helicon -> ISAPI_Rewrite -> httpd.ini), and add:

# If you're hosting in a virtual directory, enable these lines,
# entering the path of your virtual directory.
#UriMatchPrefix /myvirtdir
#UriFormatPrefix /myvirtdir

# Add extensions to this rule to avoid them being processed by ASP.NET
RewriteRule (.*)\.(css|gif|png|jpeg|jpg|js|zip) $1.$2 [I,L]

# Normalizes the homepage URL to /
RewriteRule /home(\?.*)? /$1 [I,RP,L]
RewriteRule / /home [I] 

# Prefixes URLs with "rewritten.aspx/", so that ASP.NET handles them
RewriteRule /(.*) /rewritten.aspx/$1 [I]

This excludes known, static files (CSS, GIF etc.), but for the rest, it prefixes the URL with /rewritten.aspx, making ASP.NET kick in. As a bonus, it normalizes any requests for /home to simply / via a 301 redirection, helping out with your SEO. Save this file, and restart IIS (run iisreset.exe).

That’s implemented step 1. Now, to implement step 3, add the following handler to your Global.asax.cs file:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    HttpApplication app = sender as HttpApplication;
    if (app != null)
        if (app.Request.AppRelativeCurrentExecutionFilePath == "~/rewritten.aspx")
            app.Context.RewritePath(
                app.Request.Url.PathAndQuery.Replace("/rewritten.aspx", "")
            );
}

This detects rewritten URLs, and un-rewrites them. That does it! (Or at least it works on my machine – please share your experiences.)

Now you’ve got clean, extensionless URLs on IIS 6 (and probably on IIS5, though I haven’t tried), without using a wildcard map, and without interfering with IIS’s efficient handling of static files.

Bonus option 5: Upgrade to Windows Server 2008 and IIS 7

Of course, it’s much easier with IIS 7, because it natively supports .NET IHttpModules, so by default you’ll have UrlRoutingModule plugged right into the server, and you don’t have to do anything weird to make it work perfectly.

The use-case model(System Model)

The use-case model provides detailed information about the behaviors of the system or application that you are developing. It contains use-case diagrams and activity diagrams that describe how users interact with the system.

The use-case model identifies the requirements of the system in terms of the functionality that must exist to achieve the goals set out by the user or to solve a problem identified by the user. Uses cases describe the major behaviors that you identify in the requirements and describe the value that the results give the users; they do not describe how the system operates internally. Actors are the users of the system and represent the different roles that people and other systems play when they interact with the system.

Use-case diagrams depict the relationships between the uses cases and actors, and activity diagrams describe the flow of objects and control in each identified behavior.

 

The Analysis model

The analysis model describes the structure of the system or application that you are modeling. It consists of class diagrams and sequence diagrams that describe the logical implementation of the functional requirements that you identified in the use case model.

The analysis model identifies the main classes in the system and contains a set of use case realizations that describe how the system will be built. Class diagrams describes the static structure of the system by using stereotypes to model the functional parts of the system. Sequence diagrams realize the use cases by describing the flow of events in the use cases when they are executed. These use case realizations model how the parts of the system interact within the context of a specific use case.

You can think of the analysis model as the foundation of the design model since it describes the logical structure of the system, but not how it will be implemented.

 

The design model

The design model builds on the analysis model by describing, in greater detail, the structure of the system and how the system will be implemented. Classes that were identified in the analysis model are refined to include the implementation constructs.

The design model is based on the analysis and architectural requirements of the system. It represents the application components and determines their appropriate placement and use within the overall architecture.

In the design model, packages contain the design elements of the system, such as design classes, interfaces, and design subsystems, that evolve from the analysis classes. Each package can contain any number of subpackages that further partition the contained design elements. These architectural layers form the basis for a second-level organization of the elements that describe the specifications and implementation details of the system.

Within each package, sequence diagrams illustrate how the objects in the classes interact, state machine diagrams to model the dynamic behavior in classes, component diagrams to describe the software architecture of the system, and deployment diagrams to describe the physical architecture of the system.

  1. Problem: SIMGallery uses the latest Mootools version (1.2) for its javascript features. This can cause some trouble if your
    template uses Mootools 1.1

    Solution: See”Disabling Previous Mootools Version 1.1” in document.

  2. Problem: In  IE8, picture can’t be enlarged.

    Solution: Add following code into /components/com_simgallery/shadowbox/skin/classic/skin.css

    #shadowbox_title {
      border: 0px solid;
    }
    #shadowbox_info {
      border: 0px solid;
    }

Components: Trac, Cruisecontrol, Subversion

Essential Reference:

1. http://trac.edgewall.org/wiki/TracOnWindows#Subversion

2. http://trac.edgewall.org/wiki/TracOnWindows/Python2.5

Steps:

  1. Install Python 2.5 on Windows

Add C:\Python25 and C:\Python25\Scripts to PATH environment variable.

  1. Instal Genshi for Python 2.5 by running Windows installer

Download location: http://genshi.edgewall.org/wiki/Download#Zippackage

  1. Install Setuptools for Python 2.5

The download point is in “Method1: Using Installers” section of Ref #2.

  1. Install Trac 0.11 for Python 2.5

The download point is in “Method1: Using Installers” section of Ref #2

Running Trac standalone with command:

tracd –port 8000 c:\TracProjects\Myproject

Test Trac within browser via http://mysite:8000

If you have existing projects working on older versions, you need to upgrade your projects by running command:

trac-admin c:\ TracProjects\Myproject upgrade

  1. Install Gantt Charts Plugin

Download Gantt Charts 0.3.2a plugin source from:

http://willbarton.com/code/tracgantt/

Fix the plugin to fit Python 2.5 by following the instruction at

http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/126112

Compile Gantt Charts plug in by running command under source code directory

python setup.py bdist_egg

easy_install –always-unzip TracGantt-0.3.2.a-py2.5.egg

  1. Install ClearSilver.egg

Download clearsilver.egg for Python 2.5 from http://www.clearsilver.net/downloads/

The egg file is download as .zip file extension, change it to .egg and install it with easy_install.

  1. Install Subversion

Reference Link: http://blogs.vertigosoftware.com/teamsystem/archive/2006/01/16/Setting_up_a_Subversion_Server_under_Windows.aspx

Download subversion binary package from:

http://subversion.tigris.org/files/documents/15/45600/svn-win32-1.6.1.zip

Unpack the package to C:\Program Files\subversion

Add C:\Program Files\subversion to PATH environment variables.

Install subversion Python Binding with command:

easy_install –Z http://subversion.tigris.org/files/documents/15/45607/svn-python-1.6.1.win32-py2.5.exe

Download SVNService from http://gda.utp.edu.co/pub/svn/SVNService.zip

Copy svnservice.exe to C:/Program Files/subversion/bin/

Run following commands under command line:

            svnservice -install --daemon --root "C:\Repository"
            sc config svnservice start= auto
         net start svnservice
  1. Add Trac to Service

Reference Link:http://trac.edgewall.org/wiki/TracOnWindowsStandalone

  • download the Windows Server 2003 Resource Kit at Microsoft
  • run "InstSrv <servicename> c:\path\to\resourcekit\SrvAny.exe", where you insert your own service name (without angle brackets, e.g. tracd) and the full path to the SrvAny.exe.
  • open HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<servicename> in RegEdit
  • create subkey *Parameters*, below which you will create 2 string values:
  • create string value *Application* with the full path to python.exe
  • create string value *AppParameters* with the set of desired tracd parameters, e.g. "c:\Python25\Scripts\tracd-script.py –port 8080 c:\path\to\trac" (without the quotes)
  • open the Services tool (somewhere in the administrative tools in the Windows control panel) and start your service
  1. Install CruiseControl.NET

Download CruiseControl.NET from http://sourceforge.net/project/downloading.php?group_id=71179&filename=CruiseControl.NET-1.4.3-Setup.exe&a=58074311

Install CruiseControl.NET and configure it with the source control and compilation information.

Download and install libxml2-python package.

Download Cruise Control Trac plugin TracCC-0.2.4dev_r31-py2.5.egg, install it from project Admin Panel.

This version is working with CruiseControl.Net, add CruiseControl section to project Trac configuration file trac.ini:

[cruisecontrol]

ccpath = C:\Program Files\CruiseControl.NET\server\Sanjel eService R2 Unit Tests\Artifacts\log

buildstatusfile = SanjelEServiceR2UnitTests.state

xslfile = C:\Program Files\CruiseControl.NET\server\xsl\header.xsl

  1. Add Subersion Repository setting to Trac

Update trac.ini in your project conf folder, adding subversion repository and authentication information to the [trac] section. You may link to your source control system natively with Trac.

  1. Add additional plugings
    1. ChangeLogPlugin

Reference Link: http://trac-hacks.org/wiki/ChangeLogPlugin

Adds a Wiki macro that displays a change log for a repository path

Track Links format [[ChangeLog(/path/to/project/repository, 5)]]

When we use full size image to show product instead of thumbnail, we don’t need “View Full-Size Image” link. But there is no configuration options to disable this. We have to change code to do this.

The code file is shop.products_details.php.

Or we have another easy cheating way to do this by change language file:

var $_PHPSHOP_FLYPAGE_ENLARGE_IMAGE = ”;

For other unwanted link such like “vendor information”, may do in same way.

While using VirtualMart component, we may display other than 5 items per row. Using default pagination setting as 5, 10, 15, 20, 25, 30, 50, 100, all may cause alignment problem. In this case we would like use 4, 8, 12, 16, 20, 40, 80, all for 4 items per row.

Because this is hard-coded, we have to hack it in code.

file: libraries\joomla\html\pagination.php

In function getLimitBox(), line 324:

// Make the option list
for ($i = 5; $i <= 30; $i += 5) {
    $limits[] = JHTML::_(’select.option’, "$i");
}
$limits[] = JHTML::_(’select.option’, ‘50′);
$limits[] = JHTML::_(’select.option’, ‘100′);
$limits[] = JHTML::_(’select.option’, ‘0′, JText::_(’all’));

Change it to:

// Make the option list
for ($i = 4; $i <= 20; $i += 4) {
    $limits[] = JHTML::_(’select.option’, "$i");
}
$limits[] = JHTML::_(’select.option’, ‘40′);
$limits[] = JHTML::_(’select.option’, ‘80′);
$limits[] = JHTML::_(’select.option’, ‘0′, JText::_(’all’));

This will make global change for everywhere.

Firstly, Create a new user for testing purposes using the JFusion Login Module.
Note: The Admin user will not sync for any software which is why we need to create a test user.
Dual Login from Joomla! side:-
In Joomla, go to Components > JFusion > Plugin Configuration >
Make sure there is a green check under ‘Dual Login’ for the phpbb3 plugin.
In Joomla, go to Components > JFusion > Plugin Configuration > Edit phpbb3
1. Put a dot ( . ) infront of ‘Cookie Domain’ example: .yourdomain.com
2. Note the name of the ‘Cookie Prefix’ so you can match it in the cookie setting in phpbb. Or you can change this to whatever you want but it must match the settings in phpbb.
3. Make sure ‘Cookie Path’ and ‘Allow Login Cookie’ have a forward slash ( / ).
In phpbb3, go to General > Server Configuration > Cookie Settings
1. Put a dot ( . ) infront of ‘Cookie Domain’ example: .yourdomain.com (The domain must match the domain used in ‘JFusion phpbb plugin’ and of course must be your actual domain.
2. Name the ‘Cookie name’ exactly the same as the settings in the JFusion phpbb plugin.
3. Make sure the ‘Cookie path’ has a forward slash ( / ).
Delete all your browser cookies.
Login with your test user.
Dual Login from phpBB side:-
As JFusion does not modify or hack the integrated software, the default component allows for a setup where when one logs into or out of the Joomla side, he/she is automatically logged into the phpBB side.
One of the JFusion community member has developed a phpBB auth plugin which allows dual login to take place even from the phpBB side i.e. when a person logs in or out of phpBB the same takes place on the Joomla side.
Follow the following steps for the same.
1. Download the file here.
2. Copy the downloaded file to {your_forum_directory}/includes/auth directory.
3. Proceed to the phpBB ACP. Search for the ‘Client Communication’ Category in the left column. Click the ‘Authentication’ under it.
4. On the ‘Authentication’ page set ‘Select an authentication method’ to ‘Db_joomla’ from the drop down box. Save the changes.
5. Dual Login from phpBB has been setup.
For any issues with phpBB dual login please post it in this thread.

Joomla 1.5.x中使用UTF-8编码,在对某些关键字(如:卡尔加里)进行所有字搜索时会产生如下错误:

Warning: preg_replace()  function.preg-replace: Compilation failed: invalid UTF-8 string at offset 9 in

root\components\com_search\views\search\view.html.php on line 146

这是由于在低版本PHP中preg_split函数对UTF-8编码支持的缺陷所导致的,据此情况,用explode函数代替preg_split函数可解决这一问题,在进行中文测试、英文测试和中英文混合测试,目前证明是有效的。

root\components\com_search\views\search\view.html.php line129

                    $searchwords = preg_split(”/\s+/”, $searchword);

改为:

                    $searchwords = explode(” “, $searchword);

1. Migrate users

Related tables: mos_core_acl_aro, mos_core_acl_groups_aro_map, mos_users

mos_core_acl_aro field aro_id should be rename as id.

These tables should be truncated before import to the joomla database.

2. Migrate Zoom

This part can be transfer smoothly, the directory structure is same. Just copy the image file with directory to new site.

3. Migrate Categories, Sections, contents

These tables can be migrated smoothly.