Property change notification

  • Thread starter Thread starter Craig Buchanan
  • Start date Start date
C

Craig Buchanan

I am writing an application that treats a website's forms as a really crappy
type of webservice. i do this because they don't have an API.

one of the objects in my application (called 'Employee') requires the use of
two forms (on two pages). as a result, i need to 'map' how my class'
properties are mapped to the two forms.

i've done this by creating a custom Property class which has the following
properties: Name, Value, FormName, Url, ElementName, and ElementType (e.g.
INPUT, SELECT). i also have an associated collection name
PropertyCollection. I store this mapping in an XML document and use it as a
source for the XmlDeserializer when it re-creates the PropertyCollection.

in the Save method of the Employee class, i would like to take the string
that represents the form (e.g. firstName=bob&lastName=johnson&salary=100000)
and substitute the value of the each property that changed (e.g.
firstName=bob&lastName=johnson&salary=200000). i plan to track the
properties that have values have changed and use this list to drive the
change to the form variables.

My problem is how to best alert the Employee class that a Property has
changed. i'm guessing that i can do this with a Delegate, but I don't have
much experience using them.

I would appreciate some thoughts on how to approach this.

Thanks in advance,

Craig Buchanan
 
Craig,

I am always supprised to read here that people want to use delegates.

I have used them intensively, but that was long ago and I am happy that is
seldom needed anymore.

Too I don't understand why you need a custom property.

In my idea is there nothing more simple then a webservice so why this really
crapy solution.
First try to do it simple, crapy can forever.

Simple open a Webservice template in Visual Studio and you have one.

Just my thought reading your message

Cor
 
Cor-

Unfortunately, I still need to scrap the remote site. Moreover, this is
going to be a mobile-device application, so the logic needs to be on the
client.

each custom property maps directly to a form element (e.g. <input
type='text' />). adding the extra meta-data to the property will help me
'scrape' it and persist it (using a POST).

keeping track of which property was changed by the client will help me
construct the POST. delegates seemed like the right way to do this.
essentially, the Employee class needs to 'listen' for changed properties,
make note of which have change, then use this list to reconstruct the POST.
The challenge is how to connect these together.

obviously, i know that the form variables will be and the types. i create a
mapping file (XML) to help me do the scraping. i'm hoping that during the
deserialization process (of the ProperyCollection) that i can connect each
Property's PropertyChangedEventHandler to the Employee class.

thoughts?
 
Craig said:
I am writing an application that treats a website's forms as a really crappy
type of webservice.  i do this because they don't have an API.

one of the objects in my application (called 'Employee') requires the useof
two forms (on two pages).  as a result, i need to 'map' how my class'
properties are mapped to the two forms.

Sorry, I'm having trouble visualizing the interaction here: your
application "calls" one (actually two) pages as if it was posting and
uses the resulting page? If so, uses how? I'm assuming the form page
posts to itself, is it the case? Or does it post to *the other* page
which then posts (to itself|to yet another page)? Or are the two pages
completely unrelated?
i've done this by creating a custom Property class which has the following
properties: Name, Value, FormName, Url, ElementName, and ElementType (e.g..
INPUT, SELECT).  i also have an associated collection name
PropertyCollection.  I store this mapping in an XML document and use itas a
source for the XmlDeserializer when it re-creates the PropertyCollection.

in the Save method of the Employee class, i would like to take the string
that represents the form (e.g. firstName=bob&lastName=johnson&salary=100000)
and substitute the value of the each property that changed (e.g.
firstName=bob&lastName=johnson&salary=200000).  i plan to track the
properties that have values have changed and use this list to drive the
change to the form variables.

Again, sorry for my lack of understanding, but I'm having trouble
picturing what is going on, here. Are you talking about a web
application or a "regular" app?
My problem is how to best alert the Employee class that a Property has
changed.  i'm guessing that i can do this with a Delegate, but I don't have
much experience using them.
<snip>

Uh, events? =))

Regards,

Branco.
 
Branco,

I remember me that I did a kind of thing you did, but that is long ago.

You probably are better of with this problem in the newsgroup

microsoft.public.dotnet.framework.aspnet

In my idea is this not a language question.
By instance post and get is not necessary anymore to use in ASP.Net

Cor

Craig said:
I am writing an application that treats a website's forms as a really
crappy
type of webservice. i do this because they don't have an API.

one of the objects in my application (called 'Employee') requires the use
of
two forms (on two pages). as a result, i need to 'map' how my class'
properties are mapped to the two forms.

Sorry, I'm having trouble visualizing the interaction here: your
application "calls" one (actually two) pages as if it was posting and
uses the resulting page? If so, uses how? I'm assuming the form page
posts to itself, is it the case? Or does it post to *the other* page
which then posts (to itself|to yet another page)? Or are the two pages
completely unrelated?
i've done this by creating a custom Property class which has the following
properties: Name, Value, FormName, Url, ElementName, and ElementType (e.g.
INPUT, SELECT). i also have an associated collection name
PropertyCollection. I store this mapping in an XML document and use it as
a
source for the XmlDeserializer when it re-creates the PropertyCollection.

in the Save method of the Employee class, i would like to take the string
that represents the form (e.g.
firstName=bob&lastName=johnson&salary=100000)
and substitute the value of the each property that changed (e.g.
firstName=bob&lastName=johnson&salary=200000). i plan to track the
properties that have values have changed and use this list to drive the
change to the form variables.

Again, sorry for my lack of understanding, but I'm having trouble
picturing what is going on, here. Are you talking about a web
application or a "regular" app?
My problem is how to best alert the Employee class that a Property has
changed. i'm guessing that i can do this with a Delegate, but I don't have
much experience using them.
<snip>

Uh, events? =))

Regards,

Branco.
 
Sorry, I'm having trouble visualizing the interaction here: your
i'm trying to write a Windows mobile application that gets its information
from a website. essentially, i want to create a more friendly interface
than what is provided by the terrible website. the website 'persists' the
information. i don't have access to the website, nor can i convince them to
publish a more robust API. i need to use the websites multiple pages
(pageone.asp and pagetwo.asp) and forms (one on each page) as the datasource
for my application. the each page can be use for the get or the post.

the main object's properties are spread across two pages. one page holds
the name of the object, while a second page holds other information, like
salary. the pages are related, as they contain data about the Employee, but
they act independently.

as a result, to populate my Employee instance, i need to make a call to two
page and scrape each one of them for information. the relevant data is in
two forms.

to save data, i need to determine which properties have been changed in my
client, then post the data to one or both pages.
i've done this by creating a custom Property class which has the following
properties: Name, Value, FormName, Url, ElementName, and ElementType (e.g.
INPUT, SELECT). i also have an associated collection name
PropertyCollection. I store this mapping in an XML document and use it as
a
source for the XmlDeserializer when it re-creates the PropertyCollection.

in the Save method of the Employee class, i would like to take the string
that represents the form (e.g.
firstName=bob&lastName=johnson&salary=100000)
and substitute the value of the each property that changed (e.g.
firstName=bob&lastName=johnson&salary=200000). i plan to track the
properties that have values have changed and use this list to drive the
change to the form variables.
Windows mobile application that gets its data from a website.
My problem is how to best alert the Employee class that a Property has
changed. i'm guessing that i can do this with a Delegate, but I don't have
much experience using them.
At this point, I've decide to use an IsDirty flag to mark if a property has
changed. In the Employee class, I'll enumerate all properties, and post
only those that IsDirty=true. I would rather notify the Employee class that
a property has changed so that I can store that property (in a List) and
enumerate that list during a Save. this will help me determine how many
forms need to be changed.

Perhaps there is a better approach, but until this site creates a decent
API, i'm stuck w/ scraping.
 
Cor said:
Branco,

I remember me that I did a kind of thing you did, but that is long ago.

You probably are better of with this problem in the newsgroup

microsoft.public.dotnet.framework.aspnet
<snip>

I'm not the OP. And, as his subsequent post already clarified, his
question has nothing to do with asp.net. =))

In my idea is this not a language question.
By instance post and get is not necessary anymore to use in ASP.Net
<snip>

Hmm, I disagree, GET and POST are HTTP commands and even though you
don't see then in your average Asp.Net page, these methods are working
heavily behind your Ajax back (so it may be important for any
developer working with web services to know about then). But then,
again, this seems marginaly relevant for the OP.


Regards,

Branco.
 
Craig Buchanan wrote:

i'm trying to write a Windows mobile application that gets its information
from a website.  essentially, i want to create a more friendly interface
than what is provided by the terrible website.  the website 'persists' the
information.  i don't have access to the website, nor can i convince them to
publish a more robust API.  i need to use the websites multiple pages
(pageone.asp and pagetwo.asp) and forms (one on each page) as the datasource
for my application.  the each page can be use for the get or the post.

the main object's properties are spread across two pages.  one page holds
the name of the object, while a second page holds other information, like
salary.  the pages are related, as they contain data about the Employee, but
they act independently.

as a result, to populate my Employee instance, i need to make a call to two
page and scrape each one of them for information.  the relevant data isin
two forms.

to save data, i need to determine which properties have been changed in my
client, then post the data to one or both pages.
At this point, I've decide to use an IsDirty flag to mark if a property has
changed.  In the Employee class, I'll enumerate all properties, and post
only those that IsDirty=true.  I would rather notify the Employee class that
a property has changed so that I can store that property (in a List) and
enumerate that list during a Save.  this will help me determine how many
forms need to be changed.
<snip>

I'm not aware of the tools available for the mobile framework, but can
you use DataTables and DataRows (from the System.Data namespace)?
*Maybe* using then as intermiediaries to your Employee class, you can
take advantage of the DataRow's ability to present both the original
as well as the new values for each field.

On the other hand, if System.Data isn't available or is too costy
(memory-or-performance-wise) then, alternatively, you could save a
separate version of the Employee object (from a Clone or Copy method
or similar) before the editing so you can compare each field and
decide which pages to "evoke".

HTH.

Regards,

Branco.
 
Branco,
Hmm, I disagree, GET and POST are HTTP commands and even though you
don't see then in your average Asp.Net page, these methods are working
heavily behind your Ajax back (so it may be important for any
developer working with web services to know about then). But then,
again, this seems marginaly relevant for the OP.
Who did say not. But you are not using it yourself anymore standard in .Net
languages.
They are very much wrapped in classes. Which does not mean that you cannot
use them.
You even can paint a pixel on a screen so why not this.

Cor
 
Craig,

Are you using a real webservice (what is an application type mostly running
on servers) or are you calling your application a webservice?
It looks strange to me to run a webservice on a mobile because it has to be
able serve thousands of clients in almost the same time.

Cor
 
Back
Top