Beispiel #1
0
        private void  LoadGroups()
        {
            ImageGroupGrid.Rows.Clear();

            PicesDataBaseImageGroupList groups = dbConn.ImageGroupLoad();

            foreach (PicesDataBaseImageGroup group in groups)
            {
                DataGridViewRow dgvr = new DataGridViewRow();

                Object[] data = new Object[5];
                data[0] = group.ImageGroupId;
                data[1] = group.Name;
                data[2] = group.Description;
                data[3] = group.Count;
                data[4] = "Delete";
                ImageGroupGrid.Rows.Add(data);
            }
        } /* LoadGroups */
Beispiel #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*/
        } /* ValidateGroupName */

        private void  ValidateGroupNameDoesntExist()
        {
            group = mainWinConn.ImageGroupLoad(groupName);
            if (group != null)
            {
                DialogResult dr = MessageBox.Show
                                      (this,
                                      "Group[" + groupName + "] already exists" + "\n\n" +
                                      "Do you want to replace it ?",
                                      "Group Already Exists",
                                      MessageBoxButtons.YesNo
                                      );

                if (dr == DialogResult.No)
                {
                    validationErrorFound = true;
                    errorProvider1.SetError(GroupName, "Group already exists");
                }
            }
        } /* ValidateGroupNameDoesntExist */
Beispiel #4
0
        private void  ValidateGroupName()
        {
            errorProvider1.SetError(GroupName, "");
            String errorDesc = "";
            bool   valid     = false;

            groupName = GroupName.Text;
            PicesDataBaseImageGroup.ValidName(ref groupName, ref errorDesc, ref valid);
            if (!valid)
            {
                errorProvider1.SetError(GroupName, errorDesc);
                validationErrorFound = true;
            }

            if (dbConn.ImageGroupLoad(groupName) != null)
            {
                errorDesc = "This Group name already exists.";
                errorProvider1.SetError(GroupName, errorDesc);
                validationErrorFound = true;
            }

            GroupName.Text = groupName;
        } /* ValidateGroupName */
        } /* 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 */