Exemplo n.º 1
0
        public Job UpdateJob(UpdateJobViewModel job)
        {
            var currentJob = _jobRepository.GetJobById(job.JobId);

            if (currentJob != null)
            {
                currentJob.ActualTimeTakenHour = job.ActualTimeTakenHrPart;
                currentJob.EstimatedTimeHour   = job.EstimatedTimeHrPart;
                currentJob.Comments            = job.Comments;
                currentJob.ReleaseVersion      = job.ReleaseVersion;
                if (job.JobStatus != 0)
                {
                    currentJob.Status = job.JobStatus;
                }
                else
                {
                    currentJob.Status = JobStatus.Assigned;
                }
            }
            return(_jobRepository.Update(currentJob));
        }
Exemplo n.º 2
0
        public ActionResult EditJob(int jobId)
        {
            //List<string> folders = new List<string>();
            var job = _jobBLL.GetJobById(jobId);
            //Fetch uploaded files
            var folderPath = _fileBLL.GetFolderPath(job.JobId);

            string[] files = null;
            try
            {
                files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories) != null?Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories) : null;
            }
            catch
            {
            }

            var model = new UpdateJobViewModel
            {
                JobId                 = jobId,
                JobTitle              = job.JobTitle,
                JobDescription        = job.JobDescription,
                JobType               = job.JobCategory,
                ActualTimeTakenHrPart = job.ActualTimeTakenHour,
                EstimatedTimeHrPart   = job.EstimatedTimeHour,
                ReportedBy            = job.ReportedBy.ClientOrganization,
                AssignedTo            = job.AssignedTo.TakerName,
                CreatedOn             = job.CreatedOn,
                JobStatus             = job.Status,
                Comments              = job.Comments,
                LastUpdatedOn         = job.UpdatedOn,
                JobPriority           = job.JobPriority,
                ReleaseVersion        = job.ReleaseVersion,
                FileNames             = files
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult EditJob(UpdateJobViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                //if(viewModel.Files != null)
                //{
                //    foreach(var file in viewModel.Files)
                //    {
                //        if(file != null)
                //        {
                //            var fileName = _fileBLL.GetFileName(file.FileName);
                //            var filePath = _fileBLL.GetFolderPath(viewModel.JobId);
                //            if(!(Directory.Exists(filePath)))
                //            {
                //                Directory.CreateDirectory(filePath);
                //            }

                //            file.SaveAs(Path.Combine("{0}\\{1}",filePath,fileName));
                //            ViewBag.UploadStatus = string.Format("{0} {1}",viewModel.Files.Count().ToString(),"Files Uploaded Successfully");
                //        }
                //    }
                //}
                string pathName               = string.Format("{0}\\{1}", Session.SessionID, (int)Session[Constants.CurrentUserId]);
                string actualPathName         = string.Format("{0}\\{1}", viewModel.JobId, (int)Session[Constants.CurrentUserId]);
                string sessionFolderPathName  = string.Format("{0}", Session.SessionID);
                var    temporaryJobFolderPath = _fileBLL.GetFolderPath(pathName);
                if (Directory.Exists(temporaryJobFolderPath))
                {
                    //Check whether the directory is empty or not.
                    if ((Directory.GetFiles(temporaryJobFolderPath) != null) && (Directory.GetFiles(temporaryJobFolderPath).Length != 0))
                    {
                        //Get the actual path where the files have to be moved from the existing temporary session folder.
                        //var actualJobFolderPath = _fileBLL.GetFolderPath(viewModel.JobId);
                        var      actualJobFolderPath = _fileBLL.GetFolderPath(actualPathName);
                        string   sourceFileName      = string.Empty;
                        string   destinationFileName = string.Empty;
                        string[] files = Directory.GetFiles(temporaryJobFolderPath);
                        if (!(Directory.Exists(actualJobFolderPath)))
                        {
                            Directory.CreateDirectory(actualJobFolderPath);
                        }
                        //Physically move files from the session folder
                        foreach (var file in files)
                        {
                            sourceFileName      = System.IO.Path.GetFileName(file);
                            destinationFileName = System.IO.Path.Combine(actualJobFolderPath, sourceFileName);
                            System.IO.File.Copy(file, destinationFileName, true);
                        }
                        //Delete the session directory after the file transfer is done
                        sessionFolderPathName = _fileBLL.GetFolderPath(sessionFolderPathName);

                        try
                        {
                            files = Directory.GetFiles(sessionFolderPathName, "*.*", SearchOption.AllDirectories) != null?Directory.GetFiles(sessionFolderPathName, "*.*", SearchOption.AllDirectories) : null;

                            Array.ForEach(files, System.IO.File.Delete);
                            var sessionDirectories = Directory.GetDirectories(sessionFolderPathName);
                            foreach (var directory in sessionDirectories)
                            {
                                Directory.Delete(directory);
                            }
                            Directory.Delete(sessionFolderPathName);
                        }
                        catch
                        {
                        }
                    }
                }
                viewModel.LastUpdatedOn = DateTime.Now;
                Job job = _jobBLL.UpdateJob(viewModel);
                // return RedirectToAction("ViewJobs");
                return(RedirectToAction("EditJob", new { jobId = job.JobId }));
            }
            else
            {
                ModelState.AddModelError("", "Fill in all the fields");
            }
            return(View(viewModel));
        }