Tuesday, 15 March 2011

Ext.Net and Mono

I like ext.js/Sencha for having a rich client in the browser.

On the other hand, we are using Mono for running our .Net server.

ext.net is a good library that helps you to easily write web applications, based on your .net libraries.

For OpenPetra, I have created an online application system, and the backend for the registration office is written with ext.net.

Here are some problems I came across, and how I solved them:

First, I had to recompile the ext.net dlls and also the Newtonsoft.Json.Net20.dll.

The Newtonsoft.Json.Net20.dll has been compiled with the latest compiler built from Mono 2.8 trunk. This was necessary so that no Microsoft dlls were linked in.
The ext.net dll was built against the Mono compiled Newtonsoft.Json.Net20.dll on Windows with SharpDevelop. The mono compiler crashed on Linux when trying to build the ext.net solution.
The resulting files are available from the online source repository of OpenPetra, eg. http://bazaar.launchpad.net/~openpetracore/openpetraorg/trunkhosted/files/head:/csharp/ThirdParty/ext.net/

I was not able to get Ext.Net to run with the latest Mono 2.8, but it is working fine with 2.6.7.
I had to build it from the sources.
Some links related to the problems I had with Mono 2.8 and Ext.Net:
compile ext.net: There is no implicit reference conversion from `Ext.Net.ComboBox' to `Ext.Net.ComboBoxBase'

Running ext.net on Mono 2.8: get the error: Cannot add a Ext.Net.Parameter to System.String
For the moment, the solution for me was to use Mono 2.6.7.

The examples of ext.net only show the c# code inside the aspx file, but with growing size of the code it would be good to be able to split the code behind code from the UI code.
This is possible, but you need to define all controls in the .cs file, at least those you want to use in your code behind code.
In the aspx file, make sure you have at the top:
<%@ Page Language="C#"
Inherits="Ict.Petra.WebServer.MConference.TPageOnlineApplication"
src="Desktop.aspx.cs" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
see the whole file here: OnlineRegistrationBackend/Desktop.aspx

Now I ran into errors like this when Mono was compiling the code on the fly:
Compiler Error Message: CS1644: Feature `anonymous types' cannot be used because it is not part of the C# 2.0 language specification
I found on the Internet this page: http://www.4guysfromrolla.com/articles/121207-1.aspx
linked from http://web.archiveorange.com/archive/v/c2PM7RMRJf7Ti7PP7uVb, where they discuss how to use "extension methods" and "collection initializers" with Mono.

I have added all those settings to my web.config, see the result here:

You can see a running demo here: http://demo.openpetra.org:8009/

Monday, 7 March 2011

Knowledge Tree and PHP 5.3.3

We have got the latest PHP version on Hostsharing, and Knowledge Tree 3.7.0.2 did not work anymore.
I got a long list of deprecated warnings, and the session would not even start, so not even a login screen is displayed.

Deprecated: Assigning the return value of new by reference is deprecated
Warning: The magic method __get() must have public visibility and cannot be static
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

The solution is to edit config/dmsDefaults.php, find the lines containing
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
Below that, add the following line:
error_reporting(0);
Now Knowledge Tree 3.7.0.2 will work again, and hopefully the next version of Knowledge Tree will have fixed all the deprecated PHP things.

Saturday, 13 November 2010

Digest for phpBB Forum without plugin

I am very glad for the hosted apps that Sourceforge provides. It is excellent to have only one login, and not to need to worry about updating the apps.

The problem with the phpBB forum is that the notification emails, when you watch a forum, do not include the message. On Sourceforge you are also not able to install a digest modification, eg. http://phpbbservices.com/digests/

Therefore I thought it would be good to have an external script, that regularly checks for new posts and sends an email with the contents.

In the end, it was not too hard.
This only works for a public forum, where all posts are accessible by non-registered users.
There is the page search.php (eg.http://sourceforge.net/apps/phpbb/openpetraorg/search.php?&sr=topics&search_id=newposts) that shows all new posts.
I store each post that has been sent as an email with the post number in a text file.
Then the script fetches the page of the new posts, and checks each post if it has been sent already.
The script sends HTML emails, and even quoting blocks appear quite alright in my email client (google mail).
The script is also able to parse the posts of a thread that spreads across several pages.

You also might find the functions interesting to get the HTML code and to parse for code between the beginning and the end tag.

Feel free to use the script and to modify it.

Wednesday, 25 August 2010

Install Smoothwall from bootable USB memory stick

Today I wanted to install Smoothwall on a fan-less device, Lex Light LG8302.

There is the tool UNetbootin http://unetbootin.sourceforge.net/, but it does not support the Smoothwall iso image, and even if it copies to iso file to USB, when you boot from it you get the UNetbootin default option, but that does not do anything.

I used 7zip to extract the iso image of Smoothwall, which gives me the [Boot] directory.
It seems that UNetbootin is not able to extract the boot files from the iso image, from Bootable_2.88M.img, even though it does attempt it.

I used RawWrite for Windows (http://www.chrysocome.net/rawwrite) to extract the files from Bootable_2.88M.img. The partition size of the USB stick will be only 2 MB, but that is ok for the moment. Copy the files initrd.img, vmlinuz und syslinux.cfg to your local harddrive. Change the names from capital to lower case letters. Reformat the USB stick to its normal size. Then run again UNetbootin, and use the Smoothwall iso image as the source. Then copy the 3 files initrd.img, vmlinuz und syslinux.cfg to the USB stick, you will need to overwrite the existing syslinux.cfg.

To test the USB stick with VMWare, I followed the instructions at http://www.pendrivelinux.com/boot-a-usb-flash-drive-in-virtualbox/.

Then on the fan-less device, I first was not sure how to get it to boot from the usb stick. Then the hint was on http://nion.modprobe.de/blog/archives/343-My-new-Lex-Light-CV860A.html where it tells that you have to change the boot order to use USB-ZIP which will boot from the USB stick.

UPDATE:

it seems I rejoiced too early...

The installer does start from the USB stick, and does format the harddrive, but then it does not seem to find the file smoothwall.tgz and does not install all the network card drivers. So even the network install does not work.

The function findharddiskorcdrom looks for CDROM or harddrive, but I could not figure out why it does not find the USB stick. It only seems to check /dev/scd0, but no other device.

Sunday, 6 June 2010

VirtualBox PUEL on OpenSUSE on 64 bit machine

It took me a while to solve this problem, therefore here is the solution for everyone...

I installed the PUEL version of VirtualBox from the virtualbox.org website, the version for personal use and evaluation.
There is the OSE version included in OpenSUSE, but that does not support USB connections.

Now for the PUEL version, you need to build the kernel module for VirtualBox.
You might need to install gcc and make, and also the kernel sources.
I will come to the details of the kernel sources later.

When I ran /etc/init.d/vboxdrv setup, I got the error in /var/log/vbox-install.log:
make -f /usr/src/linux-2.6.31.12-0.2/scripts/Makefile.modpost
scripts/mod/modpost -m -a -i /usr/src/linux-2.6.31.12-0.2-obj/i386/desktop/Module.symvers -I /tmp/vbox.3/Module.symvers -o /tmp/vbox.3/Module.symvers -S -K /usr/src/linux-2.6.31.12-0.2-obj/i386/desktop/Module.markers -M /tmp/vbox.3/Module.markers -w -c -s
FATAL: /tmp/vbox.3/vboxdrv.o has no symtab?
I looked for symtab on the Internet, and found that it has to do with conflicts in the architecture.

It took me a while to have a look at the versions of kernel packages I had installed:
rpm -qa | grep kernel
This showed for my system, that the package for kernel-syms was not for x86_64, but for 586. This caused the error with symtab.

Solution (please check the result of rpm above to know which exact version of the kernel you are using):
zypper install kernel-syms-2.6.31.12-0.2.1.x86_64
As an example, here is what rpm -qa | grep kernel shows after I installed the correct packages:
kernel-xen-devel-2.6.31.12-0.2.1.x86_64
kernel-syms-2.6.31.12-0.2.1.x86_64
kernel-desktop-2.6.31.12-0.2.1.x86_64
kernel-debug-devel-2.6.31.12-0.2.1.x86_64
kernel-desktop-devel-2.6.31.12-0.2.1.x86_64
linux-kernel-headers-2.6.31-3.4.noarch
kernel-default-devel-2.6.31.12-0.2.1.x86_64
kernel-source-2.6.31.12-0.2.1.noarch
Then building the kernel module for VirtualBox worked.

Monday, 10 May 2010

CruiseControl.net and Mono

I have set up CruiseControl.net (http://sourceforge.net/projects/ccnet/) on Mono for building our OpenPetra.org project, which is quite a big project.

Here are the steps I followed, and my config files so that people can benefit from it:

Here is some advice how to change the ccnet.exe.config to make it work for Mono: http://markmail.org/message/uyfqysd55u4xqhfs; main things are to change the xsl paths' backslash to forward slash, and to replace ColoredConsoleAppender with ConsoleAppender, and to remove mappings for the ConsoleAppender.

You can see my modified ccnet.exe.config, and also the ccnet.config for OpenPetra here in the online git repository:

http://openpetraorg.git.sourceforge.net/git/gitweb.cgi?p=openpetraorg/openpetraorg;a=tree;f=csharp/ICT/PetraTools/ContinuousIntegration

You will also find a cruisecontrol.sh which I use as a init.d script for starting and stopping my CruiseControl server.

I had to install Mono XSP from the Lenny backports repository, to get Mono 2.x. It was also important to install sendmail, otherwise the EmailProvider would obviously not work (which took me quite a while to notice).
apt-get -t lenny-backports install mono-xsp
apt-get install sendmail sendmail-bin

Then I had a nasty problem with the logging. After a failed build, I had this exception:

[OpenPetraOrg:ERROR] Publisher threw exception: ThoughtWorks.CruiseControl.Core.CruiseControlException: Unable to read the contents of the file: /home/timop/CruiseControl.NET/Server/OpenPetraOrg/Artifacts/nant-results-b2f2a299-05c5-42a6-a311-24df30a59b9a.xml ---> System.NotImplementedException: The requested feature is not implemented.
at ThoughtWorks.CruiseControl.Core.Tasks.FileTaskResult.ReadFileContents () [0x00000]
--- End of inner exception stack trace ---
at ThoughtWorks.CruiseControl.Core.Tasks.FileTaskResult.ReadFileContents () [0x00000]
at ThoughtWorks.CruiseControl.Core.Tasks.FileTaskResult.get_Data () [0x00000]
at ThoughtWorks.CruiseControl.Core.Publishers.XmlIntegrationResultWriter.WriteTaskResults (IIntegrationResult result) [0x00000]
at ThoughtWorks.CruiseControl.Core.Publishers.XmlIntegrationResultWriter.WriteBuildElement (IIntegrationResult result) [0x00000]
at ThoughtWorks.CruiseControl.Core.Publishers.XmlIntegrationResultWriter.Write (IIntegrationResult result) [0x00000]
at ThoughtWorks.CruiseControl.Core.Publishers.XmlLogPublisher.Execute (IIntegrationResult result) [0x00000]
at ThoughtWorks.CruiseControl.Core.Tasks.TaskBase.Run (IIntegrationResult result) [0x00000]
[OpenPetraOrg:ERROR] Unable to build email message: ThoughtWorks.CruiseControl.Core.CruiseControlException: Unable to read the contents of the file: /home/timop/CruiseControl.NET/Server/OpenPetraOrg/Artifacts/nant-results-b2f2a299-05c5-42a6-a311-24df30a59b9a.xml ---> System.NotImplementedException: The requested feature is not implemented.
After some searching, I realised that the log file had become quite big, and in the CruiseControl.net code in FileTaskResult.cs the function ReadFileContents would call MemoryFailPoint, but this class has not been implemented yet in Mono 2.x (http://anonsvn.mono-project.com/viewvc/tags/mono-2-4-2-2/mcs/class/corlib/System.Runtime/MemoryFailPoint.cs).

My solution was to download the sources of Mono, and modify MemoryFailPoint.cs to not throw that NotImplementedException, but just stay quiet. I then copied the resulting file (eg. mono-2.4.2.3/mcs/class/lib/net_2_0/mscorlib.dll) to my server with the CruiseControl.net, to /usr/lib/mono/2.0/mscorlib.dll

Now CruiseControl.net works quite nicely, though I have not played with NUnit yet, and there are more things to explore...

Monday, 1 March 2010

Charity Resource Planning - CRP and ERP

After some attempts to explain what my work is all about, I have come to the conclusion that the description "Charity Resource Planning" might fit best.

Previous attempts were "Administration Software", but then people think about administration of computers, etc. And I have not read about anyone calling any software "Administration software".

Other people call it "Back Office Software".
Wikipedia describes Back office in these words:
"A back office is a part of most corporations where tasks dedicated to running the company itself take place. The term comes from the building layout of early companies where the front office would contain the sales and other customer-facing staff and the back office would be those manufacturing or developing the products or involved in administration but without being seen by customers. Although the operations of a back office are usually not given a lot of consideration, they are a major contributor to a business."
But does a charity have a front office and a back office? It is usually quite a small team of dedicated people. I remember once a funny bookkeeper in one of our smallest offices, telling me he would ask the system administrator to do something for him... it took me a few seconds to realise he was speaking of himself in the third person...
To some degree, the work of a charity, helping people in need, empower the people without rights, telling the Good News, could be called the "front office".
But even in normal companies and enterprises, no one calls their software "Back Office Software". You want it all integrated. The salesman in the front office needs to know the addresses of the customer, etc.

This is where the term "Enterprise Resource Planning (ERP)" comes to mind.

Again the definition from Wikipedia: Enterprise Resource Planning
"Enterprise resource planning (ERP) is a term usually used in conjunction with ERP software or an ERP system which is intended to manage all the information and functions of a business or company from shared data stores.
It is a commercial software package that promotes seamless integration of all the information flowing through a company.
[...]
[The term ERP] was introduced by research and analysis firm Gartner in 1990. ERP systems now attempt to cover all core functions of an enterprise, regardless of the organization's business or charter. These systems can now be found in non-manufacturing businesses, non-profit organizations and governments."
For a while I thought about using the term ERP for the things I do. But then it sounded strange. Can you run a charity like an enterprise? On the one hand, many concepts can be brought over from the enterprise experience, and a charity can benefit from the lessons learned in business. Some charities even are run as an enterprise, and their goal is to grow and move more and more money. They pay salaries etc.

But I am not talking about those huge well-known charities that you see on TV ads. My background are mission organisations. They and many other charities work mostly on a low profile. They live from dedicated workers who are willing to work for a small salary or even raise their own support, and such organisations could not exist without their dedicated supporters that not only back the work financially but also with prayer.

There are quite a number of Open Source ERP systems around. The question is how hard it would be to modify them by adding modules to turn these software packages into "Charity Resource Planning" tools.
There is a good example of Medical, which is an Electronic Medical Record (EMR) and Hospital Information System, and it is based on OpenERP, an Open Source Enterprise Management solution.

So it would work to adjust an ERP system to work for charities. I wish there were such initiatives to use the benefit of Open Source for charities in this area.
The question will be how close the ERP system will match the processes of a charity. How far can you modify the software, and how much do you have to change your own processes?

Therefore my goal is to make a real "Charity Resource Planning (CRP)" software.
  • CRP software has to be easy to use, since charities often have much higher staff turnover than normal businesses, due to short term commitments etc
  • CRP software should center on managing relations with supporters and workers and the people involved in the projects in a way that is right and honourable.
  • CRP software should provide tools for most of the office tasks, eg. Personnel department, Donor contact management, Financial Planning, Accounting
  • CRP software has to be available in all sorts of languages and support many currencies, so that it can be used across a multi-national organisation, in such a diversity of countries that companies of the size of a usual charity normally would never work in because they don't have the manpower.
  • Such a CRP software has to allow easy integration with other software, eg. Payroll which is probably too difficult to adapt to the laws of each country. It should also provide many plugin interfaces that allow localisation of the tools, eg. for processing bank statements etc.
  • CRP software has be available at justifiable costs, considering the personal effort of supporters and workers to keep the charity going.
There is already a small number of software systems around that fit well into the category of "Charity Resource Planning". And I think there is certainly a need for more developers and IT specialists working in this area, both voluntarily and to earn their living. I think it would benefit many charities if we use Open Source software for this in order to be able to share solutions even if we are using different technology or emphasize different management/organisational styles.

My personal aim is to make OpenPetra.org one of the first choices in Charity Resource Planning systems.



Disclosure
Timotheus Pokorra is currently working as a software developer for OM, a christian charity working in many countries. OM owns the OpenPetra.org project which aims to provide a free software solution for the administration of charities.