/// <summary> /// Screens the XML lookup. /// </summary> /// <param name="xmlLookup">The XML lookup.</param> private void ScreenXMLLookup(string xmlLookup) { XmlLookupReader xmlLookupReader = new XmlLookupReader(xmlLookup); List <XmlLookupNode> xmlLookupNodeList = new List <XmlLookupNode>(); for (int i = 0; i < xmlLookupReader.LookupNodeList.Count; i++) { XmlLookupNode lookupNode = xmlLookupReader.LookupNodeList[i]; this.logger += "[" + i + "]".PadRight(5 - i.ToString(CultureInfo.InvariantCulture).Length, '_') + "<" + lookupNode.CamelCaseName + "|" + lookupNode.Type + "|" + lookupNode.Value + ">\n"; SPField xmlSPField = null; SPField validSPField = null; // finds the field unsing the current lookupnode in this.FileSPListItem bool isFound = this.IsFoundOnFileSPListItemFields(lookupNode, ref xmlSPField); bool isCopyTarget = false; this.logger += "\tisFound?" + isFound + "\n"; if (isFound) { // fileSPField = this.GetSPFieldOnSPFields(lookupNode); isCopyTarget = this.IsFieldCopyTarget(xmlSPField, ref validSPField); this.logger += "\tisCopyTarget?" + isCopyTarget + "\n"; if (!isCopyTarget) { this.logger += "\t\t(N)Continue\n"; } else { // validSPField this.logger += "\t\t(Y)Update<" + xmlSPField.Title + "|" + xmlSPField.Type + ">\twith SPFieldUpdater\n"; RecordField spFieldUpdater = new RecordField(xmlSPField, validSPField); this.logger += spFieldUpdater.ToString(); this.logger += spFieldUpdater.FixSPField( this.ContextSPWeb, this.ContextSPSite, this.FileSPListItem, lookupNode.Value) + "\n"; } } else { // if not found this.logger += "\tIfNotFound Add new (" + lookupNode.CamelCaseName + "|" + lookupNode.Value + "|" + lookupNode.Type + ")"; xmlLookupNodeList.Add(lookupNode); this.logger += "\n"; } } this.NewLookupNodes = xmlLookupNodeList; this.logger += "\n"; }
/// <summary>Determines whether [contains] [the specified sp field].</summary> /// <param name="spField">The sp field.</param> /// <returns> /// <c>true</c> if [contains] [the specified sp field]; otherwise, <c>false</c>. /// </returns> public bool Contains(SPField spField) { string fieldName = spField.Title.Replace(" ID", " Id").Replace("(Converted Document)", "").Replace(" ", String.Empty); List <XmlLookupNode> xmlLookupNodes = this.LookupNodeList; foreach (XmlLookupNode xmlLookupNode in xmlLookupNodes) { if (xmlLookupNode.CamelCaseName.Equals(fieldName)) // && lookupNode.FieldType.Equals(spField.TypeAsString)) { this.LookupNodeMatched = xmlLookupNode; return(true); } } return(false); }
/// <summary>Releases unmanaged and - optionally - managed resources.</summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// true to release both managed and unmanaged resources; false to release only unmanaged resources. /// <param name="isDisposing">The is disposing.</param> private void Dispose(bool isDisposing) { // Check if Dispose has been called if (!this.isDisposed) { // dispose managed and unmanaged resources if (isDisposing) { // managed resources clean this.LookupNodeList = null; this.LookupNodeMatched = null; } // unmanaged resources clean // confirm cleaning this.isDisposed = true; } }
/// <summary> /// Determines whether [is found on file SP list item fields] [the specified lookup node]. /// </summary> /// <param name="lookupNode">The lookup node.</param> /// <param name="xmlSPField">The file SP field.</param> /// <returns> /// <c>true</c> if [is found on SP fields] [the specified lookup node]; otherwise, <c>false</c>. /// </returns> private bool IsFoundOnFileSPListItemFields(XmlLookupNode lookupNode, ref SPField xmlSPField) { foreach (SPField fileSPFieldItemField in this.FileSPListItem.Fields) { if (lookupNode.CamelCaseName.Contains(fileSPFieldItemField.Title)) { xmlSPField = fileSPFieldItemField; // source list-item is missing the metadata field if (xmlSPField == null) { return(false); } else { return(true); } } } return(false); }