public HttpResponseMessage ToList(string _filter = "", bool _active = true, Int64 _userId = 0) { PM_ProjectBL pd = new PM_ProjectBL(); var rec = pd.ToList(_filter, Convert.ToString(_active), _userId); if (rec != null) { return(Request.CreateResponse(HttpStatusCode.OK, rec)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Data")); } }
public JsonResult ToList(string Filter, string Value) { PM_ProjectBL pd = new PM_ProjectBL(); var User = Session["user"] as LoginInformation; var rec = pd.ToList(Filter, true.ToString(), User.UserId); if (Filter == "ByStatus") { List <Sec_UserProjects> lst = new List <Sec_UserProjects>(); var items = rec.Where(l2 => !User.ProjectPermissions.Any(l1 => l1.ProjectId == l2.ProjectId)).ToList(); if (items.Count > 0) { foreach (var item in items) { Permission.AddProject(item.ProjectId); } } } return(Json(rec, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage GetProject(object Json) { try { ProjectApiObject obj = JsonConvert.DeserializeObject <ProjectApiObject>(Json.ToString()); PM_ProjectBL pd = new PM_ProjectBL(); List <PM_Projects_DTO> rec = new List <PM_Projects_DTO>(); if (obj.toDate != null && obj.fromDate != null) { rec = pd.ToList("ProjectByFilters", "True", obj.statusIds, obj.priorityIds, obj.clientIds, obj.toDate, obj.fromDate, obj.userId); } else if (obj.searchKey != null && obj.searchKey != "") { rec = pd.DTOToList("ProjectByKey", obj.searchKey, obj.userId); } else { rec = pd.DTOToList("ByStatus", "True", obj.userId); } 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 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) })); }