Wednesday, December 23, 2009

 

hi

Dear friends:

eleshopexm.com This is a very good network platform,
which operations are: motorcycles, brand-name mobile phones, MP3, MP4,
notebook computers, television, etc.; quality assurance warranty, and
absolute credit guarantee; because it is purchasing from the
manufacturer , the price is cheap, are now being sold at wholesale
prices, if not satisfied, you can also unconditional return,
opportunity, can we say Go nuts! ! !


Thursday, April 20, 2006

 

Disecting CSLA 2.0 - Looking at SimpleDataProvider in depth

One of the most common pitfalls in CSLA 1.0 during updating/inserting a editable business object is we tend to forget to place MarkNew() during deletion, MarkDirty() when saved and MarkOld() during fetching. These are common pitfalls for developers who creates CSLA business objects w/o using templates. With CSLA 2.0, these methods are automatically called after executing your implementation of DataPortal_XXXX() in your business objects.


 

Disecting CSLA 2.0 - PropertyHasChanged Combo

In CSLA 1.1 you need to call CheckRules() in your set property (if there are rules) and followed by MarkDirty(). With version 2.0, I only need to call PropertyHasChanged() and the CSLA 2.0 framework is responsible for calling the following:
However in cases you dont want to raise that a property has changed or you want to manually perform the validation rules check, you can still do the 1.1 way.

Thursday, January 26, 2006

 

VB.NET 2005 - Continue & Using keywords

Continue
This is one of the features I've been looking for in VB .NET and I'm glad they added this functionality. Using this keyword insie the loop allows you to skip and perform the next iteraion. Continue For is used cojunction with For loop and Continue While is use in while loop.

Using
This is for garbage collection where in developer wishes to explicitly clean up the unmanged resources before abandoning an object. The object must implment IDisposable. Please see below for an example:

Public Class Countries
Inherits Generic.List(Of Country)
Implements IDisposable

Public Overloads Sub Add(ByVal CountryName As String)
Dim itm As New Country
itm.CountryName = CountryName
Me.Add(itm)
Dim i As Integer = Me.Count - 1
Me.Item(i).IDCountry = Me.Count
End Sub

Public Overloads Sub Dispose() Implements IDisposable.Dispose
' Do some clean up here
End Sub
End Class




To explicity clean up the unmanged resources
Dim mCountries As New Countries
' Retrive some data from mCountries
Using (mCountries)
' Manipulate data
End Using







Tuesday, January 24, 2006

 

IMS Update

I just finished doing the bug fixes on my IMS application for my cousin. I have troubles on finding the bugs but I'm glad I've found it. The cause of the bugs were controls that were being binded to a business object properties and failed to unbind it when the form closes.
 
I told Joseph that I will be posting some technical blogs on the new features in VB .NET 2005, please hang on I'll give you a blast this week.

Monday, January 23, 2006

 

VB .NET 2005 - Global Keyword

Global
Points to .NET framework base class library when used. This is useful wherein some of the custom namespace in an assembly has the same namespace in .NET framework base class libraries.


Namespace System.IO
 
Public Class FileWriter
Public Shared Sub Write()
' Some code here for actual implementation
End Sub
End Class
 
End Namespace




Supposing you want to use the .NET framework base class library for System.IO.
Simple use the Global keyword, please see below.


Dim fstm as Global.System.IO.FileStream




 

IMS Update for Mediaspot

I just finished doing the bug fixes on the IMS application for Mediaspot. I have troubles on finding the bugs but I'm glad I've found it in the end. The cause of the bugs were controls that were being binded to a business objects properties and failed to unbind it when the form closes.

On the other hand, I did my start my new job last monday 01/16. Since the company I joined is still new here in Cebu, we are still setting up the office space and I'm starting to do research on .NET 2.0 and its new features.

I told Joseph that I will be posting some of the new features in VB .NET 2005, please hang on I'll give you a blast this week.

Thursday, January 12, 2006

 

Replacing IdleSync() w/ OnListChanged()


Environment: CLSA .NET and Windows Form


The original sample code illustrated the use of Application.IdleSync() to toggle the save button in a BusinessBaseCollection when editing a specific editable object. I've noticed when the mouse is moved the application.IdleSync() handler is triggered and I find it ineffecient.

Trying to find an efficient way, I noticed that BusinessBaseCollection overrides the OnListChanged Event. So I changed my IdleSync handler to OnListChanged.

See below for illustration:

In windows form level, I've created a method name OnListChanged()

Private Sub OnListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs)
btnSave.Enabled = mCustomer.IsSavable
'Add the code for the Broken Rules Error Provider
End Sub




After retrieving records from the database, pattern this code just replace it with your own variables.
mCustomer = Customers.GetCustomers()
'Needs to be remove first
RemoveHandler mCustomer.OnListChanged, AddressOf OnListChanged
AddHandler mCustomer.OnListChanged, AddressOf OnListChanged




Before closing the form alway remove the added handler, it can be placed on Form_Close() event.

RemoveHandler mCustomer.OnListChanged, AddressOf OnListChanged






Wednesday, January 11, 2006

 

CSLA.NET Switching root to child object and vice versa

I’ve managed to create my own switchable mechanism in CSLA .NET for editable object. I did tried to implement the original switchable editable object as presented by the author, but it confuses me a lot. As far as I understand to make the editable object switchable from root to child is by putting MarkAsChild() in the constructor of the object. When an editable child object is implemented calling Save() method it would throw an exception because it can’t be save directly. However, if we can manage to change the IsChild property from true to false then there will be no problem. But IsChild is a read only property.

So out of curiosity, I tried to use reflection to change the mIsChild of type boolean private variable to false to behave as a root object and setting it to true to behave as a child object and it works. So I decided to combine the implementation of child and root object rather than implementing switchable object.

When calling Save() method in:

So instead of duplicating the code from Update() to DataPortal_Update(), I simply call Update() in DataPortal_Update().

Below are codes for switching editable object from root to child and vice versa:

Public Sub ToRoot(ByVal o As Object)

Dim t As System.Type

t = o.GetType().BaseType()

If String.Compare(t.Name, "BusinessBase", True) > 0 Then
Throw New Exception("Not a CSLA object")
End If

Dim fi As FieldInfo = t.GetField("mIsChild", _
Reflection.BindingFlags.NonPublic Or BindingFlags.GetField Or BindingFlags.Instance _
Or BindingFlags.FlattenHierarchy Or BindingFlags.CreateInstance _
Or BindingFlags.SetField)

If fi Is Nothing Then
Throw New Exception("Unable to resolve CSLA object info")
End If

Dim IsChild As Boolean = fi.GetValue(o)

If Not IsChild Then
Throw New Exception("The object is already in Root")
End If

fi.SetValue(o, False)

End Sub

Public Sub ToChild(ByVal o As Object)

Dim t As System.Type

t = o.GetType().BaseType()

If String.Compare(t.Name, "BusinessBase", True) > 0 Then
Throw New Exception("Not a CSLA object")
End If

Dim fi As FieldInfo = t.GetField("mIsChild", _
Reflection.BindingFlags.NonPublic Or BindingFlags.GetField Or BindingFlags.Instance _
Or BindingFlags.FlattenHierarchy Or BindingFlags.CreateInstance _
Or BindingFlags.SetField)

If fi Is Nothing Then
Throw New Exception("Unable to resolve CSLA object info")
End If

Dim IsChild As Boolean = fi.GetValue(o)

If IsChild Then
Throw New Exception("The object is already in Child")
End If

fi.SetValue(o, True)

End Sub


Scenario: Switchng editable object (from child to root) inside a root collection

  1. Get a clone copy of the editable object from the root collection

    eobjName = DirectCast(Me.BindingContext(mNameCol.Current, eobjName).Clone()
  2. Call ToRoot()

    ToRoot(eobjName)
  3. Do necessary things to the root object you can also invoke Save() method

    'Do something with root object and save changes
    eobjName.Save()
  4. Call ToChild(), to reset the original setting

    ToChild(eobjName)
  5. Update root collection to update the content of it using the clone Object. Since there is no available method in BusinessBaseCollection to update the content of the collection you need to create a method UpdateCollection in the root collection

    Friend Sub UpdateCollection(ByVal o as eobjNameType)
    Dim i as Integer
    For i = 0 To List.Count - 1
    If DirectCast(List.Item(i), eobjNameType).Equals(o) Then
    List.Item(i) = o
    Exit For
    End If
    Next i
    End Sub

I know this is a hack version against the original implementation and I guess a lot of you guys will object on what I did. =)



 

Mediaspot's IMS Go Live

MediaSpot’s Inventory Management and Sales System go live. It did run with a couple of errors. LOL… It’s really different when you are the one who develop and at the same time doing the testing. I’m glad that it was my cousin’s store there was not too much pressure when the errors pop up. LOL.. Right now, I managed to finish all the bugs that were found.

There was a little delay on the time frame of the deployment of the project due to the fact that I was using CSLA .NET rather than doing in using datasets. I know that doing it datasets will give me the speed in development, but I wanted it to be in object oriented approach in dealing with the business process and another reason is that I’m a fan of Rockford Lhotka. LOL…

For the backend I was using MySQL latest version to take advantage with stored procedures, views and triggers. Why not MS-SQL? I guess the reason is clear MySQL is for free. =) But when I’ve found out the SQL 2005 Express is for free, it was too late because I was halfway doing it in MySQL. So my plan later is to create a database in SQL 2005 Express and modify the application to choose what type of backend database server to use.

I have no regrets using MySQL, at least I did have a chance to know SQL syntax in MySQL. The shift from MS-SQL to MySQL during developing the stored procedures wasn’t that hard. I’ve found some bugs in MySQL and I’ll be sending it MySQL to clarify if is really a bug or the feature is not supported.

MediaSpot is a store the sales a variety gadgets for cell phones, computers, digital cameras, DVD and MP3 players. It is located on JQS, which is beside UC Banilad Campus.


This page is powered by Blogger. Isn't yours?