public static string[] GetOrphanFiles(int _authenticatedUserId, string _connectionString) { List <string> toReturn = new List <string>(); Models.DocumenteScanateRepository dsr = new Models.DocumenteScanateRepository(_authenticatedUserId, _connectionString); Models.DocumentScanat[] dss = (Models.DocumentScanat[])dsr.GetAll().Result; Models.DocumenteScanateProceseRepository dspr = new Models.DocumenteScanateProceseRepository(_authenticatedUserId, _connectionString); Models.DocumentScanatProces[] dsps = (Models.DocumentScanatProces[])dsr.GetAll().Result; //var files = Directory.GetFiles(CommonFunctions.GetScansFolder()).AsQueryable().Except(Directory.GetFiles(CommonFunctions.GetScansFolder(), "*_Custom.jpg")); // requires System.Linq.Queryable (4.3.0) string[] files = Directory.GetFiles(CommonFunctions.GetScansFolder()); foreach (string fileName in files) { if (fileName.IndexOf("*_Custom.jpg") < 0) { string fName = Path.GetFileName(fileName); try { int f = dss.Where(item => item.CALE_FISIER == fName).Count(); int p = dsps.Where(item => item.CALE_FISIER == fName).Count(); if (f == 0 && p == 0) { toReturn.Add(fName); } } catch { toReturn.Add(fName); } } } return(toReturn.ToArray()); }
public static Models.DocumentScanat[] GetOrphanDocuments(int _authenticatedUserId, string _connectionString) { List <Models.DocumentScanat> toReturn = new List <Models.DocumentScanat>(); Models.DocumenteScanateRepository dsr = new Models.DocumenteScanateRepository(_authenticatedUserId, _connectionString); Models.DocumentScanat[] dss = (Models.DocumentScanat[])dsr.GetAll().Result; foreach (Models.DocumentScanat ds in dss) { if (!File.Exists(Path.Combine(CommonFunctions.GetScansFolder(), ds.CALE_FISIER))) { toReturn.Add(ds); } } return(toReturn.ToArray()); }