本文整理汇总了C#中Tag.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# Tag.Delete方法的具体用法?C# Tag.Delete怎么用?C# Tag.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag.Delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public override Response Delete(string objectType, IList<string> identifiers)
{
Response response = new Response() { Level = StatusLevel.Success };
Proxy proxy = null;
Session session = null;
try
{
DataObject objDef = GetObjectDefinition(objectType);
if (objDef != null)
{
try
{
Connect(ref proxy, ref session);
EqlClient eqlClient = new EqlClient(session);
Configuration config = GetConfiguration(objDef);
int objType = (int)config.Template.ObjectType;
foreach (string identifier in identifiers)
{
Status status = new Status()
{
Identifier = identifier,
Level = StatusLevel.Success
};
int objId = eqlClient.GetObjectId(identifier, string.Empty, objType);
if (objId != 0)
{
if (objType == (int)ObjectType.Tag)
{
Tag tag = new Tag(session, objId);
tag.Delete();
status.Messages.Add(string.Format("Tag [{0}] deleted succesfully.", identifier));
}
else if (objType == (int)ObjectType.Document)
{
Document doc = new Document(session, objId);
doc.Delete();
status.Messages.Add(string.Format("Document [{0}] deleted succesfully.", identifier));
}
else
{
status.Level = StatusLevel.Error;
status.Messages.Add(string.Format("Object type [{0}] not supported.", objType));
response.Level = StatusLevel.Error;
}
}
else
{
status.Level = StatusLevel.Error;
status.Messages.Add(string.Format("Object [{0}] not found.", identifier));
response.Level = StatusLevel.Error;
}
response.Append(status);
}
}
finally
{
Disconnect(ref proxy, ref session);
}
}
else
{
response.Level = StatusLevel.Error;
response.Messages.Add(string.Format("Object type [{0}] does not exist.", objectType));
}
}
catch (Exception e)
{
_logger.Error("Error deleting data object: " + e);
response.Level = StatusLevel.Error;
response.Messages.Add(e.Message);
}
return response;
}