/// <summary>
 /// 加载导出配置数据
 /// </summary>
 public bool LoadExportConfigData()
 {
     if (File.Exists(XMLConfigFileFullPath))
     {
         XmlSerializer ser = new XmlSerializer(typeof(ExportConfig));
         FileStream    fs  = new FileStream(XMLConfigFileFullPath, FileMode.Open);
         ExportConfigInfo = (ExportConfig)ser.Deserialize(fs);
         fs.Close();
         return(ExportConfigInfo != null);
     }
     else
     {
         Console.WriteLine(string.Format("导出配置文件不存在 : {0}", XMLConfigFileFullPath));
         return(false);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 加载导出配置数据
 /// </summary>
 public bool LoadExportConfigData()
 {
     if (File.Exists(XMLConfigFileFullPath))
     {
         XmlDocument xmldoc = new XmlDocument();
         xmldoc.Load(XMLConfigFileFullPath);
         var rootnode     = xmldoc.DocumentElement;
         var rootnodename = rootnode.Name;
         var reflecttype  = this.GetType().Assembly.GetType("XbufferExcelToData." + rootnodename);
         if (reflecttype == typeof(ExportConfig))
         {
             ExportConfigInfo = new ExportConfig();
             var childnodes = rootnode.ChildNodes;
             for (int i = 0, length = childnodes.Count; i < length; i++)
             {
                 var property = ExportConfigInfo.GetType().GetProperty(childnodes[i].Name);
                 if (property != null)
                 {
                     // 支持配置相对路径
                     var fullpath = Path.GetFullPath(childnodes[i].InnerText);
                     fullpath = fullpath.Replace("\\", "/");
                     property.SetValue(ExportConfigInfo, fullpath);
                 }
                 else
                 {
                     Console.WriteLine(string.Format("不支持的属性配置 : {0}", childnodes[i].Name));
                 }
             }
             ExportConfigInfo.printOutAllInfo();
             return(true);
         }
         else
         {
             Console.WriteLine(string.Format("找不到配置的类型数据信息 : {0}", rootnodename));
             Console.WriteLine("当前只支持ExportConfig类型信息配置");
             return(false);
         }
     }
     else
     {
         Console.WriteLine(string.Format("导出配置文件不存在 : {0}", XMLConfigFileFullPath));
         return(false);
     }
 }
 public XbufferExcelExportConfig()
 {
     XMLConfigFileFullPath = "./ExportConfig.xml";
     ExportConfigInfo      = null;
 }