/// <summary> /// Save the jobs in this job group. /// </summary> /// <param name="topdir">the directory to save the jobs.</param> private void SaveJobEntry(string topdir) { foreach (Job j in m_jobs) { string logdir = topdir + "/" + j.JobID; if (!Directory.Exists(logdir)) Directory.CreateDirectory(logdir); else { Directory.Delete(logdir, true); Directory.CreateDirectory(logdir); } // save parameter file. string paramFile = logdir + "/" + GroupName + "_" + j.JobID + ".param"; JobParameterFile f = new JobParameterFile(j, paramFile); f.Write(); // save script file. string scriptFile = logdir + "/" + GroupName + "_" + j.JobID + ".ess"; if (!Path.GetFullPath(scriptFile).Equals(Path.GetFullPath(j.Argument))) File.Copy(j.Argument, scriptFile); // save log file. foreach (string srcname in j.ExtraFileList) { string filename = Path.GetFileName(srcname); string dstname = logdir + "/" + filename; if (!File.Exists(srcname)) continue; if (!Path.GetFullPath(srcname).Equals(Path.GetFullPath(dstname))) File.Copy(srcname, dstname); } } }
/// <summary> /// Load the job entry from job directory. /// </summary> /// <param name="topdir">the job directory.</param> public void LoadJobEntry(string topdir) { string[] dirs = Directory.GetDirectories(topdir); for (int i = 0; i < dirs.Length; i++) { DirectoryInfo d = new DirectoryInfo(dirs[i]); int jobid = Int32.Parse(d.Name); string paramFile = dirs[i] + "/" + GroupName + "_" + jobid + ".param"; string scriptFile = dirs[i] + "/" + GroupName + "_" + jobid + ".ess"; string[] files = Directory.GetFiles(dirs[i], "*.csv"); List<string> extFileList = new List<string>(); for (int j = 0; j < files.Length; j++) { extFileList.Add(files[j]); } Job job = m_manager.CreateJobEntry(jobid, GroupName); ; JobParameterFile f = new JobParameterFile(job, paramFile); f.Read(); job.ExtraFileList = extFileList; job.Argument = scriptFile; job.JobDirectory = dirs[i]; } }