示例#1
0
        private void ImageGroupGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            if (dgv.Columns[e.ColumnIndex].Name != "Delete")
            {
                return;
            }

            if (!allowUpdates)
            {
                PicesSipperVariables.UpdatesNotAllowed("Group Maintenance");
                return;
            }

            if (e.RowIndex < 0)
            {
                return;
            }

            PicesDataBaseImageGroup ig = dbConn.ImageGroupLoad((String)dgv.Rows[e.RowIndex].Cells[1].Value);

            if (ig == null)
            {
                return;
            }
            DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete this group ?", "Delete " + ig.Name, MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                dbConn.ImageGroupDelete(ig.ImageGroupId);
                LoadGroups();
            }
        }
示例#2
0
        } /* 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*/
示例#3
0
        } /* 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 */