本文整理汇总了C#中Modulo.Collect.OVAL.SystemCharacteristics.ItemType类的典型用法代码示例。如果您正苦于以下问题:C# ItemType类的具体用法?C# ItemType怎么用?C# ItemType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemType类属于Modulo.Collect.OVAL.SystemCharacteristics命名空间,在下文中一共展示了ItemType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
var metabaseItem = (metabase_item)systemItem;
try
{
if (string.IsNullOrWhiteSpace(MetabaseFileContent) || string.IsNullOrWhiteSpace(MetabaseSchemaContent))
throw new Exception(METABASE_CONTENT_NOT_FOUND_MSG);
var metabaseSession = GetMetabaseProperty(metabaseItem.key.Value, metabaseItem.id1.Value);
metabaseItem.data = CreateMetabaseEntityItemFromMetabaseDataProperty(metabaseSession.Value);
if ((metabaseItem.data.Length == 1) && (metabaseItem.data[0].status == StatusEnumeration.doesnotexist))
{
metabaseItem.status = StatusEnumeration.doesnotexist;
metabaseItem.id1.status = StatusEnumeration.doesnotexist;
metabaseItem.name = null;
metabaseItem.data_type = null;
metabaseItem.user_type = null;
}
else
{
metabaseItem.name = CreateMetabaseEntityFromMetabaseProperty(metabaseSession.Name);
metabaseItem.data_type = CreateMetabaseEntityFromMetabaseProperty(metabaseSession.Type);
metabaseItem.user_type = CreateMetabaseEntityFromMetabaseProperty(metabaseSession.UserType);
}
}
catch (MetabaseItemNotFoundException)
{
metabaseItem.status = StatusEnumeration.doesnotexist;
metabaseItem.key.status = metabaseItem.status;
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例2: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
if (systemItem.status.Equals(StatusEnumeration.notcollected))
{
var userToBeCollected = ((user_item)systemItem).user.Value;
try
{
var collectedUser = this.WindowsAccountProvider.GetUserByName(userToBeCollected);
systemItem = new user_item()
{
status = StatusEnumeration.exists,
user = OvalHelper.CreateItemEntityWithStringValue(collectedUser.Name),
enabled = OvalHelper.CreateBooleanEntityItemFromBoolValue((bool)collectedUser.Enabled),
};
var userGroups = this.WindowsAccountProvider.GetUserGroups(userToBeCollected, AccountSearchReturnType.Name);
if (userGroups.Count() > 0)
((user_item)systemItem).group = userGroups.Select(grp => new EntityItemStringType() { Value = grp }).ToArray();
else
((user_item)systemItem).group = new EntityItemStringType[] { new EntityItemStringType() { status = StatusEnumeration.doesnotexist } };
}
catch (WindowsUserNotFound)
{
systemItem.status = StatusEnumeration.doesnotexist;
((user_item)systemItem).user.status = systemItem.status;
}
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例3: CreateCollectedItemsWithOneErrorItem
public IEnumerable<CollectedItem> CreateCollectedItemsWithOneErrorItem(
ItemType itemType, IEnumerable<ProbeLogItem> logItems, string errorMessage)
{
itemType.message = MessageType.FromErrorString(errorMessage);
itemType.status = StatusEnumeration.error;
return CreateCollectedItems(itemType, logItems);
}
示例4: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
var filePath = string.Empty;
try
{
var fileContentItem = (textfilecontent_item)systemItem;
filePath = Path.Combine(fileContentItem.path.Value, fileContentItem.filename.Value);
var interimList = WinNetUtils.getWinTextFileContent(hostUNC, filePath, fileContentItem.line.Value);
var collectedItems = new List<CollectedItem>();
foreach (FileContentItemSystemData srcItem in interimList)
{
var destItem = new textfilecontent_item();
this.BuilderFileContentItem(destItem, srcItem, fileContentItem);
var newCollectedItem = new CollectedItem() { ItemType = destItem, ExecutionLog = BuildExecutionLog() };
collectedItems.Add(newCollectedItem);
}
return collectedItems;
}
catch (FileNotFoundException)
{
base.SetDoesNotExistStatusForItemType(systemItem, filePath);
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例5: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
if (systemItem.status.Equals(StatusEnumeration.notcollected))
{
var userSIDItem = ((user_sid_item)systemItem);
try
{
var allUsers = this.WindowsAccountProvider.GetAllGroupByUsers();
var userSidValue = userSIDItem.user_sid.Value;
var collectedUserItem = allUsers.Where(user => user.AccountSID.Equals(userSidValue)).FirstOrDefault();
if (collectedUserItem == null)
throw new UserSIDNotFoundException(userSidValue);
systemItem.status = StatusEnumeration.exists;
userSIDItem.enabled = OvalHelper.CreateBooleanEntityItemFromBoolValue((bool)collectedUserItem.Enabled);
userSIDItem.group_sid = new EntityItemStringType[] { new EntityItemStringType() { status = StatusEnumeration.doesnotexist } };
if ((collectedUserItem.Members != null) && (collectedUserItem.Members.Count() > 0))
userSIDItem.group_sid =
collectedUserItem.Members.Select(grp => OvalHelper.CreateItemEntityWithStringValue(grp.AccountSID)).ToArray();
}
catch (UserSIDNotFoundException)
{
SetDoesNotExistStatusForItemType(systemItem, userSIDItem.user_sid.Value);
((user_sid_item)systemItem).user_sid.status = StatusEnumeration.doesnotexist;
}
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例6: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
this.CreateSMFCollectorInstance();
var smfItem = (smf_item)systemItem;
try
{
var collectedSmf = this.TryToCollectSMF(smfItem.fmri.Value);
smfItem.service_name = OvalHelper.CreateItemEntityWithStringValue(collectedSmf.ServiceName);
smfItem.service_state = new EntityItemSmfServiceStateType() { Value = collectedSmf.ServiceState };
smfItem.protocol = new EntityItemSmfProtocolType() { Value = collectedSmf.Protocol };
smfItem.server_executable = OvalHelper.CreateItemEntityWithStringValue(collectedSmf.ServerExecutable);
smfItem.server_arguements = OvalHelper.CreateItemEntityWithStringValue(collectedSmf.ServerArgs);
smfItem.exec_as_user = OvalHelper.CreateItemEntityWithStringValue(collectedSmf.ExecAsUser);
}
catch (NoSMFDataException)
{
ExecutionLogBuilder.AddInfo("An error occurred while trying to collect smf_object");
smfItem.status = StatusEnumeration.error;
smfItem.message = MessageType.FromErrorString("The fmri format is invalid.");
smfItem.fmri.status = StatusEnumeration.error;
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(smfItem, BuildExecutionLog());
}
示例7: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
var xmlFilepath = string.Empty;
var xmlFileContentItem = (xmlfilecontent_item)systemItem;
try
{
xmlFilepath = this.GetCompleteFilepath(xmlFileContentItem);
if (string.IsNullOrWhiteSpace(xmlFilepath))
throw new XPathNoResultException();
var xPathResult = this.XPathOperator.Apply(xmlFilepath, xmlFileContentItem.xpath.Value);
this.ConfigureXmlFileContentItem(xmlFileContentItem, xPathResult);
}
catch (FileNotFoundException)
{
var completeFilepath = this.GetCompleteFilepath((xmlfilecontent_item)xmlFileContentItem);
base.SetDoesNotExistStatusForItemType(systemItem, completeFilepath);
}
catch (XPathNoResultException)
{
var xpath = string.Format("xpath: '{0}'", xmlFileContentItem.xpath.Value);
base.SetDoesNotExistStatusForItemType(systemItem, xpath);
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例8: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
var registryItem = (registry_item)systemItem;
var fullKeyPath = Path.Combine(registryItem.hive.Value, registryItem.key.Value, registryItem.name.Value);
var itemBuilder = new RegistryItemTypeBuilder(registryItem);
try
{
base.ExecutionLogBuilder.CollectingDataFrom(fullKeyPath);
if (this.IsAllEntitiesIsSet(systemItem))
{
var collectedSystemData = this.collectSystemDataForRegistryItem(registryItem);
itemBuilder.FillItemTypeWithData(collectedSystemData);
}
}
catch (RegistryKeyNotFoundException)
{
base.ExecutionLogBuilder.Warning(string.Format("The registry key {0} is not found ", registryItem.key.Value));
itemBuilder.SetRegistryKeyStatus(StatusEnumeration.doesnotexist);
itemBuilder.SetItemTypeStatus(StatusEnumeration.doesnotexist, null);
itemBuilder.ClearRegistryName();
}
catch (RegistryNameNotFoundException)
{
base.ExecutionLogBuilder.Warning(string.Format("The registry name {0} is not found ", registryItem.name.Value));
itemBuilder.SetRegistryNameStatus(StatusEnumeration.doesnotexist);
itemBuilder.SetItemTypeStatus(StatusEnumeration.doesnotexist, null);
}
itemBuilder.BuildItemType();
itemBuilder.ClearEntitiesWithEmptyValueIfStatusDoesNotExists();
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(itemBuilder.BuiltItemType, BuildExecutionLog());
}
示例9: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
var filepath = string.Empty;
var trusteeSID = string.Empty;
try
{
filepath = ((fileauditedpermissions_item)systemItem).filepath.Value;
trusteeSID = ((fileauditedpermissions_item)systemItem).trustee_sid.Value;
base.ExecutionLogBuilder.AddInfo(string.Format(TRYING_TO_COLLECT_AUDITED_PERMISSIONS_LOG, trusteeSID, filepath));
CreateFileAuditedPermissions53ItemType((fileauditedpermissions_item)systemItem, filepath, trusteeSID);
var SACLs = this.CollectSecurityDescriptorForFileAndUser(filepath, trusteeSID);
MapSACLsToFileAuditedPermissionsItem((fileauditedpermissions_item)systemItem, SACLs);
}
catch (InvalidInvokeMethodException)
{
base.SetDoesNotExistStatusForItemType(systemItem, filepath);
this.SetAllAuditEntitiesItemToNULL((fileauditedpermissions_item)systemItem);
}
catch (ACLNotFoundException)
{
base.SetDoesNotExistStatusForItemType(systemItem, trusteeSID);
}
catch (Exception ex)
{
this.SetAllAuditEntitiesItemToEMPTY((fileauditedpermissions_item)systemItem);
throw ex;
}
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例10: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
this.CreateWmiDataProviderFromWmiItem((wmi_item)systemItem);
var wmiResult = this.WmiDataProvider.ExecuteWQL(((wmi_item)systemItem).wql.Value);
((wmi_item)systemItem).result = this.ConvertWmiResultToEntityItemList(wmiResult);
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例11: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
base.ExecutionLogBuilder.CollectingDataFrom(TargetHostName);
var collectedPasswordPolicies = PasswordPolicyHelper.getUserModalsInfo0(TargetHostName);
this.MapPasswrodPolicyToPasswordPolicyItemType((passwordpolicy_item)systemItem, collectedPasswordPolicies);
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, base.BuildExecutionLog());
}
示例12: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
base.ExecutionLogBuilder.CollectingDataFrom("Family Object");
var collectedFamily = this.FamilyCollector.GetOperatingSystemFamily();
((family_item)systemItem).family = new EntityItemFamilyType() { Value = collectedFamily };
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例13: collectDataForSystemItem
protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
{
var commandOutput = UnameCollector.RunUnameCommand();
UnixTerminalParser
.MapUnameCommandOutputToUnameItem((uname_item)systemItem, commandOutput);
return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
}
示例14: AssertItemTypeWithErrorStatus
public static void AssertItemTypeWithErrorStatus(ItemType itemToAssert, string expectedChunkOfMessageTypeValue)
{
Assert.AreEqual(StatusEnumeration.error, itemToAssert.status, "Unexpected item status was found.");
if (!string.IsNullOrEmpty(expectedChunkOfMessageTypeValue))
{
Assert.IsNotNull(itemToAssert.message, "The message type was not created.");
Assert.IsTrue(itemToAssert.message.First().Value.Contains(expectedChunkOfMessageTypeValue));
}
}
示例15: AssertItemsWithExistsStatus
public static void AssertItemsWithExistsStatus(ItemType[] itemsToAssert, int expectedItemCount, Type expectedTypeInstanceOfItems)
{
Assert.AreEqual(expectedItemCount, itemsToAssert.Count(), "Unexpected system data items count was found.");
foreach (var itemType in itemsToAssert)
{
Assert.IsInstanceOfType(itemType, expectedTypeInstanceOfItems, "An item with unexpected instance type was found.");
Assert.AreEqual(StatusEnumeration.exists, itemType.status, "An item with unexpected status was found.");
}
}