示例#1
0
        public static string ResolveFilePath(GridJob job, GridJobTask task, GridJobFile file)
        {
            if (file.ShareMode == EGridJobFileShare.SharedBetweenTasks)
            {
                return($"{JobsDirectory}\\{job.Name}\\{file.FileName}");
            }

            return($"{JobsDirectory}\\{job.Name}\\task-{task.TaskId}\\{file.FileName}");
        }
示例#2
0
        public static void StoreJobTaskFile(GridJobTask task, GridJobFile file)
        {
            CreateTaskDirectoriesIfNotExists(task);

            var fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}\\{file.FileName}";

            if (file.ShareMode == EGridJobFileShare.SharedBetweenTasks)
            {
                fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\{file.FileName}";
            }

            File.WriteAllBytes(fp, file.Bytes);
        }
示例#3
0
        public static GridJobFile ImportFromExternal(string input, EGridJobFileDirection dir, EGridJobFileShare share)
        {
            if (!File.Exists(input))
            {
                throw new Exception($"No such file {input}, you need to pass full path, not relative");
            }

            var file = new GridJobFile {
                FileName  = Path.GetFileName(input),
                InputPath = input,
                Direction = dir,
                ShareMode = share,
                Bytes     = File.ReadAllBytes(input)
            };

            file.CheckSum = CryptoUtils.CrcOfBytes(file.Bytes);
            return(file);
        }
示例#4
0
        public static bool IsJobTaskFileExistsAndValid(GridJobTask task, GridJobFile jobFile)
        {
            var fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\{jobFile.FileName}";

            if (jobFile.ShareMode == EGridJobFileShare.SharedBetweenTasks)
            {
                if (!File.Exists(fp))
                {
                    return(false);
                }

                return(CryptoUtils.CrcOfFile(fp) == jobFile.CheckSum);
            }

            fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}\\{jobFile.FileName}";
            if (!File.Exists(fp))
            {
                return(false);
            }

            return(CryptoUtils.CrcOfFile(fp) == jobFile.CheckSum);
        }
示例#5
0
 public GridJobFileLink(GridJobFile file)
 {
     FileName = file.FileName;
     CheckSum = file.CheckSum;
 }
示例#6
0
 public string ResolveFilePath(GridJobTask task, GridJobFile file)
 {
     return(GridIo.ResolveFilePath(task.ParentJob, task, file));
 }