Weird problems with SharePoint code

  • Thread starter Thread starter Khabibulla
  • Start date Start date
K

Khabibulla

Guest
Hi,

Through the NuGet Package manager I have added Microsoft.Sharepoint.dll to my project so I can update a SharePoint list. The Sharepoint code runs after I delete an object in a map. Before I added the Sharepoint code, everything worked fine (ie. I just displayed a message box), but now that I have added the Sharepoint code nothing in my OnDeleteFeature event fires. In debug mode nothing gets hit.

If I comment out the code (as seen below), everything works fine. But as soon as I un-comment the code, nothing works again.

Any ideas as to what might be going on??


//When a feature is Deleted.
void Events_OnDeleteFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
{
try
{
if (obj is IFeature)
{
//Cast to an IFeature
IFeature inFeature = (IFeature)obj;
ITable inTable = obj.Table;

if (inTable is IVersionedObject)
{
IVersionedObject3 vObject = (IVersionedObject3)inTable;

//Check if the Features Table is Versioned. If not, then exit.
if (vObject.IsRegisteredAsVersioned)
{
//Look for the Maximo field and edit.
if (inFeature.Fields.FindField("MXCREATIONSTATE") != -1)
{
MessageBox.Show("DELETE");


//using (SPSite spSite = new SPSite("https://..."))
//{
// using (SPWeb spWeb = spSite.OpenWeb())
// {
// spWeb.AllowUnsafeUpdates = true;
// SPList list = spWeb.Lists["GIS_Deletes"];

// //Add an item
// SPListItem newItem = list.Items.Add();
// newItem["MXASSETNUM"] = inFeature.Fields.FindField("MXASSETNUM").ToString();
// newItem["MXSITEID"] = inFeature.Fields.FindField("MXSITEID").ToString();
// newItem.Update();

// spWeb.AllowUnsafeUpdates = false;
// }
//}
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error in OnDeleteFeature procedure.");
}

}





Brian

Continue reading...
 
Back
Top