Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public void Remove(ProcessKey key)
        {
            var path = Path.Combine(_folder, key.ToString());

            if (File.Exists(path))
            {
                File.Delete(path);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public bool Exists(ProcessKey key)
        {
            var path = Path.Combine(_folder, key.ToString());

            return(File.Exists(path));
        }