private void tlsbtnShowCopyPanel_Click(object sender, EventArgs e)
        {
            #region "Open the Database to Copy From"

            findDatabase:
            // Check the registry
            string regValue = commonFunctions.ReadReg("Software\\NCGMPTools", "getSqlDatabase");

            // Find a Database
            IWorkspaceFactory wsFact = null;
            IWorkspace openedWorkspace = null;

            // Browse for a file, personal or SDE geodatabase
            IGxObjectFilter objectFilter = new GxFilterWorkspaces();
            IGxObject openedObject = commonFunctions.OpenArcFile(objectFilter, "Please select an NCGMP database");
            if (openedObject == null) { return; }

            // Check to see if it is a File, Personal or SDE database, create appropriate workspace factory
            string pathToOpen = null;

            switch (openedObject.Category)
            {
                case "Personal Geodatabase":
                    wsFact = new AccessWorkspaceFactoryClass();
                    pathToOpen = openedObject.FullName;
                    break;
                case "File Geodatabase":
                    wsFact = new FileGDBWorkspaceFactoryClass();
                    pathToOpen = openedObject.FullName;
                    break;
                case "Spatial Database Connection":
                case "Database Connection":
                    wsFact = new SdeWorkspaceFactoryClass();
                    IGxRemoteDatabaseFolder remoteDatabaseFolder = (IGxRemoteDatabaseFolder)openedObject.Parent;
                    pathToOpen = remoteDatabaseFolder.Path + openedObject.Name;
                    break;
                default:
                    break;
            }
            openedWorkspace = wsFact.OpenFromFile(pathToOpen, 0);

            // Check to see if the database is valid NCGMP
            bool isValid = ncgmpChecks.IsWorkspaceMinNCGMPCompliant(openedWorkspace);
            if (isValid == false)
            {
                MessageBox.Show("The selected database is not a valid NCGMP database.", "NCGMP Toolbar");
                goto findDatabase;
            }
            //else
            //{
            //    isValid = ncgmpChecks.IsSysInfoPresent(openedWorkspace);
            //    if (isValid == false)
            //    {
            //        MessageBox.Show("In order to use these tools, the NCGMP database must contain a SysInfo table.", "NCGMP Toolbar");
            //        goto findDatabase;
            //    }
            //}
            #endregion

            // Show the copy form
            sourceLegendItemSelection sourceForm = new sourceLegendItemSelection(openedWorkspace);
            sourceForm.ShowDialog();

            // Bail if they canceled
            if (sourceForm.Canceled == true) { return; }

            // Get the Ids from the form, then close it
            if (sourceForm.idsToCopy.Count == 0) { sourceForm.Close(); return; }
            List<string> idsToCopy = sourceForm.idsToCopy;
            sourceForm.Close();

            // Build the Query to get the records to copy
            string sqlWhereClause = "DescriptionOfMapUnits_ID = '";
            foreach (string idValue in idsToCopy) { sqlWhereClause += idValue + "' OR DescriptionOfMapUnits_ID = '"; }

            // Get the records
            if (sqlWhereClause == "DescriptionOfMapUnits_ID = '") { return; }
            DescriptionOfMapUnitsAccess sourceDmu = new DescriptionOfMapUnitsAccess(openedWorkspace);
            sourceDmu.AddDescriptionOfMapUnits(sqlWhereClause.Remove(sqlWhereClause.Length - 32));

            // Get the next new Hierarchy Key
            string newHierarchy = GetNewHierarchyKey();
            int newValue = int.Parse(newHierarchy.Substring(newHierarchy.Length - 4));

            // Loop through the source records, add them to the target legend after adjusting the Hierarchy
            DescriptionOfMapUnitsAccess targetDmu = new DescriptionOfMapUnitsAccess(m_theWorkspace);
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> sourceEntry in sourceDmu.DescriptionOfMapUnitsDictionary)
            {
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit sourceDmuEntry = sourceEntry.Value;
                string thisHierachyKey = newValue.ToString().PadLeft(4, '0');

                targetDmu.NewDescriptionOfMapUnit(sourceDmuEntry.MapUnit, sourceDmuEntry.Name, sourceDmuEntry.FullName, sourceDmuEntry.Label,
                    sourceDmuEntry.Age, sourceDmuEntry.Description, thisHierachyKey,
                    sourceDmuEntry.ParagraphStyle, sourceDmuEntry.AreaFillRGB, sourceDmuEntry.AreaFillPatternDescription,
                    commonFunctions.GetCurrentDataSourceID(), sourceDmuEntry.GeneralLithology, sourceDmuEntry.GeneralLithologyConfidence);

                newValue++;
            }

            // Save the target Dmu
            targetDmu.SaveDescriptionOfMapUnits();

            // Refresh the tree
            ClearMapUnitInput();
            PopulateMainLegendTree();
        }
        private void UpdateChildrenKeys(string oldParentKey, string newParentKey, IOrderedEnumerable<KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit>> sortedChildren = null)
        {
            // If a set of children are not passed in to update, then get them based on the oldParentKey that is sent in
            if (sortedChildren == null) { sortedChildren = GetSortedChildren(oldParentKey); }

            // Get a DMU Access object to perform an update
            DescriptionOfMapUnitsAccess DmuAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            // Cycle through the children
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> anEntry in sortedChildren)
            {
                // Grab, adjust the hierarchy information
                string thisKey = anEntry.Value.HierarchyKey;
                string thisKeyValue = thisKey.Substring(thisKey.Length - 4);
                string newKey = newParentKey + "." + thisKeyValue;

                // Get the DMU entry for this entry
                DmuAccess.AddDescriptionOfMapUnits("DescriptionOfMapUnits_ID = '" + anEntry.Value.DescriptionOfMapUnits_ID + "'");
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDmuEntry = DmuAccess.DescriptionOfMapUnitsDictionary[anEntry.Value.DescriptionOfMapUnits_ID];

                // Update its key
                thisDmuEntry.HierarchyKey = newKey;
                DmuAccess.UpdateDescriptionOfMapUnit(thisDmuEntry);

                // Update its children's keys
                UpdateChildrenKeys(thisKey, newKey);
            }

            // Save the changes
            DmuAccess.SaveDescriptionOfMapUnits();
        }
        private void saveMapUnit()
        {
            // Get attributes from the form
            string thisDmuAge = txtMapUnitAge.Text;
            string thisDmuDefinitionSourceID = commonFunctions.GetCurrentDataSourceID();
            string thisDmuDescription = txtMapUnitDescription.Text;
            string thisDmuFullName = txtMapUnitFullName.Text;
            string thisDmuLabel = txtMapUnitAbbreviation.Text;
            string thisDmuMapUnit = txtMapUnitAbbreviation.Text;
            string thisDmuName = txtUnitName.Text;

            // These attributes are dependant on whether this is a heading or not
            string thisDmuParagraphStyle = "";
            string thisDmuAreaFillRGB = "";
            if (chkIsHeading.Checked == true)
            {
                thisDmuParagraphStyle = "Heading";
                thisDmuAreaFillRGB = "";
            }
            else
            {
                thisDmuParagraphStyle = "Standard";
                thisDmuAreaFillRGB = pnlColor.BackColor.R + ";" + pnlColor.BackColor.G + ";" + pnlColor.BackColor.B;
            }

            // Get the DMU reference that will be used to provide table access
            DescriptionOfMapUnitsAccess dmuAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            // Set the variable to represent the updated Dmu entry in the case of an update. This will be used to update polygons later
            DescriptionOfMapUnitsAccess.DescriptionOfMapUnit dmuEntry = new DescriptionOfMapUnitsAccess.DescriptionOfMapUnit();

            switch (m_ThisIsAnUpdate)
            {
                case true:
                    // Get the DMU entry that should be updated
                    dmuAccess.AddDescriptionOfMapUnits("DescriptionOfMapUnits_ID = '" + trvLegendItems.SelectedNode.Name + "'");
                    dmuEntry = dmuAccess.DescriptionOfMapUnitsDictionary[trvLegendItems.SelectedNode.Name];

                    // Add attributes from the form
                    dmuEntry.Age = thisDmuAge;
                    dmuEntry.DescriptionSourceID = thisDmuDefinitionSourceID;
                    dmuEntry.Description = thisDmuDescription;
                    dmuEntry.FullName = thisDmuFullName;
                    dmuEntry.Label = thisDmuLabel;
                    dmuEntry.MapUnit = thisDmuMapUnit;
                    dmuEntry.Name = thisDmuName;
                    dmuEntry.RequiresUpdate = true;

                    // These attributes are dependant on whether this is a heading or not
                    if (chkIsHeading.Checked == true)
                    {
                        dmuEntry.ParagraphStyle = thisDmuParagraphStyle;
                        dmuEntry.AreaFillRGB = thisDmuAreaFillRGB;
                    }
                    else
                    {
                        dmuEntry.ParagraphStyle = thisDmuParagraphStyle;
                        dmuEntry.AreaFillRGB = thisDmuAreaFillRGB;
                    }

                    // Perform the update
                    dmuAccess.UpdateDescriptionOfMapUnit(dmuEntry);

                    break;

                case false:
                    // This is a new entry, get an Hierarchy Key
                    string thisDmuHierarchyKey = GetNewHierarchyKey();

                    // Add the record
                    dmuAccess.NewDescriptionOfMapUnit(thisDmuMapUnit, thisDmuName, thisDmuFullName,
                        thisDmuLabel, thisDmuAge, thisDmuDescription,
                        thisDmuHierarchyKey, thisDmuParagraphStyle, thisDmuAreaFillRGB,
                        "", thisDmuDefinitionSourceID, "", "");

                    break;
            }

            // All done - save
            dmuAccess.SaveDescriptionOfMapUnits();

            // Refresh the tree
            PopulateMainLegendTree();

            // Update polys
            if ((m_ThisIsAnUpdate == true) && (m_theOldMapUnitName != null)) { UpdatePolygons(m_theOldMapUnitName, dmuEntry); }

            // Clear Inputs
            ClearMapUnitInput();
        }
        private void RemoveItemFromHierarchy(string keyBeingRemoved)
        {
            // Get the parent Hierearchy Key
            string parentKey;
            if (keyBeingRemoved.Length == 4) { parentKey = null; }
            else { parentKey = keyBeingRemoved.Remove(keyBeingRemoved.Length - 5); }

            int removedKeyValue = int.Parse(keyBeingRemoved.Substring(keyBeingRemoved.Length - 4));

            // Get the children of the removed node's parent
            var sortedChildren = GetSortedChildren(parentKey);

            // Get a DMU Access object to perform an update
            DescriptionOfMapUnitsAccess DmuAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            // Cycle through the children
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> anEntry in sortedChildren)
            {
                // Grab the hierarchy information
                string thisKey = anEntry.Value.HierarchyKey;
                int thisKeyValue = int.Parse(thisKey.Substring(thisKey.Length - 4));

                // If the value is greater than the removed key, decrement by one, and update children
                if (thisKeyValue > removedKeyValue)
                {
                    string newKey;
                    if (parentKey == null) { newKey = (thisKeyValue - 1).ToString().PadLeft(4, '0'); }
                    else { newKey = parentKey + "." + (thisKeyValue - 1).ToString().PadLeft(4, '0'); }

                    // Get the DMU entry for this entry
                    DmuAccess.AddDescriptionOfMapUnits("DescriptionOfMapUnits_ID = '" + anEntry.Value.DescriptionOfMapUnits_ID + "'");
                    DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDmuEntry = DmuAccess.DescriptionOfMapUnitsDictionary[anEntry.Value.DescriptionOfMapUnits_ID];

                    // Update its key
                    thisDmuEntry.HierarchyKey = newKey;
                    DmuAccess.UpdateDescriptionOfMapUnit(thisDmuEntry);

                    // Update its children's keys
                    UpdateChildrenKeys(thisKey, newKey);
                }
            }

            // Save the changes
            DmuAccess.SaveDescriptionOfMapUnits();
        }
        private void InsertItemIntoHierarchy(DescriptionOfMapUnitsAccess.DescriptionOfMapUnit theInsertedDmuEntry, string theNewHierarchyKey,
            IOrderedEnumerable<KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit>> thisItemsChildren)
        {
            // Get the insert location parent Hierarchy Key
            string parentKey;
            if (theNewHierarchyKey.Length == 4) { parentKey = null; }
            else { parentKey = theNewHierarchyKey.Remove(theNewHierarchyKey.Length - 5); }

            int newKeyValue = int.Parse(theNewHierarchyKey.Substring(theNewHierarchyKey.Length - 4));

            // Get the children of the inserted item's new parent
            var sortedChildren = GetSortedChildren(parentKey);

            // Get a DMU Access object to perform an update
            DescriptionOfMapUnitsAccess DmuAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            // I need to have each of the entry's children gathered before I start updating them.
            // What a f*****g mess.
            Dictionary<string, IOrderedEnumerable<KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit>>> theChildren = new Dictionary<string, IOrderedEnumerable<KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit>>>();
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> anEntry in sortedChildren)
            {
                theChildren.Add(anEntry.Value.DescriptionOfMapUnits_ID, GetSortedChildren(anEntry.Value.HierarchyKey));
            }

            // Cycle through these children
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> anEntry in sortedChildren)
            {
                // Grab this item's hierarchy info
                string thisKey = anEntry.Value.HierarchyKey;
                int thisKeyValue = int.Parse(thisKey.Substring(thisKey.Length - 4));

                // If the value is greater than or equal to the inserted item's new hierarchy value, increment by one, update children
                if (thisKeyValue >= newKeyValue)
                {
                    string thisNewKey;
                    if (parentKey == null) { thisNewKey = (thisKeyValue + 1).ToString().PadLeft(4, '0'); }
                    else { thisNewKey = parentKey + "." + (thisKeyValue + 1).ToString().PadLeft(4, '0'); }

                    // Get the DMU entry for this entry
                    DmuAccess.AddDescriptionOfMapUnits("DescriptionOfMapUnits_ID = '" + anEntry.Value.DescriptionOfMapUnits_ID + "'");
                    DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDmuEntry = DmuAccess.DescriptionOfMapUnitsDictionary[anEntry.Value.DescriptionOfMapUnits_ID];

                    // Update its key
                    thisDmuEntry.HierarchyKey = thisNewKey;
                    DmuAccess.UpdateDescriptionOfMapUnit(thisDmuEntry);

                    // Update its children's keys, gathered beforehand
                    UpdateChildrenKeys(thisKey, thisNewKey, theChildren[thisDmuEntry.DescriptionOfMapUnits_ID]);
                }
            }

            // Update the Children of the dragged item using the collection of children passed in
            UpdateChildrenKeys(theInsertedDmuEntry.HierarchyKey, theNewHierarchyKey, thisItemsChildren);

            // Update the dragged item itself
            theInsertedDmuEntry.HierarchyKey = theNewHierarchyKey;
            DmuAccess.UpdateDescriptionOfMapUnit(theInsertedDmuEntry);

            // Save changes
            DmuAccess.SaveDescriptionOfMapUnits();
        }
예제 #6
0
        private void UpdateDataSources(Dictionary<string, object> dataAccessClasses)
        {
            // Get the Data Source to set
            string dataSourceID = commonFunctions.GetCurrentDataSourceID();

            // Bail if there isn't one
            if (dataSourceID == null) { return; }

            // Get DataAccess Classes to perform updates
            MapUnitPolysAccess mapUnitPolysAccess = new MapUnitPolysAccess(m_theWorkspace);
            OverlayPolysAccess OverlayPolysAccess = new OverlayPolysAccess(m_theWorkspace);
            ContactsAndFaultsAccess ContactsAndFaultsAccess = new ContactsAndFaultsAccess(m_theWorkspace);
            OtherLinesAccess OtherLinesAccess = new OtherLinesAccess(m_theWorkspace);
            StationPointsAccess StationPointsAccess = new StationPointsAccess(m_theWorkspace);
            SamplePointsAccess SamplePointsAccess = new SamplePointsAccess(m_theWorkspace);
            OrientationDataPointsAccess OrientationDataPointsAccess = new OrientationDataPointsAccess(m_theWorkspace);
            GlossaryAccess GlossaryAccess = new GlossaryAccess(m_theWorkspace);
            NotesAccess NotesAccess = new NotesAccess(m_theWorkspace);
            RelatedDocumentsAccess RelatedDocumentsAccess = new RelatedDocumentsAccess(m_theWorkspace);
            DescriptionOfMapUnitsAccess DescriptionOfMapUnitsAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            // Loop through the dictionary
            foreach (KeyValuePair<string, object> anEntry in dataAccessClasses)
            {
                // What table does this come from?
                switch (anEntry.Key)
                {
                    case "MapUnitPolys":
                        // Loop through the records in the data access object that comes in
                        MapUnitPolysAccess thisMapUnitPolysAccess = (MapUnitPolysAccess)anEntry.Value;
                        foreach (KeyValuePair<string, MapUnitPolysAccess.MapUnitPoly> MapUnitPolysToUpdate in thisMapUnitPolysAccess.MapUnitPolysDictionary)
                        {
                            MapUnitPolysAccess.MapUnitPoly thisMapUnitPoly = (MapUnitPolysAccess.MapUnitPoly)MapUnitPolysToUpdate.Value;
                            thisMapUnitPoly.DataSourceID = dataSourceID;
                            mapUnitPolysAccess.UpdateMapUnitPoly(thisMapUnitPoly);
                        }
                        mapUnitPolysAccess.SaveMapUnitPolys();
                        break;
                    case "OverlayPolys":
                        OverlayPolysAccess thisOverlayPolysAccess = (OverlayPolysAccess)anEntry.Value;
                        foreach (KeyValuePair<string, OverlayPolysAccess.OverlayPoly> OverlayPolysToUpdate in thisOverlayPolysAccess.OverlayPolysDictionary)
                        {
                            OverlayPolysAccess.OverlayPoly thisOverlayPoly = (OverlayPolysAccess.OverlayPoly)OverlayPolysToUpdate.Value;
                            thisOverlayPoly.DataSourceID = dataSourceID;
                            OverlayPolysAccess.UpdateOverlayPoly(thisOverlayPoly);
                        }
                        OverlayPolysAccess.SaveOverlayPolys();
                        break;
                    case "ContactsAndFaults":
                        ContactsAndFaultsAccess thisContactsAndFaultsAccess = (ContactsAndFaultsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, ContactsAndFaultsAccess.ContactsAndFault> ContactsAndFaultsToUpdate in thisContactsAndFaultsAccess.ContactsAndFaultsDictionary)
                        {
                            ContactsAndFaultsAccess.ContactsAndFault thisContactsAndFault = (ContactsAndFaultsAccess.ContactsAndFault)ContactsAndFaultsToUpdate.Value;
                            thisContactsAndFault.DataSourceID = dataSourceID;
                            ContactsAndFaultsAccess.UpdateContactsAndFault(thisContactsAndFault);
                        }
                        ContactsAndFaultsAccess.SaveContactsAndFaults();
                        break;
                    case "OtherLines":
                        OtherLinesAccess thisOtherLinesAccess = (OtherLinesAccess)anEntry.Value;
                        foreach (KeyValuePair<string, OtherLinesAccess.OtherLine> OtherLinesToUpdate in thisOtherLinesAccess.OtherLinesDictionary)
                        {
                            OtherLinesAccess.OtherLine thisOtherLine = (OtherLinesAccess.OtherLine)OtherLinesToUpdate.Value;
                            thisOtherLine.DataSourceID = dataSourceID;
                            OtherLinesAccess.UpdateOtherLine(thisOtherLine);
                        }
                        OtherLinesAccess.SaveOtherLines();
                        break;
                    case "StationPoints":
                        StationPointsAccess thisStationPointsAccess = (StationPointsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, StationPointsAccess.StationPoint> StationPointsToUpdate in thisStationPointsAccess.StationPointsDictionary)
                        {
                            StationPointsAccess.StationPoint thisStationPoint = (StationPointsAccess.StationPoint)StationPointsToUpdate.Value;
                            thisStationPoint.DataSourceID = dataSourceID;
                            StationPointsAccess.UpdateStationPoint(thisStationPoint);
                        }
                        StationPointsAccess.SaveStationPoints();
                        break;
                    case "SamplePoints":
                        SamplePointsAccess thisSamplePointsAccess = (SamplePointsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, SamplePointsAccess.SamplePoint> SamplePointsToUpdate in thisSamplePointsAccess.SamplePointsDictionary)
                        {
                            SamplePointsAccess.SamplePoint thisSamplePoint = (SamplePointsAccess.SamplePoint)SamplePointsToUpdate.Value;
                            thisSamplePoint.DataSourceID = dataSourceID;
                            SamplePointsAccess.UpdateSamplePoint(thisSamplePoint);
                        }
                        SamplePointsAccess.SaveSamplePoints();
                        break;
                    case "OrientationDataPoints":
                        OrientationDataPointsAccess thisOrientationDataPointsAccess = (OrientationDataPointsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, OrientationDataPointsAccess.OrientationDataPoint> OrientationDataPointsToUpdate in thisOrientationDataPointsAccess.OrientationDataPointsDictionary)
                        {
                            OrientationDataPointsAccess.OrientationDataPoint thisOrientationDataPoint = (OrientationDataPointsAccess.OrientationDataPoint)OrientationDataPointsToUpdate.Value;
                            thisOrientationDataPoint.DataSourceID = dataSourceID;
                            OrientationDataPointsAccess.UpdateOrientationDataPoint(thisOrientationDataPoint);
                        }
                        OrientationDataPointsAccess.SaveOrientationDataPoints();
                        break;
                    case "Glossary":
                        GlossaryAccess thisGlossaryAccess = (GlossaryAccess)anEntry.Value;
                        foreach (KeyValuePair<string, GlossaryAccess.Glossary> GlossaryToUpdate in thisGlossaryAccess.GlossaryDictionary)
                        {
                            GlossaryAccess.Glossary thisGlossary = (GlossaryAccess.Glossary)GlossaryToUpdate.Value;
                            thisGlossary.DefinitionSourceID = dataSourceID;
                            GlossaryAccess.UpdateGlossary(thisGlossary);
                        }
                        GlossaryAccess.SaveGlossary();
                        break;
                    case "Notes":
                        NotesAccess thisNotesAccess = (NotesAccess)anEntry.Value;
                        foreach (KeyValuePair<string, NotesAccess.Note> NotesToUpdate in thisNotesAccess.NotesDictionary)
                        {
                            NotesAccess.Note thisNote = (NotesAccess.Note)NotesToUpdate.Value;
                            thisNote.DataSourceID = dataSourceID;
                            NotesAccess.UpdateNote(thisNote);
                        }
                        NotesAccess.SaveNotes();
                        break;
                    case "RelatedDocuments":
                        RelatedDocumentsAccess thisRelatedDocumentsAccess = (RelatedDocumentsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, RelatedDocumentsAccess.RelatedDocument> RelatedDocumentsToUpdate in thisRelatedDocumentsAccess.RelatedDocumentsDictionary)
                        {
                            RelatedDocumentsAccess.RelatedDocument thisRelatedDocument = (RelatedDocumentsAccess.RelatedDocument)RelatedDocumentsToUpdate.Value;
                            thisRelatedDocument.DataSourceID = dataSourceID;
                            RelatedDocumentsAccess.UpdateRelatedDocument(thisRelatedDocument);
                        }
                        RelatedDocumentsAccess.SaveRelatedDocuments();
                        break;
                    case "DescriptionOfMapUnits":
                        DescriptionOfMapUnitsAccess thisDescriptionOfMapUnitsAccess = (DescriptionOfMapUnitsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> DescriptionOfMapUnitsToUpdate in thisDescriptionOfMapUnitsAccess.DescriptionOfMapUnitsDictionary)
                        {
                            DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDescriptionOfMapUnit = (DescriptionOfMapUnitsAccess.DescriptionOfMapUnit)DescriptionOfMapUnitsToUpdate.Value;
                            thisDescriptionOfMapUnit.DescriptionSourceID = dataSourceID;
                            DescriptionOfMapUnitsAccess.UpdateDescriptionOfMapUnit(thisDescriptionOfMapUnit);
                        }
                        DescriptionOfMapUnitsAccess.SaveDescriptionOfMapUnits();
                        break;
                }
            }
        }
예제 #7
0
        private void UpdateDataSources(Dictionary<string, object> dataAccessClasses)
        {
            // Get the Data Source to set
            string dataSourceID = commonFunctions.GetCurrentDataSourceID();

            // Bail if there isn't one
            if (dataSourceID == null) { return; }

            // Get DataAccess Classes to perform updates
            MapUnitPolysAccess mapUnitPolysAccess = new MapUnitPolysAccess(m_theWorkspace);
            DataSourcePolysAccess dataSourcePolysAccess = new DataSourcePolysAccess(m_theWorkspace);
            OtherPolysAccess OtherPolysAccess = new OtherPolysAccess(m_theWorkspace);
            ContactsAndFaultsAccess ContactsAndFaultsAccess = new ContactsAndFaultsAccess(m_theWorkspace);
            GeologicLinesAccess GeologicLinesAccess = new GeologicLinesAccess(m_theWorkspace);
            StationsAccess StationsAccess = new StationsAccess(m_theWorkspace);
            GenericSamplesAccess GenericSamplesAccess = new GenericSamplesAccess(m_theWorkspace);
            OrientationPointsAccess OrientationPointsAccess = new OrientationPointsAccess(m_theWorkspace);
            GlossaryAccess GlossaryAccess = new GlossaryAccess(m_theWorkspace);
            DescriptionOfMapUnitsAccess DescriptionOfMapUnitsAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            // Loop through the dictionary
            foreach (KeyValuePair<string, object> anEntry in dataAccessClasses)
            {
                // What table does this come from?
                switch (anEntry.Key)
                {
                    case "MapUnitPolys":
                        // Loop through the records in the data access object that comes in
                        MapUnitPolysAccess thisMapUnitPolysAccess = (MapUnitPolysAccess)anEntry.Value;
                        foreach (KeyValuePair<string, MapUnitPolysAccess.MapUnitPoly> MapUnitPolysToUpdate in thisMapUnitPolysAccess.MapUnitPolysDictionary)
                        {
                            MapUnitPolysAccess.MapUnitPoly thisMapUnitPoly = (MapUnitPolysAccess.MapUnitPoly)MapUnitPolysToUpdate.Value;
                            thisMapUnitPoly.DataSourceID = dataSourceID;
                            mapUnitPolysAccess.UpdateMapUnitPoly(thisMapUnitPoly);
                        }
                        mapUnitPolysAccess.SaveMapUnitPolys();
                        break;
                    case "DataSourcePolys":
                        // Loop through the records in the data access object that comes in
                        DataSourcePolysAccess thisDataSourcePolysAccess = (DataSourcePolysAccess)anEntry.Value;
                        foreach (KeyValuePair<string, DataSourcePolysAccess.DataSourcePoly> DataSourcePolysToUpdate in thisDataSourcePolysAccess.DataSourcePolysDictionary)
                        {
                            DataSourcePolysAccess.DataSourcePoly thisDataSourcePoly = (DataSourcePolysAccess.DataSourcePoly)DataSourcePolysToUpdate.Value;
                            thisDataSourcePoly.DataSourceID = dataSourceID;
                            dataSourcePolysAccess.UpdateDataSourcePoly(thisDataSourcePoly);
                        }
                        dataSourcePolysAccess.SaveDataSourcePolys();
                        break;
                    case "OtherPolys":
                        OtherPolysAccess thisOtherPolysAccess = (OtherPolysAccess)anEntry.Value;
                        foreach (KeyValuePair<string, OtherPolysAccess.OtherPoly> OtherPolysToUpdate in thisOtherPolysAccess.OtherPolysDictionary)
                        {
                            OtherPolysAccess.OtherPoly thisOtherPoly = (OtherPolysAccess.OtherPoly)OtherPolysToUpdate.Value;
                            thisOtherPoly.DataSourceID = dataSourceID;
                            OtherPolysAccess.UpdateOtherPoly(thisOtherPoly);
                        }
                        OtherPolysAccess.SaveOtherPolys();
                        break;
                    case "ContactsAndFaults":
                        ContactsAndFaultsAccess thisContactsAndFaultsAccess = (ContactsAndFaultsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, ContactsAndFaultsAccess.ContactsAndFault> ContactsAndFaultsToUpdate in thisContactsAndFaultsAccess.ContactsAndFaultsDictionary)
                        {
                            ContactsAndFaultsAccess.ContactsAndFault thisContactsAndFault = (ContactsAndFaultsAccess.ContactsAndFault)ContactsAndFaultsToUpdate.Value;
                            thisContactsAndFault.DataSourceID = dataSourceID;
                            ContactsAndFaultsAccess.UpdateContactsAndFault(thisContactsAndFault);
                        }
                        ContactsAndFaultsAccess.SaveContactsAndFaults();
                        break;
                    case "GeologicLines":
                        GeologicLinesAccess thisGeologicLinesAccess = (GeologicLinesAccess)anEntry.Value;
                        foreach (KeyValuePair<string, GeologicLinesAccess.GeologicLine> GeologicLinesToUpdate in thisGeologicLinesAccess.GeologicLinesDictionary)
                        {
                            GeologicLinesAccess.GeologicLine thisGeologicLine = (GeologicLinesAccess.GeologicLine)GeologicLinesToUpdate.Value;
                            thisGeologicLine.DataSourceID = dataSourceID;
                            GeologicLinesAccess.UpdateGeologicLine(thisGeologicLine);
                        }
                        GeologicLinesAccess.SaveGeologicLines();
                        break;
                    case "Stations":
                        StationsAccess thisStationsAccess = (StationsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, StationsAccess.Station> StationsToUpdate in thisStationsAccess.StationsDictionary)
                        {
                            StationsAccess.Station thisStation = (StationsAccess.Station)StationsToUpdate.Value;
                            thisStation.DataSourceID = dataSourceID;
                            StationsAccess.UpdateStation(thisStation);
                        }
                        StationsAccess.SaveStations();
                        break;
                    case "GenericSamples":
                        GenericSamplesAccess thisGenericSamplesAccess = (GenericSamplesAccess)anEntry.Value;
                        foreach (KeyValuePair<string, GenericSamplesAccess.GenericSample> GenericSamplesToUpdate in thisGenericSamplesAccess.GenericSamplesDictionary)
                        {
                            GenericSamplesAccess.GenericSample thisGenericSample = (GenericSamplesAccess.GenericSample)GenericSamplesToUpdate.Value;
                            thisGenericSample.DataSourceID = dataSourceID;
                            GenericSamplesAccess.UpdateGenericSample(thisGenericSample);
                        }
                        GenericSamplesAccess.SaveGenericSamples();
                        break;
                    case "OrientationPoints":
                        OrientationPointsAccess thisOrientationPointsAccess = (OrientationPointsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, OrientationPointsAccess.OrientationPoint> OrientationPointsToUpdate in thisOrientationPointsAccess.OrientationPointsDictionary)
                        {
                            OrientationPointsAccess.OrientationPoint thisOrientationPoint = (OrientationPointsAccess.OrientationPoint)OrientationPointsToUpdate.Value;
                            thisOrientationPoint.DataSourceID = dataSourceID;
                            OrientationPointsAccess.UpdateOrientationPoint(thisOrientationPoint);
                        }
                        OrientationPointsAccess.SaveOrientationPoints();
                        break;
                    case "Glossary":
                        GlossaryAccess thisGlossaryAccess = (GlossaryAccess)anEntry.Value;
                        foreach (KeyValuePair<string, GlossaryAccess.Glossary> GlossaryToUpdate in thisGlossaryAccess.GlossaryDictionary)
                        {
                            GlossaryAccess.Glossary thisGlossary = (GlossaryAccess.Glossary)GlossaryToUpdate.Value;
                            thisGlossary.DefinitionSourceID = dataSourceID;
                            GlossaryAccess.UpdateGlossary(thisGlossary);
                        }
                        GlossaryAccess.SaveGlossary();
                        break;
                    case "DescriptionOfMapUnits":
                        DescriptionOfMapUnitsAccess thisDescriptionOfMapUnitsAccess = (DescriptionOfMapUnitsAccess)anEntry.Value;
                        foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> DescriptionOfMapUnitsToUpdate in thisDescriptionOfMapUnitsAccess.DescriptionOfMapUnitsDictionary)
                        {
                            DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDescriptionOfMapUnit = (DescriptionOfMapUnitsAccess.DescriptionOfMapUnit)DescriptionOfMapUnitsToUpdate.Value;
                            thisDescriptionOfMapUnit.DescriptionSourceID = dataSourceID;
                            DescriptionOfMapUnitsAccess.UpdateDescriptionOfMapUnit(thisDescriptionOfMapUnit);
                        }
                        DescriptionOfMapUnitsAccess.SaveDescriptionOfMapUnits();
                        break;
                }
            }
        }