public void Add(JobProcess jobProcess) { if (string.IsNullOrWhiteSpace(jobProcess.TraceId)) { throw new ArgumentNullException(nameof(jobProcess.TraceId)); } if (string.IsNullOrWhiteSpace(jobProcess.JobId)) { throw new ArgumentNullException(nameof(jobProcess.JobId)); } if (jobProcess.Sharding <= 0) { throw new ArgumentException($"{nameof(jobProcess.Sharding)} should larger than 0"); } if (jobProcess.ProcessId <= 0) { throw new ArgumentException($"{nameof(jobProcess.ProcessId)} should larger than 0"); } if (string.IsNullOrWhiteSpace(jobProcess.Application)) { throw new ArgumentNullException(nameof(jobProcess.Application)); } var key = new ProcessKey(jobProcess.JobId, jobProcess.TraceId, jobProcess.Sharding); var path = Path.Combine(_folder, key.ToString()); File.WriteAllText(path, JsonConvert.SerializeObject(jobProcess)); }
public void Remove(ProcessKey key) { var path = Path.Combine(_folder, key.ToString()); if (File.Exists(path)) { File.Delete(path); } }
public JobProcess GetProcess(ProcessKey key) { var path = Path.Combine(_folder, key.ToString()); if (File.Exists(path)) { return(JsonConvert.DeserializeObject <JobProcess>(File.ReadAllText(path))); } return(null); }
public bool Exists(ProcessKey key) { var path = Path.Combine(_folder, key.ToString()); return(File.Exists(path)); }