Exemple #1
0
 public void LoadData()
 {
     for (int i = 0; i < _inputFiles.Length; i++)
     {
         string path = _inputFiles[i];
         try
         {
             string    ext      = Path.GetExtension(path);
             string    fullType = "list:" + _fullName;
             FieldWrap field    = new FieldWrap(null, Name, fullType, Util.Split(fullType), _groups);
             if (ext == ".xml")
             {
                 var xml = new ImportXml(path);
                 if (_data == null)
                 {
                     _data = new FList(null, field);
                 }
                 _data.LoadOneRecord(xml.Data);
             }
             else
             {
                 var excel = new ImportExcel(path);
                 _data = new FList(null, field, excel);
             }
         }
         catch (Exception e)
         {
             Util.LogErrorFormat("{0}\n[加载文件失败]:{1}\n{2}\n", e.Message, path, e.StackTrace);
         }
     }
 }
Exemple #2
0
        public ConfigWrap(ClassXml des, string namespace0, string moduleDir)
        {
            _des       = des;
            _namespace = namespace0;
            _fullName  = string.Format("{0}.{1}", namespace0, des.Name);
            _groups    = new HashSet <string>(Util.Split(des.Group));
            if (_groups.Count == 0)
            {
                _groups.Add(Setting.DefualtGroup);
            }

            if (des.Index.IsEmpty())
            {
                Error("索引(Index)未填写");
            }
            ClassWrap cls = ClassWrap.Get(_fullName);

            _index = cls.Fields.Find(f => f.Name == des.Index);
            if (_index == null)
            {
                Error("配置主键字段不存在:" + des.Index);
                return;
            }
            _index.CreateKeyChecker();

            string path = Path.Combine(moduleDir, _des.DataPath);

            if (File.Exists(path))
            {
                _inputFiles = new string[] { path }
            }
            ;
            else if (Directory.Exists(path))
            {
                _inputFiles = Directory.GetFiles(path);
            }
            else
            {
                Error("数据路径不存在:" + path);
            }
            _outputFile = _fullName.Replace('.', '\\').ToLower();

            Add(this);
        }
Exemple #3
0
        public ClassWrap(ClassXml des, string namespace0)
        {
            _des      = des;
            _fields   = new List <FieldWrap>();
            _children = new HashSet <string>();
            if (Name.IsEmpty())
            {
                Error("未指定Class名称");
            }
            if (!Util.MatchIdentifier(Name))
            {
                Error("命名不合法:" + Name);
            }

            _namespace = namespace0;
            _fullName  = string.Format("{0}.{1}", namespace0, des.Name);
            _inherit   = des.Inherit;
            _inherit   = CorrectType(this, _inherit);
            _groups    = new HashSet <string>(Util.Split(des.Group == null ? "" : des.Group.ToLower()));
            if (_groups.Count == 0)
            {
                _groups.Add(Setting.DefualtGroup);
            }

            Add(this);
            _fields = new List <FieldWrap>();
            for (int i = 0; i < des.Fields.Count; i++)
            {
                var fieldDes = des.Fields[i];
                var info     = new FieldWrap(this, fieldDes.Name, fieldDes.Type, fieldDes.Group, fieldDes.Desc, fieldDes.Attribute, _groups);
                info.CreateChecker(fieldDes);
                Fields.Add(info);
            }
            _consts = new List <ConstWrap>();
            for (int i = 0; i < des.Consts.Count; i++)
            {
                var constDes = des.Consts[i];
                var info     = new ConstWrap(this, constDes.Name, constDes.Type, constDes.Value, constDes.Group, constDes.Desc, _groups);
                Consts.Add(info);
            }
        }