public HttpResponseMessage GetProjectTaskByProjectId(int projectid) { try { PM_TaskBL tb = new PM_TaskBL(); List <PM_Task> rec = new List <PM_Task>(); if (projectid != 0) { rec = tb.ToList("ByProjectId", string.Empty, string.Empty, projectid, 0); } if (rec != null) { return(Request.CreateResponse(HttpStatusCode.OK, rec)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Data")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public JsonResult getMaxSortOrder(string filter, string value = "0", string value2 = "0") { PM_TaskBL tb = new PM_TaskBL(); var rec = tb.ToList(filter, value, value2); return(Json(rec, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage SaveTodo(PM_Todo todo) { PM_TaskBL pb = new PM_TaskBL(); if (todo.TodoId > 0) { bool result = pb.SaveTodo(todo, "Update_Todo"); if (result) { return(this.Request.CreateResponse(HttpStatusCode.OK, new { Message = "To do List Updated", Value = 1 })); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "To do List Not Updated")); } } else { bool result = pb.SaveTodo(todo, "Insert_Todo"); if (result) { return(this.Request.CreateResponse(HttpStatusCode.OK, new { Message = "To do List Added", Value = 1 })); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "To do List Not Added")); } } }
public ActionResult PlanningNew(List <PM_SiteTasks> SiteTasks) { PM_TaskBL pb = new PM_TaskBL(); var result = pb.InsertPM_siteTask("Update_SiteTask_PLAN_BULK", SiteTasks, ViewBag.UserId); return(PartialView("~/Areas/Project/Views/Dashboard/_PlanningView.cshtml")); }
[System.Web.Http.Route("swi/PM_Tasks"), System.Web.Http.HttpPost] //Filters:ByTaskTypeId,ByTaskTypeKeyCode,ByPTaskId,ByTaskId,ByProjectId public HttpResponseMessage PM_Tasks(string filter, string pType, string pId, bool Resources = false, Int64 ProjectId = 0, Int64 TaskId = 0) { PM_TaskBL tb = new PM_TaskBL(); var result = tb.ToList(filter, pType, pId, ProjectId, TaskId); if (Resources) { PM_ProjectResourceBL prb = new PM_ProjectResourceBL(); foreach (var item in result) { item.ProjectResources = prb.ToList("byTaskId", item.TaskId.ToString(), ProjectId, TaskId); } } //return Json(rec, JsonRequestBehavior.AllowGet); if (result != null) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Record for Id " + TaskId.ToString() + " not found")); } }
public HttpResponseMessage GetReadniessByProjectId(int projectid, int userId, string marketIds = "", DateTime?fromDate = null, DateTime?todate = null) { try { PM_TaskBL tb = new PM_TaskBL(); List <PM_Task_DTO> rec = new List <PM_Task_DTO>(); if (projectid != 0) { rec = tb.Radiness("Get_Readiness", fromDate.ToString(), todate.ToString(), marketIds, projectid, 0); } if (rec != null) { return(Request.CreateResponse(HttpStatusCode.OK, rec)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Data")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public ActionResult PostEditToDo(PM_Todo todo) { PM_TaskBL pb = new PM_TaskBL(); var result = pb.EditTodo(todo, "Edit_Todo"); return(Json(result == true ? "success" : "fail", JsonRequestBehavior.AllowGet)); }
public ActionResult ToSingle(string filter, string value = "0", string value2 = "0") { PM_TaskBL tb = new PM_TaskBL(); var rec = tb.ToList(filter, value, value2).FirstOrDefault(); if (rec != null) { PM_ProjectResourceBL prb = new PM_ProjectResourceBL(); rec.ProjectResources = prb.ToList("byTaskId", rec.TaskId.ToString()); } return(Json(rec, JsonRequestBehavior.AllowGet)); }
public ActionResult ToList(string filter, string value, string value2) { PM_TaskBL tb = new PM_TaskBL(); var rec = tb.ToList(filter, value = "0", value2 = "0", 0, 0); //if (Resources) //{ // PM_ProjectResourceBL prb = new PM_ProjectResourceBL(); // foreach (var item in rec) // { // item.ProjectResources = prb.ToList("byTaskId", item.TaskId.ToString(), ProjectId, TaskId); // } //} return(Json(rec, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage PlanningNew(PM_SiteTasks siteTask) { PM_TaskBL pb = new PM_TaskBL(); var result = pb.InsertPM_siteTask("Update_Task_Plan", siteTask); if (result != null) { return(this.Request.CreateResponse(HttpStatusCode.OK, new { Message = "Site Task Planed", Value = 1 })); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Site Task Not Planed")); } }
public ActionResult SaveTodo(PM_Todo todo) { PM_TaskBL pb = new PM_TaskBL(); todo.CreatedById = ViewBag.UserId; todo.CreatedOn = DateTime.Now; if (todo.TodoId == 0) { var result = pb.SaveTodo(todo, "Insert_Todo"); return(Json(result == true ? "success" : "fail", JsonRequestBehavior.AllowGet)); } else { var result = pb.SaveTodo(todo, "Update_Todo"); return(Json(result == true ? "success" : "fail", JsonRequestBehavior.AllowGet)); } }
public ActionResult StatusChange(PM_SiteTasks siteTask) { Response res = new Response(); siteTask.CreatedBy = ViewBag.UserId; try { PM_TaskBL pb = new PM_TaskBL(); res.Value = pb.InsertPM_siteTask("Update_SiteTask_PLAN", siteTask); res.Status = "success"; res.Message = "Save successfully"; } catch (Exception ex) { res.Status = "danger"; res.Message = ex.Message; } return(Json(res, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage UpdateEventInProjectByProjectId([FromUri] int UserId, [FromUri] int eventId, PM_Todo todo) { try { PM_TaskBL pb = new PM_TaskBL(); todo.CreatedOn = DateTime.Now; if (todo.TodoId != 0) { var result = pb.SaveTodo(todo, "Edit_Todo"); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Data")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public Response _New(List <PM_Task> t) { Response res = new Response(); try { if (t.Count > 0) { AD_DefinationBL db = new AD_DefinationBL(); List <AD_Defination> ProjectStatus = db.ToList("byDefinationType", "Project Task Status"); PM_TaskBL pb = new PM_TaskBL(); dbDataTable dbdt = new dbDataTable(); PM_TaskDL ptd = new PM_TaskDL(); var dt1 = dbdt.TaskList(); int Counter = 1; foreach (var item in t) { var Status = item.Status.Split('_'); if (Status.Length > 0) { switch (Status[1].ToLower()) { case "active": var active = ProjectStatus.Where(x => x.DefinationName.ToLower() == "active").FirstOrDefault(); if (active != null) { item.StatusId = active.DefinationId; } else { item.StatusId = 0; } break; case "suspended": var suspend = ProjectStatus.Where(x => x.DefinationName.ToLower() == "suspended").FirstOrDefault(); if (suspend != null) { item.StatusId = suspend.DefinationId; } else { item.StatusId = 0; } break; case "done": var done = ProjectStatus.Where(x => x.DefinationName.ToLower() == "completed").FirstOrDefault(); if (done != null) { item.StatusId = done.DefinationId; } else { item.StatusId = 0; } break; case "failed": var failed = ProjectStatus.Where(x => x.DefinationName.ToLower() == "cancelled").FirstOrDefault(); if (failed != null) { item.StatusId = failed.DefinationId; } else { item.StatusId = 0; } break; case "undefined": var undefined = ProjectStatus.Where(x => x.DefinationName.ToLower() == "undefined").FirstOrDefault(); if (undefined != null) { item.StatusId = undefined.DefinationId; } else { item.StatusId = 0; } break; case "planned": var planned = ProjectStatus.Where(x => x.DefinationName.ToLower() == "planned").FirstOrDefault(); if (planned != null) { item.StatusId = planned.DefinationId; } else { item.StatusId = 0; } break; //default : // item.StatusId = 0; } if (item.StatusId == 0) { item.StatusId = ProjectStatus.Where(x => x.DefinationName.ToLower() == "planned").FirstOrDefault().PDefinationId; item.Status = "STATUS_PLANNED"; } } var Parentid = item.PTaskId; var Preid = item.PredecessorId; if (string.IsNullOrEmpty(item.PTaskId) || item.PTaskId.StartsWith("tmp_")) { Parentid = "0"; } else if (string.IsNullOrEmpty(item.PredecessorId) || item.PredecessorId.StartsWith("tmp_")) { Preid = "0"; } myDataTable.AddRow(dt1, "Value1", item.TaskId, "Value2", Parentid, "Value3", item.ProjectId, "Value4", item.TaskTypeId, "Value5", item.StatusId, "Value6", item.PriorityId, "Value7", Preid, "Value8", item.Title , "Value9", item.PlannedDate, "Value10", item.TargetDate, "Value11", item.ActualStartDate, "Value12", item.ActualEndDate, "Value13", item.EstimatedStartDate, "Value14", item.EstimatedEndDate, "Value15", item.Description, "Value16", item.IsEstimate, "Value17", item.ForecastedSites, "Value18", item.CompletionPercent, "Value19", item.BudgetCost, "Value20", item.ActualCost, "Value21", item.MapCode, "Value22", item.MapColumn, "Value23", item.Color, "Value24", item.IsActive, "Value25", item.ScopeId, "Value26", item.IsStartMilestone, "Value27", item.IsEndMilestone, "Value28", Counter , "Value29", item.Level, "Value30", item.Duration, "Value31", "Mobile" ); Counter++; } DataTable NewTasks = ptd.Manage("Insert2", dt1); List <PM_Task> ParentUpdate = new List <PM_Task>(); List <int> NewTasksId = (from row in NewTasks.AsEnumerable() select Convert.ToInt32(row["ID"])).ToList(); int NewTask = 0; for (int i = 0; i < t.Count; i++) { if (t[i].TaskId == 0) { NewTask = NewTasksId[i]; } t[i].TaskId = NewTasksId[i]; } for (int i = 0; i < t.Count; i++) { if (!string.IsNullOrEmpty(t[i].PTaskId) && t[i].PTaskId.StartsWith("tmp_")) { t[i].PTaskId = t.Where(x => x.id == t[i].PTaskId).FirstOrDefault().TaskId.ToString(); ParentUpdate.Add(t[i]); } else if (!string.IsNullOrEmpty(t[i].PredecessorId) && t[i].PredecessorId.StartsWith("tmp_")) { t[i].PredecessorId = t.Where(x => x.id == t[i].PredecessorId).FirstOrDefault().TaskId.ToString(); ParentUpdate.Add(t[i]); } } if (ParentUpdate.Count > 0) { var dt3 = dbdt.TaskList(); foreach (var item in ParentUpdate) { myDataTable.AddRow(dt3, "Value1", item.TaskId, "Value2", item.PTaskId, "Value3", item.ProjectId, "Value4", item.TaskTypeId, "Value5", item.StatusId, "Value6", item.PriorityId, "Value7", item.PredecessorId, "Value8", item.Title , "Value9", item.PlannedDate, "Value10", item.TargetDate, "Value11", item.ActualStartDate, "Value12", item.ActualEndDate, "Value13", item.EstimatedStartDate, "Value14", item.EstimatedEndDate, "Value15", item.Description, "Value16", item.IsEstimate, "Value17", item.ForecastedSites, "Value18", item.CompletionPercent, "Value19", item.BudgetCost, "Value20", item.ActualCost, "Value21", item.MapCode, "Value22", item.MapColumn, "Value23", item.Color, "Value24", item.IsActive, "Value25", item.ScopeId, "Value26", item.IsStartMilestone, "Value27", item.IsEndMilestone, "Value28", item.SortOrder , "Value29", item.Level ); } DataTable NewTasks2 = ptd.Manage("UpdateParent", dt3); List <int> NewTasksIds = (from row in NewTasks2.AsEnumerable() select Convert.ToInt32(row["ID"])).ToList(); } res.Value = NewTask; res.Status = "true"; res.Message = "Save successfully"; } else { res.Status = "false"; res.Message = "No row effected"; } } catch (Exception ex) { res.Status = "false"; res.Message = ex.Message; } return(res); }
public ActionResult FileUpload(HttpPostedFileBase Upload) { dbDataTable ddt = new dbDataTable(); DataTable FileRecord = ddt.Tb_PM_Target(); PM_TargetsBL tb = new PM_TargetsBL(); PM_ProjectBL P = new PM_ProjectBL(); PM_TaskBL ttb = new PM_TaskBL(); dbDataTable dbdt = new dbDataTable(); TempData.Keep("ProjectId"); string ProjectId = TempData["ProjectId"] as string; try { if (Upload != null && Upload.ContentLength > 0) { if (Upload.FileName.EndsWith(".csv") || Upload.FileName.EndsWith(".CSV")) { Stream stream = Upload.InputStream; using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true)) { FileRecord.Load(csvReader); } List <PM_Target_File> target = FileRecord.ToList <PM_Target_File>(); var dtt = ttb.ToList("Get_Project_Tasks", string.Empty, string.Empty, Convert.ToInt64(ProjectId), 0).ToArray(); string ProjectName = P.ToList("ByProjectId", ProjectId, 0).Select(x => x.ProjectName).FirstOrDefault(); var id = Session["user"]; var userId = (LoginInformation)id; DataTable dt = dbdt.List(); foreach (var tr in target) { if (tr.Project == ProjectName) { var results = Array.FindAll(dtt, s => s.Title.Equals(tr.Task)).FirstOrDefault(); if (results != null) { if (tr.TargetType.ToLower() == "day") { myDataTable.AddRow(dt, "Value1", ProjectId, "Value2", results.TaskId, "Value3", null, "Value4", tr.TargetType, "Value5", tr.TargetValue, "Value6", null, "Value7", tr.SiteCount, "Value8", userId.UserId.ToString()); } else { myDataTable.AddRow(dt, "Value1", ProjectId, "Value2", results.TaskId, "Value3", null, "Value4", tr.TargetType, "Value5", null, "Value6", tr.TargetValue, "Value7", tr.SiteCount, "Value8", userId.UserId.ToString()); } } } } if (tb.Manage("Insert", "", dt)) { TempData["msg_success"] = "Save successfully."; } else { TempData["msg_nothing"] = "No row effect"; } } else { TempData["msg_error"] = "Select .csv File"; } } else { TempData["msg_error"] = "No file selected"; } } catch (Exception ex) { TempData["msg_error"] = ex.Message; } return(RedirectToAction("Index", new { @id = Convert.ToInt64(ProjectId) })); }
public Response _Tasks(string filter = "", string value = "", string value2 = "", bool Resources = false, Int64 ProjectId = 0, Int64 TaskId = 0) { Response _res = new Response(); try { PM_TaskBL tb = new PM_TaskBL(); var rec = tb.ToList(filter, value, ProjectId.ToString(), ProjectId, TaskId); if (Resources) { PM_ProjectResourceBL prb = new PM_ProjectResourceBL(); foreach (var item in rec) { item.ProjectResources = prb.ToList("byTaskId", item.TaskId.ToString(), ProjectId, TaskId); } } if (filter == "ByTaskTypeKeyCode") { AD_DefinationBL db = new AD_DefinationBL(); List <AD_Defination> ProjectStatus = db.ToList("byDefinationType", "Project Task Status"); foreach (var item in rec) { var Splited = ProjectStatus.Where(x => x.DefinationId == item.StatusId).FirstOrDefault(); if (Splited != null) { var CurrentStatus = Splited.DefinationName.ToLower(); switch (CurrentStatus) { case "active": item.Status = "STATUS_ACTIVE"; break; case "suspended": item.Status = "STATUS_SUSPENDED"; break; case "completed": item.Status = "STATUS_DONE"; break; case "cancelled": item.Status = "STATUS_FAILED"; break; case "undefined": item.Status = "STATUS_UNDEFINED"; break; case "planned": item.Status = "STATUS_PLANNED"; break; //default : // item.StatusId = 0; } // item.Status = GanttStatusses.Where(x=>x.Split('_')[1].ToLower() == Splited.DefinationName.ToLower()).FirstOrDefault(); } if (item.Status == null || item.Status == "") { item.Status = "STATUS_PLANNED"; item.StatusId = ProjectStatus.Where(x => x.DefinationName == "Planned").FirstOrDefault().PDefinationId; } } } _res.Value = rec; _res.Message = "Ok"; _res.Status = "true"; return(_res); } catch (Exception _ex) { _res.Message = _ex.Message; _res.Status = "false"; return(_res); } }
public ActionResult getAllTask(string filter, Int64 ProjectId = 0) { List <MilestoneModel> Mlist = new List <MilestoneModel>(); List <MilestoneModel> Tlist = new List <MilestoneModel>(); PM_TaskBL tb = new PM_TaskBL(); var dt = tb.ToList(filter, string.Empty, string.Empty, ProjectId, 0); if (filter == "Get_Project_Tasks") { List <MilestoneModel> MyList = new List <MilestoneModel>(); foreach (var item in dt) { MilestoneModel mil = new MilestoneModel(); mil.PTaskId = Convert.ToInt64(item.PTaskId); mil.Task = item.Title; mil.TaskId = item.TaskId; MyList.Add(mil); } foreach (var item in MyList.Where(x => x.PTaskId == 0)) { MilestoneModel mil = new MilestoneModel(); mil.Tasks = FlatToHierarchy(MyList, item.TaskId); mil.TaskId = item.TaskId; mil.Task = item.Task; Mlist.Add(mil); } return(Json(Mlist, JsonRequestBehavior.AllowGet)); } if (dt.Count() > 0) { foreach (PM_Task obj in dt) { if (obj.PTaskId == "0") { MilestoneModel mil = new MilestoneModel(); mil.TaskId = Convert.ToInt64(obj.TaskId.ToString()); mil.PTaskId = Convert.ToInt64(obj.PTaskId.ToString()); mil.Task = obj.Title.ToString(); Mlist.Add(mil); } else { MilestoneModel tsk = new MilestoneModel(); tsk.TaskId = Convert.ToInt64(obj.TaskId.ToString()); tsk.PTaskId = Convert.ToInt64(obj.PTaskId.ToString()); tsk.Task = obj.Title.ToString(); Tlist.Add(tsk); } } foreach (var mile in Mlist) { foreach (var task in Tlist) { if (task.PTaskId == mile.TaskId) { mile.Tasks.Add(task); } } } } return(Json(Mlist, JsonRequestBehavior.AllowGet)); }
public ActionResult ToList(string filter, string value, string value2, bool Resources = false, Int64 ProjectId = 0, Int64 TaskId = 0) { PM_TaskBL tb = new PM_TaskBL(); var rec = tb.ToList(filter, value, value2, ProjectId, TaskId); if (Resources) { PM_ProjectResourceBL prb = new PM_ProjectResourceBL(); foreach (var item in rec) { item.ProjectResources = prb.ToList("byTaskId", item.TaskId.ToString(), ProjectId, TaskId); } } if (filter == "ByTaskTypeKeyCode") { AD_DefinationBL db = new AD_DefinationBL(); List <AD_Defination> ProjectStatus = db.ToList("byDefinationType", "Project Task Status"); foreach (var item in rec) { var Splited = ProjectStatus.Where(x => x.DefinationId == item.StatusId).FirstOrDefault(); if (Splited != null) { var CurrentStatus = Splited.DefinationName.ToLower(); switch (CurrentStatus) { case "active": item.Status = "STATUS_ACTIVE"; break; case "suspended": item.Status = "STATUS_SUSPENDED"; break; case "completed": item.Status = "STATUS_DONE"; break; case "cancelled": item.Status = "STATUS_FAILED"; break; case "undefined": item.Status = "STATUS_UNDEFINED"; break; case "planned": item.Status = "STATUS_PLANNED"; break; //default : // item.StatusId = 0; } // item.Status = GanttStatusses.Where(x=>x.Split('_')[1].ToLower() == Splited.DefinationName.ToLower()).FirstOrDefault(); } if (item.Status == null || item.Status == "") { item.Status = "STATUS_PLANNED"; item.StatusId = ProjectStatus.Where(x => x.DefinationName == "Planned").FirstOrDefault().PDefinationId; } } } return(Json(rec, JsonRequestBehavior.AllowGet)); }