private IEnumerable<ItemType> ProcessOperation(xmlfilecontent_object objectToCollect) { IEnumerable<string> processedFilenames = null; IEnumerable<string> processedPaths = null; if (objectToCollect.IsFilePathDefined()) { var filepath = this.GetDictionaryWithElement(xmlfilecontent_ItemsChoices.filepath, objectToCollect.GetAllObjectEntities()); var filePathOperationResult = this.PathOperatorEvaluator.ProcessOperationFilePath(filepath); processedPaths = filePathOperationResult.Paths; processedFilenames = new List<String>(); foreach (var completeFilepath in filePathOperationResult.FileNames) ((List<String>)processedFilenames).Add(System.IO.Path.GetFileName(completeFilepath)); } else { var paths = this.GetDictionaryWithElement(xmlfilecontent_ItemsChoices.path, objectToCollect.GetAllObjectEntities()); processedPaths =this.PathOperatorEvaluator.ProcessOperationsPaths(paths); var fileNames = this.GetDictionaryWithElement(xmlfilecontent_ItemsChoices.filename, objectToCollect.GetAllObjectEntities()); processedFilenames = this.PathOperatorEvaluator.ProcessOperationFileName(fileNames, processedPaths, false); } var xPathEntity = ((EntitySimpleBaseType)objectToCollect.GetItemValue(xmlfilecontent_ItemsChoices.xpath)); var xpaths = new string[] { xPathEntity.Value }; if ((processedPaths == null) || (processedPaths.Count() == 0) || (processedFilenames == null) || (processedFilenames.Count() == 0)) { var completeFilepath = objectToCollect.GetCompleteFilepath(); if (PathOperatorEvaluator.Platform.Equals(FamilyEnumeration.unix)) completeFilepath = completeFilepath.ToUnixPath(); var newXmlFileContentItem = CreateXmlFileItem(completeFilepath, xpaths.First()); newXmlFileContentItem.status = StatusEnumeration.doesnotexist; newXmlFileContentItem.filepath.status = newXmlFileContentItem.status; return new ItemType[] { newXmlFileContentItem }; } var mustCheckIfFileExists = true; // this.MustCheckIfFileExists(objectToCollect); return this.CreateFileItemTypesByCombinationOfEntitiesFrom(processedPaths, processedFilenames, xpaths, mustCheckIfFileExists); }
private ObjectType CreateObjectTypeFrom(xmlfilecontent_object objectType, string filepath, string filename, string path, string xpath) { EntityObjectStringType filePathFrom = null; EntityObjectStringType pathFrom = null; EntityObjectStringType fileNameFrom = null; EntityObjectStringType newFilePath = null; EntityObjectStringType newPath = null; EntityObjectStringType newFileName = null; var xpathFrom = (EntityObjectStringType)objectType.GetItemValue(xmlfilecontent_ItemsChoices.xpath); var newTrusteeSID = this.CreateObjectStringTypeFrom(xpathFrom); newTrusteeSID.Value = string.IsNullOrEmpty(xpath) ? newTrusteeSID.Value : xpath; if (objectType.IsFilePathDefined()) { filePathFrom = (EntityObjectStringType)objectType.GetItemValue(xmlfilecontent_ItemsChoices.filepath); newFilePath = this.CreateObjectStringTypeFrom(filePathFrom); newFilePath.Value = string.IsNullOrEmpty(filepath) ? newFilePath.Value : filepath; return this.CreateFileObject(newFilePath, null, null, newTrusteeSID); } else { pathFrom = (EntityObjectStringType)objectType.GetItemValue(xmlfilecontent_ItemsChoices.path); fileNameFrom = (EntityObjectStringType)objectType.GetItemValue(xmlfilecontent_ItemsChoices.filename); newPath = this.CreateObjectStringTypeFrom(pathFrom); newPath.Value = string.IsNullOrEmpty(path) ? newPath.Value : path; newFileName = this.CreateObjectStringTypeFrom(fileNameFrom); newFileName.Value = string.IsNullOrEmpty(filename) ? newFileName.Value : filename; return this.CreateFileObject(null, newFileName, newPath, newTrusteeSID); } }