Example #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);
 }
Example #2
0
        private bool DeleteDeviceFromDB(int id)
        {
            try
            {
                IFileService     _fileService     = new SCA.BusinessLib.Utility.FileService();
                ILogRecorder     logger           = null;
                IDatabaseService _databaseService = new SCA.DatabaseAccess.SQLiteDatabaseAccess(TheLoop.Controller.Project.SavePath, logger, _fileService);

                IDeviceDBServiceTest deviceDBService = SCA.DatabaseAccess.DBContext.DeviceManagerDBServiceTest.GetDeviceDBContext(TheLoop.Controller.Type, _databaseService);

                deviceDBService.DeleteDeviceByID(id);
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }