Exemplo n.º 1
0
 private bool DeleteDeviceFromDB(int id)
 {
     try
     {
         IFileService          _fileService         = new SCA.BusinessLib.Utility.FileService();
         ILogRecorder          logger               = null;
         DBFileVersionManager  dbFileVersionManager = new DBFileVersionManager(TheLoop.Controller.Project.SavePath, logger, _fileService);
         IDBFileVersionService dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(DBFileVersionManager.CurrentDBFileVersion);
         IDeviceDBServiceTest  deviceDBService      = SCA.DatabaseAccess.DBContext.DeviceManagerDBServiceTest.GetDeviceDBContext(TheLoop.Controller.Type, dbFileVersionService);
         if (deviceDBService.DeleteDeviceByID(id))
         {
             if (BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8021 == id) //如果最大ID等于被删除的ID,则重新赋值
             {
                 ControllerOperation8021 controllerOperation = new ControllerOperation8021();
                 BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8021 = controllerOperation.GetMaxDeviceID();
             }
         }
         ILoopDBService loopDBService = new SCA.DatabaseAccess.DBContext.LoopDBService(dbFileVersionService); //更新回路中存储的器件数量
         loopDBService.AddLoopInfo(TheLoop);
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
 public bool SaveToDB()
 {
     try
     {
         ILogRecorder          logger                = null;
         IFileService          fileService           = new SCA.BusinessLib.Utility.FileService();
         DBFileVersionManager  dbFileVersionManager  = new DBFileVersionManager(this.TheLoop.Controller.Project.SavePath, logger, fileService);
         IDBFileVersionService _dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(SCA.BusinessLogic.DBFileVersionManager.CurrentDBFileVersion);
         ILoopDBService        _loopDBService        = new SCA.DatabaseAccess.DBContext.LoopDBService(_dbFileVersionService);
         _loopDBService.AddLoopInfo(TheLoop);
         IDeviceDBServiceTest dbService = DeviceManagerDBServiceTest.GetDeviceDBContext(ControllerType.NT8021, _dbFileVersionService);
         dbService.AddDevice(TheLoop);
     }
     catch
     {
         return(false);
     }
     return(true);
 }