/// <summary>
 /// 加载WinServiceJob配置。
 /// </summary>
 private void LoadJobsConfigruation()
 {
     this.allJobsCache.Clear();
     List<String> configJobs = ServiceJobsConfig.ModuleConfig.AllJobs;
     if (configJobs != null && configJobs.Count > 0)
     {
         foreach (String jobKey in configJobs)
         {
             try
             {
                 if (!string.IsNullOrEmpty(jobKey))
                 {
                     //获取Job配置。
                     JobConfiguration configuration = new JobConfiguration(jobKey);
                     if (configuration != null && !string.IsNullOrEmpty(configuration.ModuleAssembly)
                         && !string.IsNullOrEmpty(configuration.ModuleClassName))
                     {
                         string moduleAssembly = configuration.ModuleAssembly;
                         Assembly executingAssembly = null;
                         if (Assembly.GetExecutingAssembly().FullName.StartsWith(moduleAssembly))
                             executingAssembly = Assembly.GetExecutingAssembly();
                         else
                             executingAssembly = Assembly.Load(moduleAssembly);
                         //加载程序集。
                         if (executingAssembly != null)
                         {
                             IJob job = executingAssembly.CreateInstance(configuration.ModuleClassName) as IJob;
                             if (job != null)
                             {
                                 this.allJobsCache[jobKey] = job;
                             }
                         }
                     }
                 }
             }
             catch (Exception e)
             {
                 this.ServiceLog.ErrorLog(new Exception("加载[" + jobKey + "]配置时发生异常.", e));
             }
         }
     }
 }
 /// <summary>
 /// 加载WinServiceJob。
 /// </summary>
 private void LoadJobs()
 {
     lock (this)
     {
         this.allJobsCache.Clear();
         List<String> configJobs = ServiceJobsConfig.ModuleConfig.AllJobs;
         if (configJobs != null && configJobs.Count > 0)
         {
             foreach (String jobKey in configJobs)
             {
                 try
                 {
                     this.OnChanged("任务[" + jobKey + "],状态:" + "启用");
                     if (!string.IsNullOrEmpty(jobKey))
                     {
                         //获取配置。
                         this.OnChanged("准备加载任务[" + jobKey + "]的配置...");
                         JobConfiguration configuration = new JobConfiguration(jobKey);
                         if (configuration != null && !string.IsNullOrEmpty(configuration.ModuleAssembly) && !string.IsNullOrEmpty(configuration.ModuleClassName))
                         {
                             this.OnChanged(string.Format("加载任务程序集[{0}],周期:{1},同步时间点:{2}", configuration.ModuleAssembly, configuration.CycleTicks, configuration.RunTimeTicks));
                             string moduleAssembly = configuration.ModuleAssembly;
                             Assembly executingAssembly = null;
                             if (Assembly.GetExecutingAssembly().FullName.StartsWith(moduleAssembly))
                             {
                                 executingAssembly = Assembly.GetExecutingAssembly();
                             }
                             else
                             {
                                 executingAssembly = Assembly.Load(moduleAssembly);
                             }
                             //加载程序集。
                             if (executingAssembly != null)
                             {
                                 IJob wjob = executingAssembly.CreateInstance(configuration.ModuleClassName) as IJob;
                                 if (wjob != null)
                                 {
                                     wjob.LogChanged += this.LogRecord;
                                     this.allJobsCache[jobKey] = wjob;
                                     this.OnChanged("配置加载完毕!");
                                 }
                             }
                         }
                     }
                 }
                 catch (Exception x)
                 {
                     this.servlog.ErrorLog(x);
                 }
             }
         }
     }
 }