Beispiel #1
0
        /// <summary><![CDATA[
        /// Task Interval methods help manage scheduled activities triggered by web page views.
        /// These methods only track status and time. They do not execute anything.
        ///
        /// Run TimeIntervalStop() from your actual task method to indicate that it has ended.
        /// ]]></summary>
        /// <param name="activityName">Name of the activity, like "TwitterImport".</param>
        /// <param name="context">Manually set the context if running the method from a thread.</param>
        public static void TaskIntervalStop(string activityName, HttpContext context = null)
        {
            try
            {
                if (context == null)
                {
                    context = HttpContext.Current;
                }

                CacheHelpers.CacheAddPermanent(activityName + "_Running", false, context);

                if (CacheHelpers.CacheExists(activityName + "_Seconds", context))
                {
                    CacheHelpers.CacheAdd(activityName + "_Waiting", DateTime.Now.AddSeconds(CacheHelpers.Cache <double>(activityName + "_Seconds", context)), DateTime.Now.AddSeconds(CacheHelpers.Cache <double>(activityName + "_Seconds", context)), context);

                    Debug.WriteLine("Carbide.TemporalHelpers.TaskIntervalStop (" + activityName + ") - STOPPED");
                }

                else
                {
                    CacheHelpers.CacheDelete(activityName + "_Running", context);
                    CacheHelpers.CacheDelete(activityName + "_Seconds", context);
                    CacheHelpers.CacheDelete(activityName + "_Waiting", context);

                    Debug.WriteLine("Carbide.TemporalHelpers.TaskIntervalStop (" + activityName + ") - task time doesn't exist; resetting");
                }
            }

            catch (Exception e)
            {
                Debug.WriteLine("Carbide.Temporal EXCEPTION: TaskIntervalStop (" + activityName + ") - " + e.Message);
            }
        }
Beispiel #2
0
        /// <summary><![CDATA[
        /// Task Interval methods help manage scheduled activities triggered by web page views.
        /// These methods only track status and time. They do not execute anything.
        ///
        /// Start by running TaskIntervalInit(). This can be placed on a web page and will skip
        /// its processes if it has been run prior. This establishes the name of the task and the
        /// time interval in seconds (or greater) before it will run again.
        /// ]]></summary>
        /// <param name="activityName">Name of the activity, like "TwitterImport".</param>
        /// <param name="seconds">Number of seconds between runs.</param>
        /// <param name="context">Manually set the context if running the method from a thread.</param>
        public static void TaskIntervalInit(string activityName, double seconds, HttpContext context = null)
        {
            try
            {
                if (context == null)
                {
                    context = HttpContext.Current;
                }

                if (CacheHelpers.CacheExists(activityName + "_Seconds", context) == false || CacheHelpers.CacheExists(activityName + "_Running", context) == false)
                {
                    CacheHelpers.CacheAddPermanent(activityName + "_Running", false, context);
                    CacheHelpers.CacheAddPermanent(activityName + "_Seconds", seconds, context);
                    CacheHelpers.CacheDelete(activityName + "_Waiting", context);

                    Debug.WriteLine("Carbide.TemporalHelpers.TaskIntervalInit (" + activityName + ") - INITIALIZED");
                }

                else
                {
                    Debug.WriteLine("Carbide.TemporalHelpers.TaskIntervalInit (" + activityName + ") - ALREADY INITIALIZED, skipping");
                }
            }

            catch (Exception e)
            {
                Debug.WriteLine("Carbide.Temporal EXCEPTION: TaskIntervalInit (" + activityName + ") - " + e.Message);
            }
        }
Beispiel #3
0
        /// <summary><![CDATA[
        /// Task Interval methods help manage scheduled activities triggered by web page views.
        /// These methods only track status and time. They do not execute anything.
        ///
        /// Run TimeIntervalStart() from your actual task method to indicate that it has begun.
        /// ]]></summary>
        /// <param name="activityName">Name of the activity, like "TwitterImport".</param>
        /// <param name="context">Manually set the context if running the method from a thread.</param>
        public static void TaskIntervalStart(string activityName, HttpContext context = null)
        {
            try
            {
                if (context == null)
                {
                    context = HttpContext.Current;
                }

                CacheHelpers.CacheAddPermanent(activityName + "_Running", true, context);
                CacheHelpers.CacheDelete(activityName + "_Waiting", context);

                Debug.WriteLine("Carbide.TemporalHelpers.TaskIntervalStart (" + activityName + ") - STARTED");
            }

            catch (Exception e)
            {
                Debug.WriteLine("Carbide.Temporal EXCEPTION: TaskIntervalStart (" + activityName + ") - " + e.Message);
            }
        }