/// <summary>
        /// Method for run process
        /// </summary>
        /// <param name="doBatchProcess"></param>
        /// <param name="callback"></param>
        public static void RunProcess(BatchProcessRunAll_Result doBatchProcess, BatchCallBackDel callback = null)
        {
            ISchedulerFactory schedFact = new StdSchedulerFactory();
            IScheduler        sched     = schedFact.GetScheduler();

            sched.Start();
            try
            {
                string[] batchJobName = doBatchProcess.BatchJobName.Split(',');
                string   assemblyName = batchJobName[0];
                string   typeName     = assemblyName + '.' + batchJobName[1];
                //JobDetail jobDetail = new JobDetail("SECOM_AJIS_" + assemblyName, null, typeof(ProcessJob));
                JobDetail jobDetail = new JobDetail(string.Join(".", doBatchProcess.BatchCode, doBatchProcess.BatchJobName), null, typeof(ProcessJob));
                jobDetail.JobDataMap["assemblyName"]   = assemblyName;
                jobDetail.JobDataMap["typeName"]       = typeName;
                jobDetail.JobDataMap["doBatchProcess"] = doBatchProcess;
                jobDetail.JobDataMap["Callback"]       = callback;

                //Modify by Phoomsak L. 2012-11-15 Change time span from 1 to 12
                //Modify by Phoomsak L. 2012-12-19 Change repeat count from 1 to 0
                Trigger trigger2 = TriggerUtils.MakeImmediateTrigger(0, new TimeSpan(12, 0, 0));

                //trigger2.Name = "ExecuteImmediate";
                trigger2.Name = String.Format("ExecuteImmediate_{0}", doBatchProcess.BatchCode); //Modify by Jutarat A. on 26032013

                sched.ScheduleJob(jobDetail, trigger2);
            }
            catch (Exception)
            {
                sched.Shutdown();
                throw;
            }
        }
        public void Execute(JobExecutionContext context)
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;

            doBatchProcessResult      result         = new doBatchProcessResult();
            BatchCallBackDel          callback       = (BatchCallBackDel)dataMap.Get("Callback");
            BatchProcessRunAll_Result doBatchProcess = (BatchProcessRunAll_Result)dataMap.Get("doBatchProcess");

            try
            {
                if (callback != null)
                {
                    result.BatchName   = doBatchProcess.BatchName;
                    result.BatchCode   = doBatchProcess.BatchCode;
                    result.BatchStatus = BatchStatus.C_BATCH_STATUS_PROCESSING;
                    result.BatchUser   = doBatchProcess.BatchUser;
                    result.BatchDate   = doBatchProcess.BatchDate;
                    callback(result);
                }

                string assemblyName = dataMap.GetString("assemblyName");
                string typeName     = dataMap.GetString("typeName");

                Assembly      assembly = Assembly.Load(assemblyName + ", Version=0.0.0.0, PublicKeyToken=null,Culture=neutral");
                Type          type     = assembly.GetType(typeName);
                IBatchProcess process  = (IBatchProcess)Activator.CreateInstance(type);
                result = process.WorkProcess(doBatchProcess.BatchUser, (DateTime)doBatchProcess.BatchDate);

                // Added by Non A. 30/Mar/2012 : Set BatchStatus only if it's null.
                if (string.IsNullOrWhiteSpace(result.BatchStatus))
                {
                    if (result.Result == true)
                    {
                        result.BatchStatus = BatchStatus.C_BATCH_STATUS_SUCCEEDED;
                    }
                    else
                    {
                        result.BatchStatus = BatchStatus.C_BATCH_STATUS_FAILED;
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMessage = string.Format("{0} {1}", ex.Message, ex.InnerException != null ? ex.InnerException.Message : string.Empty);
                result.BatchStatus  = BatchStatus.C_BATCH_STATUS_FAILED;

                throw ex;
            }
            finally
            {
                if (string.IsNullOrWhiteSpace(result.BatchUser))
                {
                    result.BatchUser = doBatchProcess.BatchUser;
                }
                result.BatchJobName = doBatchProcess.BatchCode;
                result.BatchName    = doBatchProcess.BatchName;
                result.BatchCode    = doBatchProcess.BatchCode;
                result.BatchDate    = doBatchProcess.BatchDate;
                if (callback != null)
                {
                    callback(result);
                }

                bool keepScheduler = dataMap.GetBoolean("KeepScheduler");
                if (!keepScheduler)
                {
                    context.Scheduler.Shutdown();
                }
            }
        }