Looking for old forum posts and information? View the old forum archive here ยป
Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

A static copy of our previous forums website is available online for reference. Click here to access the forum archive.

Learn more about...

AspDotNetStorefront
DotFeed

Global.asax problem

Hi, i would like to add functionality to send emails at a specified time. I add code for send email into Global.asax file.

<%@ Import Namespace="System.Timers" %>
<%@ Import Namespace="AspDotNetStorefrontCommon" %>

<script runat="server">
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            System.Timers.Timer myTimer = new System.Timers.Timer();
            // Set the Interval to 5 seconds (5000 milliseconds).
            myTimer.Interval = 5000;
            myTimer.AutoReset = true;
            myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
            myTimer.Enabled = true;
        }

        public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
        {
            AppLogic.SendMailTo("some", "some", true, "some.email@gmail.com");
        }
</script>

I add breakpoint on this line 

AppLogic.SendMailTo("some", "some", true, "some.email@gmail.com");

Yes, this doesnt work. If i remove 

Inherits="AspDotNetStorefront.Global"

from

<%@ Application Language="C#" Inherits="AspDotNetStorefront.Global" %>

then sendining email works. But its problem with store, because in file SkinBase.cs at line

templateName = AppLogic.AppConfig("Template" + 
CommonLogic.GetThisPageName(false));

throws an NullReferenceException. What can i do? Can i move this code in any other file, or what to do, to my code implemented in this file (Global.asax)? Thanks

asked Jun 24, 2014 in MultiStore by articuno (160 points)

1 Answer

0 votes

Hmm, when your timer is running, does the site even render? I think it might not serve requests while running?

With the null reference, since the inheritence is removed, I bet it can't find the master or such inherited resources needed?

Thank you,
Jan
 
Compunix, LLC (Phoenix, AZ)
AspDotNetStorefront Development Partner and Reseller since 2005
------------------------------------------------------------------------------------------------------
 AspDotNetStorefront add-ons and plugins : http://www.ecommercecartmods.com
 Complete Automotive Solution : http://www.autopartsshoppingcart.com
------------------------------------------------------------------------------------------------------
answered Jun 24, 2014 by jsimacek (6,655 points)

I dont have any idea why, what and where, because Ive tried everything. I think, this

Inherits="AspDotNetStorefront.Global"

redirect the program to another file. Is there any other file which can be implemented "Scheduled Task", which every 12hour check for some specific conditions?

Thanks

Ok, I'm pretty sure it would... to do a scheduled task, I would recommend one of 2 things:

- create a Windows Service that is self scheduled etc doing the chore you need

- create a task into the Windows Scheduler on the server which will just invoke a new/special page on your site which does what you need

This way, you don't have to make such drastic changes...

Thank you,
Jan
 
Compunix, LLC (Phoenix, AZ)
AspDotNetStorefront Development Partner and Reseller since 2005
------------------------------------------------------------------------------------------------------
 AspDotNetStorefront add-ons and plugins : http://www.ecommercecartmods.com
 Complete Automotive Solution : http://www.autopartsshoppingcart.com
------------------------------------------------------------------------------------------------------

Ok, thanks! Do you have maybe some sample for similar windows service?

A Windows Service isn't a simple file or code I could share, it's a Windows Application/Utility that runs on the server. If you would like a quote etc, feel free to email me at  jsimacek @ compunix.us

Thank you,
Jan
 
Compunix, LLC (Phoenix, AZ)
AspDotNetStorefront Development Partner and Reseller since 2005
------------------------------------------------------------------------------------------------------
 AspDotNetStorefront add-ons and plugins : http://www.ecommercecartmods.com
 Complete Automotive Solution : http://www.autopartsshoppingcart.com
------------------------------------------------------------------------------------------------------
...