Exemplo n.º 1
0
        public static List <string> GetFilePathByType(BOFileType fileType, string filePath = null)
        {
            if (filePath != null)
            {
                return(new List <string> {
                    filePath
                });
            }

            switch (fileType)
            {
            case BOFileType.Items:
                return(new List <string>()
                {
                    ItemsFile
                });

            case BOFileType.Departments:
                return(new List <string>()
                {
                    DepartmentsFile
                });

            case BOFileType.Transactions:
                return(TransactionFiles);
            }

            return(null);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public void MapModelToBO()
        {
            var mapper = new BOLFileTypeMapper();
            ApiFileTypeRequestModel model = new ApiFileTypeRequestModel();

            model.SetProperties("A");
            BOFileType response = mapper.MapModelToBO(1, model);

            response.Name.Should().Be("A");
        }
Exemplo n.º 4
0
        public void MapBOToModel()
        {
            var        mapper = new BOLFileTypeMapper();
            BOFileType bo     = new BOFileType();

            bo.SetProperties(1, "A");
            ApiFileTypeResponseModel response = mapper.MapBOToModel(bo);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 5
0
        public void MapEFToBO()
        {
            var      mapper = new DALFileTypeMapper();
            FileType entity = new FileType();

            entity.SetProperties(1, "A");

            BOFileType response = mapper.MapEFToBO(entity);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 6
0
        public void MapBOToEF()
        {
            var mapper = new DALFileTypeMapper();
            var bo     = new BOFileType();

            bo.SetProperties(1, "A");

            FileType response = mapper.MapBOToEF(bo);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 7
0
        public void MapBOToModelList()
        {
            var        mapper = new BOLFileTypeMapper();
            BOFileType bo     = new BOFileType();

            bo.SetProperties(1, "A");
            List <ApiFileTypeResponseModel> response = mapper.MapBOToModel(new List <BOFileType>()
            {
                { bo }
            });

            response.Count.Should().Be(1);
        }
Exemplo n.º 8
0
 public static void AddBOFile(int retailerId, BOFileType fileType, string filePath)
 {
     try
     {
         JobAudit job = new JobAudit {
             RetailerId = retailerId, FileType = (InputFileType)fileType, FilePath = filePath, JobStatus = BOFileStatus.NotUploaded
         };
         JobAuditDAL.InsertJobAudit(job);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Exemplo n.º 9
0
 public static void PushBOFileFromZip(BOFileType type, Stream stream, DateTime?fileDate, int?retailerID = null, string retailerName = null)
 {
     using (var ms = new MemoryStream())
     {
         StreamUtils.Copy(stream, ms, new byte[4096]);
         var result = new LocalFile()
         {
             BOFile = new BOFile()
             {
                 RetailerId   = retailerID ?? ConfigurationHelper.RetailerId,
                 RetailerName = retailerName ?? ConfigurationHelper.RetailerName,
                 FileType     = type,
                 FileDate     = fileDate ?? DateTime.Now,
             },
             FileContent = ms.ToArray()
         };
         result.BOFile.FileLength = result.FileContent.Length;
         Proxy.PushBOFile(result);
     }
 }