} /* GetDatabaseImageRecords */ private void UpdateImageGroupTables(PicesDataBase threadConn, PicesDataBaseImageList harvestedImages ) { RunLogAddMsg("Create Image Group Entries" + "\n"); PicesDataBaseImageGroup existingGroup = threadConn.ImageGroupLoad(groupName); if (existingGroup != null) { // Since the group already exists we will have to delete it. threadConn.ImageGroupDelete(existingGroup.ImageGroupId); } String description = "Created by Harvester" + "\n" + "DateTime" + "\t" + DateTime.Now.ToLongDateString() + "\n" + "NumImages" + "\t" + harvestedImages.Count.ToString("#,###,##0") + "\n"; PicesDataBaseImageGroup group = new PicesDataBaseImageGroup(-1, groupName, description, (uint)harvestedImages.Count); threadConn.ImageGroupInsert(group); int idx = 0; while (idx < harvestedImages.Count) { PicesDataBaseImageList updateGroup = new PicesDataBaseImageList(); while ((idx < harvestedImages.Count) && (updateGroup.Count < 50)) { updateGroup.Add(harvestedImages[idx]); idx++; } threadConn.ImageGroupEntriesInsert(group.ImageGroupId, updateGroup); RunLogAddMsg("Added To ImageGroup[" + idx + "] of [" + harvestedImages.Count + "]" + "\n"); } if (threadConn.Valid()) { RunLogAddMsg("Image Group Tables Updated" + "\n"); } else { RunLogAddMsg("\n" + "\n" + "Image Group Tables Update FAILED ***ERROR***" + "\n" ); } } /* UpdateImageGroupTables*/
} /* ValidateGroupName */ private void UpdateDatabase() { PicesDataBaseImageGroup ig = new PicesDataBaseImageGroup(-1, GroupName.Text, Description.Text, 0); dbConn.ImageGroupInsert(ig); if (!dbConn.Valid()) { MessageBox.Show(this, "Error Creating new Image Group" + "\n" + dbConn.LastErrorDesc(), "Assign Selected Images to Group", MessageBoxButtons.OK ); } else { int zed = 0; while (zed < selImages.Count) { PicesDataBaseImageList subSet = new PicesDataBaseImageList(); while ((subSet.Count < 100) && (zed < selImages.Count)) { subSet.Add(selImages[zed]); ++zed; } dbConn.ImageGroupEntriesInsert(ig.ImageGroupId, subSet); if (!dbConn.Valid()) { break; } } if (dbConn.Valid()) { newGroupCreated = true; MessageBox.Show(this, "Group[" + GroupName.Text + "] Created successfully.", "Assign Selected Images to Group", MessageBoxButtons.OK); } else { MessageBox.Show(this, "Error Creating new Image Group" + "\n" + dbConn.LastErrorDesc(), "Assign Selected Images to Group", MessageBoxButtons.OK); } } } /* UpdateDatabase */
} /* StartTheHarvestingProcedure */ private void ImportAssignments() { PicesDataBase.ThreadInit(); backGroundRunning = true; backGroundCompleted = false; PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); RunLogAddMsg("Source Directory [" + sourceDirectory + "]"); RunLogAddMsg("Group Name [" + groupName + "]"); RunLogAddMsg("Start Date/Time [" + DateTime.Now.ToString("yyyy-MMM-dd HH:mm:ss") + "]"); RunLogAddMsg("Active DataBase [" + threadConn.Server.Description + "]"); importedFileNames = new List <String> (); group = threadConn.ImageGroupLoad(groupName); if (group != null) { // Group already exists; will delete it. RunLogAddMsg("\n" + "Group[" + groupName + "] already exists. Will remove and replace with new one." + "\n"); threadConn.ImageGroupDelete(group.ImageGroupId); } group = new PicesDataBaseImageGroup(-1, groupName, groupDesc, 0); threadConn.ImageGroupInsert(group); ImportAssignmentsImportDir(sourceDirectory); if (cancelBackGround) { RunLogAddMsg("\n" + "Importing Assignments has been Canceled." + "\n"); } else { RunLogAddMsg("\n\n" + "Total Images[" + importedFileNames.Count.ToString("###,##0") + "\n"); RunLogAddMsg("Writing to DataBase Now" + "\n"); imageFileErrorList = new List <string>(); int numInserted = 0; for (int x = 0; (x < importedFileNames.Count) && (!cancelBackGround); x++) { PicesDataBaseImageGroupEntry ige = new PicesDataBaseImageGroupEntry(); ige.ImageGroupId = group.ImageGroupId; ige.ImageFileName = importedFileNames[x]; threadConn.ImageGroupEntriesInsert(ige); if (!threadConn.Valid()) { imageFileErrorList.Add(importedFileNames[x]); RunLogAddMsg("Image[" + importedFileNames[x] + "] ***ERROR***"); } else { numInserted++; } if ((x % 100) == 0) { RunLogAddMsg("Images Assigned[" + numInserted + "] Failures[" + imageFileErrorList.Count + "]"); } } } threadConn.Close(); threadConn = null; GC.Collect(); PicesDataBase.ThreadEnd(); backGroundRunning = false; backGroundCompleted = true; } /* ImportAssignments */