Wednesday, September 14, 2011

Windows 8 lets you build apps for tablets!

Today at Microsoft's build conference, Microsoft released a Developer Preview of Windows 8 and showcased its potential for competing in the tablet PC industry. If you want to get a leg up on the competition, and the opportunity to make some money building apps, check out the video of the preview at http://www.buildwindows.com/ . In addition to the video of the conference, you can download a pseudo CTP (a.k.a Developer Preview) of the OS on the website (also found at http://msdn.microsoft.com/en-us/windows/apps/br229516) .

If you've heard rumors that .NET was dead and that new apps would have to be built using HTML5 and javascript, you can put your fears aside. Microsoft lets you build apps in the language of your choosing. This includes C++, C#, VB, HTML5, and I could go on. Windows 8 apps are marketed as using the Metro UI, which includes touch capability, and simplistic app sharing. During the conference, they showcase how easy it is to manipulate the UI design using HTML5 and Expression Blend 5 (new version which works with XAML and HTML5), but they don't discuss how easy it is to design a C# application using Metro's features. I'm curious to try and hope to show the pros/cons in another post.

If you don't want to watch the 3 hour long video in its entirety, you should at the very least skip to the Keynote #1 speach at about 14:27 minutes in. They show off a new feature called picture password, that allows you to login to the system using a system of touches and swipes. No more passwords...how cool!
http://channel9.msdn.com/Events/BUILD/BUILD2011/KEY-0001

Monday, April 18, 2011

Quartz.NET 2.0 is available!

There is a second release of Quart.Net called Quart.Net 2.0. It's still in the beta stage, but it's a big step up from version 1.0.3. It has support for Generics and much more. Check it out here. For those who are github savvy you can find it at https://github.com/lahma/quartznet.git.

Saturday, April 2, 2011

Quartz.NET is available on NuGet

The Quartz.Net library has been uploaded to NuGet. If you’re using Quartz.Net and NuGet, this should help you with setting up your environment and in keeping things current. The Common.Logging and the Common.Logging.Log4net and Log4net libraries are on NuGet as well. These are all required dependencies for running Quartz.Net with Log4net.

Tuesday, March 29, 2011

Event Based Listeners in Quartz.NET

Since Quartz.NET is ported from Java, it does not have an inkling of what a delegate is or should be. Below, I show how to use events in your Quartz.Net implementation. You can rename the namespaces and classes.

.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using System.Threading;
 
namespace Hizzah.JobListeners
{
    public class BeforeJobExecutedEventArgs : EventArgs
    {
        JobExecutionContext _context;
        public BeforeJobExecutedEventArgs(JobExecutionContext context)
        {
            _context = context;
        }
 
        public JobExecutionContext Context
        {
            get { return _context; }
            set { _context = value; }
 
        }
    }
 
    public class AfterJobExecutedEventArgs : EventArgs
    {
        JobExecutionContext _context;
        public JobExecutionContext Context
        {
            get { return _context; }
            set { _context = value; }
 
        }
        JobExecutionException _exception;
        public JobExecutionException Exception
        {
            get { return _exception; }
            set { _exception = value; }
        }
 
        public AfterJobExecutedEventArgs(JobExecutionContext context, JobExecutionException exception)
        {
            _context = context;
            _exception = exception;
        }
    }





using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Quartz;

using System.Threading;



namespace Hizzah.JobListeners

{



    public class HizzahJobListener : IJobListener

    {

        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public event EventHandler<BeforeJobExecutedEventArgs> BeforeJobExecution;

        public event EventHandler<AfterJobExecutedEventArgs> AfterJobExecution;



        public HizzahJobListener(string name)

        {

            _name = name;

        }

        #region IJobListener Members



        private string _name;

        public string Name

        {

            get { return _name; }

        }



        public void JobToBeExecuted(JobExecutionContext context)

        {

            _name = context.JobDetail.Name;

            OnBeforeJobExecution(new BeforeJobExecutedEventArgs(context));



        }



        protected void OnBeforeJobExecution(BeforeJobExecutedEventArgs args)

        {

            // Copy a reference to the delegate field now into a temporary field for thread safety

            EventHandler<BeforeJobExecutedEventArgs> temp = Interlocked.CompareExchange(ref BeforeJobExecution, nullnull);

            if (temp != null)

            {

                temp(thisargs);

            }

        }



        protected void OnAfterJobExecution(AfterJobExecutedEventArgs args)

        {

            // Copy a reference to the delegate field now into a temporary field for thread safety

            EventHandler<AfterJobExecutedEventArgs> temp = Interlocked.CompareExchange(ref AfterJobExecution, nullnull);

            if (temp != null)

            {

                temp(thisargs);

            }

        }



        public void JobExecutionVetoed(JobExecutionContext context)

        {

            throw new NotImplementedException();

         }



        public void JobWasExecuted(JobExecutionContext context, JobExecutionException jobException)

        {

            _name = context.JobDetail.Name;

            OnAfterJobExecution(new AfterJobExecutedEventArgs(context, jobException));

        }



        #endregion

    }

}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using System.Threading;
 
namespace Hizzah.TriggerListeners
{
    public class TriggerFiredEventArgs : EventArgs
    {
        JobExecutionContext _context;
        Trigger _trigger;
        public TriggerFiredEventArgs()
            :base()
        {}
 
        public TriggerFiredEventArgs(Trigger trigger, JobExecutionContext context)
            :base()
        {
            _context = context;
            _trigger = trigger;
        }
 
        public JobExecutionContext Context
        {
            get { return _context; }
            set { _context = value; }
        }
 
        public Trigger Trigger
        {
            get
            {
                return _trigger;
            }
            set
            {
                _trigger = value;
            }
        }
    }
 
    public class TriggerCompletedEventArgs : EventArgs
    {
        JobExecutionContext _context;
        Trigger _trigger;
        SchedulerInstruction _instruction;
 
        public JobExecutionContext Context
        {
            get { return _context; }
            set { _context = value; }
 
        }
 
        public Trigger Trigger
        {
            get
            {
                return _trigger;
            }
            set
            {
                _trigger = value;
            }
        }
 
        public SchedulerInstruction Instruction
        {
            get
            {
                return _instruction;
            }
            set
            {
                _instruction = value;
            }
        }
 
        public TriggerCompletedEventArgs()
        { }
 
        public TriggerCompletedEventArgs(Trigger trigger, JobExecutionContext context, SchedulerInstruction instruction)
            :base()
        {
            _context = context;
            _trigger = trigger;
            _instruction = instruction;
        }
    }
 
 
    public class HizzahTriggerListener : ITriggerListener
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private string _name;
        public event EventHandler<TriggerFiredEventArgs> TriggerFiredEvent;
        public event EventHandler<TriggerCompletedEventArgs> TriggerCompletedEvent;
 
        public HizzahTriggerListener(string name)
        {
            _name = name;
        }
 
        #region ITriggerListener Members
 
        public string Name
        {
            get
            {
                return _name;
            }
        }
 
        public void TriggerFired(Trigger trigger, JobExecutionContext context)
        {
            log.Debug("TriggerFired Fired");
            OnTriggerFired(new TriggerFiredEventArgs(trigger, context));
            
        }
 
        public bool VetoJobExecution(Trigger trigger, JobExecutionContext context)
        {
            log.Debug("VetoJobExecution Fired");
            return false;
            //throw new NotImplementedException();
        }
 
        public void TriggerMisfired(Trigger trigger)
        {
            log.Debug("TriggerMisfired Fired");
            throw new NotImplementedException();
        }
 
        public void TriggerComplete(Trigger trigger, JobExecutionContext context, SchedulerInstruction triggerInstructionCode)
        {
            log.Debug("TriggerComplete Fired");
            OnTriggerCompleted(new TriggerCompletedEventArgs(trigger, context, triggerInstructionCode));
        }
 
        #endregion
 
        public void OnTriggerFired(TriggerFiredEventArgs args)
        {
            // Copy a reference to the delegate field now into a temporary field for thread safety
            EventHandler<TriggerFiredEventArgs> temp = Interlocked.CompareExchange(ref TriggerFiredEvent, nullnull);
            if (temp != null)
            {
                temp(thisargs);
            }
        }
 
        public void OnTriggerCompleted(TriggerCompletedEventArgs args)
        {
            // Copy a reference to the delegate field into a temp var for thread safety
            EventHandler<TriggerCompletedEventArgs> temp = Interlocked.CompareExchange(ref TriggerCompletedEvent, nullnull);
            if (temp != null)
            {
                temp(thisargs);
            }
        }
    }
}