Пример #1
0
 /// <summary>
 /// 获取列映射数组
 /// </summary>
 /// <param name="columnMappingString"></param>
 /// <returns></returns>
 public static DataColumnMapping[] GetColumnMappings(string columnMappingString)
 {
     DataColumnMapping[] columns;
     Regex regex = new Regex("\\s*([^:]+):([^;]*);*\\s*");
     MatchCollection mcs = regex.Matches(columnMappingString);
     columns = new DataColumnMapping[mcs.Count];
     int i = 0;
     foreach (Match m in mcs)
     {
         columns[i++] = new DataColumnMapping(m.Groups[1].Value, m.Groups[2].Value);
     }
     return columns;
 }
Пример #2
0
        public virtual IDictionary <string, string> GetExportFieldAndName(String[] exportFields)
        {
            if (this._columnNames == null || this._columnNames.Length == 0)
            {
                return(null);
            }

            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (string columnField in exportFields)
            {
                DataColumnMapping map = this._columnNames.SingleOrDefault(
                    a => String.Compare(a.Field, columnField, true,
                                        CultureInfo.InvariantCulture) == 0);

                if (map.Field != null)
                {
                    dictionary.Add(map.Field, map.Name);
                }
            }
            return(dictionary);
        }
Пример #3
0
 public ExportItem(string queryName, DataColumnMapping[] columns):base(columns)
 {
     this.PortalKey = queryName;
 }
Пример #4
0
        public static bool ReadExportConfigFormXml(
            string xml,
            string xpath,
            out DataColumnMapping[] columns)
        {
            XmlDocument xd = new XmlDocument();
            xd.LoadXml(xml);
            if (String.IsNullOrEmpty(xpath))
            {
                xpath = "/item";
            }
            XmlNode rootNode = xd.SelectSingleNode(xpath);
            XmlNode node;

            if (rootNode == null)
            {
                throw new ArgumentNullException("xpath");
            }

            #region 获取列配置

            node = rootNode.SelectSingleNode("column");
            if (node == null)
            {
                columns = null;
            }
            else
            {
                string columnMappingString = node.Attributes["mapping"].Value;
                columns = GetColumnMappings(columnMappingString);
            }

            #endregion

            return true;
        }
Пример #5
0
 /// <summary>
 /// 从文件中读取导出配置
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="columns"></param>
 /// <param name="queryName"></param>
 /// <returns></returns>
 public static bool ReadExportConfigFormFile(
     string filePath,
     out DataColumnMapping[] columns)
 {
     return ReadExportConfigFormXml(
         System.IO.File.ReadAllText(filePath),
         null,
         out columns);
 }
Пример #6
0
 protected BaseDataExportPortal(DataColumnMapping[] columnNames)
 {
     this._columnNames = columnNames;
 }