Example #1
0
        public static Job Create(JobData jobData)
        {
            var job = new Job(jobData);

            //job.Initialize();

            return job;
        }
Example #2
0
        public Job(JobData jobData)
        {
            _jobData = jobData;

            Initialize();
        }
Example #3
0
        public void ImportJobs()
        {
            StringBuilder messages = new StringBuilder();

            List<Job> jobs = new List<Job>();

            try
            {
                string jobDirectory = ConfigurationManager.AppSettings.Get("JobReportGenerater.JobFolder");

                DirectoryInfo dir = new DirectoryInfo(jobDirectory);

                FileInfo[] jobXmlFiles = dir.GetFiles("*.xml", SearchOption.AllDirectories);

                    foreach (FileInfo f in jobXmlFiles)
                    {
                        try
                        {
                            Console.WriteLine(f.Name);

                            XDocument jobXml = XDocument.Load(f.FullName);

                            XElement jobParameters = jobXml.Element("data");

                            JobData jd = new JobData()
                            {
                                Parameters = jobParameters
                            };

                            Job job = JobFactory.Create(jd);

                            jobs.Add(job);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }

                try
                {
                    foreach (Job j in jobs)
                    {
                        string loadOperationDetails;
                        bool success = _storage.ImportJob(out loadOperationDetails, j);

                        if (!success)
                            throw new Exception(String.Format("Failed to import job. Details: '{0}'", loadOperationDetails));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }