Beispiel #1
0
        private static LocalFile GetBOFile(BOFileType type, DateTime?fileDate = null, string filePath = null)
        {
            List <string> filesPath = BOFilesHelper.GetFilePathByType(type, filePath);

            if (filesPath != null && filesPath.Count > 0)
            {
                LocalFile lf = new LocalFile();

                BOFile result = new BOFile();

                result.RetailerId   = ConfigurationHelper.RetailerId;
                result.RetailerName = ConfigurationHelper.RetailerName;
                result.FileType     = type;
                result.FileDate     = fileDate ?? DateTime.Now;
                lf.BOFile           = result;

                lf.FileContent    = BOFilesHelper.Compress(filesPath);
                result.FileLength = lf.FileContent.Length;

                return(lf);
            }
            else
            {
                Logger.LogInfo(string.Format("Couldn't find today's {0} file(s).", type), System.Diagnostics.EventLogEntryType.Warning);
                return(null);
            }
        }
        public AzureUploadFile PushBOFile(BOFile file)
        {
            if (file == null)
            {
                Trace.WriteLine("PushBOFile(null)");
                return(null);
            }

            Trace.WriteLine(string.Format("PushBOFile (RetailerId = {0}, RetailerName = {1}, FileType = {2}, FileDate = {3}, FileContentLength = {4}",
                                          file.RetailerId,
                                          file.RetailerName,
                                          file.FileType,
                                          file.FileDate,
                                          file.FileLength));

            string filePath  = BOFilesHelper.GetFileName(file);
            var    signature = BOFilesHelper.GetSignature(filePath);

            RetailerProcessor retProcessor = new RetailerProcessor();

            retProcessor.EnsureRetailerExists(file.RetailerId, file.RetailerName);

            JobAuditWrapper.AddBOFile(file.RetailerId, file.FileType, filePath);

            Trace.WriteLine("Returning " + signature.ToString());
            return(signature);
        }
Beispiel #3
0
        public void MapBOToModelList()
        {
            var    mapper = new BOLFileMapper();
            BOFile bo     = new BOFile();

            bo.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1m, 1, "A", "A", "A");
            List <ApiFileResponseModel> response = mapper.MapBOToModel(new List <BOFile>()
            {
                { bo }
            });

            response.Count.Should().Be(1);
        }
Beispiel #4
0
        public void MapModelToBO()
        {
            var mapper = new BOLFileMapper();
            ApiFileRequestModel model = new ApiFileRequestModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1m, 1, "A", "A", "A");
            BOFile response = mapper.MapModelToBO(1, model);

            response.BucketId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Description.Should().Be("A");
            response.Expiration.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Extension.Should().Be("A");
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.FileSizeInBytes.Should().Be(1m);
            response.FileTypeId.Should().Be(1);
            response.Location.Should().Be("A");
            response.PrivateKey.Should().Be("A");
            response.PublicKey.Should().Be("A");
        }
Beispiel #5
0
        public void MapBOToModel()
        {
            var    mapper = new BOLFileMapper();
            BOFile bo     = new BOFile();

            bo.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, 1, "A", "A", "A");
            ApiFileResponseModel response = mapper.MapBOToModel(bo);

            response.BucketId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Description.Should().Be("A");
            response.Expiration.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Extension.Should().Be("A");
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.FileSizeInByte.Should().Be(1);
            response.FileTypeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Location.Should().Be("A");
            response.PrivateKey.Should().Be("A");
            response.PublicKey.Should().Be("A");
        }
Beispiel #6
0
        public void MapEFToBO()
        {
            var  mapper = new DALFileMapper();
            File entity = new File();

            entity.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1m, 1, 1, "A", "A", "A");

            BOFile response = mapper.MapEFToBO(entity);

            response.BucketId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Description.Should().Be("A");
            response.Expiration.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Extension.Should().Be("A");
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.FileSizeInBytes.Should().Be(1m);
            response.FileTypeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Location.Should().Be("A");
            response.PrivateKey.Should().Be("A");
            response.PublicKey.Should().Be("A");
        }
        public static string GetFileName(BOFile file)
        {
            var container = getContainer();

            if (file == null)
            {
                return(string.Empty);
            }

            string filePath = string.Format("Data\\{0}\\{1}_{2}.zip", file.RetailerId, file.FileDate.ToString("yyyyMMdd"), file.FileType);

            var blobRef = container.GetBlobReference(filePath);

            if (blobRef.Exists())
            {
                string path            = Path.GetDirectoryName(filePath);
                string fileWOExtension = Path.GetFileNameWithoutExtension(filePath);
                string extension       = Path.GetExtension(filePath);
                filePath = Path.Combine(path, fileWOExtension + DateTime.Now.ToString("HHmmss") + extension);
                blobRef  = container.GetBlobReference(filePath);
            }

            return(filePath);
        }