How to get one class change history by own code,not use IversionService
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        


12»»

How to get one class change history by own... Expand / Collapse
Author
Message
Posted 2010-03-15 06:47:18
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
I want to know which field is modified at updatedatabase,So I use Idirtylistservice. But I find it seems there are only changed object list,not the field list of changed object list. I think eco realy update objects to database,should only update the changed field value,not all fields value changed,is realy?
Who can tell me how to get the change list of field of one object when the object update to database by simple ways?
thanks!
Post #5004
Posted 2010-03-15 09:21:19
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230, Visits: 1 382
The default setting in ECO is to only update the values that has been changed, but it is also possible to "update whole object". THis is controlled by a property on the EcoSpace (bool UpdateWholeObjects).

If you have an object that has been modified and want to know what properties of that object has been modified, you need to use IStateService. Something like this:

Invoice myInvoice = ... something that returns an invoice
IObject obj = myInvoice.AsIObject();
IStateService ss = obj.ServiceProvider.GetEcoService<IStateService>();

foreach (IProperty prop in myInvoice.AsIObject().Properties)
if (ss.IsDirty(prop))
DoSomething(prop);


/Jonas Hogstrom [CapableObjects]
Post #5005
Posted 2010-03-16 04:28:15
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
thank you!
Post #5012
Posted 2010-03-17 00:50:07
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: 2012-01-27 22:15:27
Posts: 61, Visits: 854
We are doing something similar to this to record an audit traill of changes to objects. Is there any way to get the original value of the object using the state service, or otherwise.

Regards,

David
Post #5014
Posted 2010-03-19 00:29:13
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230, Visits: 1 382
In the cache (ICache interface), you can query for the fetched value of an object:

object GetFetchedValue(Locator locator, IStructuralFeature structuralFeature);

You can check if the fetched value differs from the current value using:

bool GetMemberHasFetchedValue(Locator locator, IStructuralFeature structuralFeature);

You can only get the cache interface from inside the EcoSpace-class, but you can register it as a service yourself:

        public WhenImThereEcoSpace() : base()
{
this.InitializeComponent();
RegisterEcoService<Eco.Cache.ICache>(this.FrontsidePolicy.Cache);
}


/Jonas Hogstrom [CapableObjects]
Post #5017
Posted 2010-03-24 07:26:56
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
I add some code to record the change value at the method UpdateDatabase() of parecospace.cs file;But I found when submitchange at the autoform.aspx or I set the manualUpdate=false of ecodatasource ,this method updatedatabase() didn't called.
I don't know where can I trigger the updatedabase action?
Another question is how to get the old value and new value of changed field ?
thanks !
Post #5035
Posted 2010-03-24 10:24:02
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230, Visits: 1 382
To get the old value of the object, see my previous post (ICache interface).

It is correct that the ASP autoform doesn't call the Update method on the ecospace, it uses the services to perform the updates. You can intercept the calls to update with the following code:

        public class MyPersistenceService : Eco.Persistence.ChainedPersistenceServiceBase
{
public override void UpdateDatabaseWithList<T>(IEnumerable<T> list)
{
base.UpdateDatabaseWithList<T>(list);
}
}

public MyEcoSpace() : base()
{
this.InitializeComponent();
RegisterEcoService<IPersistenceService>(new MyPersistenceService() { NextPersistenceService = Persistence });
}


In the overridden UpdateDatabaseWithList you can perform your own stuff before or after the call to the base class. The list will be a list of IObjects if I'm not mistaken.


/Jonas Hogstrom [CapableObjects]
Post #5036
Posted 2010-03-24 11:38:10
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
Some questions:
1. the first param in the method GetFetchedValue(Locator locator, IStructuralFeature structuralFeature) should how to get?
I get the id from iid.IdForObject(anobj.AsIObject()),how to translat the string id to ObjectId?
like this:ics.GetFetchedValue(ics.GetLocatorById(objid), prop.StructuralFeature),isn't right?
2.as your code,
public class MyPersistenceService : Eco.Persistence.ChainedPersistenceServiceBase

{

public override void UpdateDatabaseWithList(IEnumerable list)

{
[color=#ff0000] // where I can do some[/color]

base.UpdateDatabaseWithList(list);

}

}
In the method of UpdateDatabaseWithList,How can I get IEcoServiceProvider? I will add new object,and use IEcoServiceProvider to get all dirtyobjest lsit.
3.this line: RegisterEcoService(new MyPersistenceService() { NextPersistenceService = Persistence })
new MyPersistenceService() { NextPersistenceService = Persistence } what's means? I don't understand.

Thanks.
Post #5037
Posted 2010-03-24 15:49:26
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230, Visits: 1 382
A locator is an internal representation of an object. To convert from a locator to an object, you should use the ObjectRepresentationProvider that you can access from myEcoSpace.FrontSidePolicy.ObjectRepresentationProvider. You can add this as a parameter to the constructor of your PersistenceService so that you have that easily accessible in your service.

To have access to the IEcoServiceProvider in your service, just do like the suggestion above, pass it as a parameter to the constructor and keep a local reference in the service for future use.


The following syntax:

new MyPersistenceService() { NextPersistenceService = Persistence }

simply means that it will create a new instance of MyPersistenceService and set the property NextPersistenceService to the value of "Persistence" (which is the old persistenceservice that you are replacing).



/Jonas Hogstrom [CapableObjects]
Post #5040
Posted 2010-03-25 05:01:08
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
thank you!,I have resolved.
Post #5045
« Prev Topic | Next Topic »

12»»

Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: HansKarlsen, Jonas Hogstrom, PeterMorris

Permissions Expand / Collapse

All times are GMT +1:00, Time now is 10:01

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0,203. 9 queries. Compression Disabled.