public IQueryable <DTO_CUS_DOC_File> Get() { var result = BS_CUS_DOC_File.get_CUS_DOC_File(db, PartnerID, QueryStrings, true).ToList(); if (QueryStrings.Any(d => d.Key == "IncludeOwner")) { var query = db.tbl_CUS_DOC_File .Where(d => d.IsDeleted == false && d.IsHidden != true && d.IDPartner == PartnerID && (d.ModifiedBy == Username || d.CreatedBy == Username)); if (QueryStrings.Any(d => d.Key == "IDFolder")) { var IDList = QueryStrings.FirstOrDefault(d => d.Key == "IDFolder").Value.Replace("[", "").Replace("]", "").Split(','); List <int> IDs = new List <int>(); foreach (var item in IDList) { if (int.TryParse(item, out int i)) { IDs.Add(i); } else if (item == "null") { query = query.Where(d => !d.tbl_CUS_DOC_FileInFolder.Any()); } } if (IDs.Count > 0) { query = query.Where(d => d.tbl_CUS_DOC_FileInFolder.Any(c => c.IDFolder.HasValue && IDs.Contains(c.IDFolder.Value))); } } var result2 = BS_CUS_DOC_File.ctoDTO(query).ToList(); if (result2.Count > 0) { foreach (var item in result2) { if (!result.Any(d => d.ID == item.ID)) { result.Add(item); } } } } return(result.AsQueryable()); }
public IQueryable <DTO_CUS_DOC_File> GetMissingFile() { var result = BS_CUS_DOC_File.get_CUS_DOC_File(db, PartnerID, QueryStrings, true).ToList(); List <DTO_CUS_DOC_File> r2 = new List <DTO_CUS_DOC_File>(); if (QueryStrings.Any(d => d.Key == "IncludeOwner")) { var query = db.tbl_CUS_DOC_File .Where(d => d.IsDeleted == false && d.IDPartner == PartnerID && (d.ModifiedBy == Username || d.CreatedBy == Username)); if (QueryStrings.Any(d => d.Key == "IDFolder")) { var IDList = QueryStrings.FirstOrDefault(d => d.Key == "IDFolder").Value.Replace("[", "").Replace("]", "").Split(','); List <int> IDs = new List <int>(); foreach (var item in IDList) { if (int.TryParse(item, out int i)) { IDs.Add(i); } else if (item == "null") { query = query.Where(d => !d.tbl_CUS_DOC_FileInFolder.Any()); } } if (IDs.Count > 0) { query = query.Where(d => d.tbl_CUS_DOC_FileInFolder.Any(c => c.IDFolder.HasValue && IDs.Contains(c.IDFolder.Value))); } } var result2 = BS_CUS_DOC_File.ctoDTO(query).ToList(); if (result2.Count > 0) { foreach (var item in result2) { if (!result.Any(d => d.ID == item.ID)) { result.Add(item); } } } } string mapPath = System.Web.HttpContext.Current.Server.MapPath("~/"); foreach (var item in result) { if ((item.Extension == "doc" || item.Extension == "docx") && !File.Exists(mapPath + item.Code)) { if (File.Exists(mapPath + item.Path)) { r2.Add(item); convertWordToPDF(mapPath + item.Path, mapPath + item.Code); } else { item.Remark = "Ko file goc"; r2.Add(item); } } } return(r2.AsQueryable()); }