/// <summary> /// remove the nosense columns from dictionary /// </summary> /// <param name="columnName">column of xml</param> /// <param name="columns">the column of dictionary</param> /// <returns>return the actual value of title</returns> private static string ActualResult(string columnName, ref IDictionary <string, string> columns) { if (columns.ContainsKey(columnName)) { string value = columns[columnName].ToString(); if (!DataChecker.IsEmpty(value)) { columns.Remove(columnName); return(value); } columns.Remove(columnName); return(string.Empty); } return(string.Empty); }
/// <summary> /// get the xml Mapping fields /// </summary> /// <param name="xmlPath">the xml path</param> /// <param name="keyName">the key name, unique of the row</param> /// <returns>return the mapping fields</returns> public static IDictionary <string, string> GetXmlMappingField(string xmlPath, string keyName) { IDictionary <string, string> columns = new Dictionary <string, string>(); DataTable dt = XmlToFirstDataTable(xmlPath); DataRow row = null; for (int i = 0; i < dt.Rows.Count; i++) { string name = dt.Rows[i]["KeyName"].ToString(); if (name.ToLower() == keyName.ToLower()) { row = dt.Rows[i]; foreach (DataColumn dc in dt.Columns) { if (!DataChecker.IsEmpty(row[dc.ColumnName].ToString())) { columns.Add(dc.ColumnName, row[dc.ColumnName].ToString()); } } break; } } return(columns); }