/// <summary> /// 查找图片 /// </summary> /// <param name="gl_Barcode"></param> public List <string> FindImage(string gl_Barcode) { UInt32 i; const int bufsize = 260; StringBuilder buf = new StringBuilder(bufsize); List <string> paths = new List <string>(); // set the search Everything_SetSearch(gl_Barcode); // request name and size Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH | EVERYTHING_REQUEST_DATE_MODIFIED); Everything_SetSort(13); // execute the query SearchFiles.Everything_Query(true); // loop through the results, adding each result to the listbox. for (i = 0; i < Everything_GetNumResults(); i++) { long date_modified; long size; Everything_GetResultFullPathName(i, buf, bufsize); Everything_GetResultSize(i, out size); paths.Add(buf.ToString()); } return(paths); }
/// <summary> /// 查找csv文件 /// </summary> /// <returns></returns> public List <string> FindCSVByDate() { UInt32 i; const int bufsize = 260; StringBuilder buf = new StringBuilder(bufsize); List <string> paths = new List <string>(); string date = DateTime.Now.ToString("yyyyMMdd"); SearchFiles.Everything_SetSearch(date + "*.csv"); // request name and size SearchFiles.Everything_SetRequestFlags(SearchFiles.EVERYTHING_REQUEST_FILE_NAME | SearchFiles.EVERYTHING_REQUEST_PATH | SearchFiles.EVERYTHING_REQUEST_DATE_MODIFIED); SearchFiles.Everything_SetSort(13); // execute the query SearchFiles.Everything_Query(true); // loop through the results, adding each result to the listbox. for (i = 0; i < SearchFiles.Everything_GetNumResults(); i++) { long date_modified; long size; SearchFiles.Everything_GetResultDateModified(i, out date_modified); SearchFiles.Everything_GetResultFullPathName(i, buf, bufsize); SearchFiles.Everything_GetResultSize(i, out size); paths.Add(buf.ToString()); } return(paths); }
internal string[] FindAllImageByBarcode(string barcode) { SearchFiles search = new SearchFiles(); List <string> pics = search.FindImage(barcode); return(pics.ToArray()); }
internal string[] searchImageByBarcode(string barcode) { string[] paths = new string[] { "", "", "" }; List <string> pic_S1 = new List <string>(); List <string> pic_S2 = new List <string>(); List <string> pic_S3 = new List <string>(); SearchFiles search = new SearchFiles(); pic_S1.AddRange(search.FindImage("主站" + barcode)); pic_S2.AddRange(search.FindImage("从站" + barcode)); foreach (string path in pic_S2) { if (path.Contains(GlobalVar.gl_key_Machine1_S3_TestResult) || path.Contains(GlobalVar.gl_key_Machine2_S3_TestResult) || path.Contains(GlobalVar.gl_key_Machine3_S3_TestResult)) { pic_S3.Add(path); } } foreach (string path in pic_S3) { if (pic_S2.Contains(path)) { pic_S2.Remove(path); } } if (pic_S1.Count > 1) { for (int j = 0; j < pic_S1.Count - 1; j++) { if (pic_S1[j + 1] != "" && pic_S1[j] != "") { string temp; FileInfo file = new FileInfo(pic_S1[j]); FileInfo file_1 = new FileInfo(pic_S1[j + 1]); if ((file.CreationTime - file_1.CreationTime).TotalDays > 0) { temp = pic_S1[j]; pic_S1[j] = pic_S1[j + 1]; pic_S1[j + 1] = temp; } } } if (pic_S1[pic_S1.Count - 1].Contains(DateTime.Now.ToString("yyyyMMdd")))//只查当天 { paths[0] = pic_S1[pic_S1.Count - 1]; } } else if (pic_S1.Count == 1) { if (pic_S1[0].Contains(DateTime.Now.ToString("yyyyMMdd"))) { paths[0] = pic_S1[0]; } } if (pic_S2.Count > 1) { for (int j = 0; j < pic_S2.Count - 1; j++) { if (pic_S2[j + 1] != "" && pic_S2[j] != "") { string temp; FileInfo file = new FileInfo(pic_S2[j]); FileInfo file_1 = new FileInfo(pic_S2[j + 1]); if ((file.CreationTime - file_1.CreationTime).TotalDays > 0) { temp = pic_S2[j]; pic_S2[j] = pic_S2[j + 1]; pic_S2[j + 1] = temp; } } } if (pic_S2[pic_S2.Count - 1].Contains(DateTime.Now.ToString("yyyyMMdd")))//只查当天 { paths[1] = pic_S2[pic_S2.Count - 1]; } } else if (pic_S2.Count == 1) { if (pic_S2[0].Contains(DateTime.Now.ToString("yyyyMMdd"))) { paths[1] = pic_S2[0]; } } if (pic_S3.Count > 1) { for (int j = 0; j < pic_S3.Count - 1; j++) { if (pic_S3[j + 1] != "" && pic_S3[j] != "") { string temp; FileInfo file = new FileInfo(pic_S3[j]); FileInfo file_1 = new FileInfo(pic_S3[j + 1]); if ((file.CreationTime - file_1.CreationTime).TotalDays > 0) { temp = pic_S3[j]; pic_S3[j] = pic_S3[j + 1]; pic_S3[j + 1] = temp; } } } if (pic_S3[pic_S3.Count - 1].Contains(DateTime.Now.ToString("yyyyMMdd")))//只查当天 { paths[2] = pic_S3[pic_S3.Count - 1]; } } else if (pic_S3.Count == 1) { if (pic_S3[0].Contains(DateTime.Now.ToString("yyyyMMdd"))) { paths[2] = pic_S3[0]; } } return(paths); }