List<lib.imagemaster> imageList = new List<lib.imagemaster>(); public const string KEY_FIELD_ReferenceNumber = "ReferenceNumber"; public const string KEY_FIELD_ImageNumber = "ImageNumber"; public const string KEY_FIELD_IsIndexed = "IsIndexed"; public MainForm() { InitializeComponent(); } private void btnGetIndexingFaults_Click(object sender, EventArgs e) { imageList = new List<lib.imagemaster>(); dgvImageDetails.Columns.Clear(); try { using (DocumentImagingDB db = new DocumentImagingDB()) { // Get Images for the previous 2 days DateTime fromDate = DateTime.Now.AddDays(Properties.Settings.Default.DaysToCheck); //////// this Line is where it breaks var images = db.Images.Where(i => i.SubmitDateTime >= fromDate).ToList(); Application.DoEvents(); if (images.Count() > 0) { IntegrationAccessLayer.AccessLayerService ALS = new IntegrationAccessLayer.AccessLayerService(); // Check each image against AS400 images.ToList().ForEach(i => { // Check "IsIndexed" from Metadata List<integrationaccesslayer.keyvalue> keyValue = new List<integrationaccesslayer.keyvalue>(); string[] strArr = new string[0]; keyValue.Add(new IntegrationAccessLayer.KeyValue { Key = KEY_FIELD_ImageNumber, Value = i.ImageNumber }); IntegrationAccessLayer.ImageDetails[] imageDetails = ALS.GetImageDetails(keyValue.ToArray(), strArr); bool isIndexed = false; imageDetails[0].metaData.ToList().ForEach(md => { if (md.Key == KEY_FIELD_IsIndexed && md.Value == "true") { isIndexed = true; } }); Application.DoEvents(); if (isIndexed) { lib.ImageMaster image = lib.TapeHelper.DoRequest<lib.imagemaster>("Document", "ws_getimagemaster", new lib.ImageNumber { imageNumber = i.ImageNumber }); if (image != null && image.IMAGENUMBER != "") { // Check if BDZ exists. string indexedPath = db.ImagingSettings.FirstOrDefault().AS400URI.Replace("%YYYY", DateTime.Now.Year.ToString()); indexedPath = indexedPath.Replace("MM%", DateTime.Now.Month.ToString().PadLeft(2, '0')); string pathURI = indexedPath + "\\" + i.ImageNumber + ".BDZ"; if (!File.Exists(pathURI)) { // Add Image to List imageList.Add(image); txtReindexCount.Text = imageList.Count.ToString(); Application.DoEvents(); } } } }); txtReindexCount.Text = imageList.Count.ToString(); dgvImageDetails.DataSource = imageList; Application.DoEvents(); } } } catch (Exception ex) { MessageBox.Show("Oops...it broke", "Aaaaahhhhh!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)