public bool _Task_Active(PM_Task _task) { try { PM_TaskDL ptd = new PM_TaskDL(); return(ptd.Manage("Active_Deactive", _task.TaskId, _task.IsActive, _task.StatusId)); } catch { return(false); } }
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 dynamic Manage(string Filter, PM_Task t) { return(td.Manage(Filter, t.TaskId, t.PTaskId, t.ProjectId, t.PriorityId, t.TaskTypeId, t.StatusId, t.PredecessorId, t.Title, t.PlannedDate, t.ActualStartDate, t.ActualEndDate , t.EstimatedStartDate, t.EstimatedEndDate, t.Description, t.IsEstimate, t.IsActive, t.TargetDate, t.ForecastedSites, t.CompletionPercent, t.BudgetCost, t.ActualCost, t.MapCode, t.MapColumn , t.Color, t.ScopeId, t.IsStartMilestone, t.IsEndMilestone, t.SortOrder)); }