Esempio n. 1
0
 public IActionResult DeleteJob([FromBody] DTOJob jobObject)
 {
     //_unitOfWork.Jobs.Remove(jobObject);
     //_unitOfWork.Complete();
     DeleteFile(jobObject);
     return(Ok());
 }
Esempio n. 2
0
        private void DeleteFile(DTOJob obj)
        {
            JObject jObject   = (JObject)JToken.FromObject(obj);
            string  uploadDir = Path.Combine(_webHostEnvironment.ContentRootPath, "Json");
            string  filePath  = Path.Combine(uploadDir, obj.Guid);

            System.IO.File.Delete(filePath);
        }
Esempio n. 3
0
 public void AddJob(DTOJob job)
 {
     using (SampleDBEntities Entities = new SampleDBEntities())
     {
         var jobEntity = job.ToEntity();
         Entities.Jobs.Add(jobEntity);
         Entities.SaveChanges();
     }
 }
Esempio n. 4
0
        public IActionResult UpdateJob([FromBody] DTOJob jobObject)
        {
            //_unitOfWork.Jobs.Update(jobObject);
            //_unitOfWork.Complete();
            DeleteJob(jobObject);
            CreateJob(jobObject);

            return(Ok());
        }
Esempio n. 5
0
        public static Job ToEntity(this DTOJob dtoJob)
        {
            Job entityJob = new Job()
            {
                JobNumber = dtoJob.JobNumber,
                status    = dtoJob.status,
                Path      = dtoJob.Path
            };

            return(entityJob);
        }
Esempio n. 6
0
        /// <summary>
        /// Method used for Generating Json Files to Store Data
        /// </summary>
        /// <param name="obj"></param>
        private void CreateFile(DTOJob obj)
        {
            string uploadDir = Path.Combine(_webHostEnvironment.ContentRootPath, "Json");
            var    fileName  = Guid.NewGuid().ToString() + ".json";

            //use the guid for file identification when updating
            obj.Guid = fileName;
            JObject jObject  = (JObject)JToken.FromObject(obj);
            string  filePath = Path.Combine(uploadDir, fileName);

            System.IO.File.WriteAllText(filePath, jObject.ToString());
        }
Esempio n. 7
0
 public void UpdateJob(DTOJob job)
 {
     using (SampleDBEntities Entities = new SampleDBEntities())
     {
         var result = Entities.Jobs.FirstOrDefault(x => x.JobNumber == job.JobNumber);
         if (result != null)
         {
             result.status = job.status;
         }
         Entities.SaveChanges();
     }
 }
Esempio n. 8
0
        public IActionResult CreateJob([FromBody] Job jobObject)
        {
            var jobMapping = new DTOJob
            {
                JobId       = jobObject.JobId == -1 ? LongRandom() : jobObject.JobId,
                JobTitle    = jobObject.JobTitle,
                Description = jobObject.Description,
                CreatedAt   = jobObject.CreatedAt,
                ExpiresAt   = jobObject.ExpiresAt
            };

            CreateFile(jobMapping);
            //_unitOfWork.Jobs.Add(jobMapping);
            //_unitOfWork.Complete();
            return(Ok());
        }
Esempio n. 9
0
        private void InsertIntoJobTracking(DTOJob job)
        {
            DTOJobTracking jobTrack = new DTOJobTracking()
            {
                JobNumber = job.JobNumber,
                status    = job.status,
                Path      = job.Path
            };

            try
            {
                objBL.AddJobTracking(jobTrack);
            }
            catch (Exception ex)
            {
                Log.LogMessage("Add Job Tracking Failed");
                Log.LogMessage(ex.Message);
            }
        }
Esempio n. 10
0
        private void UpdateJob(long jobnumber)
        {
            DTOJob job = new DTOJob()
            {
                JobNumber = jobnumber,
                status    = (int)Status.Moved,
                Path      = destPath
            };

            try
            {
                objBL.UpdateJob(job);
                Log.LogMessage("job Updated.....");
                InsertIntoJobTracking(job);
            }
            catch (Exception ex)
            {
                Log.LogMessage("job updation failed");
                Log.LogMessage(ex.Message);
            }
        }
Esempio n. 11
0
        private long CreateJob(string file)
        {
            DTOJob job = new DTOJob()
            {
                JobNumber = objBL.GetJobNumber(),
                status    = (int)Status.created,
                Path      = file
            };

            try
            {
                objBL.AddJob(job);
                Log.LogMessage("Job created....");
                InsertIntoJobTracking(job);
            }
            catch (Exception ex)
            {
                Log.LogMessage("job creation failed, Exception");
                Log.LogMessage(ex.Message);
            }
            return(job.JobNumber);
        }
Esempio n. 12
0
 public void UpdateJob(DTOJob job)
 {
     objDal.UpdateJob(job);
 }
Esempio n. 13
0
 public void AddJob(DTOJob job)
 {
     objDal.AddJob(job);
 }