Esempio n. 1
0
 /// <summary>
 /// 保存增量为Xml文件
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="path">路径</param>
 /// <returns></returns>
 public static bool SaveVariable(this XmlDBManager manager, string path)
 {
     try
     {
         using (var newDb = XmlDB.Create(path))
         {
             var version = MapConfig.Instance.Version;
             version++;
             foreach (var table in manager.DB.Tables)
             {
                 var newTable = XmlTable.Create(table.Name);
                 var entities = table.Entities.Where(o => o.EntityState != EntityState.None);
                 if (entities.Any())
                 {
                     //更新版本号
                     entities.ToList().ForEach(o => o.Version = version);
                     newTable.AddRange(entities);
                     newDb.AddTable(newTable);
                 }
             }
             InsertCadVersion(version, newDb);
             newDb.Save();
             //保存版本号
             SaveVersion(version);
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
         return(false);
     }
 }
Esempio n. 2
0
 private void CheckTable(XmlTable table, string name)
 {
     if (table == null)
     {
         throw new NotExistException(name + "不存在");
     }
 }
Esempio n. 3
0
        private XmlTable GetTable(string typeName, bool create)
        {
            var table = _db.GetTable(typeName);

            if (table == null && create)
            {
                table = XmlTable.Create(typeName);
                _db.AddTable(table);
            }
            return(table);
        }
Esempio n. 4
0
 /// <summary>
 /// 创建CAD版本
 /// </summary>
 /// <param name="version"></param>
 /// <param name="xmlDB"> </param>
 private static void InsertCadVersion(int version, XmlDB xmlDB)
 {
     try
     {
         var cadVersion = new CadVersion
         {
             G3E_ID      = 1,
             G3E_FID     = 1,
             G3E_FNO     = 2014,
             Version     = version,
             EntityState = EntityState.None
         };
         var versionTable = XmlTable.Create("CadVersion");
         versionTable.AddEntity(cadVersion);
         xmlDB.AddTable(versionTable);
     }
     catch
     {
         LogManager.Instance.Error("CADVersion添加失败!");
     }
 }
Esempio n. 5
0
 public void AddTable(XmlTable table)
 {
     Tables.Add(table);
     TableIndex.Add(table.Name, table);
 }