File Timestamp and Saving Transformed XML to Server

  • Thread starter Greg Collins [MVP]
  • Start date
G

Greg Collins [MVP]

For background, please refer to my original thread: http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and C# and need the expertese of individuals with more experience in these languages than I have.

I may be completely off target as I thought this up very early in the morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML with the associated XSL file, and then save it to the same server folder as BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 
G

Greg Collins [MVP]

Is there no one who can help with any portion of this?

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



For background, please refer to my original thread: http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and C# and need the expertese of individuals with more experience in these languages than I have.

I may be completely off target as I thought this up very early in the morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML with the associated XSL file, and then save it to the same server folder as BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 
A

Alvin Bruney [MVP]

post the relevant portions of the code please

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Is there no one who can help with any portion of this?

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



For background, please refer to my original thread:
http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and
C# and need the expertese of individuals with more experience in these
languages than I have.

I may be completely off target as I thought this up very early in the
morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML
with the associated XSL file, and then save it to the same server folder as
BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application
Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named
BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 
G

Greg Collins [MVP]

Yes-- that is where I need help. I have the process down in my mind, but am not sure it will even work, and since my ASP.NET and C# skills are fairly weak at this point, I need help getting started.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message post the relevant portions of the code please

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Is there no one who can help with any portion of this?

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



For background, please refer to my original thread:
http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and
C# and need the expertese of individuals with more experience in these
languages than I have.

I may be completely off target as I thought this up very early in the
morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML
with the associated XSL file, and then save it to the same server folder as
BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application
Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named
BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 
A

Alvin Bruney [MVP]

Two approaches

Approach 1

1. InfoPath saves out the XML file to the server.

i assume you have the file on the server. you will need to add the account
the asp.net process is running under to the ACL for that folder. this will
allow it to access the file without throwing a permissions exception. it
should be as easy as rightclicking on the folder and selecting read
permissions.

2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.

Use the filesystem object for this. the lastaccess(???) property will give
you the file stamp.

3. If the timestamp is different, a call is made to re-transform the XML

Use whatever is available to transform the XSL file. there are a heap of
classes which specialize in transforms. to save you will need write
permissions to the directory. basically it is the same as in step one. you
can use the filesystem object to blast it out to disk

4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.

If the body.inc file is in use by another process, it will throw an
exception so bare that in mind. otherwise it should roll smoothely.

Approach 2

another more elegant approach makes itself apparent. the cache object
contains a dependency function which allows the cache to be updated when a
specific file changes. so, set a cache dependency on the XML file and map it
to a function. when the file changes, the framework calls your function
automatically.
Your function just goes ahead and re-transforms the file and resets the
dependency. here is some code for this approach:

private CacheItemRemovedCallback onRemove = null;

Application_start handler
{
onRemove = new CacheItemRemovedCallback(this.onRemoveReload);
}

functionToRetransform()
{
//retransform your XSL here

// reset the cache dependency using a dummy cache value
HttpContext.Current.Cache.Insert("CUSTOMERLIST", ds, null,
DateTime.Now.AddMinutes(GlobalRateMan.CacheReloadTimeOut),
Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemove);
}

private void onRemoveReload(String k, Object v, CacheItemRemovedReason r)
{
DataSet ds = new DataSet();
HttpContext.Current.Cache.Insert("CUSTOMERLIST", ds, null,
DateTime.Now.AddMinutes(GlobalRateMan.CacheReloadTimeOut),
Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemove);
}

The benefit of this approach is that it doesn't have to be in a web page, it
could be a standalone executable or even a webservice. Additionally, the
invalidation retransform happens automatically so you don't need to write
code to manage the file stamp process. let me know if that gets you a step
closer to what you are trying to achieve.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Yes-- that is where I need help. I have the process down in my mind, but am
not sure it will even work, and since my ASP.NET and C# skills are fairly
weak at this point, I need help getting started.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
post the relevant portions of the code please

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Is there no one who can help with any portion of this?

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



For background, please refer to my original thread:
http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and
C# and need the expertese of individuals with more experience in these
languages than I have.

I may be completely off target as I thought this up very early in the
morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML
with the associated XSL file, and then save it to the same server folder as
BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application
Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named
BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 
J

John Timney \(Microsoft MVP\)

Also Greg, the XML control in asp.net can transform for you - so your XML
and your XSL could be bound to control, pretty much meaning you wont have
much to do. You should be able to build your cahce dependency into a user
control containing the XML control so you have an encapsulated control, thus
taking away the need for the include file.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP


Alvin Bruney said:
Two approaches

Approach 1

1. InfoPath saves out the XML file to the server.

i assume you have the file on the server. you will need to add the account
the asp.net process is running under to the ACL for that folder. this will
allow it to access the file without throwing a permissions exception. it
should be as easy as rightclicking on the folder and selecting read
permissions.

2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.

Use the filesystem object for this. the lastaccess(???) property will give
you the file stamp.

3. If the timestamp is different, a call is made to re-transform the XML

Use whatever is available to transform the XSL file. there are a heap of
classes which specialize in transforms. to save you will need write
permissions to the directory. basically it is the same as in step one. you
can use the filesystem object to blast it out to disk

4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.

If the body.inc file is in use by another process, it will throw an
exception so bare that in mind. otherwise it should roll smoothely.

Approach 2

another more elegant approach makes itself apparent. the cache object
contains a dependency function which allows the cache to be updated when a
specific file changes. so, set a cache dependency on the XML file and map it
to a function. when the file changes, the framework calls your function
automatically.
Your function just goes ahead and re-transforms the file and resets the
dependency. here is some code for this approach:

private CacheItemRemovedCallback onRemove = null;

Application_start handler
{
onRemove = new CacheItemRemovedCallback(this.onRemoveReload);
}

functionToRetransform()
{
//retransform your XSL here

// reset the cache dependency using a dummy cache value
HttpContext.Current.Cache.Insert("CUSTOMERLIST", ds, null,
DateTime.Now.AddMinutes(GlobalRateMan.CacheReloadTimeOut),
Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemove);
}

private void onRemoveReload(String k, Object v, CacheItemRemovedReason r)
{
DataSet ds = new DataSet();
HttpContext.Current.Cache.Insert("CUSTOMERLIST", ds, null,
DateTime.Now.AddMinutes(GlobalRateMan.CacheReloadTimeOut),
Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemove);
}

The benefit of this approach is that it doesn't have to be in a web page, it
could be a standalone executable or even a webservice. Additionally, the
invalidation retransform happens automatically so you don't need to write
code to manage the file stamp process. let me know if that gets you a step
closer to what you are trying to achieve.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Yes-- that is where I need help. I have the process down in my mind, but am
not sure it will even work, and since my ASP.NET and C# skills are fairly
weak at this point, I need help getting started.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
post the relevant portions of the code please

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Is there no one who can help with any portion of this?

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



For background, please refer to my original thread:
http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and
C# and need the expertese of individuals with more experience in these
languages than I have.

I may be completely off target as I thought this up very early in the
morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML
with the associated XSL file, and then save it to the same server folder as
BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application
Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named
BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 
G

Greg Collins [MVP]

The reason I chose to do the include file is because I need the XML/XSLT to return ASP.NET code to be run and processed in DEFAULT.ASPX. I've already tried using <asp:Xml>, but it isn't expecting any ASP.NET code to be returned and therefore it is never processed. If there is some other way to do XML transformations that will allow the ASP.NET code returned from the transform to be processed, then that would work too. But I know of none.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Also Greg, the XML control in asp.net can transform for you - so your XML
and your XSL could be bound to control, pretty much meaning you wont have
much to do. You should be able to build your cahce dependency into a user
control containing the XML control so you have an encapsulated control, thus
taking away the need for the include file.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP


Alvin Bruney said:
Two approaches

Approach 1

1. InfoPath saves out the XML file to the server.

i assume you have the file on the server. you will need to add the account
the asp.net process is running under to the ACL for that folder. this will
allow it to access the file without throwing a permissions exception. it
should be as easy as rightclicking on the folder and selecting read
permissions.

2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.

Use the filesystem object for this. the lastaccess(???) property will give
you the file stamp.

3. If the timestamp is different, a call is made to re-transform the XML

Use whatever is available to transform the XSL file. there are a heap of
classes which specialize in transforms. to save you will need write
permissions to the directory. basically it is the same as in step one. you
can use the filesystem object to blast it out to disk

4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.

If the body.inc file is in use by another process, it will throw an
exception so bare that in mind. otherwise it should roll smoothely.

Approach 2

another more elegant approach makes itself apparent. the cache object
contains a dependency function which allows the cache to be updated when a
specific file changes. so, set a cache dependency on the XML file and map it
to a function. when the file changes, the framework calls your function
automatically.
Your function just goes ahead and re-transforms the file and resets the
dependency. here is some code for this approach:

private CacheItemRemovedCallback onRemove = null;

Application_start handler
{
onRemove = new CacheItemRemovedCallback(this.onRemoveReload);
}

functionToRetransform()
{
//retransform your XSL here

// reset the cache dependency using a dummy cache value
HttpContext.Current.Cache.Insert("CUSTOMERLIST", ds, null,
DateTime.Now.AddMinutes(GlobalRateMan.CacheReloadTimeOut),
Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemove);
}

private void onRemoveReload(String k, Object v, CacheItemRemovedReason r)
{
DataSet ds = new DataSet();
HttpContext.Current.Cache.Insert("CUSTOMERLIST", ds, null,
DateTime.Now.AddMinutes(GlobalRateMan.CacheReloadTimeOut),
Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemove);
}

The benefit of this approach is that it doesn't have to be in a web page, it
could be a standalone executable or even a webservice. Additionally, the
invalidation retransform happens automatically so you don't need to write
code to manage the file stamp process. let me know if that gets you a step
closer to what you are trying to achieve.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Yes-- that is where I need help. I have the process down in my mind, but am
not sure it will even work, and since my ASP.NET and C# skills are fairly
weak at this point, I need help getting started.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
post the relevant portions of the code please

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Is there no one who can help with any portion of this?

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



For background, please refer to my original thread:
http://groups.google.com/[email protected]

I've thought of a potential way around the issue, but I'm new to ASP.NET and
C# and need the expertese of individuals with more experience in these
languages than I have.

I may be completely off target as I thought this up very early in the
morning.

Here's the process as I see it:

1. InfoPath saves out the XML file to the server.
2. When DEFAULT.ASPX is launched, it checks the XML file's timestamp against
an Application Object variable to see if it has changed.
3. If the timestamp is different, a call is made to re-transform the XML
with the associated XSL file, and then save it to the same server folder as
BODY.INC.
4. DEFAULT.ASPX includes BODY.INC which conains ASPX code. This code will
now be processed because it is just an include.


Here's what I need to figure out:

1. How do I get the timestamp of RSS.XML to compare against the Application
Object variable?
2. How do I process the <asp:Xml/> such that it saves to a file named
BODY.INC on the server in the same folder as the DEFAULT.ASPX?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top