The personal Geographic Database Based on AE (mdb Format) is imported into the enterprise-level database (SDE database, using the Oracle database) (C #).
A personal geographic database has datasets. After being imported to an enterprise-level database, there are no datasets and only element classes.
Private void btnpgd2egd_click (Object sender, eventargs E)
{
Try
{
String pworkspacename = strname;
String sdeuser = psdewsp. connectionproperties. getproperty ("user"). tostring ();
Iworkspacefactory pmdbwspf = new accessworkspacefactoryclass ();
Pmdbwsp = pmdbwspf. openfromfile (pworkspacename, 0 );
Cursor = cursors. waitcursor;
If (psdewsp! = NULL)
{
// Progressbar. Visible = true;
Datavonverter (ref pmdbwsp, ref psdewsp, sdeuser); // data import
Progressbar. Visible = false;
}
Cursor = cursors. default;
}
Catch (exception ex)
{
MessageBox. Show (ex. tostring ());
}
MessageBox. Show ("MDB data is successfully uploaded to the SDE database! "," Data Import ", messageboxbuttons. OK, messageboxicon. information );
This. Close ();
}
Public void datavonverter (ref iworkspace fromworkspace, ref iworkspace toworkspace, string sdeuser)
{< br> If (sdeuser = ") return;
ifeatureworkspace release;
ifeatureworkspace pinfeatureworkspace;
ifeatureclass pfeatureclass;
skip;
iworkspace2 pworkspace2;
ienumdataset penumdataset;
idataset poutdataset;
Ifeaturedataset poutfeaturedataset;
Ienumfeatureclass penumfeatureclass;
Ifeatureclasscontainer pfeatureclasscontainer;
Poutfeatureworkspace = (ifeatureworkspace) toworkspace;
Pinfeatureworkspace = (ifeatureworkspace) fromworkspace;
Pworkspace2 = (iworkspace2) toworkspace;
Penumdataset = (ienumdataset) fromworkspace. get_datasets (esridatasettype. esridtfeaturedataset); // obtain all datasets on the MDB end
Poutdataset = (idataset) penumdataset. Next ();
While (poutdataset! = NULL) // traverse the dataset
{
Poutfeaturedataset = (ifeaturedataset) poutdataset;
If (poutfeaturedataset! = NULL)
{
Pfeatureclasscontainer = (ifeatureclasscontainer) poutfeaturedataset;
Penumfeatureclass = (ienumfeatureclass) pfeatureclasscontainer. classes;
Pfeatureclass = (ifeatureclass) penumfeatureclass. Next ();
While (pfeatureclass! = NULL) // traverse the data layer ifeatureclass in each dataset
{
If (! Pfeatureclass. aliasname. Contains ("unclassfied "))
{
If (pworkspace2.get _ nameexists (esridatasettype. esridtfeatureclass, sdeuser + "." + pfeatureclass. aliasname ))
{
Poutfeatureclass = poutfeatureworkspace. openfeatureclass (sdeuser + "." + pfeatureclass. aliasname );
Fc2fc (ref pfeatureclass, ref poutfeatureclass );
}
Else
{
Fc2fc (ref pfeatureclass, ref toworkspace );
}
}
Pfeatureclass = (ifeatureclass) penumfeatureclass. Next ();
}
}
Poutdataset = (idataset) penumdataset. Next ();
}
Itable pintable;
Pintable = pinfeatureworkspace. OpenTable ("aindexinfo ");
// If the SDE database already has the aindexinfo table, append the new record
If (pworkspace2.get _ nameexists (esridatasettype. esridttable, sdeuser + "." + "aindexinfo "))
{
Itable pouttable = poutfeatureworkspace. OpenTable ("aindexinfo ");
Fusedindextable (ref pintable, ref pouttable );
}
Else // If the SDE database does not have the aindexinfo table, the aindexinfo table, which is the same as the source database, will be regenerated.
{
Fusedindextable (ref pintable, ref toworkspace );
}
}
Reprinted, please indicate the source: http://www.cnblogs.com/njlhb/archive/2007/06/17/786242.html and Author: GIS cloud crane