Esempio n. 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);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public static void ProcessJobs(int retailerId)
        {
            Trace.WriteLine("Checking for available jobs - " + retailerId);
            List <JobAudit> jobs = JobAuditDAL.GetNewJobAudits(retailerId);

            if (jobs == null || jobs.Count == 0)
            {
                Trace.WriteLine("No Jobs Waiting");
                return;
            }

            Trace.WriteLine(jobs.Count + " jobs found");

            DepartmentProcessor  deptProcessor  = new DepartmentProcessor();
            ItemProcessor        itmProcessor   = new ItemProcessor();
            TransactionProcessor transProcessor = new TransactionProcessor();

            while (jobs != null && jobs.Count > 0)
            {
                JobAudit job = jobs.First();

                if (!BOFilesHelper.Exists(job.FilePath))
                {
                    Trace.WriteLine("Job Not Found - " + job.Id);
                    job.JobStatus = BOFileStatus.FileNotFound;
                    JobAuditDAL.UpdateJobAudit(job);
                    jobs.Remove(job);
                    continue;
                }

                Trace.WriteLine(job.FileType + " Job Found" + "(" + job.Id + ")");

                switch (job.FileType)
                {
                case InputFileType.Items:
                    itmProcessor.ProcessItems(job);
                    break;

                case InputFileType.Departments:
                    deptProcessor.ProcessDepartments(job);
                    break;

                case InputFileType.Transactions:
                    transProcessor.ProcessTransactions(job);
                    break;

                default:
                    break;
                }

                Trace.WriteLine("Job Processed");

                jobs = JobAuditDAL.GetNewJobAudits(retailerId);
            }
            deptProcessor  = null;
            itmProcessor   = null;
            transProcessor = null;
        }