Category: "Example Codes"
Our .Net CMS - AdvGenCMS
Recently, our Company(AdvanGeneration) have built a lightweight .Net CMS,AdvGenCMS. I did some researches for .Net CMS. The most of them have own their ORM and Dependency injection framework. That is very hard to adapt into a web development framework. Thus, we decided to build our own.
AdvGenCMS is very simple. Our ORM is ms entity framework. Moreover, we have not any dependency injection framework. Currently, it used a factory design pattern, but that can choose to add dependency injection framework on your choice. Lastly, it used ASP.Net MVC. All of them are very very standard Microsoft technologies.
I don't want to add any functions you don't need. I just needed the core functions. Our CMS should be as simple as possible.
It has a user management function:
Moreover, it has a page function. You can add the static content and access them via http://[server]/Content/[PageName]
Lastly, it uses tinymce to be a html editor.
Let's use AdvGenCMS to be your web development framework. It uses Apache License.
MVC 3 Example
I have completed the users section for AdvGenCMS. I used ASP.Net MVC 3 and Razor to do. It has CRUD functions and used the LINQ Repository Pattern. I think that is a good example for MVC3 in C#.
Please download the source and check it out http://localhost:44271/Account/List page in your own development box.
Custom Membership Provider
Custom Membership Provider is easy to do. Firstly, please extends MembershipProvider
Code
public class AdvCMSMembershipProvider : MembershipProvider |
Secondly, Right Click MembershipProvider, and then implements all abstract methods.
The only method you need to change:
Code
public override bool ValidateUser(string username, string password) | |
{ | |
IAdvUser user = userRepository.GetByUserName(username); | |
| |
return user.Password == password; | |
} |
Lastly, chaging web.config
Code
<membership defaultProvider="AdvCMSMembershipProvider"> | |
<providers> | |
<clear/> | |
<add name="AdvCMSMembershipProvider" | |
type="AdvCMS.Security.AdvCMSMembershipProvider, AdvCMS.Security" /> | |
</providers> | |
</membership> |
Please download our opensource project, AdvGenCMS, as the example.
Timer in WPF
In Windows Form time, there is a component for Timer. But in WPF, there is not such things. So, what thing we can do, when we need to execute a piece of code periodically. We can use the timers under System.Timers. But please do not use System.Timers.Timer, because it triggered, it will execute the code in a new thread. If you try to access any controls in WPF Windows, the system will throw an exception. I like to use System.Windows.Threading.DispatcherTimer in WPF, because that is very similar with the Timer in Windows Timer.
There are the example code:
Code
DispatcherTimer sysTimer = new DispatcherTimer(); | |
sysTimer.IsEnabled = true; | |
sysTimer.Interval = new TimeSpan(0, 0, 1); | |
sysTimer.Tick += new EventHandler(sysTimer_Tick); |
To find more about this, please download the example project, AdvGenStopWatch.
WPF Example Code - AdvGenStopWatch
I created an opensource project, AdvGenStopWatch. This is a simple stop watch program and aimed to show how to use WPF. Including the following features:
- How to use Grid Layout and ViewPoint, this make all elements will be autosize.
- How to use Timer in WPF
- How to use ListView
I believe this is a good starting point to learn WPF.