Exemplo n.º 1
0
        public Boolean LoadAttributeMappings(FeatureMappingData theMap, IWorkspace theWS, int serial)
        {
            OleDbCommand theCMD;
              OleDbDataReader theReader;
              String theSQL = "";
              int srcDT, destDT, srcL, destL, fCount;
              String srcC, destC, srcF, destF, srcE, destE, constant, result;
              AttributeMappingData theAMap;

              try
              {
            theSQL = "SELECT * FROM [AttributeMappings] WHERE [SerialNumber] = " + serial.ToString();
            theCMD = new OleDbCommand(theSQL, theConn);

            checkOpen();
            theReader = theCMD.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            while (theReader.Read())
            {
              srcC = theReader.GetString(1);
              destC = theReader.GetString(2);
              srcF = theReader.GetString(3);
              destF = theReader.GetString(7);
              srcDT = theReader.GetInt32(4);
              destDT = theReader.GetInt32(8);
              srcL = theReader.GetInt32(5);
              destL = theReader.GetInt32(9);
              srcE = theReader.GetString(6);
              destE = theReader.GetString(10);
              constant = theReader.GetString(12);
              result = theReader.GetString(13);
              fCount = theReader.GetInt32(11);

              IField theSF = new FieldClass();
              IFieldEdit theES = (IFieldEdit)theSF;
              theES.Name_2 = srcF;
              theES.AliasName_2 = srcF;
              theES.Type_2 = ToESRIDataType(srcDT);
              theES.Length_2 = srcL;

              IFields destFld = GeoDbProcs.GetFeatureClassFields(theWS, destC);

              int theIndex = destFld.FindField(destF);

              if (theIndex >= 0)
              {
            IField theDF = destFld.get_Field(theIndex);
            AttributeData theS = new AttributeData(srcC, theSF, fCount);
            AttributeData theD = new AttributeData(destC, theDF, fCount);
            theAMap = new AttributeMappingData(theMap, theS, theD);

            theAMap.AddResults(result);
            theAMap.constant = constant;
            theMap.AddTransform(theAMap);

            LoadValueMappings(theAMap);

            LoadDataLoss(theAMap, serial);
              }
            }

            return true;
              }
              catch (Exception ex) { return false; }
        }
Exemplo n.º 2
0
 internal AttributeMappingData(FeatureMappingData aMap, AttributeData sourceA, AttributeData destA)
 {
   this.serialNumber = aMap.serialNumber;
   this.srcFC = aMap.srcFC;
   this.destFC = aMap.destFC;
   if (sourceA.Name != "")
   {
     this.srcAtt = sourceA.Name;
     this.srcDT = sourceA.dataType;
     this.srcLen = sourceA.charLength;
     this.srcEnum = sourceA.enumName;
   }
   else
   {
     this.srcAtt = "Constant";
     this.srcDT = esriFieldType.esriFieldTypeBlob;
     this.srcLen = 0;
     this.srcEnum = "";
   }
   this.destAtt = destA.Name;
   this.destDT = destA.dataType;
   this.destLen = destA.charLength;
   this.destEnum = destA.enumName;
   this.transform = MiscProcs.getTransformNumber(this.srcDT, this.destDT);
   if (destA.dataType == esriFieldType.esriFieldTypeString && destA.charLength < this.srcLen) { this.transform = 4; }
   if (destA.enumName != "") { this.transform = 20; }
   this.valueCount = 0;
   this.dataLoss = 0;
   this.constant = "";
   this.results = "";
   this.theConversions = null;
   this.Parent = aMap;
 }
Exemplo n.º 3
0
        private void mnuInsertConstant_Click(object sender, EventArgs e)
        {
            dlgConstant theDlg = new dlgConstant();

            AttributeData theItem = (AttributeData)lbDestAttributes.SelectedItem;
            theDlg.lblInsertHere.Text = theMap.destFC + " --- " + theItem.Name;
            theDlg.lblDataType.Text = MiscProcs.UnBuildDataType(theItem.dataType, theItem.charLength);
            theDlg.lblLength.Text = theItem.charLength.ToString();
            theDlg.forNulls.Text = "F";

            if (theItem.enumName != "")
            {
                theDlg.lblEnum.Text = theItem.enumName;
            }

            if (theItem.usesConstant)
            {
            }

            DialogResult theRes = theDlg.ShowDialog(this);

            if (theRes == DialogResult.OK)
            {
                AttributeData EmptyAttribute = new AttributeData(theMap.srcFC, null, 0);

                theAMap = new AttributeMappingData(theMap, EmptyAttribute, theItem);
                theAMap.constant = theDlg.txtConst.Text;

                lstAttMappings.Items.Add(theAMap);
                theAMap.transform = 20;
                theMap.AddTransform(theAMap);

                theItem.numMappings += 1;
                theItem.usesConstant = true;
            }
        }
Exemplo n.º 4
0
    internal static string GetAttributeMetadata(IWorkspace theWS, String theFC, AttributeData theD)
    {
      String theFDef = "None Metadata Found";
      IPropertySet curPS;
      int Index = -1;

      try
      {
        IFeatureClass theFClass = GetFeatureClass(theWS, theFC);
        IDataset theDS = (IDataset)theFClass;
        IFeatureClassName FCN = (IFeatureClassName)theDS.FullName;

        Index = theFClass.Fields.FindField(theD.Name);

        IMetadata MasMeta = (IMetadata)FCN;
        MasMeta.Synchronize(esriMetadataSyncAction.esriMSAAlways, 1);
        curPS = MasMeta.Metadata;

        object[] theO = (object[])curPS.GetProperty("eainfo/detailed/attr[" + Index.ToString() + "]/attrdef");

        object theS = theO[0];
        return theS.ToString();
      }
      catch (Exception ex) { }

      return theFDef;
    }