public ProjectModel CreateProject(ProjectModel project) { IProjectService _projectService = new SCA.BusinessLib.BusinessLogic.ProjectService(); IFileService _fileService = new SCA.BusinessLib.Utility.FileService(); return(CreateProject(project, _projectService, _fileService)); }
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); }
private bool DeleteLoopFromDB(int loopID) { try { IFileService _fileService = new SCA.BusinessLib.Utility.FileService(); ILogRecorder logger = null; IDatabaseService _databaseService = new SCA.DatabaseAccess.SQLiteDatabaseAccess(_controller.Project.SavePath, logger, _fileService); ILoopDBService loopDBService = new SCA.DatabaseAccess.DBContext.LoopDBService(_databaseService); loopDBService.DeleteLoopInfo(loopID); } catch (Exception ex) { return(false); } return(true); }
public void ExportProjectToExcelExecute() { VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog(); dialog.Description = "选择存储的文件夹"; dialog.UseDescriptionForTitle = true; // This applies to the Vista style dialog only, not the old dialog. dialog.ShowDialog(); string strSelectedFolderPath = dialog.SelectedPath; using (new WaitCursor()) { IFileService fileService = new SCA.BusinessLib.Utility.FileService(); ProjectService projectService = new ProjectService(); projectService.ExportProjectToExcel(ProjectManager.GetInstance.Project, strSelectedFolderPath, fileService); } }
private bool DeleteLoopFromDB(int loopID) { try { IFileService fileService = new SCA.BusinessLib.Utility.FileService(); ILogRecorder logger = null; DBFileVersionManager dbFileVersionManager = new DBFileVersionManager(_controller.Project.SavePath, logger, fileService); IDBFileVersionService dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(SCA.BusinessLogic.DBFileVersionManager.CurrentDBFileVersion); ILoopDBService loopDBService = new SCA.DatabaseAccess.DBContext.LoopDBService(dbFileVersionService); loopDBService.DeleteLoopInfo(loopID); } catch (Exception ex) { return(false); } return(true); }
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); }
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); }
public void PublishAsDatabaseFileExecute() { VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog(); dialog.Description = "选择存储的文件夹"; dialog.UseDescriptionForTitle = true; // This applies to the Vista style dialog only, not the old dialog. dialog.ShowDialog(); string strSelectedFolderPath = dialog.SelectedPath; using (new WaitCursor()) { IFileService fileService = new SCA.BusinessLib.Utility.FileService(); ProjectService projectService = new ProjectService(); projectService.ExportProjectToExcel(ProjectManager.GetInstance.Project, strSelectedFolderPath, fileService); ProjectManager.GetInstance.SaveProject(); string sourcePath = ProjectManager.GetInstance.Project.SavePath; string destPath = strSelectedFolderPath + "//" + ProjectManager.GetInstance.Project.Name + ".nt"; fileService.Copy(sourcePath, destPath, true); } }
private bool DeleteControllerFromDB(ControllerModel controller) { try { IFileService _fileService = new SCA.BusinessLib.Utility.FileService(); ILogRecorder logger = null; IDatabaseService _databaseService = new SCA.DatabaseAccess.SQLiteDatabaseAccess(controller.Project.SavePath, logger, _fileService); IControllerDBService controllerDBService = new SCA.DatabaseAccess.DBContext.ControllerDBService(_databaseService); ILoopDBService loopDBService = new SCA.DatabaseAccess.DBContext.LoopDBService(_databaseService); IDeviceDBServiceTest deviceDBService = SCA.DatabaseAccess.DBContext.DeviceManagerDBServiceTest.GetDeviceDBContext(controller.Type, _databaseService); deviceDBService.DeleteAllDevicesByControllerID(controller.ID); loopDBService.DeleteLoopsByControllerID(controller.ID); controllerDBService.DeleteController(controller.ID); } catch (Exception ex) { return(false); } return(true); }