FRAMES | NO FRAMES
DeleteItem Method

Deletes an item in the repository.

Availability: Business Analyst Server.

void DeleteItem ( 
    string          WorkspaceName, 
    string          ProjectName, 
    esriFolderType  FolderType, 
    string          ItemName 
);

Parameter Description
WorkspaceName Workspace name. Type String.
ProjectName Project name. Type String.
FolderType Folder type to create item in. Type esriFolderType.
ItemName Item name. Type String.

Remarks

If the item to delete is absent, this method has no effect.

Examples

The example below demonstrates the deletion of an existing folder item in the Business Analyst Server Repository.

C#
// Instantiate the BAServerHelper class to access analysis methods
BAServerHelper baServerHelper = new BAServerHelper();
 
string workspace = "Default Workspace";
string project = "Default Project";
esriFolderType itemType = esriFolderType.esriFolderTradeAreas;
string deletedItem = "existingItem_DeleteItem";
 
// ========= STEP 1: Create custom trade area layer using simple rings
 
PointRecord[] storePoints = new PointRecord[1];
 
storePoints[0] = new PointRecord();
storePoints[0].Name = "store_study_site";
storePoints[0].Description = "Store Study Site";
storePoints[0].StoreID = "1";
storePoints[0].Latitude = 34.057596;
storePoints[0].Longitude = -117.195683;
 
// Create a store feature layer based on an array of point records.
PointLayer storeLayer = new PointLayer();
storeLayer.Points = storePoints;
 
SimpleRingsParameters parameters = new SimpleRingsParameters();
 
// Set specific analysis parameters
parameters.DistanceUnits = esriUnits.esriMiles;
parameters.Donut = true;
parameters.Radii = new double[] { 1, 2, 3 };
parameters.Stores = storeLayer;
 
// Set other parameters
RenderingParameters imageOptions = null;
TaskOutputType[] outputOptions = new TaskOutputType[] { }; // Save item in repository only
 
esriFolderItem outputLayer = new esriFolderItem();
outputLayer.workspaceName = workspace;
outputLayer.projectName = project;
outputLayer.folderType = itemType;
outputLayer.itemName = deletedItem;
 
esriFolderItem outputReport = null;
 
// Create an item to be deleted
baServerHelper.SimpleRings(parameters, imageOptions, outputOptions, outputLayer, outputReport);
 
// ========= STEP 2: Get the list of all items and ensure that the given item exists
 
esriFolderItem[] items = baServerHelper.GetListProjectItems(workspace, project, itemType);
bool itemFound = false;
foreach (esriFolderItem item in items)
    if (item.itemName == deletedItem)
    {
        itemFound = true;
        break;
    }
 
// ========= STEP 3: Delete item
 
baServerHelper.DeleteItem(workspace, project, itemType, deletedItem);
 
// ========= STEP 4: Get the list of all items and ensure that the given item is absent
 
items = baServerHelper.GetListProjectItems(workspace, project, itemType);
bool itemDeleted = true;
foreach (esriFolderItem item in items)
    if (item.itemName == deletedItem)
    {
        itemDeleted = false;
        break;
    }

See Also