Пример #1
0
        private CreateFileRequest GetCreateFileRequest(FileActionData data)
        {
            var fileFullName  = $"{_syncFolder}\\{data.FileName}";
            var bytes         = File.ReadAllBytes(fileFullName);
            var checkSum      = _fileService.CalculateCheckSum(bytes);
            var createRequest = new CreateFileRequest
            {
                FileName = data.FileName,
                Content  = bytes,
                CheckSum = checkSum
            };

            return(createRequest);
        }
Пример #2
0
        private Response CheckFileRequest(CreateFileRequest file)
        {
            var baseStatus = CheckFileRequest((FileRequestBase)file);

            if (baseStatus.ResponseStatus == false)
            {
                return(baseStatus);
            }

            var localCheckSum = _fileService.CalculateCheckSum(file.Content);

            if (localCheckSum != file.CheckSum)
            {
                return(CreateResponse(file.FileName, "CheckSum was failed", false));
            }

            return(file.Content != null
                ? CreateResponse(file.FileName, "File Is Valid", true)
                : CreateResponse(file.FileName, "File Content is null", false));
        }