示例#1
0
        public ActionResult Create(int projectId)
        {
            if (!DoIHaveAccessToProject(projectId))
            {
                return(RedirectToAction("NotAuthorized", "Error", new { area = "" }));
            }

            var mileStone = new ProjectMileStone
            {
                ProjectId  = projectId,
                TargetDate = DateTime.Now
            };

            return(View(mileStone));
        }
        public ActionResult AddProjectMilestone(ProjectMileStone projectMileStone)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (!ModelState.IsValid)
                {
                    projectMileStone.Error     = "Please supply all required fields and try again";
                    projectMileStone.ErrorCode = -1;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(projectMileStone);
                if (wx.Code < 1)
                {
                    projectMileStone.Error     = wx.Error;
                    projectMileStone.ErrorCode = -1;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }
                projectMileStone.LastUpdated = DateTime.Now.ToString("yyyyMM/dd");
                var k = new ProjectMileStoneServices().AddProjectMileStoneCheckDuplicate(projectMileStone);
                if (k < 1)
                {
                    projectMileStone.Error     = "Process Failed! Please contact the Admin or try again later";
                    projectMileStone.ErrorCode = 0;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                projectMileStone.Error              = "Record was added successfully";
                projectMileStone.ErrorCode          = 1;
                projectMileStone.ProjectMileStoneId = k;
                projectMileStone.DateDueString      = projectMileStone.DateDue.ToString("yyyy/MM/dd");
                return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                projectMileStone.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                projectMileStone.ErrorCode = 0;
                return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public ActionResult Create(ProjectMileStone projectMileStone)
        {
            if (ModelState.IsValid)
            {
                if (!DoIHaveAccessToProject(projectMileStone.ProjectId))
                {
                    return(RedirectToAction("NotAuthorized", "Error", new { area = "" }));
                }

                projectMileStone.CreatedByUserId = WebUser.Id;

                _projectMileStoneRepository.Create(projectMileStone);
                _unitOfWork.Commit();

                return(RedirectToAction("Details", "Projects", new { Id = projectMileStone.ProjectId }));
            }

            ViewBag.ProjectId = new SelectList(_projectRepository.GetAll(), "Id", "Title", projectMileStone.ProjectId);
            return(View(projectMileStone));
        }
 public int UpdateProjectMileStoneCheckDuplicate(ProjectMileStone projectMileStone)
 {
     try
     {
         if (projectMileStone == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             db.ProjectMileStones.Attach(projectMileStone);
             db.Entry(projectMileStone).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public long AddProjectMileStoneCheckDuplicate(ProjectMileStone projectMileStone)
 {
     try
     {
         if (projectMileStone == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             var tgr = db.ProjectMileStones.Add(projectMileStone);
             db.SaveChanges();
             return(tgr.ProjectMileStoneId);
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
示例#6
0
        private ProjectMileStone ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var mInfo = new ProjectMileStone
                {
                    Title = dv.Row["ProjectMilestoneTitle"].ToString().Trim()
                };

                if (!string.IsNullOrEmpty(dv.Row["Description"].ToString().Trim()))
                {
                    mInfo.Description = dv.Row["Description"].ToString().Trim();
                }

                if (!string.IsNullOrEmpty(dv.Row["DateDue(dd/MM/yy)"].ToString().Trim()))
                {
                    DateTime ddt;
                    var      dtResult = DateTime.TryParse(dv.Row["DateDue(dd/MM/yy)"].ToString().Trim(), out ddt);

                    if (!dtResult)
                    {
                        msg = "Invalid Date Due";
                        return(null);
                    }

                    mInfo.DateDue = ddt;
                }

                return(mInfo);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public ActionResult EditProjectMilestone(int id)
        {
            var projectMileStone = new ProjectMileStone();

            try
            {
                if (id < 1)
                {
                    projectMileStone.Error     = "Invalid Selection!";
                    projectMileStone.ErrorCode = -1;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                var myViewObj = new ProjectMileStoneServices().GetProjectMileStone(id);

                if (myViewObj == null || myViewObj.ProjectId < 1)
                {
                    projectMileStone.Error     = "Project MileStone  Information could not be retrieved.";
                    projectMileStone.ErrorCode = -1;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }
                if (myViewObj.DateDue != null)
                {
                    myViewObj.DateDueString = myViewObj.DateDue.ToString("yyyy/MM/dd");
                }
                Session["_projectMileStone"] = myViewObj;
                myViewObj.ErrorCode          = 7;
                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                projectMileStone.Error     = "An unknown error was ProjectMileStone  Information could not be retrieved.";
                projectMileStone.ErrorCode = -1;
                return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult SaveToFolder(ProjectMileStone projectMileStone, HttpPostedFileBase file)
        {
            int dataCount;

            try
            {
                if (projectMileStone.ProjectId < 1 || projectMileStone.MileStoneStatusId < 1)
                {
                    ViewBag.Title        = "Manage Project Milestones";
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "Please select the required fields and try again.";
                    return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                                new ProjectMilestoneViewModel
                    {
                        MilestoneStatuses = GetMilestoneStatus(),
                        Projects = GetProjects(),
                        ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                    }));
                }

                if (file.ContentLength > 0)
                {
                    const string folderPath = "~/BulkUploadTemplate";

                    var fileName = file.FileName;
                    var path     = folderPath + "/" + fileName;
                    if (System.IO.File.Exists(Server.MapPath(path)))
                    {
                        System.IO.File.Delete(Server.MapPath(path));
                    }

                    file.SaveAs(Server.MapPath(folderPath + "/" + fileName));
                    var mList = new List <ProjectMileStone>();
                    var msg   = string.Empty;
                    if (
                        !new ProjectMilestoneUploadManager().Import(Server.MapPath(path), "projectmilestones", ref mList, ref msg))
                    {
                        ViewBag.ErrorCode    = -1;
                        ViewBag.ErrorMessage = "Bulk upload Failed! An unknown error was encountered.";
                        return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                                    new ProjectMilestoneViewModel
                        {
                            MilestoneStatuses = GetMilestoneStatus(),
                            Projects = GetProjects(),
                            CompletionStatuses = GetCompletionStatuses(),
                            ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                        }));
                    }

                    if (!mList.Any())
                    {
                        ViewBag.ErrorCode    = -1;
                        ViewBag.ErrorMessage = msg.Length > 0 ? msg : "Bulk upload Failed! unknown error occurred";
                        return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                                    new ProjectMilestoneViewModel
                        {
                            MilestoneStatuses = GetMilestoneStatus(),
                            Projects = GetProjects(),
                            CompletionStatuses = GetCompletionStatuses(),
                            ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                        }));
                    }

                    var errorList = new List <ProjectMileStone>();
                    foreach (var projectInfo in mList)
                    {
                        projectInfo.ParentId           = (int)ProjectMilestoneNotAvailable.Not_Available;
                        projectInfo.ProjectId          = projectMileStone.ProjectId;
                        projectInfo.LastUpdated        = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss t");
                        projectInfo.MileStoneStatusId  = projectMileStone.MileStoneStatusId;
                        projectMileStone.DateDueString = projectMileStone.DateDue.ToString("yyyy/MM/dd");
                        var processedItem = new ProjectMileStoneServices().AddProjectMileStoneCheckDuplicate(projectInfo);

                        if (processedItem < 1)
                        {
                            errorList.Add(projectInfo);
                        }
                    }

                    if (errorList.Any())
                    {
                        ViewBag.ErrorCode    = -1;
                        ViewBag.ErrorMessage = "Bulk upload failed";
                        ViewBag.ErrorList    = errorList;
                        return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                                    new ProjectMilestoneViewModel
                        {
                            MilestoneStatuses = GetMilestoneStatus(),
                            Projects = GetProjects(),
                            CompletionStatuses = GetCompletionStatuses(),
                            ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                        }));
                    }

                    ViewBag.ErrorCode    = 1;
                    ViewBag.ErrorMessage = "Bulk upload was successfully completed";
                    return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                                new ProjectMilestoneViewModel
                    {
                        MilestoneStatuses = GetMilestoneStatus(),
                        Projects = GetProjects(),
                        CompletionStatuses = GetCompletionStatuses(),
                        ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                    }));
                }

                ViewBag.ErrorCode    = -1;
                ViewBag.ErrorMessage = "Bulk upload Failed! unknown error occurred";
                return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                            new ProjectMilestoneViewModel
                {
                    MilestoneStatuses = GetMilestoneStatus(),
                    Projects = GetProjects(),
                    CompletionStatuses = GetCompletionStatuses(),
                    ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                }));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                ViewBag.ErrorCode    = -1;
                ViewBag.ErrorMessage = "Bulk upload Failed! unknown error occurred";
                return(View("~/Views/ProjectMileStone/ProjectMileStones.cshtml",
                            new ProjectMilestoneViewModel
                {
                    MilestoneStatuses = GetMilestoneStatus(),
                    Projects = GetProjects(),
                    CompletionStatuses = GetCompletionStatuses(),
                    ProjectMileStones = GetProjectMileStones(ItemsPerPage, PageNumber, out dataCount)
                }));
            }
        }
        public ActionResult EditProjectprojectMileStone(ProjectMileStone projectMileStone)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (Session["_projectMileStone"] == null)
                {
                    projectMileStone.Error     = "Session has expired";
                    projectMileStone.ErrorCode = 0;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                var oldProjectMileStone = Session["_projectMileStone"] as ProjectMileStone;

                if (oldProjectMileStone == null || oldProjectMileStone.ProjectId < 1)
                {
                    projectMileStone.Error     = "Session has expired";
                    projectMileStone.ErrorCode = 0;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                if (!ModelState.IsValid)
                {
                    projectMileStone.Error     = "Please supply all required fields Projects and try again";
                    projectMileStone.ErrorCode = -1;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                if (projectMileStone.ProjectId < 1)

                {
                    if (Session["_project_For_Milestone"] == null)
                    {
                        projectMileStone.Error     = "Please select a valid Project";
                        projectMileStone.ErrorCode = -1;
                        return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                    }

                    var project = Session["_project_For_Milestone"] as Project;

                    if (project == null || project.ProjectId < 1)
                    {
                        projectMileStone.Error     = "Please select a valid Project";
                        projectMileStone.ErrorCode = -1;
                        return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                    }

                    projectMileStone.ProjectId        = project.ProjectId;
                    Session["_project_For_Milestone"] = null;
                }
                var wx = ValidateControl(projectMileStone);

                if (wx.Code < 1)
                {
                    projectMileStone.Error     = wx.Error;
                    projectMileStone.ErrorCode = -1;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                oldProjectMileStone.ParentId          = projectMileStone.ParentId;
                oldProjectMileStone.ProjectId         = projectMileStone.ProjectId;
                oldProjectMileStone.Title             = projectMileStone.Title;
                oldProjectMileStone.DateDue           = projectMileStone.DateDue;
                oldProjectMileStone.LastUpdated       = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss t");
                oldProjectMileStone.MileStoneStatusId = projectMileStone.MileStoneStatusId;
                projectMileStone.DateDueString        = projectMileStone.DateDue.ToString("yyyy/MM/dd");
                var k = new ProjectMileStoneServices().UpdateProjectMileStoneCheckDuplicate(oldProjectMileStone);
                if (k < 1)
                {
                    projectMileStone.Error     = "Process Failed! Please contact the Admin or try again later";
                    projectMileStone.ErrorCode = 0;
                    return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
                }

                projectMileStone.Error     = "Project MileStone  Information was successfully updated";
                projectMileStone.ErrorCode = 1;
                return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                projectMileStone.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                projectMileStone.ErrorCode = 0;
                return(Json(projectMileStone, JsonRequestBehavior.AllowGet));
            }
        }